style selector option
This commit is contained in:
@@ -11,6 +11,8 @@ var CONFIG = {
|
||||
RELATION_THICKNESS: 2,
|
||||
RELATION_SPACING: 15,
|
||||
RELATION_COLORS: ["#000", "#800", "#080", "#008", "#088", "#808", "#088"],
|
||||
|
||||
STYLES: ["material-inspired", "original"],
|
||||
|
||||
STATIC_PATH: "",
|
||||
XHR_PATH: "",
|
||||
|
||||
+34
-22
@@ -1,36 +1,37 @@
|
||||
/* --------------------- options ------------ */
|
||||
|
||||
SQL.Options = function(owner) {
|
||||
SQL.Options = function (owner) {
|
||||
this.owner = owner;
|
||||
this.dom = {
|
||||
container:OZ.$("opts"),
|
||||
btn:OZ.$("options")
|
||||
container: OZ.$("opts"),
|
||||
btn: OZ.$("options")
|
||||
}
|
||||
this.dom.btn.value = _("options");
|
||||
this.save = this.save.bind(this);
|
||||
this.build();
|
||||
}
|
||||
|
||||
SQL.Options.prototype.build = function() {
|
||||
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.optionstyle = OZ.$("optionstyle");
|
||||
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 ids = ["language", "db", "snap", "pattern", "style", "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++) {
|
||||
for (var i = 0; i < ls.length; i++) {
|
||||
var o = OZ.DOM.elm("option");
|
||||
o.value = ls[i];
|
||||
o.innerHTML = ls[i];
|
||||
@@ -40,7 +41,7 @@ SQL.Options.prototype.build = function() {
|
||||
|
||||
var dbs = CONFIG.AVAILABLE_DBS;
|
||||
OZ.DOM.clear(this.dom.optiondb);
|
||||
for (var i=0;i<dbs.length;i++) {
|
||||
for (var i = 0; i < dbs.length; i++) {
|
||||
var o = OZ.DOM.elm("option");
|
||||
o.value = dbs[i];
|
||||
o.innerHTML = dbs[i];
|
||||
@@ -48,25 +49,36 @@ SQL.Options.prototype.build = function() {
|
||||
if (this.owner.getOption("db") == dbs[i]) { this.dom.optiondb.selectedIndex = i; }
|
||||
}
|
||||
|
||||
|
||||
var styles = CONFIG.STYLES;
|
||||
OZ.DOM.clear(this.dom.optionstyle);
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
var o = OZ.DOM.elm("option");
|
||||
o.value = styles[i];
|
||||
o.innerHTML= styles[i];
|
||||
this.dom.optionstyle.appendChild(o);
|
||||
if (this.owner.getOption("style") == styles[i]) { this.dom.optionstyle.selectedIndex = i; }
|
||||
}
|
||||
|
||||
|
||||
OZ.Event.add(this.dom.btn, "click", this.click.bind(this));
|
||||
|
||||
|
||||
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.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("style", this.dom.optionstyle.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);
|
||||
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");
|
||||
|
||||
@@ -29,6 +29,7 @@ SQL.Designer = function() {
|
||||
this.flag = 2;
|
||||
this.requestLanguage();
|
||||
this.requestDB();
|
||||
this.requestStyle();
|
||||
}
|
||||
SQL.Designer.prototype = Object.create(SQL.Visual.prototype);
|
||||
|
||||
@@ -79,6 +80,17 @@ SQL.Designer.prototype.requestDB = function() { /* get datatypes file */
|
||||
OZ.Request(url, this.dbResponse.bind(this), {method:"get", xml:true});
|
||||
}
|
||||
|
||||
SQL.Designer.prototype.requestStyle = function() { /* set style */
|
||||
var style = this.getOption("style");
|
||||
var i, link_elms;
|
||||
for (i=0; link_elms = document.getElementsByTagName("link"); i++) {
|
||||
if (link_elms[i].getAttribute("rel").indexOf("style") != -1 && link_elms[i].getAttribute("title")) {
|
||||
link_elms[i].disabled = true;
|
||||
if (link_elms[i].getAttribute("title") == style) link_elms[i].disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SQL.Designer.prototype.dbResponse = function(xmlDoc) {
|
||||
if (xmlDoc) {
|
||||
window.DATATYPES = xmlDoc.documentElement;
|
||||
@@ -187,6 +199,7 @@ SQL.Designer.prototype.getOption = function(name) {
|
||||
case "pattern": return "%R_%T";
|
||||
case "hide": return false;
|
||||
case "vector": return true;
|
||||
case "style": return "material-inspired";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user