diff --git a/backend/core/static/price-format.js b/backend/core/static/price-format.js deleted file mode 100644 index bf968e6..0000000 --- a/backend/core/static/price-format.js +++ /dev/null @@ -1,67 +0,0 @@ -document.addEventListener("DOMContentLoaded", () => { - // Format all existing inputs - formatAllPriceInputs(); - - // Use event delegation for input events on price-input fields - document.addEventListener("input", (event) => { - if (event.target.classList.contains("price-input")) { - const input = event.target; - const cursor = input.selectionStart; - const raw = input.value.replace(/,/g, ""); - const formatted = format(raw); - - if (input.value !== formatted) { - input.value = formatted; - input.setSelectionRange(cursor, cursor); - } - } - }); - - // Use event delegation for focus events to format on focus - document.addEventListener("focus", (event) => { - if (event.target.classList.contains("price-input")) { - event.target.value = format(event.target.value); - } - }, true); - - // Use event delegation for form submit - document.addEventListener("submit", (event) => { - event.target.querySelectorAll(".price-input").forEach((input) => { - input.value = input.value.replace(/,/g, ""); - }); - }); - - // Use MutationObserver to format newly added inputs - const observer = new MutationObserver((mutations) => { - let hasNewInputs = false; - mutations.forEach((mutation) => { - mutation.addedNodes.forEach((node) => { - if (node.nodeType === 1) { - if (node.classList?.contains("price-input") || - node.querySelectorAll?.(".price-input").length > 0) { - hasNewInputs = true; - } - } - }); - }); - if (hasNewInputs) { - formatAllPriceInputs(); - } - }); - - observer.observe(document.body, { - childList: true, - subtree: true - }); -}); - -function formatAllPriceInputs() { - document.querySelectorAll(".price-input").forEach((input) => { - input.value = format(input.value); - }); -} - -function format(value) { - if (!value) return ""; - return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","); -} diff --git a/backend/templates/admin/base_site.html b/backend/templates/admin/base_site.html index bab7144..ef7dfcc 100644 --- a/backend/templates/admin/base_site.html +++ b/backend/templates/admin/base_site.html @@ -19,4 +19,73 @@ {% if plausible_domain %} {% endif %} + {% endblock %}