changeset 67:3a9dae71aa6c

static (js/css): method to toggle clicked class on all elements matching a selector
author Goffi <goffi@goffi.org>
date Fri, 01 Dec 2017 00:46:45 +0100
parents 9834106678da
children 46109efcf671
files default/static/css.js
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/default/static/css.js	Fri Dec 01 00:46:42 2017 +0100
+++ b/default/static/css.js	Fri Dec 01 00:46:45 2017 +0100
@@ -1,9 +1,15 @@
-function set_clicked_class_tag(tag_name, class_name='clicked') {
+function toggle_clicked_class_tag(tag_name, class_name='clicked') {
     for (let elt of document.getElementsByTagName(tag_name)) {
         elt.classList.toggle(class_name);
     }
 }
 
+function toggle_clicked_class_sel(selectors, class_name='clicked') {
+    for (let elt of document.querySelectorAll(selectors)) {
+        elt.classList.toggle(class_name);
+    }
+}
+
 function set_clicked_class_id(trigger_elem_id, target_elem_id=null, class_name='clicked') {
     if (target_elem_id === null) { target_elem_id = trigger_elem_id; }
     document.getElementById(trigger_elem_id).addEventListener(