diff default/static/css.js @ 15:c319291943be

static: css.js (library for basic style manipulation) first draft
author Goffi <goffi@goffi.org>
date Thu, 04 May 2017 00:55:06 +0200
parents
children 494d740aa3d6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/default/static/css.js	Thu May 04 00:55:06 2017 +0200
@@ -0,0 +1,15 @@
+function set_clicked_class_tag(tag_name, class_name='clicked') {
+    for (let elt of document.getElementsByTagName(tag_name)) {
+        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(
+        "click",
+        function() {
+            document.getElementById(target_elem_id).classList.toggle(class_name);
+        }
+    );
+}