summaryrefslogtreecommitdiff
path: root/frontend/static/js/src/toggler.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/static/js/src/toggler.js')
-rw-r--r--frontend/static/js/src/toggler.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/frontend/static/js/src/toggler.js b/frontend/static/js/src/toggler.js
new file mode 100644
index 0000000..afe69ee
--- /dev/null
+++ b/frontend/static/js/src/toggler.js
@@ -0,0 +1,27 @@
+function Toggler (div, on, off)
+ {
+ var state = false
+ function activate ()
+ {
+ $(div).addClass("on").html("ON")
+ on ()
+ }
+ function deactivate ()
+ {
+ $(div).removeClass("on").html("off")
+ off ()
+ }
+ function toggle ()
+ {
+ state = ! state
+ if (state)
+ activate ()
+ else
+ deactivate ()
+ }
+ function destroy ()
+ {
+ $(div).unbind("click")
+ }
+ $(div).bind("click", toggle)
+ }