Mercurial > libervia-templates
changeset 29:494d740aa3d6
static/css.js: added clicked_cls function:
this function toggle "clicked" class on each click, and remove "init" class on first click. Useful to make CSS react easily on clicks.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 24 Jun 2017 20:25:39 +0200 |
parents | 4bf00291b895 |
children | 69a2e3bf5e17 |
files | default/static/css.js |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/default/static/css.js Sat Jun 24 20:24:14 2017 +0200 +++ b/default/static/css.js Sat Jun 24 20:25:39 2017 +0200 @@ -13,3 +13,14 @@ } ); } + +function clicked_cls(elt) { + /* toggle "clicked" class on each click, and remove "init" class if present */ + // init + if (elt.classList.contains("init")) { + elt.classList.remove("init"); + } + + // clicked + elt.classList.toggle("clicked"); +}