zakladka ustawien

This commit is contained in:
Mateusz Gruszczyński
2025-10-21 12:08:05 +02:00
parent a51e44847e
commit 4128d617a7
2 changed files with 29 additions and 6 deletions

View File

@@ -77,6 +77,28 @@
form.querySelectorAll('input[type="color"].category-color').forEach(updatePreview);
});
form.querySelectorAll(".use-default").forEach(btn => {
btn.addEventListener("click", () => {
const name = btn.getAttribute("data-target");
const input = form.querySelector(`input[name="${name}"]`);
if (!input) return;
const card = input.closest(".col-12, .col-md-6, .col-lg-4") || input.closest(".col-12");
let autoHex = (input.dataset.auto || "").trim();
if (!autoHex && card) {
autoHex = (card.querySelector(".hex-auto")?.textContent || "").trim();
}
if (autoHex && !autoHex.startsWith("#")) autoHex = `#${autoHex}`;
if (autoHex) {
input.disabled = false;
removeHiddenClear(input);
input.value = autoHex;
updatePreview(input);
}
});
});
(function () {
const slider = document.getElementById("ocr_sensitivity");
const badge = document.getElementById("ocr_sens_badge");

View File

@@ -68,12 +68,13 @@
<div class="input-group">
<input
type="color"
class="form-control form-control-color category-color"
name="color_{{ c.id }}"
value="{{ hex_override or '' }}"
{% if not hex_override %}data-empty="1"{% endif %}
aria-label="Kolor kategorii {{ c.name }}"
type="color"
class="form-control form-control-color category-color"
name="color_{{ c.id }}"
value="{{ hex_override or '' }}"
data-auto="{{ hex_auto }}"
{% if not hex_override %}data-empty="1"{% endif %}
aria-label="Kolor kategorii {{ c.name }}"
>
<div class="btn-group" role="group" aria-label="Akcje koloru">