Files
WYGIWYH/app/templates/includes/scripts/hyperscript/hide_amount.html
2025-11-05 13:09:31 -03:00

33 lines
1.3 KiB
HTML

<script type="text/hyperscript">
behavior hide_amounts
on load or htmx:afterSwap if body include #settings-hide-amounts
set elements to <.amount/> in me
for el in elements
set el.textContent to '•••••••••••'
end
end
on load or htmx:afterSwap if body do not include #settings-hide-amounts
set elements to <.amount/> in me
for el in elements
set el.textContent to el.dataset.originalValue
set el.innerHTML to `<span>${el.dataset.originalSign}</span><span>${el.dataset.originalPrefix}</span><span>${el.dataset.originalAmount}</span><span>${el.dataset.originalSuffix}</span>`
end
end
on click[target matches .amount or target.parentNode matches .amount] if I include #settings-hide-amounts
if event.target matches .amount
set el to event.target
else
set el to event.target.parentNode
end
if el do not matches .revealed
then set el.innerHTML to `<span>${el.dataset.originalSign}</span><span>${el.dataset.originalPrefix}</span><span>${el.dataset.originalAmount}</span><span>${el.dataset.originalSuffix}</span>`
else
set el.textContent to '•••••••••••' end
then toggle .revealed on el
end
end
</script>