Mercurial > libervia-templates
changeset 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 | 9a77174abc1e |
children | 8cdcbe0d7dee |
files | default/static/css.js |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
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); + } + ); +}