diff options
| author | Pepper <pepper@scannerjammer.com> | 2015-05-20 11:16:13 -0400 |
|---|---|---|
| committer | Pepper <pepper@scannerjammer.com> | 2015-05-20 11:16:13 -0400 |
| commit | a4916103efb2d97896c456ff0e83064b21e85d25 (patch) | |
| tree | b3eb529e4b96375109626bbeada35d4f8a2667ee /frontend/static/js/src/toggler.js | |
| parent | 3790eedc2f48c725c586b8c7b924875fedbeb7b4 (diff) | |
first commit in a while
Diffstat (limited to 'frontend/static/js/src/toggler.js')
| -rw-r--r-- | frontend/static/js/src/toggler.js | 27 |
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) + } |
