108 lines
3.4 KiB
JavaScript
108 lines
3.4 KiB
JavaScript
/* --------------------- options ------------ */
|
|
|
|
SQL.Options = OZ.Class();
|
|
|
|
SQL.Options.prototype.init = function(owner) {
|
|
this.owner = owner;
|
|
this.dom = {
|
|
container:OZ.$("opts"),
|
|
btn:OZ.$("options")
|
|
}
|
|
this.dom.btn.value = _("options");
|
|
this.save = this.bind(this.save);
|
|
this.build();
|
|
}
|
|
|
|
SQL.Options.prototype.build = function() {
|
|
this.dom.optionlocale = OZ.$("optionlocale");
|
|
this.dom.optiondb = OZ.$("optiondb");
|
|
this.dom.optionsnap = OZ.$("optionsnap");
|
|
this.dom.optionpattern = OZ.$("optionpattern");
|
|
this.dom.optionhide = OZ.$("optionhide");
|
|
this.dom.optionvector = OZ.$("optionvector");
|
|
this.dom.optionshowsize = OZ.$("optionshowsize");
|
|
this.dom.optionshowtype = OZ.$("optionshowtype");
|
|
|
|
var ids = ["language","db","snap","pattern","hide","vector","showsize","showtype","optionsnapnotice","optionpatternnotice","optionsnotice"];
|
|
for (var i=0;i<ids.length;i++) {
|
|
var id = ids[i];
|
|
var elm = OZ.$(id);
|
|
elm.innerHTML = _(id);
|
|
}
|
|
|
|
var ls = CONFIG.AVAILABLE_LOCALES;
|
|
OZ.DOM.clear(this.dom.optionlocale);
|
|
for (var i=0;i<ls.length;i++) {
|
|
var o = OZ.DOM.elm("option");
|
|
o.value = ls[i];
|
|
o.innerHTML = ls[i];
|
|
this.dom.optionlocale.appendChild(o);
|
|
if (this.owner.getOption("locale") == ls[i]) { this.dom.optionlocale.selectedIndex = i; }
|
|
}
|
|
|
|
var dbs = CONFIG.AVAILABLE_DBS;
|
|
OZ.DOM.clear(this.dom.optiondb);
|
|
for (var i=0;i<dbs.length;i++) {
|
|
var o = OZ.DOM.elm("option");
|
|
o.value = dbs[i];
|
|
o.innerHTML = dbs[i];
|
|
this.dom.optiondb.appendChild(o);
|
|
if (this.owner.getOption("db") == dbs[i]) { this.dom.optiondb.selectedIndex = i; }
|
|
}
|
|
|
|
|
|
OZ.Event.add(this.dom.btn, "click", this.bind(this.click));
|
|
|
|
this.dom.container.parentNode.removeChild(this.dom.container);
|
|
}
|
|
|
|
SQL.Options.prototype.save = function() {
|
|
this.owner.setOption("locale",this.dom.optionlocale.value);
|
|
this.owner.setOption("db",this.dom.optiondb.value);
|
|
this.owner.setOption("snap",this.dom.optionsnap.value);
|
|
this.owner.setOption("pattern",this.dom.optionpattern.value);
|
|
this.owner.setOption("hide",this.dom.optionhide.checked ? "1" : "");
|
|
this.owner.setOption("vector",this.dom.optionvector.checked ? "1" : "");
|
|
this.owner.setOption("showsize",this.dom.optionshowsize.checked ? "1" : "");
|
|
this.owner.setOption("showtype",this.dom.optionshowtype.checked ? "1" : "");
|
|
}
|
|
|
|
SQL.Options.prototype.click = function() {
|
|
this.owner.window.open(_("options"),this.dom.container,this.save);
|
|
this.dom.optionsnap.value = this.owner.getOption("snap");
|
|
this.dom.optionpattern.value = this.owner.getOption("pattern");
|
|
this.dom.optionhide.checked = this.owner.getOption("hide");
|
|
this.dom.optionvector.checked = this.owner.getOption("vector");
|
|
this.dom.optionshowsize.checked = this.owner.getOption("showsize");
|
|
this.dom.optionshowtype.checked = this.owner.getOption("showtype");
|
|
}
|
|
|
|
/* ------------------ minimize/restore bar ----------- */
|
|
|
|
SQL.Toggle = OZ.Class();
|
|
|
|
SQL.Toggle.prototype.init = 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");
|
|
}
|