no more OZ.Class(), dedicated pubsub, std bind
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
<script src="js/key.js"></script>
|
<script src="js/key.js"></script>
|
||||||
<script src="js/rubberband.js"></script>
|
<script src="js/rubberband.js"></script>
|
||||||
<script src="js/map.js"></script>
|
<script src="js/map.js"></script>
|
||||||
|
<script src="js/toggle.js"></script>
|
||||||
<script src="js/io.js"></script>
|
<script src="js/io.js"></script>
|
||||||
<script src="js/tablemanager.js"></script>
|
<script src="js/tablemanager.js"></script>
|
||||||
<script src="js/rowmanager.js"></script>
|
<script src="js/rowmanager.js"></script>
|
||||||
|
|||||||
+48
-1
@@ -9,6 +9,53 @@ if (typeof String.prototype.endsWith !== 'function') {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 DATATYPES = false;
|
||||||
var LOCALE = {};
|
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 = function(owner) {
|
||||||
|
|
||||||
SQL.IO = OZ.Class();
|
|
||||||
|
|
||||||
SQL.IO.prototype.init = function(owner) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this._name = ""; /* last used name with server load/save */
|
this._name = ""; /* last used name with server load/save */
|
||||||
this.lastUsedName = ""; /* last used name with local storage or dropbox 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.parentNode.removeChild(this.dom.container);
|
||||||
this.dom.container.style.visibility = "";
|
this.dom.container.style.visibility = "";
|
||||||
|
|
||||||
this.saveresponse = this.bind(this.saveresponse);
|
this.saveresponse = this.saveresponse.bind(this);
|
||||||
this.loadresponse = this.bind(this.loadresponse);
|
this.loadresponse = this.loadresponse.bind(this);
|
||||||
this.listresponse = this.bind(this.listresponse);
|
this.listresponse = this.listresponse.bind(this);
|
||||||
this.importresponse = this.bind(this.importresponse);
|
this.importresponse = this.importresponse.bind(this);
|
||||||
|
|
||||||
OZ.Event.add(this.dom.saveload, "click", this.bind(this.click));
|
OZ.Event.add(this.dom.saveload, "click", this.click.bind(this));
|
||||||
OZ.Event.add(this.dom.clientlocalsave, "click", this.bind(this.clientlocalsave));
|
OZ.Event.add(this.dom.clientlocalsave, "click", this.clientlocalsave.bind(this));
|
||||||
OZ.Event.add(this.dom.clientsave, "click", this.bind(this.clientsave));
|
OZ.Event.add(this.dom.clientsave, "click", this.clientsave.bind(this));
|
||||||
OZ.Event.add(this.dom.clientlocalload, "click", this.bind(this.clientlocalload));
|
OZ.Event.add(this.dom.clientlocalload, "click", this.clientlocalload.bind(this));
|
||||||
OZ.Event.add(this.dom.clientlocallist, "click", this.bind(this.clientlocallist));
|
OZ.Event.add(this.dom.clientlocallist, "click", this.clientlocallist.bind(this));
|
||||||
OZ.Event.add(this.dom.clientload, "click", this.bind(this.clientload));
|
OZ.Event.add(this.dom.clientload, "click", this.clientload.bind(this));
|
||||||
OZ.Event.add(this.dom.dropboxload, "click", this.bind(this.dropboxload));
|
OZ.Event.add(this.dom.dropboxload, "click", this.dropboxload.bind(this));
|
||||||
OZ.Event.add(this.dom.dropboxsave, "click", this.bind(this.dropboxsave));
|
OZ.Event.add(this.dom.dropboxsave, "click", this.dropboxsave.bind(this));
|
||||||
OZ.Event.add(this.dom.dropboxlist, "click", this.bind(this.dropboxlist));
|
OZ.Event.add(this.dom.dropboxlist, "click", this.dropboxlist.bind(this));
|
||||||
OZ.Event.add(this.dom.clientsql, "click", this.bind(this.clientsql));
|
OZ.Event.add(this.dom.clientsql, "click", this.clientsql.bind(this));
|
||||||
OZ.Event.add(this.dom.quicksave, "click", this.bind(this.quicksave));
|
OZ.Event.add(this.dom.quicksave, "click", this.quicksave.bind(this));
|
||||||
OZ.Event.add(this.dom.serversave, "click", this.bind(this.serversave));
|
OZ.Event.add(this.dom.serversave, "click", this.serversave.bind(this));
|
||||||
OZ.Event.add(this.dom.serverload, "click", this.bind(this.serverload));
|
OZ.Event.add(this.dom.serverload, "click", this.serverload.bind(this));
|
||||||
OZ.Event.add(this.dom.serverlist, "click", this.bind(this.serverlist));
|
OZ.Event.add(this.dom.serverlist, "click", this.serverlist.bind(this));
|
||||||
OZ.Event.add(this.dom.serverimport, "click", this.bind(this.serverimport));
|
OZ.Event.add(this.dom.serverimport, "click", this.serverimport.bind(this));
|
||||||
OZ.Event.add(document, "keydown", this.bind(this.press));
|
OZ.Event.add(document, "keydown", this.press.bind(this));
|
||||||
this.build();
|
this.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,7 +363,7 @@ SQL.IO.prototype.clientsql = function() {
|
|||||||
var bp = this.owner.getOption("staticpath");
|
var bp = this.owner.getOption("staticpath");
|
||||||
var path = bp + "db/"+window.DATATYPES.getAttribute("db")+"/output.xsl";
|
var path = bp + "db/"+window.DATATYPES.getAttribute("db")+"/output.xsl";
|
||||||
this.owner.window.showThrobber();
|
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) {
|
SQL.IO.prototype.finish = function(xslDoc) {
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
/* --------------------- db index ------------ */
|
/* --------------------- db index ------------ */
|
||||||
|
SQL.Key = function(owner, type, name) {
|
||||||
SQL.Key = OZ.Class().extend(SQL.Visual);
|
|
||||||
|
|
||||||
SQL.Key.prototype.init = function(owner, type, name) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.rows = [];
|
this.rows = [];
|
||||||
this.type = type || "INDEX";
|
this.type = type || "INDEX";
|
||||||
this.name = name || "";
|
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) {
|
SQL.Key.prototype.setName = function(n) {
|
||||||
this.name = n;
|
this.name = n;
|
||||||
|
|||||||
+9
-11
@@ -1,8 +1,6 @@
|
|||||||
/* ----------------- key manager ---------- */
|
/* ----------------- key manager ---------- */
|
||||||
|
|
||||||
SQL.KeyManager = OZ.Class();
|
SQL.KeyManager = function(owner) {
|
||||||
|
|
||||||
SQL.KeyManager.prototype.init = function(owner) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.dom = {
|
this.dom = {
|
||||||
container:OZ.$("keys")
|
container:OZ.$("keys")
|
||||||
@@ -44,15 +42,15 @@ SQL.KeyManager.prototype.build = function() {
|
|||||||
this.dom.type.appendChild(o);
|
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.list, "change", this.listchange.bind(this));
|
||||||
OZ.Event.add(this.dom.type, "change", this.bind(this.typechange));
|
OZ.Event.add(this.dom.type, "change", this.typechange.bind(this));
|
||||||
OZ.Event.add(this.dom.name, "keyup", this.bind(this.namechange));
|
OZ.Event.add(this.dom.name, "keyup", this.namechange.bind(this));
|
||||||
OZ.Event.add(this.dom.keyadd, "click", this.bind(this.add));
|
OZ.Event.add(this.dom.keyadd, "click", this.add.bind(this));
|
||||||
OZ.Event.add(this.dom.keyremove, "click", this.bind(this.remove));
|
OZ.Event.add(this.dom.keyremove, "click", this.remove.bind(this));
|
||||||
OZ.Event.add(this.dom.left, "click", this.bind(this.left));
|
OZ.Event.add(this.dom.left, "click", this.left.bind(this));
|
||||||
OZ.Event.add(this.dom.right, "click", this.bind(this.right));
|
OZ.Event.add(this.dom.right, "click", this.right.bind(this));
|
||||||
|
|
||||||
this.dom.container.parentNode.removeChild(this.dom.container);
|
this.dom.container.parentNode.removeChild(this.dom.container);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
/* --------------------- minimap ------------ */
|
/* --------------------- minimap ------------ */
|
||||||
|
|
||||||
SQL.Map = OZ.Class().extend(SQL.Visual);
|
SQL.Map = function(owner) {
|
||||||
|
|
||||||
SQL.Map.prototype.init = function(owner) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
SQL.Visual.prototype.init.apply(this);
|
SQL.Visual.apply(this);
|
||||||
this.dom.container = OZ.$("minimap");
|
this.dom.container = OZ.$("minimap");
|
||||||
this.width = this.dom.container.offsetWidth - 2;
|
this.width = this.dom.container.offsetWidth - 2;
|
||||||
this.height = this.dom.container.offsetHeight - 2;
|
this.height = this.dom.container.offsetHeight - 2;
|
||||||
|
|
||||||
this.dom.port = OZ.DOM.elm("div",{className:"port", zIndex:1});
|
this.dom.port = OZ.DOM.elm("div",{className:"port", zIndex:1});
|
||||||
this.dom.container.appendChild(this.dom.port);
|
this.dom.container.appendChild(this.dom.port);
|
||||||
this.sync = this.bind(this.sync);
|
this.sync = this.sync.bind(this);
|
||||||
|
|
||||||
this.flag = false;
|
this.flag = false;
|
||||||
this.sync();
|
this.sync();
|
||||||
|
|
||||||
OZ.Event.add(window, "resize", this.sync);
|
OZ.Event.add(window, "resize", this.sync);
|
||||||
OZ.Event.add(window, "scroll", 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, "mousedown", this.down.bind(this));
|
||||||
OZ.Event.add(this.dom.container, "touchstart", this.bind(this.down));
|
OZ.Event.add(this.dom.container, "touchstart", this.down.bind(this));
|
||||||
OZ.Event.add(this.dom.container, "touchmove", OZ.Event.prevent);
|
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 */
|
SQL.Map.prototype.down = function(e) { /* mousedown - move view and start drag */
|
||||||
this.flag = true;
|
this.flag = true;
|
||||||
@@ -40,8 +39,8 @@ SQL.Map.prototype.down = function(e) { /* mousedown - move view and start drag *
|
|||||||
var eventUp = "mouseup";
|
var eventUp = "mouseup";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.documentMove = OZ.Event.add(document, eventMove, this.bind(this.move));
|
this.documentMove = OZ.Event.add(document, eventMove, this.move.bind(this));
|
||||||
this.documentUp = OZ.Event.add(document, eventUp, this.bind(this.up));
|
this.documentUp = OZ.Event.add(document, eventUp, this.up.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQL.Map.prototype.move = function(e) { /* mousemove */
|
SQL.Map.prototype.move = function(e) { /* mousemove */
|
||||||
|
|||||||
+3
-34
@@ -1,15 +1,13 @@
|
|||||||
/* --------------------- options ------------ */
|
/* --------------------- options ------------ */
|
||||||
|
|
||||||
SQL.Options = OZ.Class();
|
SQL.Options = function(owner) {
|
||||||
|
|
||||||
SQL.Options.prototype.init = function(owner) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.dom = {
|
this.dom = {
|
||||||
container:OZ.$("opts"),
|
container:OZ.$("opts"),
|
||||||
btn:OZ.$("options")
|
btn:OZ.$("options")
|
||||||
}
|
}
|
||||||
this.dom.btn.value = _("options");
|
this.dom.btn.value = _("options");
|
||||||
this.save = this.bind(this.save);
|
this.save = this.save.bind(this);
|
||||||
this.build();
|
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);
|
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.optionshowsize.checked = this.owner.getOption("showsize");
|
||||||
this.dom.optionshowtype.checked = this.owner.getOption("showtype");
|
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");
|
|
||||||
}
|
|
||||||
|
|||||||
+4
-4
@@ -1,14 +1,12 @@
|
|||||||
/* --------------------------- relation (connector) ----------- */
|
/* --------------------------- relation (connector) ----------- */
|
||||||
|
|
||||||
SQL.Relation = OZ.Class().extend(SQL.Visual);
|
SQL.Relation = function(owner, row1, row2) {
|
||||||
SQL.Relation._counter = 0;
|
|
||||||
SQL.Relation.prototype.init = function(owner, row1, row2) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.row1 = row1;
|
this.row1 = row1;
|
||||||
this.row2 = row2;
|
this.row2 = row2;
|
||||||
this.color = "#000";
|
this.color = "#000";
|
||||||
this.hidden = false;
|
this.hidden = false;
|
||||||
SQL.Visual.prototype.init.apply(this);
|
SQL.Visual.apply(this);
|
||||||
|
|
||||||
/* if one of the rows already has relations, inherit color */
|
/* if one of the rows already has relations, inherit color */
|
||||||
var all = row1.relations.concat(row2.relations);
|
var all = row1.relations.concat(row2.relations);
|
||||||
@@ -46,6 +44,8 @@ SQL.Relation.prototype.init = function(owner, row1, row2) {
|
|||||||
|
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
}
|
||||||
|
SQL.Relation._counter = 0;
|
||||||
|
SQL.Relation.prototype = Object.create(SQL.Visual.prototype);
|
||||||
|
|
||||||
SQL.Relation.prototype.getColor = function() {
|
SQL.Relation.prototype.getColor = function() {
|
||||||
return this.color;
|
return this.color;
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
/* --------------------- table row ( = db column) ------------ */
|
/* --------------------- table row ( = db column) ------------ */
|
||||||
|
SQL.Row = function(owner, title, data) {
|
||||||
SQL.Row = OZ.Class().extend(SQL.Visual);
|
|
||||||
|
|
||||||
SQL.Row.prototype.init = function(owner, title, data) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.relations = [];
|
this.relations = [];
|
||||||
this.keys = [];
|
this.keys = [];
|
||||||
this.selected = false;
|
this.selected = false;
|
||||||
this.expanded = false;
|
this.expanded = false;
|
||||||
|
|
||||||
SQL.Visual.prototype.init.apply(this);
|
SQL.Visual.apply(this);
|
||||||
|
|
||||||
this.data.type = 0;
|
this.data.type = 0;
|
||||||
this.data.size = "";
|
this.data.size = "";
|
||||||
@@ -21,6 +18,7 @@ SQL.Row.prototype.init = function(owner, title, data) {
|
|||||||
if (data) { this.update(data); }
|
if (data) { this.update(data); }
|
||||||
this.setTitle(title);
|
this.setTitle(title);
|
||||||
}
|
}
|
||||||
|
SQL.Row.prototype = Object.create(SQL.Visual.prototype);
|
||||||
|
|
||||||
SQL.Row.prototype._build = function() {
|
SQL.Row.prototype._build = function() {
|
||||||
this.dom.container = OZ.DOM.elm("tbody");
|
this.dom.container = OZ.DOM.elm("tbody");
|
||||||
@@ -38,11 +36,11 @@ SQL.Row.prototype._build = function() {
|
|||||||
[td1, this.dom.selected, this.dom.title]
|
[td1, this.dom.selected, this.dom.title]
|
||||||
);
|
);
|
||||||
|
|
||||||
this.enter = this.bind(this.enter);
|
this.enter = this.enter.bind(this);
|
||||||
this.changeComment = this.bind(this.changeComment);
|
this.changeComment = this.changeComment.bind(this);
|
||||||
|
|
||||||
OZ.Event.add(this.dom.container, "click",this.bind(this.click));
|
OZ.Event.add(this.dom.container, "click",this.click.bind(this));
|
||||||
OZ.Event.add(this.dom.container, "dblclick",this.bind(this.dblclick));
|
OZ.Event.add(this.dom.container, "dblclick",this.dblclick.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQL.Row.prototype.select = function() {
|
SQL.Row.prototype.select = function() {
|
||||||
@@ -71,7 +69,7 @@ SQL.Row.prototype.setTitle = function(t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SQL.Row.prototype.click = function(e) { /* clicked on row */
|
SQL.Row.prototype.click = function(e) { /* clicked on row */
|
||||||
this.dispatch("rowclick", this);
|
SQL.publish("rowclick", this);
|
||||||
this.owner.owner.rowManager.select(this);
|
this.owner.owner.rowManager.select(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-14
@@ -1,8 +1,5 @@
|
|||||||
/* --------------------- row manager ------------ */
|
/* --------------------- row manager ------------ */
|
||||||
|
SQL.RowManager = function(owner) {
|
||||||
SQL.RowManager = OZ.Class();
|
|
||||||
|
|
||||||
SQL.RowManager.prototype.init = function(owner) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.dom = {};
|
this.dom = {};
|
||||||
this.selected = null;
|
this.selected = null;
|
||||||
@@ -19,16 +16,17 @@ SQL.RowManager.prototype.init = function(owner) {
|
|||||||
|
|
||||||
this.select(false);
|
this.select(false);
|
||||||
|
|
||||||
OZ.Event.add(this.dom.editrow, "click", this.bind(this.edit));
|
OZ.Event.add(this.dom.editrow, "click", this.edit.bind(this));
|
||||||
OZ.Event.add(this.dom.uprow, "click", this.bind(this.up));
|
OZ.Event.add(this.dom.uprow, "click", this.up.bind(this));
|
||||||
OZ.Event.add(this.dom.downrow, "click", this.bind(this.down));
|
OZ.Event.add(this.dom.downrow, "click", this.down.bind(this));
|
||||||
OZ.Event.add(this.dom.removerow, "click", this.bind(this.remove));
|
OZ.Event.add(this.dom.removerow, "click", this.remove.bind(this));
|
||||||
OZ.Event.add(this.dom.foreigncreate, "click", this.bind(this.foreigncreate));
|
OZ.Event.add(this.dom.foreigncreate, "click", this.foreigncreate.bind(this));
|
||||||
OZ.Event.add(this.dom.foreignconnect, "click", this.bind(this.foreignconnect));
|
OZ.Event.add(this.dom.foreignconnect, "click", this.foreignconnect.bind(this));
|
||||||
OZ.Event.add(this.dom.foreigndisconnect, "click", this.bind(this.foreigndisconnect));
|
OZ.Event.add(this.dom.foreigndisconnect, "click", this.foreigndisconnect.bind(this));
|
||||||
OZ.Event.add(false, "tableclick", this.bind(this.tableClick));
|
OZ.Event.add(document, "keydown", this.press.bind(this));
|
||||||
OZ.Event.add(false, "rowclick", this.bind(this.rowClick));
|
|
||||||
OZ.Event.add(document, "keydown", this.bind(this.press));
|
SQL.subscribe("tableclick", this.tableClick.bind(this));
|
||||||
|
SQL.subscribe("rowclick", this.rowClick.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQL.RowManager.prototype.select = function(row) { /* activate a row */
|
SQL.RowManager.prototype.select = function(row) { /* activate a row */
|
||||||
|
|||||||
+6
-7
@@ -1,13 +1,12 @@
|
|||||||
/* --------------------- rubberband -------------------- */
|
/* --------------------- rubberband -------------------- */
|
||||||
|
|
||||||
SQL.Rubberband = OZ.Class().extend(SQL.Visual);
|
SQL.Rubberband = function(owner) {
|
||||||
|
|
||||||
SQL.Rubberband.prototype.init = function(owner) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
SQL.Visual.prototype.init.apply(this);
|
SQL.Visual.apply(this);
|
||||||
this.dom.container = OZ.$("rubberband");
|
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) {
|
SQL.Rubberband.prototype.down = function(e) {
|
||||||
OZ.Event.prevent(e);
|
OZ.Event.prevent(e);
|
||||||
@@ -17,8 +16,8 @@ SQL.Rubberband.prototype.down = function(e) {
|
|||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.height = 0;
|
this.height = 0;
|
||||||
this.redraw();
|
this.redraw();
|
||||||
this.documentMove = OZ.Event.add(document, "mousemove", this.bind(this.move));
|
this.documentMove = OZ.Event.add(document, "mousemove", this.move.bind(this));
|
||||||
this.documentUp = OZ.Event.add(document, "mouseup", this.bind(this.up));
|
this.documentUp = OZ.Event.add(document, "mouseup", this.up.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQL.Rubberband.prototype.move = function(e) {
|
SQL.Rubberband.prototype.move = function(e) {
|
||||||
|
|||||||
+10
-12
@@ -1,8 +1,5 @@
|
|||||||
/* --------------------- db table ------------ */
|
/* --------------------- db table ------------ */
|
||||||
|
SQL.Table = function(owner, name, x, y, z) {
|
||||||
SQL.Table = OZ.Class().extend(SQL.Visual);
|
|
||||||
|
|
||||||
SQL.Table.prototype.init = function(owner, name, x, y, z) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.rows = [];
|
this.rows = [];
|
||||||
this.keys = [];
|
this.keys = [];
|
||||||
@@ -11,7 +8,7 @@ SQL.Table.prototype.init = function(owner, name, x, y, z) {
|
|||||||
|
|
||||||
this.flag = false;
|
this.flag = false;
|
||||||
this.selected = false;
|
this.selected = false;
|
||||||
SQL.Visual.prototype.init.apply(this);
|
SQL.Visual.apply(this);
|
||||||
this.data.comment = "";
|
this.data.comment = "";
|
||||||
|
|
||||||
this.setTitle(name);
|
this.setTitle(name);
|
||||||
@@ -20,6 +17,7 @@ SQL.Table.prototype.init = function(owner, name, x, y, z) {
|
|||||||
this.setZ(z);
|
this.setZ(z);
|
||||||
this.snap();
|
this.snap();
|
||||||
}
|
}
|
||||||
|
SQL.Table.prototype = Object.create(SQL.Visual.prototype);
|
||||||
|
|
||||||
SQL.Table.prototype._build = function() {
|
SQL.Table.prototype._build = function() {
|
||||||
this.dom.container = OZ.DOM.elm("div", {className:"table"});
|
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.dom.mini = OZ.DOM.elm("div", {className:"mini"});
|
||||||
this.owner.map.dom.container.appendChild(this.dom.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, "click", this.click.bind(this)));
|
||||||
this._ec.push(OZ.Event.add(this.dom.container, "dblclick", this.bind(this.dblclick)));
|
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.bind(this.down)));
|
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.bind(this.down)));
|
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));
|
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 */
|
if (t != this.dom.title) { return; } /* click on row */
|
||||||
|
|
||||||
this.dispatch("tableclick",this);
|
SQL.publish("tableclick", this);
|
||||||
this.owner.rowManager.select(false);
|
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.documentMove = OZ.Event.add(document, moveEvent, this.move.bind(this));
|
||||||
this.documentUp = OZ.Event.add(document, upEvent, this.bind(this.up));
|
this.documentUp = OZ.Event.add(document, upEvent, this.up.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQL.Table.prototype.toXML = function() {
|
SQL.Table.prototype.toXML = function() {
|
||||||
|
|||||||
+11
-13
@@ -1,8 +1,6 @@
|
|||||||
/* --------------------- table manager ------------ */
|
/* --------------------- table manager ------------ */
|
||||||
|
|
||||||
SQL.TableManager = OZ.Class();
|
SQL.TableManager = function(owner) {
|
||||||
|
|
||||||
SQL.TableManager.prototype.init = function(owner) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.dom = {
|
this.dom = {
|
||||||
container:OZ.$("table"),
|
container:OZ.$("table"),
|
||||||
@@ -30,17 +28,17 @@ SQL.TableManager.prototype.init = function(owner) {
|
|||||||
|
|
||||||
this.select(false);
|
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("area", "click", this.click.bind(this));
|
||||||
OZ.Event.add(this.dom.addtable, "click", this.bind(this.preAdd));
|
OZ.Event.add(this.dom.addtable, "click", this.preAdd.bind(this));
|
||||||
OZ.Event.add(this.dom.removetable, "click", this.bind(this.remove));
|
OZ.Event.add(this.dom.removetable, "click", this.remove.bind(this));
|
||||||
OZ.Event.add(this.dom.cleartables, "click", this.bind(this.clear));
|
OZ.Event.add(this.dom.cleartables, "click", this.clear.bind(this));
|
||||||
OZ.Event.add(this.dom.addrow, "click", this.bind(this.addRow));
|
OZ.Event.add(this.dom.addrow, "click", this.addRow.bind(this));
|
||||||
OZ.Event.add(this.dom.aligntables, "click", this.owner.bind(this.owner.alignTables));
|
OZ.Event.add(this.dom.aligntables, "click", this.owner.alignTables.bind(this.owner));
|
||||||
OZ.Event.add(this.dom.edittable, "click", this.bind(this.edit));
|
OZ.Event.add(this.dom.edittable, "click", this.edit.bind(this));
|
||||||
OZ.Event.add(this.dom.tablekeys, "click", this.bind(this.keys));
|
OZ.Event.add(this.dom.tablekeys, "click", this.keys.bind(this));
|
||||||
OZ.Event.add(document, "keydown", this.bind(this.press));
|
OZ.Event.add(document, "keydown", this.press.bind(this));
|
||||||
|
|
||||||
this.dom.container.parentNode.removeChild(this.dom.container);
|
this.dom.container.parentNode.removeChild(this.dom.container);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
/* -------------------- base visual element -------------------- */
|
/* -------------------- base visual element -------------------- */
|
||||||
|
SQL.Visual = function() {
|
||||||
SQL.Visual = OZ.Class(); /* abstract parent */
|
|
||||||
SQL.Visual.prototype.init = function() {
|
|
||||||
this._init();
|
this._init();
|
||||||
this._build();
|
this._build();
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-7
@@ -1,8 +1,6 @@
|
|||||||
/* --------------------- window ------------ */
|
/* --------------------- window ------------ */
|
||||||
|
|
||||||
SQL.Window = OZ.Class();
|
SQL.Window = function(owner) {
|
||||||
|
|
||||||
SQL.Window.prototype.init = function(owner) {
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.dom = {
|
this.dom = {
|
||||||
container:OZ.$("window"),
|
container:OZ.$("window"),
|
||||||
@@ -16,11 +14,11 @@ SQL.Window.prototype.init = function(owner) {
|
|||||||
this.dom.ok.value = _("windowok");
|
this.dom.ok.value = _("windowok");
|
||||||
this.dom.cancel.value = _("windowcancel");
|
this.dom.cancel.value = _("windowcancel");
|
||||||
this.dom.throbber.alt = this.dom.throbber.title = _("throbber");
|
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.ok, "click", this.ok.bind(this));
|
||||||
OZ.Event.add(this.dom.cancel, "click", this.bind(this.close));
|
OZ.Event.add(this.dom.cancel, "click", this.close.bind(this));
|
||||||
OZ.Event.add(document, "keydown", this.bind(this.key));
|
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, "scroll", this.sync);
|
||||||
OZ.Event.add(window, "resize", this.sync);
|
OZ.Event.add(window, "resize", this.sync);
|
||||||
|
|||||||
+5
-12
@@ -1,15 +1,11 @@
|
|||||||
/* --------------------- www sql designer ------------ */
|
SQL.Designer = function() {
|
||||||
|
|
||||||
SQL.Designer = OZ.Class().extend(SQL.Visual);
|
|
||||||
|
|
||||||
SQL.Designer.prototype.init = function() {
|
|
||||||
SQL.Designer = this;
|
SQL.Designer = this;
|
||||||
|
|
||||||
this.tables = [];
|
this.tables = [];
|
||||||
this.relations = [];
|
this.relations = [];
|
||||||
this.title = document.title;
|
this.title = document.title;
|
||||||
|
|
||||||
SQL.Visual.prototype.init.apply(this);
|
SQL.Visual.apply(this);
|
||||||
new SQL.Toggle(OZ.$("toggle"));
|
new SQL.Toggle(OZ.$("toggle"));
|
||||||
|
|
||||||
this.dom.container = OZ.$("area");
|
this.dom.container = OZ.$("area");
|
||||||
@@ -34,6 +30,7 @@ SQL.Designer.prototype.init = function() {
|
|||||||
this.requestLanguage();
|
this.requestLanguage();
|
||||||
this.requestDB();
|
this.requestDB();
|
||||||
}
|
}
|
||||||
|
SQL.Designer.prototype = Object.create(SQL.Visual.prototype);
|
||||||
|
|
||||||
/* update area size */
|
/* update area size */
|
||||||
SQL.Designer.prototype.sync = function() {
|
SQL.Designer.prototype.sync = function() {
|
||||||
@@ -59,7 +56,7 @@ SQL.Designer.prototype.requestLanguage = function() { /* get locale file */
|
|||||||
var lang = this.getOption("locale")
|
var lang = this.getOption("locale")
|
||||||
var bp = this.getOption("staticpath");
|
var bp = this.getOption("staticpath");
|
||||||
var url = bp + "locale/"+lang+".xml";
|
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) {
|
SQL.Designer.prototype.languageResponse = function(xmlDoc) {
|
||||||
@@ -79,7 +76,7 @@ SQL.Designer.prototype.requestDB = function() { /* get datatypes file */
|
|||||||
var db = this.getOption("db");
|
var db = this.getOption("db");
|
||||||
var bp = this.getOption("staticpath");
|
var bp = this.getOption("staticpath");
|
||||||
var url = bp + "db/"+db+"/datatypes.xml";
|
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) {
|
SQL.Designer.prototype.dbResponse = function(xmlDoc) {
|
||||||
@@ -348,7 +345,3 @@ SQL.Designer.prototype.getFKTypeFor = function(typeIndex) {
|
|||||||
}
|
}
|
||||||
return this.fkTypeFor[typeIndex];
|
return this.fkTypeFor[typeIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onbeforeunload = function(e) {
|
|
||||||
return ""; /* some browsers will show this text, some won't. */
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user