diff options
author | Yorhel <git@yorhel.nl> | 2019-10-27 11:41:42 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-11-10 12:44:55 +0100 |
commit | 279c4c9f82b45863f91a16867e4830695de7e0ce (patch) | |
tree | 819685a29d3c421e68cccb45d56849592afe1c8e /elm | |
parent | 9616e64115940ea0008ca5243c7085c40fe11013 (diff) |
ulist: Add some styling, sorting and a framework for extended info/options
Diffstat (limited to 'elm')
-rw-r--r-- | elm/global.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/elm/global.js b/elm/global.js index d396e0bc..367507c5 100644 --- a/elm/global.js +++ b/elm/global.js @@ -26,13 +26,34 @@ document.querySelectorAll('div[data-elm-module]').forEach(function(el) { }); -/* "check all" checkbox */ +/* "checkall" checkbox, usage: + * + * <input type="checkbox" class="checkall" name="$somename"> + * + * Checking that will synchronize all other checkboxes with name="$somename". + */ document.querySelectorAll('input[type=checkbox].checkall').forEach(function(el) { el.onclick = function() { document.querySelectorAll('input[type=checkbox][name="'+el.name+'"]').forEach(function(el2) { if(!el2.classList.contains('hidden')) { - el2.checked = el.checked; + if(el2.checked != el.checked) + el2.click(); } }); }; }); + + +/* "checkhidden" checkbox, usage: + * + * <input type="checkbox" class="checkhidden" value="$somename"> + * + * Checking that will toggle the 'hidden' class of all elements with the "$somename" class. + */ +document.querySelectorAll('input[type=checkbox].checkhidden').forEach(function(el) { + el.onclick = function() { + document.querySelectorAll('.'+el.value).forEach(function(el2) { + el2.classList.toggle('hidden', !el.checked); + }); + }; +}); |