diff options
-rwxr-xr-x | index.html | 1 | ||||
-rw-r--r-- | js/globals.js | 55 | ||||
-rw-r--r-- | js/io.js | 48 | ||||
-rw-r--r-- | js/key.js | 8 | ||||
-rw-r--r-- | js/keymanager.js | 20 | ||||
-rw-r--r-- | js/map.js | 17 | ||||
-rw-r--r-- | js/options.js | 37 | ||||
-rw-r--r-- | js/relation.js | 8 | ||||
-rw-r--r-- | js/row.js | 18 | ||||
-rw-r--r-- | js/rowmanager.js | 26 | ||||
-rw-r--r-- | js/rubberband.js | 13 | ||||
-rw-r--r-- | js/table.js | 22 | ||||
-rw-r--r-- | js/tablemanager.js | 24 | ||||
-rw-r--r-- | js/visual.js | 4 | ||||
-rw-r--r-- | js/window.js | 12 | ||||
-rwxr-xr-x | js/wwwsqldesigner.js | 17 |
16 files changed, 159 insertions, 171 deletions
@@ -25,6 +25,7 @@ <script src="js/key.js"></script> <script src="js/rubberband.js"></script> <script src="js/map.js"></script> + <script src="js/toggle.js"></script> <script src="js/io.js"></script> <script src="js/tablemanager.js"></script> <script src="js/rowmanager.js"></script> diff --git a/js/globals.js b/js/globals.js index 1dad0dc..29f62c5 100644 --- a/js/globals.js +++ b/js/globals.js @@ -4,11 +4,58 @@ function _(str) { /* getText */ } if (typeof String.prototype.endsWith !== 'function') { - String.prototype.endsWith = function(suffix) { - return this.indexOf(suffix, this.length - suffix.length) !== -1; - }; + String.prototype.endsWith = function(suffix) { + return this.indexOf(suffix, this.length - suffix.length) !== -1; + }; +} + +if (!String.prototype.trim) { + String.prototype.trim = function() { + return this.match(/^\s*([\s\S]*?)\s*$/)[1]; + } +} + +if (!String.trim) { + String.trim = function(obj) { return String.prototype.trim.call(obj);} +} + +if (!Object.create) { + Object.create = function (o) { + if (arguments.length > 1) { throw new Error("Object.create polyfill only accepts the first parameter"); } + var tmp = function() {}; + tmp.prototype = o; + return new tmp(); + }; } var DATATYPES = false; var LOCALE = {}; -var SQL = {}; +var SQL = { + _subscribers: {}, + + publish: function(message, publisher, data) { + var subscribers = this._subscribers[message] || []; + var obj = { + target: publisher, + data: data + } + subscribers.forEach(function(subscriber) { subscriber(obj); }); + }, + + subscribe: function(message, subscriber) { + if (!(message in this._subscribers)) { + this._subscribers[message] = []; + } + var index = this._subscribers[message].indexOf(subscriber); + if (index == -1) { this._subscribers[message].push(subscriber); } + }, + + unsubscribe: function(message, subscriber) { + var index = this._subscribers[message].indexOf(subscriber); + if (index > -1) { this._subscribers[message].splice(index, 1); } + } +} + +window.onbeforeunload = function(e) { + return ""; /* some browsers will show this text, some won't. */ +} @@ -1,8 +1,4 @@ -/* --------------------- io ------------ */ - -SQL.IO = OZ.Class(); - -SQL.IO.prototype.init = function(owner) { +SQL.IO = function(owner) { this.owner = owner; this._name = ""; /* last used name with server load/save */ this.lastUsedName = ""; /* last used name with local storage or dropbox load/save */ @@ -39,27 +35,27 @@ SQL.IO.prototype.init = function(owner) { this.dom.container.parentNode.removeChild(this.dom.container); this.dom.container.style.visibility = ""; - this.saveresponse = this.bind(this.saveresponse); - this.loadresponse = this.bind(this.loadresponse); - this.listresponse = this.bind(this.listresponse); - this.importresponse = this.bind(this.importresponse); + this.saveresponse = this.saveresponse.bind(this); + this.loadresponse = this.loadresponse.bind(this); + this.listresponse = this.listresponse.bind(this); + this.importresponse = this.importresponse.bind(this); - OZ.Event.add(this.dom.saveload, "click", this.bind(this.click)); - OZ.Event.add(this.dom.clientlocalsave, "click", this.bind(this.clientlocalsave)); - OZ.Event.add(this.dom.clientsave, "click", this.bind(this.clientsave)); - OZ.Event.add(this.dom.clientlocalload, "click", this.bind(this.clientlocalload)); - OZ.Event.add(this.dom.clientlocallist, "click", this.bind(this.clientlocallist)); - OZ.Event.add(this.dom.clientload, "click", this.bind(this.clientload)); - OZ.Event.add(this.dom.dropboxload, "click", this.bind(this.dropboxload)); - OZ.Event.add(this.dom.dropboxsave, "click", this.bind(this.dropboxsave)); - OZ.Event.add(this.dom.dropboxlist, "click", this.bind(this.dropboxlist)); - OZ.Event.add(this.dom.clientsql, "click", this.bind(this.clientsql)); - OZ.Event.add(this.dom.quicksave, "click", this.bind(this.quicksave)); - OZ.Event.add(this.dom.serversave, "click", this.bind(this.serversave)); - OZ.Event.add(this.dom.serverload, "click", this.bind(this.serverload)); - OZ.Event.add(this.dom.serverlist, "click", this.bind(this.serverlist)); - OZ.Event.add(this.dom.serverimport, "click", this.bind(this.serverimport)); - OZ.Event.add(document, "keydown", this.bind(this.press)); + OZ.Event.add(this.dom.saveload, "click", this.click.bind(this)); + OZ.Event.add(this.dom.clientlocalsave, "click", this.clientlocalsave.bind(this)); + OZ.Event.add(this.dom.clientsave, "click", this.clientsave.bind(this)); + OZ.Event.add(this.dom.clientlocalload, "click", this.clientlocalload.bind(this)); + OZ.Event.add(this.dom.clientlocallist, "click", this.clientlocallist.bind(this)); + OZ.Event.add(this.dom.clientload, "click", this.clientload.bind(this)); + OZ.Event.add(this.dom.dropboxload, "click", this.dropboxload.bind(this)); + OZ.Event.add(this.dom.dropboxsave, "click", this.dropboxsave.bind(this)); + OZ.Event.add(this.dom.dropboxlist, "click", this.dropboxlist.bind(this)); + OZ.Event.add(this.dom.clientsql, "click", this.clientsql.bind(this)); + OZ.Event.add(this.dom.quicksave, "click", this.quicksave.bind(this)); + OZ.Event.add(this.dom.serversave, "click", this.serversave.bind(this)); + OZ.Event.add(this.dom.serverload, "click", this.serverload.bind(this)); + OZ.Event.add(this.dom.serverlist, "click", this.serverlist.bind(this)); + OZ.Event.add(this.dom.serverimport, "click", this.serverimport.bind(this)); + OZ.Event.add(document, "keydown", this.press.bind(this)); this.build(); } @@ -367,7 +363,7 @@ SQL.IO.prototype.clientsql = function() { var bp = this.owner.getOption("staticpath"); var path = bp + "db/"+window.DATATYPES.getAttribute("db")+"/output.xsl"; this.owner.window.showThrobber(); - OZ.Request(path, this.bind(this.finish), {xml:true}); + OZ.Request(path, this.finish.bind(this), {xml:true}); } SQL.IO.prototype.finish = function(xslDoc) { @@ -1,14 +1,12 @@ /* --------------------- db index ------------ */ - -SQL.Key = OZ.Class().extend(SQL.Visual); - -SQL.Key.prototype.init = function(owner, type, name) { +SQL.Key = function(owner, type, name) { this.owner = owner; this.rows = []; this.type = type || "INDEX"; this.name = name || ""; - SQL.Visual.prototype.init.apply(this); + SQL.Visual.apply(this); } +SQL.Key.prototype = Object.create(SQL.Visual.prototype); SQL.Key.prototype.setName = function(n) { this.name = n; diff --git a/js/keymanager.js b/js/keymanager.js index e053a0a..5e08e2a 100644 --- a/js/keymanager.js +++ b/js/keymanager.js @@ -1,8 +1,6 @@ /* ----------------- key manager ---------- */ -SQL.KeyManager = OZ.Class(); - -SQL.KeyManager.prototype.init = function(owner) { +SQL.KeyManager = function(owner) { this.owner = owner; this.dom = { container:OZ.$("keys") @@ -44,15 +42,15 @@ SQL.KeyManager.prototype.build = function() { this.dom.type.appendChild(o); } - this.purge = this.bind(this.purge); + this.purge = this.purge.bind(this); - OZ.Event.add(this.dom.list, "change", this.bind(this.listchange)); - OZ.Event.add(this.dom.type, "change", this.bind(this.typechange)); - OZ.Event.add(this.dom.name, "keyup", this.bind(this.namechange)); - OZ.Event.add(this.dom.keyadd, "click", this.bind(this.add)); - OZ.Event.add(this.dom.keyremove, "click", this.bind(this.remove)); - OZ.Event.add(this.dom.left, "click", this.bind(this.left)); - OZ.Event.add(this.dom.right, "click", this.bind(this.right)); + OZ.Event.add(this.dom.list, "change", this.listchange.bind(this)); + OZ.Event.add(this.dom.type, "change", this.typechange.bind(this)); + OZ.Event.add(this.dom.name, "keyup", this.namechange.bind(this)); + OZ.Event.add(this.dom.keyadd, "click", this.add.bind(this)); + OZ.Event.add(this.dom.keyremove, "click", this.remove.bind(this)); + OZ.Event.add(this.dom.left, "click", this.left.bind(this)); + OZ.Event.add(this.dom.right, "click", this.right.bind(this)); this.dom.container.parentNode.removeChild(this.dom.container); } @@ -1,27 +1,26 @@ /* --------------------- minimap ------------ */ -SQL.Map = OZ.Class().extend(SQL.Visual); - -SQL.Map.prototype.init = function(owner) { +SQL.Map = function(owner) { this.owner = owner; - SQL.Visual.prototype.init.apply(this); + SQL.Visual.apply(this); this.dom.container = OZ.$("minimap"); this.width = this.dom.container.offsetWidth - 2; this.height = this.dom.container.offsetHeight - 2; this.dom.port = OZ.DOM.elm("div",{className:"port", zIndex:1}); this.dom.container.appendChild(this.dom.port); - this.sync = this.bind(this.sync); + this.sync = this.sync.bind(this); this.flag = false; this.sync(); OZ.Event.add(window, "resize", this.sync); OZ.Event.add(window, "scroll", this.sync); - OZ.Event.add(this.dom.container, "mousedown", this.bind(this.down)); - OZ.Event.add(this.dom.container, "touchstart", this.bind(this.down)); + OZ.Event.add(this.dom.container, "mousedown", this.down.bind(this)); + OZ.Event.add(this.dom.container, "touchstart", this.down.bind(this)); OZ.Event.add(this.dom.container, "touchmove", OZ.Event.prevent); } +SQL.Map.prototype = Object.create(SQL.Visual.prototype); SQL.Map.prototype.down = function(e) { /* mousedown - move view and start drag */ this.flag = true; @@ -40,8 +39,8 @@ SQL.Map.prototype.down = function(e) { /* mousedown - move view and start drag * var eventUp = "mouseup"; } - this.documentMove = OZ.Event.add(document, eventMove, this.bind(this.move)); - this.documentUp = OZ.Event.add(document, eventUp, this.bind(this.up)); + this.documentMove = OZ.Event.add(document, eventMove, this.move.bind(this)); + this.documentUp = OZ.Event.add(document, eventUp, this.up.bind(this)); } SQL.Map.prototype.move = function(e) { /* mousemove */ diff --git a/js/options.js b/js/options.js index 64dbd95..90854e5 100644 --- a/js/options.js +++ b/js/options.js @@ -1,15 +1,13 @@ /* --------------------- options ------------ */ -SQL.Options = OZ.Class(); - -SQL.Options.prototype.init = function(owner) { +SQL.Options = 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.save = this.save.bind(this); this.build(); } @@ -51,7 +49,7 @@ SQL.Options.prototype.build = function() { } - OZ.Event.add(this.dom.btn, "click", this.bind(this.click)); + OZ.Event.add(this.dom.btn, "click", this.click.bind(this)); this.dom.container.parentNode.removeChild(this.dom.container); } @@ -76,32 +74,3 @@ SQL.Options.prototype.click = function() { 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"); -} diff --git a/js/relation.js b/js/relation.js index 40e48c8..f593759 100644 --- a/js/relation.js +++ b/js/relation.js @@ -1,14 +1,12 @@ /* --------------------------- relation (connector) ----------- */ -SQL.Relation = OZ.Class().extend(SQL.Visual); -SQL.Relation._counter = 0; -SQL.Relation.prototype.init = function(owner, row1, row2) { +SQL.Relation = function(owner, row1, row2) { this.owner = owner; this.row1 = row1; this.row2 = row2; this.color = "#000"; this.hidden = false; - SQL.Visual.prototype.init.apply(this); + SQL.Visual.apply(this); /* if one of the rows already has relations, inherit color */ var all = row1.relations.concat(row2.relations); @@ -46,6 +44,8 @@ SQL.Relation.prototype.init = function(owner, row1, row2) { this.redraw(); } +SQL.Relation._counter = 0; +SQL.Relation.prototype = Object.create(SQL.Visual.prototype); SQL.Relation.prototype.getColor = function() { return this.color; @@ -1,15 +1,12 @@ /* --------------------- table row ( = db column) ------------ */ - -SQL.Row = OZ.Class().extend(SQL.Visual); - -SQL.Row.prototype.init = function(owner, title, data) { +SQL.Row = function(owner, title, data) { this.owner = owner; this.relations = []; this.keys = []; this.selected = false; this.expanded = false; - SQL.Visual.prototype.init.apply(this); + SQL.Visual.apply(this); this.data.type = 0; this.data.size = ""; @@ -21,6 +18,7 @@ SQL.Row.prototype.init = function(owner, title, data) { if (data) { this.update(data); } this.setTitle(title); } +SQL.Row.prototype = Object.create(SQL.Visual.prototype); SQL.Row.prototype._build = function() { this.dom.container = OZ.DOM.elm("tbody"); @@ -38,11 +36,11 @@ SQL.Row.prototype._build = function() { [td1, this.dom.selected, this.dom.title] ); - this.enter = this.bind(this.enter); - this.changeComment = this.bind(this.changeComment); + this.enter = this.enter.bind(this); + this.changeComment = this.changeComment.bind(this); - OZ.Event.add(this.dom.container, "click",this.bind(this.click)); - OZ.Event.add(this.dom.container, "dblclick",this.bind(this.dblclick)); + OZ.Event.add(this.dom.container, "click",this.click.bind(this)); + OZ.Event.add(this.dom.container, "dblclick",this.dblclick.bind(this)); } SQL.Row.prototype.select = function() { @@ -71,7 +69,7 @@ SQL.Row.prototype.setTitle = function(t) { } SQL.Row.prototype.click = function(e) { /* clicked on row */ - this.dispatch("rowclick", this); + SQL.publish("rowclick", this); this.owner.owner.rowManager.select(this); } diff --git a/js/rowmanager.js b/js/rowmanager.js index a0257f6..baa643d 100644 --- a/js/rowmanager.js +++ b/js/rowmanager.js @@ -1,8 +1,5 @@ /* --------------------- row manager ------------ */ - -SQL.RowManager = OZ.Class(); - -SQL.RowManager.prototype.init = function(owner) { +SQL.RowManager = function(owner) { this.owner = owner; this.dom = {}; this.selected = null; @@ -19,16 +16,17 @@ SQL.RowManager.prototype.init = function(owner) { this.select(false); - OZ.Event.add(this.dom.editrow, "click", this.bind(this.edit)); - OZ.Event.add(this.dom.uprow, "click", this.bind(this.up)); - OZ.Event.add(this.dom.downrow, "click", this.bind(this.down)); - OZ.Event.add(this.dom.removerow, "click", this.bind(this.remove)); - OZ.Event.add(this.dom.foreigncreate, "click", this.bind(this.foreigncreate)); - OZ.Event.add(this.dom.foreignconnect, "click", this.bind(this.foreignconnect)); - OZ.Event.add(this.dom.foreigndisconnect, "click", this.bind(this.foreigndisconnect)); - OZ.Event.add(false, "tableclick", this.bind(this.tableClick)); - OZ.Event.add(false, "rowclick", this.bind(this.rowClick)); - OZ.Event.add(document, "keydown", this.bind(this.press)); + OZ.Event.add(this.dom.editrow, "click", this.edit.bind(this)); + OZ.Event.add(this.dom.uprow, "click", this.up.bind(this)); + OZ.Event.add(this.dom.downrow, "click", this.down.bind(this)); + OZ.Event.add(this.dom.removerow, "click", this.remove.bind(this)); + OZ.Event.add(this.dom.foreigncreate, "click", this.foreigncreate.bind(this)); + OZ.Event.add(this.dom.foreignconnect, "click", this.foreignconnect.bind(this)); + OZ.Event.add(this.dom.foreigndisconnect, "click", this.foreigndisconnect.bind(this)); + OZ.Event.add(document, "keydown", this.press.bind(this)); + + SQL.subscribe("tableclick", this.tableClick.bind(this)); + SQL.subscribe("rowclick", this.rowClick.bind(this)); } SQL.RowManager.prototype.select = function(row) { /* activate a row */ diff --git a/js/rubberband.js b/js/rubberband.js index 1c2d0c2..9a08771 100644 --- a/js/rubberband.js +++ b/js/rubberband.js @@ -1,13 +1,12 @@ /* --------------------- rubberband -------------------- */ -SQL.Rubberband = OZ.Class().extend(SQL.Visual); - -SQL.Rubberband.prototype.init = function(owner) { +SQL.Rubberband = function(owner) { this.owner = owner; - SQL.Visual.prototype.init.apply(this); + SQL.Visual.apply(this); this.dom.container = OZ.$("rubberband"); - OZ.Event.add("area", "mousedown", this.bind(this.down)); + OZ.Event.add("area", "mousedown", this.down.bind(this)); } +SQL.Rubberband.prototype = Object.create(SQL.Visual.prototype); SQL.Rubberband.prototype.down = function(e) { OZ.Event.prevent(e); @@ -17,8 +16,8 @@ SQL.Rubberband.prototype.down = function(e) { this.width = 0; this.height = 0; this.redraw(); - this.documentMove = OZ.Event.add(document, "mousemove", this.bind(this.move)); - this.documentUp = OZ.Event.add(document, "mouseup", this.bind(this.up)); + this.documentMove = OZ.Event.add(document, "mousemove", this.move.bind(this)); + this.documentUp = OZ.Event.add(document, "mouseup", this.up.bind(this)); } SQL.Rubberband.prototype.move = function(e) { diff --git a/js/table.js b/js/table.js index b9c53a0..b72ce11 100644 --- a/js/table.js +++ b/js/table.js @@ -1,8 +1,5 @@ /* --------------------- db table ------------ */ - -SQL.Table = OZ.Class().extend(SQL.Visual); - -SQL.Table.prototype.init = function(owner, name, x, y, z) { +SQL.Table = function(owner, name, x, y, z) { this.owner = owner; this.rows = []; this.keys = []; @@ -11,7 +8,7 @@ SQL.Table.prototype.init = function(owner, name, x, y, z) { this.flag = false; this.selected = false; - SQL.Visual.prototype.init.apply(this); + SQL.Visual.apply(this); this.data.comment = ""; this.setTitle(name); @@ -20,6 +17,7 @@ SQL.Table.prototype.init = function(owner, name, x, y, z) { this.setZ(z); this.snap(); } +SQL.Table.prototype = Object.create(SQL.Visual.prototype); SQL.Table.prototype._build = function() { this.dom.container = OZ.DOM.elm("div", {className:"table"}); @@ -38,10 +36,10 @@ SQL.Table.prototype._build = function() { this.dom.mini = OZ.DOM.elm("div", {className:"mini"}); this.owner.map.dom.container.appendChild(this.dom.mini); - this._ec.push(OZ.Event.add(this.dom.container, "click", this.bind(this.click))); - this._ec.push(OZ.Event.add(this.dom.container, "dblclick", this.bind(this.dblclick))); - this._ec.push(OZ.Event.add(this.dom.container, "mousedown", this.bind(this.down))); - this._ec.push(OZ.Event.add(this.dom.container, "touchstart", this.bind(this.down))); + this._ec.push(OZ.Event.add(this.dom.container, "click", this.click.bind(this))); + this._ec.push(OZ.Event.add(this.dom.container, "dblclick", this.dblclick.bind(this))); + this._ec.push(OZ.Event.add(this.dom.container, "mousedown", this.down.bind(this))); + this._ec.push(OZ.Event.add(this.dom.container, "touchstart", this.down.bind(this))); this._ec.push(OZ.Event.add(this.dom.container, "touchmove", OZ.Event.prevent)); } @@ -88,7 +86,7 @@ SQL.Table.prototype.click = function(e) { if (t != this.dom.title) { return; } /* click on row */ - this.dispatch("tableclick",this); + SQL.publish("tableclick", this); this.owner.rowManager.select(false); } @@ -231,8 +229,8 @@ SQL.Table.prototype.down = function(e) { /* mousedown - start drag */ } } - this.documentMove = OZ.Event.add(document, moveEvent, this.bind(this.move)); - this.documentUp = OZ.Event.add(document, upEvent, this.bind(this.up)); + this.documentMove = OZ.Event.add(document, moveEvent, this.move.bind(this)); + this.documentUp = OZ.Event.add(document, upEvent, this.up.bind(this)); } SQL.Table.prototype.toXML = function() { diff --git a/js/tablemanager.js b/js/tablemanager.js index 29f1b6a..4c340bc 100644 --- a/js/tablemanager.js +++ b/js/tablemanager.js @@ -1,8 +1,6 @@ /* --------------------- table manager ------------ */ -SQL.TableManager = OZ.Class(); - -SQL.TableManager.prototype.init = function(owner) { +SQL.TableManager = function(owner) { this.owner = owner; this.dom = { container:OZ.$("table"), @@ -30,17 +28,17 @@ SQL.TableManager.prototype.init = function(owner) { this.select(false); - this.save = this.bind(this.save); + this.save = this.save.bind(this); - OZ.Event.add("area", "click", this.bind(this.click)); - OZ.Event.add(this.dom.addtable, "click", this.bind(this.preAdd)); - OZ.Event.add(this.dom.removetable, "click", this.bind(this.remove)); - OZ.Event.add(this.dom.cleartables, "click", this.bind(this.clear)); - OZ.Event.add(this.dom.addrow, "click", this.bind(this.addRow)); - OZ.Event.add(this.dom.aligntables, "click", this.owner.bind(this.owner.alignTables)); - OZ.Event.add(this.dom.edittable, "click", this.bind(this.edit)); - OZ.Event.add(this.dom.tablekeys, "click", this.bind(this.keys)); - OZ.Event.add(document, "keydown", this.bind(this.press)); + OZ.Event.add("area", "click", this.click.bind(this)); + OZ.Event.add(this.dom.addtable, "click", this.preAdd.bind(this)); + OZ.Event.add(this.dom.removetable, "click", this.remove.bind(this)); + OZ.Event.add(this.dom.cleartables, "click", this.clear.bind(this)); + OZ.Event.add(this.dom.addrow, "click", this.addRow.bind(this)); + OZ.Event.add(this.dom.aligntables, "click", this.owner.alignTables.bind(this.owner)); + OZ.Event.add(this.dom.edittable, "click", this.edit.bind(this)); + OZ.Event.add(this.dom.tablekeys, "click", this.keys.bind(this)); + OZ.Event.add(document, "keydown", this.press.bind(this)); this.dom.container.parentNode.removeChild(this.dom.container); } diff --git a/js/visual.js b/js/visual.js index 4fb7045..5b84e4f 100644 --- a/js/visual.js +++ b/js/visual.js @@ -1,7 +1,5 @@ /* -------------------- base visual element -------------------- */ - -SQL.Visual = OZ.Class(); /* abstract parent */ -SQL.Visual.prototype.init = function() { +SQL.Visual = function() { this._init(); this._build(); } diff --git a/js/window.js b/js/window.js index fd25bd6..c3cceae 100644 --- a/js/window.js +++ b/js/window.js @@ -1,8 +1,6 @@ /* --------------------- window ------------ */ -SQL.Window = OZ.Class(); - -SQL.Window.prototype.init = function(owner) { +SQL.Window = function(owner) { this.owner = owner; this.dom = { container:OZ.$("window"), @@ -16,11 +14,11 @@ SQL.Window.prototype.init = function(owner) { this.dom.ok.value = _("windowok"); this.dom.cancel.value = _("windowcancel"); this.dom.throbber.alt = this.dom.throbber.title = _("throbber"); - OZ.Event.add(this.dom.ok, "click", this.bind(this.ok)); - OZ.Event.add(this.dom.cancel, "click", this.bind(this.close)); - OZ.Event.add(document, "keydown", this.bind(this.key)); + OZ.Event.add(this.dom.ok, "click", this.ok.bind(this)); + OZ.Event.add(this.dom.cancel, "click", this.close.bind(this)); + OZ.Event.add(document, "keydown", this.key.bind(this)); - this.sync = this.bind(this.sync); + this.sync = this.sync.bind(this); OZ.Event.add(window, "scroll", this.sync); OZ.Event.add(window, "resize", this.sync); diff --git a/js/wwwsqldesigner.js b/js/wwwsqldesigner.js index d1bd0a4..c860d79 100755 --- a/js/wwwsqldesigner.js +++ b/js/wwwsqldesigner.js @@ -1,15 +1,11 @@ -/* --------------------- www sql designer ------------ */ - -SQL.Designer = OZ.Class().extend(SQL.Visual); - -SQL.Designer.prototype.init = function() { +SQL.Designer = function() { SQL.Designer = this; this.tables = []; this.relations = []; this.title = document.title; - SQL.Visual.prototype.init.apply(this); + SQL.Visual.apply(this); new SQL.Toggle(OZ.$("toggle")); this.dom.container = OZ.$("area"); @@ -34,6 +30,7 @@ SQL.Designer.prototype.init = function() { this.requestLanguage(); this.requestDB(); } +SQL.Designer.prototype = Object.create(SQL.Visual.prototype); /* update area size */ SQL.Designer.prototype.sync = function() { @@ -59,7 +56,7 @@ SQL.Designer.prototype.requestLanguage = function() { /* get locale file */ var lang = this.getOption("locale") var bp = this.getOption("staticpath"); var url = bp + "locale/"+lang+".xml"; - OZ.Request(url, this.bind(this.languageResponse), {method:"get", xml:true}); + OZ.Request(url, this.languageResponse.bind(this), {method:"get", xml:true}); } SQL.Designer.prototype.languageResponse = function(xmlDoc) { @@ -79,7 +76,7 @@ SQL.Designer.prototype.requestDB = function() { /* get datatypes file */ var db = this.getOption("db"); var bp = this.getOption("staticpath"); var url = bp + "db/"+db+"/datatypes.xml"; - OZ.Request(url, this.bind(this.dbResponse), {method:"get", xml:true}); + OZ.Request(url, this.dbResponse.bind(this), {method:"get", xml:true}); } SQL.Designer.prototype.dbResponse = function(xmlDoc) { @@ -348,7 +345,3 @@ SQL.Designer.prototype.getFKTypeFor = function(typeIndex) { } return this.fkTypeFor[typeIndex]; } - -window.onbeforeunload = function(e) { - return ""; /* some browsers will show this text, some won't. */ -} |