summaryrefslogtreecommitdiffstats
path: root/js/toggle.js
diff options
context:
space:
mode:
authorOndrej Zara <ondrej.zara@firma.seznam.cz>2015-06-15 08:25:02 +0200
committerOndrej Zara <ondrej.zara@firma.seznam.cz>2015-06-15 08:25:02 +0200
commitdcea4c24e5efcb66cefb18eec8e7c9b596000867 (patch)
tree4894507ef01dea0ec7e9d4bc6d4647eb68d3f188 /js/toggle.js
parent097b9e89c95e4de2c184f40a1e8ef5e05bda9ddc (diff)
downloadwwwsqldesigner-dcea4c24e5efcb66cefb18eec8e7c9b596000867.zip
wwwsqldesigner-dcea4c24e5efcb66cefb18eec8e7c9b596000867.tar.gz
wwwsqldesigner-dcea4c24e5efcb66cefb18eec8e7c9b596000867.tar.bz2
added missing toggle.js
Diffstat (limited to 'js/toggle.js')
-rw-r--r--js/toggle.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/js/toggle.js b/js/toggle.js
new file mode 100644
index 0000000..6b1ec05
--- /dev/null
+++ b/js/toggle.js
@@ -0,0 +1,26 @@
+/* ------------------ minimize/restore bar ----------- */
+
+SQL.Toggle = function(elm) {
+ this._state = null;
+ this._elm = elm;
+ OZ.Event.add(elm, "click", this._click.bind(this));
+
+ var defaultState = true;
+ if (document.location.href.match(/toolbar=hidden/)) { defaultState = false; }
+ this._switch(defaultState);
+}
+
+SQL.Toggle.prototype._click = function(e) {
+ this._switch(!this._state);
+}
+
+SQL.Toggle.prototype._switch = function(state) {
+ this._state = state;
+ if (this._state) {
+ OZ.$("bar").style.height = "";
+ } else {
+ OZ.$("bar").style.overflow = "hidden";
+ OZ.$("bar").style.height = this._elm.offsetHeight + "px";
+ }
+ this._elm.className = (this._state ? "on" : "off");
+}