Merge pull request #318 from bilogic/vscode-auto-format
Auto formatters used
This commit is contained in:
+52
-34
@@ -1,18 +1,23 @@
|
|||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<!--
|
<!--
|
||||||
WWW SQL Designer, (C) 2005-2015 Ondrej Zara, ondras@zarovi.cz
|
WWW SQL Designer, (C) 2005-2015 Ondrej Zara, ondras@zarovi.cz
|
||||||
Version: 2.7
|
Version: 2.7
|
||||||
See license.txt for licencing information.
|
See license.txt for licencing information.
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>WWW SQL Designer</title>
|
<title>WWW SQL Designer</title>
|
||||||
<meta name="viewport" content="initial-scale=1,maximum-scale=1" />
|
<meta name="viewport" content="initial-scale=1,maximum-scale=1" />
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="stylesheet" title="material-inspired" href="styles/material-inspired.css" media="all" />
|
<link rel="stylesheet" title="material-inspired" href="styles/material-inspired.css" media="all" />
|
||||||
<link rel="alternate stylesheet" title="original" href="styles/original.css" media="all" />
|
<link rel="alternate stylesheet" title="original" href="styles/original.css" media="all" />
|
||||||
<!--[if IE 6]><link rel="stylesheet" type="text/css" href="styles/ie6.css" /><![endif]-->
|
<!--[if IE 6
|
||||||
<!--[if IE 7]><link rel="stylesheet" type="text/css" href="styles/ie7.css" /><![endif]-->
|
]><link rel="stylesheet" type="text/css" href="styles/ie6.css"
|
||||||
|
/><![endif]-->
|
||||||
|
<!--[if IE 7
|
||||||
|
]><link rel="stylesheet" type="text/css" href="styles/ie7.css"
|
||||||
|
/><![endif]-->
|
||||||
<link rel="stylesheet" href="styles/print.css" type="text/css" media="print" />
|
<link rel="stylesheet" href="styles/print.css" type="text/css" media="print" />
|
||||||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.10.2/dropbox.min.js"></script>
|
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.10.2/dropbox.min.js"></script>
|
||||||
|
|
||||||
@@ -66,7 +71,8 @@
|
|||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<input type="button" id="options" />
|
<input type="button" id="options" />
|
||||||
<a href="https://github.com/ondras/wwwsqldesigner/wiki" target="_blank"><input type="button" id="docs" value="" /></a>
|
<a href="https://github.com/ondras/wwwsqldesigner/wiki" target="_blank"><input type="button" id="docs"
|
||||||
|
value="" /></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="rubberband"></div>
|
<div id="rubberband"></div>
|
||||||
@@ -76,30 +82,33 @@
|
|||||||
<div id="background"></div>
|
<div id="background"></div>
|
||||||
|
|
||||||
<div id="window">
|
<div id="window">
|
||||||
<div id="windowtitle"><img id="throbber" src="images/throbber.gif" alt="" title=""/></div>
|
<div id="windowtitle">
|
||||||
|
<img id="throbber" src="images/throbber.gif" alt="" title="" />
|
||||||
|
</div>
|
||||||
<div id="windowcontent"></div>
|
<div id="windowcontent"></div>
|
||||||
<input type="button" id="windowok" />
|
<input type="button" id="windowok" />
|
||||||
<input type="button" id="windowcancel" />
|
<input type="button" id="windowcancel" />
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- #controls -->
|
</div>
|
||||||
|
<!-- #controls -->
|
||||||
|
|
||||||
<div id="opts">
|
<div id="opts">
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>* <label id="language" for="optionlocale"></label></td>
|
||||||
<td>
|
<td>
|
||||||
* <label id="language" for="optionlocale"></label>
|
<select id="optionlocale">
|
||||||
</td>
|
<option></option>
|
||||||
<td>
|
</select>
|
||||||
<select id="optionlocale"><option></option></select>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>* <label id="db" for="optiondb"></label></td>
|
||||||
<td>
|
<td>
|
||||||
* <label id="db" for="optiondb"></label>
|
<select id="optiondb">
|
||||||
</td>
|
<option></option>
|
||||||
<td>
|
</select>
|
||||||
<select id="optiondb"><option></option></select>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -121,11 +130,11 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>* <label id="style" for="optionstyle"></label></td>
|
||||||
<td>
|
<td>
|
||||||
* <label id="style" for="optionstyle"></label>
|
<select id="optionstyle">
|
||||||
</td>
|
<option></option>
|
||||||
<td>
|
</select>
|
||||||
<select id="optionstyle"><option></option></select>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -137,25 +146,19 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>* <label id="vector" for="optionvector"></label></td>
|
||||||
* <label id="vector" for="optionvector"></label>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" id="optionvector" />
|
<input type="checkbox" id="optionvector" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>* <label id="showsize" for="optionshowsize"></label></td>
|
||||||
* <label id="showsize" for="optionshowsize"></label>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" id="optionshowsize" />
|
<input type="checkbox" id="optionshowsize" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>* <label id="showtype" for="optionshowtype"></label></td>
|
||||||
* <label id="showtype" for="optionshowtype"></label>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" id="optionshowtype" />
|
<input type="checkbox" id="optionshowtype" />
|
||||||
</td>
|
</td>
|
||||||
@@ -196,7 +199,10 @@
|
|||||||
<td style="width: 40%">
|
<td style="width: 40%">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend id="server"></legend>
|
<legend id="server"></legend>
|
||||||
<label for="backend" id="backendlabel"></label> <select id="backend"><option></option></select>
|
<label for="backend" id="backendlabel"></label>
|
||||||
|
<select id="backend">
|
||||||
|
<option></option>
|
||||||
|
</select>
|
||||||
<hr />
|
<hr />
|
||||||
<input type="button" id="serversave" />
|
<input type="button" id="serversave" />
|
||||||
<input type="button" id="quicksave" />
|
<input type="button" id="quicksave" />
|
||||||
@@ -210,7 +216,8 @@
|
|||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend id="output"></legend>
|
<legend id="output"></legend>
|
||||||
<textarea id="textarea" rows="1" cols="1"></textarea><!--modified by javascript later-->
|
<textarea id="textarea" rows="1" cols="1"></textarea>
|
||||||
|
<!--modified by javascript later-->
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -221,7 +228,9 @@
|
|||||||
<div id="keys">
|
<div id="keys">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend id="keyslistlabel"></legend>
|
<legend id="keyslistlabel"></legend>
|
||||||
<select id="keyslist"><option></option></select>
|
<select id="keyslist">
|
||||||
|
<option></option>
|
||||||
|
</select>
|
||||||
<input type="button" id="keyadd" />
|
<input type="button" id="keyadd" />
|
||||||
<input type="button" id="keyremove" />
|
<input type="button" id="keyremove" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -232,7 +241,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="keytype" id="keytypelabel"></label>
|
<label for="keytype" id="keytypelabel"></label>
|
||||||
<select id="keytype"><option></option></select>
|
<select id="keytype">
|
||||||
|
<option></option>
|
||||||
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
@@ -241,12 +252,16 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3"><hr/></td>
|
<td colspan="3">
|
||||||
|
<hr />
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="keyfields" id="keyfieldslabel"></label><br />
|
<label for="keyfields" id="keyfieldslabel"></label><br />
|
||||||
<select id="keyfields" size="5" multiple="multiple"><option></option></select>
|
<select id="keyfields" size="5" multiple="multiple">
|
||||||
|
<option></option>
|
||||||
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="button" id="keyleft" value="<<" /><br />
|
<input type="button" id="keyleft" value="<<" /><br />
|
||||||
@@ -254,7 +269,9 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label for="keyavail" id="keyavaillabel"></label><br />
|
<label for="keyavail" id="keyavaillabel"></label><br />
|
||||||
<select id="keyavail" size="5" multiple="multiple"><option></option></select>
|
<select id="keyavail" size="5" multiple="multiple">
|
||||||
|
<option></option>
|
||||||
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -291,4 +308,5 @@
|
|||||||
// d.setXhrHeaders({"X-CSRF-TOKEN": "xxx"});
|
// d.setXhrHeaders({"X-CSRF-TOKEN": "xxx"});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
+69
-7
@@ -1,11 +1,56 @@
|
|||||||
var CONFIG = {
|
var CONFIG = {
|
||||||
AVAILABLE_DBS: ["mysql", "sqlite", "web2py", "mssql", "postgresql", "oracle", "sqlalchemy", "vfp9", "cubrid", "web2py"],
|
AVAILABLE_DBS: [
|
||||||
|
"mysql",
|
||||||
|
"sqlite",
|
||||||
|
"web2py",
|
||||||
|
"mssql",
|
||||||
|
"postgresql",
|
||||||
|
"oracle",
|
||||||
|
"sqlalchemy",
|
||||||
|
"vfp9",
|
||||||
|
"cubrid",
|
||||||
|
"web2py",
|
||||||
|
],
|
||||||
DEFAULT_DB: "mysql",
|
DEFAULT_DB: "mysql",
|
||||||
|
|
||||||
AVAILABLE_LOCALES: ["ar", "cs", "de", "el", "en", "eo", "es", "fr", "hu", "it", "ja", "ko", "nl", "pl", "pt_BR", "ro", "ru", "sv", "tr", "zh"],
|
AVAILABLE_LOCALES: [
|
||||||
|
"ar",
|
||||||
|
"cs",
|
||||||
|
"de",
|
||||||
|
"el",
|
||||||
|
"en",
|
||||||
|
"eo",
|
||||||
|
"es",
|
||||||
|
"fr",
|
||||||
|
"hu",
|
||||||
|
"it",
|
||||||
|
"ja",
|
||||||
|
"ko",
|
||||||
|
"nl",
|
||||||
|
"pl",
|
||||||
|
"pt_BR",
|
||||||
|
"ro",
|
||||||
|
"ru",
|
||||||
|
"sv",
|
||||||
|
"tr",
|
||||||
|
"zh",
|
||||||
|
],
|
||||||
DEFAULT_LOCALE: "en",
|
DEFAULT_LOCALE: "en",
|
||||||
|
|
||||||
AVAILABLE_BACKENDS: ["php-mysql", "php-s3", "php-blank", "php-file", "php-sqlite", "php-mysql+file", "php-postgresql", "php-pdo", "perl-file", "php-cubrid", "asp-file", "web2py"],
|
AVAILABLE_BACKENDS: [
|
||||||
|
"php-mysql",
|
||||||
|
"php-s3",
|
||||||
|
"php-blank",
|
||||||
|
"php-file",
|
||||||
|
"php-sqlite",
|
||||||
|
"php-mysql+file",
|
||||||
|
"php-postgresql",
|
||||||
|
"php-pdo",
|
||||||
|
"perl-file",
|
||||||
|
"php-cubrid",
|
||||||
|
"asp-file",
|
||||||
|
"web2py",
|
||||||
|
],
|
||||||
DEFAULT_BACKEND: ["php-mysql"],
|
DEFAULT_BACKEND: ["php-mysql"],
|
||||||
|
|
||||||
RELATION_THICKNESS: 2,
|
RELATION_THICKNESS: 2,
|
||||||
@@ -16,7 +61,25 @@ var CONFIG = {
|
|||||||
RELATION_HIGHLIGHTED_THICKNESS: 5,
|
RELATION_HIGHLIGHTED_THICKNESS: 5,
|
||||||
|
|
||||||
STYLES: ["material-inspired", "original"],
|
STYLES: ["material-inspired", "original"],
|
||||||
MATERIAL_RELATION_COLORS: ["#323232", "#F44336", "#E91E63", "#9C27B0", "#3F51B5", "#673AB7", "#2196F3", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8BC34A", "#CDDC39", "#FFC107", "#FF5722", "#795548", "#607D8B"],
|
MATERIAL_RELATION_COLORS: [
|
||||||
|
"#323232",
|
||||||
|
"#F44336",
|
||||||
|
"#E91E63",
|
||||||
|
"#9C27B0",
|
||||||
|
"#3F51B5",
|
||||||
|
"#673AB7",
|
||||||
|
"#2196F3",
|
||||||
|
"#03A9F4",
|
||||||
|
"#00BCD4",
|
||||||
|
"#009688",
|
||||||
|
"#4CAF50",
|
||||||
|
"#8BC34A",
|
||||||
|
"#CDDC39",
|
||||||
|
"#FFC107",
|
||||||
|
"#FF5722",
|
||||||
|
"#795548",
|
||||||
|
"#607D8B",
|
||||||
|
],
|
||||||
|
|
||||||
STATIC_PATH: "",
|
STATIC_PATH: "",
|
||||||
XHR_PATH: "",
|
XHR_PATH: "",
|
||||||
@@ -31,6 +94,5 @@ var CONFIG = {
|
|||||||
* http://localhost/sqldesigner/dropbox-oauth-receiver.html as a Redirection URI.
|
* http://localhost/sqldesigner/dropbox-oauth-receiver.html as a Redirection URI.
|
||||||
* Copy the shown "App key" and paste it here below instead of the null value:
|
* Copy the shown "App key" and paste it here below instead of the null value:
|
||||||
*/
|
*/
|
||||||
DROPBOX_KEY: null // such as: "d6stdscwewhl6sa"
|
DROPBOX_KEY: null, // such as: "d6stdscwewhl6sa"
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|||||||
+33
-15
@@ -1,9 +1,12 @@
|
|||||||
function _(str) { /* getText */
|
function _(str) {
|
||||||
if (!(str in window.LOCALE)) { return str; }
|
/* getText */
|
||||||
|
if (!(str in window.LOCALE)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
return window.LOCALE[str];
|
return window.LOCALE[str];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof String.prototype.endsWith !== 'function') {
|
if (typeof String.prototype.endsWith !== "function") {
|
||||||
String.prototype.endsWith = function (suffix) {
|
String.prototype.endsWith = function (suffix) {
|
||||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||||
};
|
};
|
||||||
@@ -12,16 +15,22 @@ if (typeof String.prototype.endsWith !== 'function') {
|
|||||||
if (!String.prototype.trim) {
|
if (!String.prototype.trim) {
|
||||||
String.prototype.trim = function () {
|
String.prototype.trim = function () {
|
||||||
return this.match(/^\s*([\s\S]*?)\s*$/)[1];
|
return this.match(/^\s*([\s\S]*?)\s*$/)[1];
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.trim) {
|
if (!String.trim) {
|
||||||
String.trim = function(obj) { return String.prototype.trim.call(obj);}
|
String.trim = function (obj) {
|
||||||
|
return String.prototype.trim.call(obj);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Object.create) {
|
if (!Object.create) {
|
||||||
Object.create = function (o) {
|
Object.create = function (o) {
|
||||||
if (arguments.length > 1) { throw new Error("Object.create polyfill only accepts the first parameter"); }
|
if (arguments.length > 1) {
|
||||||
|
throw new Error(
|
||||||
|
"Object.create polyfill only accepts the first parameter"
|
||||||
|
);
|
||||||
|
}
|
||||||
var tmp = function () {};
|
var tmp = function () {};
|
||||||
tmp.prototype = o;
|
tmp.prototype = o;
|
||||||
return new tmp();
|
return new tmp();
|
||||||
@@ -37,9 +46,11 @@ var SQL = {
|
|||||||
var subscribers = this._subscribers[message] || [];
|
var subscribers = this._subscribers[message] || [];
|
||||||
var obj = {
|
var obj = {
|
||||||
target: publisher,
|
target: publisher,
|
||||||
data: data
|
data: data,
|
||||||
}
|
};
|
||||||
subscribers.forEach(function(subscriber) { subscriber(obj); });
|
subscribers.forEach(function (subscriber) {
|
||||||
|
subscriber(obj);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
subscribe: function (message, subscriber) {
|
subscribe: function (message, subscriber) {
|
||||||
@@ -47,19 +58,26 @@ var SQL = {
|
|||||||
this._subscribers[message] = [];
|
this._subscribers[message] = [];
|
||||||
}
|
}
|
||||||
var index = this._subscribers[message].indexOf(subscriber);
|
var index = this._subscribers[message].indexOf(subscriber);
|
||||||
if (index == -1) { this._subscribers[message].push(subscriber); }
|
if (index == -1) {
|
||||||
|
this._subscribers[message].push(subscriber);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
unsubscribe: function (message, subscriber) {
|
unsubscribe: function (message, subscriber) {
|
||||||
var index = this._subscribers[message].indexOf(subscriber);
|
var index = this._subscribers[message].indexOf(subscriber);
|
||||||
if (index > -1) { this._subscribers[message].splice(index, 1); }
|
if (index > -1) {
|
||||||
|
this._subscribers[message].splice(index, 1);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
escape: function (str) {
|
escape: function (str) {
|
||||||
return str.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<");
|
return str
|
||||||
}
|
.replace(/&/g, "&")
|
||||||
}
|
.replace(/>/g, ">")
|
||||||
|
.replace(/</g, "<");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
window.onbeforeunload = function (e) {
|
window.onbeforeunload = function (e) {
|
||||||
return ""; /* some browsers will show this text, some won't. */
|
return ""; /* some browsers will show this text, some won't. */
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,15 +1,29 @@
|
|||||||
SQL.IO = function (owner) {
|
SQL.IO = 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 */
|
||||||
this.dom = {
|
this.dom = {
|
||||||
container:OZ.$("io")
|
container: OZ.$("io"),
|
||||||
};
|
};
|
||||||
|
|
||||||
var ids = ["saveload","clientlocalsave", "clientsave", "clientlocalload", "clientlocallist","clientload", "clientsql",
|
var ids = [
|
||||||
"dropboxsave", "dropboxload", "dropboxlist",
|
"saveload",
|
||||||
"quicksave", "serversave", "serverload",
|
"clientlocalsave",
|
||||||
"serverlist", "serverimport"];
|
"clientsave",
|
||||||
|
"clientlocalload",
|
||||||
|
"clientlocallist",
|
||||||
|
"clientload",
|
||||||
|
"clientsql",
|
||||||
|
"dropboxsave",
|
||||||
|
"dropboxload",
|
||||||
|
"dropboxlist",
|
||||||
|
"quicksave",
|
||||||
|
"serversave",
|
||||||
|
"serverload",
|
||||||
|
"serverlist",
|
||||||
|
"serverimport",
|
||||||
|
];
|
||||||
for (var i = 0; i < ids.length; i++) {
|
for (var i = 0; i < ids.length; i++) {
|
||||||
var id = ids[i];
|
var id = ids[i];
|
||||||
var elm = OZ.$(id);
|
var elm = OZ.$(id);
|
||||||
@@ -41,10 +55,22 @@ SQL.IO = function(owner) {
|
|||||||
this.importresponse = this.importresponse.bind(this);
|
this.importresponse = this.importresponse.bind(this);
|
||||||
|
|
||||||
OZ.Event.add(this.dom.saveload, "click", this.click.bind(this));
|
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.clientlocalsave,
|
||||||
|
"click",
|
||||||
|
this.clientlocalsave.bind(this)
|
||||||
|
);
|
||||||
OZ.Event.add(this.dom.clientsave, "click", this.clientsave.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(
|
||||||
OZ.Event.add(this.dom.clientlocallist, "click", this.clientlocallist.bind(this));
|
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.clientload, "click", this.clientload.bind(this));
|
||||||
OZ.Event.add(this.dom.dropboxload, "click", this.dropboxload.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.dropboxsave, "click", this.dropboxsave.bind(this));
|
||||||
@@ -57,7 +83,7 @@ SQL.IO = function(owner) {
|
|||||||
OZ.Event.add(this.dom.serverimport, "click", this.serverimport.bind(this));
|
OZ.Event.add(this.dom.serverimport, "click", this.serverimport.bind(this));
|
||||||
OZ.Event.add(document, "keydown", this.press.bind(this));
|
OZ.Event.add(document, "keydown", this.press.bind(this));
|
||||||
this.build();
|
this.build();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.build = function () {
|
SQL.IO.prototype.build = function () {
|
||||||
OZ.DOM.clear(this.dom.backend);
|
OZ.DOM.clear(this.dom.backend);
|
||||||
@@ -76,16 +102,20 @@ SQL.IO.prototype.build = function() {
|
|||||||
o.value = bs[i];
|
o.value = bs[i];
|
||||||
o.innerHTML = bs[i];
|
o.innerHTML = bs[i];
|
||||||
this.dom.backend.appendChild(o);
|
this.dom.backend.appendChild(o);
|
||||||
if (bs[i] == be) { this.dom.backend.selectedIndex = i; }
|
if (bs[i] == be) {
|
||||||
|
this.dom.backend.selectedIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.click = function() { /* open io dialog */
|
SQL.IO.prototype.click = function () {
|
||||||
|
/* open io dialog */
|
||||||
this.build();
|
this.build();
|
||||||
this.dom.ta.value = "";
|
this.dom.ta.value = "";
|
||||||
this.dom.clientsql.value = _("clientsql") + " (" + window.DATATYPES.getAttribute("db") + ")";
|
this.dom.clientsql.value =
|
||||||
|
_("clientsql") + " (" + window.DATATYPES.getAttribute("db") + ")";
|
||||||
this.owner.window.open(_("saveload"), this.dom.container);
|
this.owner.window.open(_("saveload"), this.dom.container);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.fromXMLText = function (xml) {
|
SQL.IO.prototype.fromXMLText = function (xml) {
|
||||||
try {
|
try {
|
||||||
@@ -99,26 +129,26 @@ SQL.IO.prototype.fromXMLText = function(xml) {
|
|||||||
throw new Error("No XML parser available.");
|
throw new Error("No XML parser available.");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert(_("xmlerror")+': '+e.message);
|
alert(_("xmlerror") + ": " + e.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.fromXML(xmlDoc);
|
this.fromXML(xmlDoc);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.fromXML = function (xmlDoc) {
|
SQL.IO.prototype.fromXML = function (xmlDoc) {
|
||||||
if (!xmlDoc || !xmlDoc.documentElement) {
|
if (!xmlDoc || !xmlDoc.documentElement) {
|
||||||
alert(_("xmlerror")+': Null document');
|
alert(_("xmlerror") + ": Null document");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.owner.fromXML(xmlDoc.documentElement);
|
this.owner.fromXML(xmlDoc.documentElement);
|
||||||
this.owner.window.close();
|
this.owner.window.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.clientsave = function () {
|
SQL.IO.prototype.clientsave = function () {
|
||||||
var xml = this.owner.toXML();
|
var xml = this.owner.toXML();
|
||||||
this.dom.ta.value = xml;
|
this.dom.ta.value = xml;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.clientload = function () {
|
SQL.IO.prototype.clientload = function () {
|
||||||
var xml = this.dom.ta.value;
|
var xml = this.dom.ta.value;
|
||||||
@@ -128,12 +158,15 @@ SQL.IO.prototype.clientload = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.fromXMLText(xml);
|
this.fromXMLText(xml);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.promptName = function (title, suffix) {
|
SQL.IO.prototype.promptName = function (title, suffix) {
|
||||||
var lastUsedName = this.owner.getOption("lastUsedName") || this.lastUsedName;
|
var lastUsedName =
|
||||||
|
this.owner.getOption("lastUsedName") || this.lastUsedName;
|
||||||
var name = prompt(_(title), lastUsedName);
|
var name = prompt(_(title), lastUsedName);
|
||||||
if (!name) { return null; }
|
if (!name) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (suffix && name.endsWith(suffix)) {
|
if (suffix && name.endsWith(suffix)) {
|
||||||
// remove suffix from name
|
// remove suffix from name
|
||||||
name = name.substr(0, name.length - 4);
|
name = name.substr(0, name.length - 4);
|
||||||
@@ -141,7 +174,7 @@ SQL.IO.prototype.promptName = function(title, suffix) {
|
|||||||
this.owner.setOption("lastUsedName", name);
|
this.owner.setOption("lastUsedName", name);
|
||||||
this.lastUsedName = name; // save this also in variable in case cookies are disabled
|
this.lastUsedName = name; // save this also in variable in case cookies are disabled
|
||||||
return name;
|
return name;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.clientlocalsave = function () {
|
SQL.IO.prototype.clientlocalsave = function () {
|
||||||
if (!window.localStorage) {
|
if (!window.localStorage) {
|
||||||
@@ -150,23 +183,34 @@ SQL.IO.prototype.clientlocalsave = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var xml = this.owner.toXML();
|
var xml = this.owner.toXML();
|
||||||
if (xml.length >= (5*1024*1024)/2) { /* this is a very big db structure... */
|
if (xml.length >= (5 * 1024 * 1024) / 2) {
|
||||||
alert("Warning: your database structure is above 5 megabytes in size, this is above the localStorage single key limit allowed by some browsers, example Mozilla Firefox 10");
|
/* this is a very big db structure... */
|
||||||
|
alert(
|
||||||
|
"Warning: your database structure is above 5 megabytes in size, this is above the localStorage single key limit allowed by some browsers, example Mozilla Firefox 10"
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var key = this.promptName("serversaveprompt");
|
var key = this.promptName("serversaveprompt");
|
||||||
if (!key) { return; }
|
if (!key) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
key = "wwwsqldesigner_databases_" + (key || "default");
|
key = "wwwsqldesigner_databases_" + (key || "default");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(key, xml);
|
localStorage.setItem(key, xml);
|
||||||
if (localStorage.getItem(key) != xml) { throw new Error("Content verification failed"); }
|
if (localStorage.getItem(key) != xml) {
|
||||||
|
throw new Error("Content verification failed");
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert("Error saving database structure to localStorage! ("+e.message+")");
|
alert(
|
||||||
}
|
"Error saving database structure to localStorage! (" +
|
||||||
|
e.message +
|
||||||
|
")"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.clientlocalload = function () {
|
SQL.IO.prototype.clientlocalload = function () {
|
||||||
if (!window.localStorage) {
|
if (!window.localStorage) {
|
||||||
@@ -175,20 +219,28 @@ SQL.IO.prototype.clientlocalload = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var key = this.promptName("serverloadprompt");
|
var key = this.promptName("serverloadprompt");
|
||||||
if (!key) { return; }
|
if (!key) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
key = "wwwsqldesigner_databases_" + (key || "default");
|
key = "wwwsqldesigner_databases_" + (key || "default");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var xml = localStorage.getItem(key);
|
var xml = localStorage.getItem(key);
|
||||||
if (!xml) { throw new Error("No data available"); }
|
if (!xml) {
|
||||||
|
throw new Error("No data available");
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert("Error loading database structure from localStorage! ("+e.message+")");
|
alert(
|
||||||
|
"Error loading database structure from localStorage! (" +
|
||||||
|
e.message +
|
||||||
|
")"
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fromXMLText(xml);
|
this.fromXMLText(xml);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.clientlocallist = function () {
|
SQL.IO.prototype.clientlocallist = function () {
|
||||||
if (!window.localStorage) {
|
if (!window.localStorage) {
|
||||||
@@ -207,7 +259,7 @@ SQL.IO.prototype.clientlocallist = function() {
|
|||||||
try {
|
try {
|
||||||
for (var i = 0; i < localLen; ++i) {
|
for (var i = 0; i < localLen; ++i) {
|
||||||
var key = localStorage.key(i);
|
var key = localStorage.key(i);
|
||||||
if((new RegExp(baseKeysName)).test(key)) {
|
if (new RegExp(baseKeysName).test(key)) {
|
||||||
var result = key.substring(baseKeysName.length);
|
var result = key.substring(baseKeysName.length);
|
||||||
schemasFound = true;
|
schemasFound = true;
|
||||||
data += result + "\n";
|
data += result + "\n";
|
||||||
@@ -217,11 +269,15 @@ SQL.IO.prototype.clientlocallist = function() {
|
|||||||
throw new Error("No data available");
|
throw new Error("No data available");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert("Error loading database names from localStorage! ("+e.message+")");
|
alert(
|
||||||
|
"Error loading database names from localStorage! (" +
|
||||||
|
e.message +
|
||||||
|
")"
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.listresponse(data, code);
|
this.listresponse(data, code);
|
||||||
}
|
};
|
||||||
|
|
||||||
/* ------------------------- Dropbox start ------------------------ */
|
/* ------------------------- Dropbox start ------------------------ */
|
||||||
|
|
||||||
@@ -235,11 +291,11 @@ SQL.IO.prototype.dropBoxInit = function() {
|
|||||||
this.dropboxClient = null;
|
this.dropboxClient = null;
|
||||||
// Hide the Dropbox buttons
|
// Hide the Dropbox buttons
|
||||||
var elems = document.querySelectorAll("[id^=dropbox]"); // gets all tags whose id start with "dropbox"
|
var elems = document.querySelectorAll("[id^=dropbox]"); // gets all tags whose id start with "dropbox"
|
||||||
[].slice.call(elems).forEach(
|
[].slice.call(elems).forEach(function (elem) {
|
||||||
function(elem) { elem.style.display = "none"; }
|
elem.style.display = "none";
|
||||||
);
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.showDropboxError = function (error) {
|
SQL.IO.prototype.showDropboxError = function (error) {
|
||||||
var prefix = _("Dropbox error") + ": ";
|
var prefix = _("Dropbox error") + ": ";
|
||||||
@@ -250,7 +306,9 @@ SQL.IO.prototype.showDropboxError = function(error) {
|
|||||||
// If you're using dropbox.js, the only cause behind this error is that
|
// If you're using dropbox.js, the only cause behind this error is that
|
||||||
// the user token expired.
|
// the user token expired.
|
||||||
// Get the user through the authentication flow again.
|
// Get the user through the authentication flow again.
|
||||||
msg = _("Token expired - retry the operation, authenticating again with Dropbox");
|
msg = _(
|
||||||
|
"Token expired - retry the operation, authenticating again with Dropbox"
|
||||||
|
);
|
||||||
this.dropboxClient.reset();
|
this.dropboxClient.reset();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -294,8 +352,12 @@ SQL.IO.prototype.showDropboxAuthenticate = function(connectedCallBack) {
|
|||||||
|
|
||||||
// We want to use a popup window for authentication as the default redirection won't work for us as it'll make us lose our schema data
|
// We want to use a popup window for authentication as the default redirection won't work for us as it'll make us lose our schema data
|
||||||
var href = window.location.href;
|
var href = window.location.href;
|
||||||
var prefix = href.substring(0, href.lastIndexOf('/')) + "/";
|
var prefix = href.substring(0, href.lastIndexOf("/")) + "/";
|
||||||
this.dropboxClient.authDriver(new Dropbox.AuthDriver.Popup({ receiverUrl: prefix+"dropbox-oauth-receiver.html" }));
|
this.dropboxClient.authDriver(
|
||||||
|
new Dropbox.AuthDriver.Popup({
|
||||||
|
receiverUrl: prefix + "dropbox-oauth-receiver.html",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
// Now let's authenticate us
|
// Now let's authenticate us
|
||||||
var sql_io = this;
|
var sql_io = this;
|
||||||
@@ -310,13 +372,15 @@ SQL.IO.prototype.showDropboxAuthenticate = function(connectedCallBack) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.dropboxsave = function () {
|
SQL.IO.prototype.dropboxsave = function () {
|
||||||
var sql_io = this;
|
var sql_io = this;
|
||||||
sql_io.showDropboxAuthenticate(function () {
|
sql_io.showDropboxAuthenticate(function () {
|
||||||
var key = sql_io.promptName("serversaveprompt", ".xml");
|
var key = sql_io.promptName("serversaveprompt", ".xml");
|
||||||
if (!key) { return; }
|
if (!key) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var filename = (key || "default") + ".xml";
|
var filename = (key || "default") + ".xml";
|
||||||
|
|
||||||
@@ -327,16 +391,21 @@ SQL.IO.prototype.dropboxsave = function() {
|
|||||||
sql_io.listresponse("", 200);
|
sql_io.listresponse("", 200);
|
||||||
return sql_io.showDropboxError(error);
|
return sql_io.showDropboxError(error);
|
||||||
}
|
}
|
||||||
sql_io.listresponse(filename+" "+_("was saved to Dropbox"), 200);
|
sql_io.listresponse(
|
||||||
|
filename + " " + _("was saved to Dropbox"),
|
||||||
|
200
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.dropboxload = function () {
|
SQL.IO.prototype.dropboxload = function () {
|
||||||
var sql_io = this;
|
var sql_io = this;
|
||||||
sql_io.showDropboxAuthenticate(function () {
|
sql_io.showDropboxAuthenticate(function () {
|
||||||
var key = sql_io.promptName("serverloadprompt", ".xml");
|
var key = sql_io.promptName("serverloadprompt", ".xml");
|
||||||
if (!key) { return; }
|
if (!key) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var filename = (key || "default") + ".xml";
|
var filename = (key || "default") + ".xml";
|
||||||
|
|
||||||
@@ -349,7 +418,7 @@ SQL.IO.prototype.dropboxload = function() {
|
|||||||
sql_io.fromXMLText(data);
|
sql_io.fromXMLText(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.dropboxlist = function () {
|
SQL.IO.prototype.dropboxlist = function () {
|
||||||
var sql_io = this;
|
var sql_io = this;
|
||||||
@@ -364,8 +433,7 @@ SQL.IO.prototype.dropboxlist = function() {
|
|||||||
sql_io.listresponse(data, 200);
|
sql_io.listresponse(data, 200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------- Dropbox end ------------------------ */
|
/* ------------------------- Dropbox end ------------------------ */
|
||||||
|
|
||||||
@@ -375,7 +443,7 @@ SQL.IO.prototype.clientsql = function() {
|
|||||||
var h = this.owner.getXhrHeaders();
|
var h = this.owner.getXhrHeaders();
|
||||||
this.owner.window.showThrobber();
|
this.owner.window.showThrobber();
|
||||||
OZ.Request(path, this.finish.bind(this), { xml: true, headers: h });
|
OZ.Request(path, this.finish.bind(this), { xml: true, headers: h });
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.finish = function (xslDoc) {
|
SQL.IO.prototype.finish = function (xslDoc) {
|
||||||
this.owner.window.hideThrobber();
|
this.owner.window.hideThrobber();
|
||||||
@@ -397,41 +465,60 @@ SQL.IO.prototype.finish = function(xslDoc) {
|
|||||||
throw new Error("No XSLT processor available");
|
throw new Error("No XSLT processor available");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert(_("xmlerror")+': '+e.message);
|
alert(_("xmlerror") + ": " + e.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.dom.ta.value = sql.trim();
|
this.dom.ta.value = sql.trim();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.serversave = function (e, keyword) {
|
SQL.IO.prototype.serversave = function (e, keyword) {
|
||||||
var name = keyword || prompt(_("serversaveprompt"), this._name);
|
var name = keyword || prompt(_("serversaveprompt"), this._name);
|
||||||
if (!name) { return; }
|
if (!name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._name = name;
|
this._name = name;
|
||||||
var xml = this.owner.toXML();
|
var xml = this.owner.toXML();
|
||||||
var bp = this.owner.getOption("xhrpath");
|
var bp = this.owner.getOption("xhrpath");
|
||||||
var url = bp + "backend/"+this.dom.backend.value+"/?action=save&keyword="+encodeURIComponent(name);
|
var url =
|
||||||
|
bp +
|
||||||
|
"backend/" +
|
||||||
|
this.dom.backend.value +
|
||||||
|
"/?action=save&keyword=" +
|
||||||
|
encodeURIComponent(name);
|
||||||
var h = this.owner.getXhrHeaders();
|
var h = this.owner.getXhrHeaders();
|
||||||
h["Content-type"] = "application/xml";
|
h["Content-type"] = "application/xml";
|
||||||
this.owner.window.showThrobber();
|
this.owner.window.showThrobber();
|
||||||
this.owner.setTitle(name);
|
this.owner.setTitle(name);
|
||||||
OZ.Request(url, this.saveresponse, {xml:true, method:"post", data:xml, headers:h});
|
OZ.Request(url, this.saveresponse, {
|
||||||
}
|
xml: true,
|
||||||
|
method: "post",
|
||||||
|
data: xml,
|
||||||
|
headers: h,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.quicksave = function (e) {
|
SQL.IO.prototype.quicksave = function (e) {
|
||||||
this.serversave(e, this._name);
|
this.serversave(e, this._name);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.serverload = function (e, keyword) {
|
SQL.IO.prototype.serverload = function (e, keyword) {
|
||||||
var name = keyword || prompt(_("serverloadprompt"), this._name);
|
var name = keyword || prompt(_("serverloadprompt"), this._name);
|
||||||
if (!name) { return; }
|
if (!name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._name = name;
|
this._name = name;
|
||||||
var bp = this.owner.getOption("xhrpath");
|
var bp = this.owner.getOption("xhrpath");
|
||||||
var url = bp + "backend/"+this.dom.backend.value+"/?action=load&keyword="+encodeURIComponent(name);
|
var url =
|
||||||
|
bp +
|
||||||
|
"backend/" +
|
||||||
|
this.dom.backend.value +
|
||||||
|
"/?action=load&keyword=" +
|
||||||
|
encodeURIComponent(name);
|
||||||
var h = this.owner.getXhrHeaders();
|
var h = this.owner.getXhrHeaders();
|
||||||
this.owner.window.showThrobber();
|
this.owner.window.showThrobber();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
OZ.Request(url, this.loadresponse, { xml: true, headers: h });
|
OZ.Request(url, this.loadresponse, { xml: true, headers: h });
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.serverlist = function (e) {
|
SQL.IO.prototype.serverlist = function (e) {
|
||||||
var bp = this.owner.getOption("xhrpath");
|
var bp = this.owner.getOption("xhrpath");
|
||||||
@@ -439,17 +526,24 @@ SQL.IO.prototype.serverlist = function(e) {
|
|||||||
var h = this.owner.getXhrHeaders();
|
var h = this.owner.getXhrHeaders();
|
||||||
this.owner.window.showThrobber();
|
this.owner.window.showThrobber();
|
||||||
OZ.Request(url, this.listresponse, { headers: h });
|
OZ.Request(url, this.listresponse, { headers: h });
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.serverimport = function (e) {
|
SQL.IO.prototype.serverimport = function (e) {
|
||||||
var name = prompt(_("serverimportprompt"), "");
|
var name = prompt(_("serverimportprompt"), "");
|
||||||
if (!name) { return; }
|
if (!name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var bp = this.owner.getOption("xhrpath");
|
var bp = this.owner.getOption("xhrpath");
|
||||||
var url = bp + "backend/"+this.dom.backend.value+"/?action=import&database="+name;
|
var url =
|
||||||
|
bp +
|
||||||
|
"backend/" +
|
||||||
|
this.dom.backend.value +
|
||||||
|
"/?action=import&database=" +
|
||||||
|
name;
|
||||||
var h = this.owner.getXhrHeaders();
|
var h = this.owner.getXhrHeaders();
|
||||||
this.owner.window.showThrobber();
|
this.owner.window.showThrobber();
|
||||||
OZ.Request(url, this.importresponse, { xml: true, headers: h });
|
OZ.Request(url, this.importresponse, { xml: true, headers: h });
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.check = function (code) {
|
SQL.IO.prototype.check = function (code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
@@ -462,35 +556,42 @@ SQL.IO.prototype.check = function(code) {
|
|||||||
this.dom.ta.value = _("httpresponse") + ": " + _(lang);
|
this.dom.ta.value = _("httpresponse") + ": " + _(lang);
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
default: return true;
|
default:
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.saveresponse = function (data, code) {
|
SQL.IO.prototype.saveresponse = function (data, code) {
|
||||||
this.owner.window.hideThrobber();
|
this.owner.window.hideThrobber();
|
||||||
this.check(code);
|
this.check(code);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.loadresponse = function (data, code) {
|
SQL.IO.prototype.loadresponse = function (data, code) {
|
||||||
this.owner.window.hideThrobber();
|
this.owner.window.hideThrobber();
|
||||||
if (!this.check(code)) { return; }
|
if (!this.check(code)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.fromXML(data);
|
this.fromXML(data);
|
||||||
this.owner.setTitle(this.name);
|
this.owner.setTitle(this.name);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.listresponse = function (data, code) {
|
SQL.IO.prototype.listresponse = function (data, code) {
|
||||||
this.owner.window.hideThrobber();
|
this.owner.window.hideThrobber();
|
||||||
if (!this.check(code)) { return; }
|
if (!this.check(code)) {
|
||||||
this.dom.ta.value = data;
|
return;
|
||||||
}
|
}
|
||||||
|
this.dom.ta.value = data;
|
||||||
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.importresponse = function (data, code) {
|
SQL.IO.prototype.importresponse = function (data, code) {
|
||||||
this.owner.window.hideThrobber();
|
this.owner.window.hideThrobber();
|
||||||
if (!this.check(code)) { return; }
|
if (!this.check(code)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.fromXML(data)) {
|
if (this.fromXML(data)) {
|
||||||
this.owner.alignTables();
|
this.owner.alignTables();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.IO.prototype.press = function (e) {
|
SQL.IO.prototype.press = function (e) {
|
||||||
switch (e.keyCode) {
|
switch (e.keyCode) {
|
||||||
@@ -501,4 +602,4 @@ SQL.IO.prototype.press = function(e) {
|
|||||||
this.quicksave(e);
|
this.quicksave(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -5,60 +5,69 @@ SQL.Key = function(owner, type, name) {
|
|||||||
this.type = type || "INDEX";
|
this.type = type || "INDEX";
|
||||||
this.name = name || "";
|
this.name = name || "";
|
||||||
SQL.Visual.apply(this);
|
SQL.Visual.apply(this);
|
||||||
}
|
};
|
||||||
SQL.Key.prototype = Object.create(SQL.Visual.prototype);
|
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;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Key.prototype.getName = function () {
|
SQL.Key.prototype.getName = function () {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Key.prototype.setType = function (t) {
|
SQL.Key.prototype.setType = function (t) {
|
||||||
if (!t) { return; }
|
if (!t) {
|
||||||
this.type = t;
|
return;
|
||||||
for (var i=0;i<this.rows.length;i++) { this.rows[i].redraw(); }
|
|
||||||
}
|
}
|
||||||
|
this.type = t;
|
||||||
|
for (var i = 0; i < this.rows.length; i++) {
|
||||||
|
this.rows[i].redraw();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Key.prototype.getType = function () {
|
SQL.Key.prototype.getType = function () {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Key.prototype.addRow = function (r) {
|
SQL.Key.prototype.addRow = function (r) {
|
||||||
if (r.owner != this.owner) { return; }
|
if (r.owner != this.owner) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.rows.push(r);
|
this.rows.push(r);
|
||||||
r.addKey(this);
|
r.addKey(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Key.prototype.removeRow = function (r) {
|
SQL.Key.prototype.removeRow = function (r) {
|
||||||
var idx = this.rows.indexOf(r);
|
var idx = this.rows.indexOf(r);
|
||||||
if (idx == -1) { return; }
|
if (idx == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
r.removeKey(this);
|
r.removeKey(this);
|
||||||
this.rows.splice(idx, 1);
|
this.rows.splice(idx, 1);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Key.prototype.destroy = function () {
|
SQL.Key.prototype.destroy = function () {
|
||||||
for (var i = 0; i < this.rows.length; i++) {
|
for (var i = 0; i < this.rows.length; i++) {
|
||||||
this.rows[i].removeKey(this);
|
this.rows[i].removeKey(this);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Key.prototype.getLabel = function () {
|
SQL.Key.prototype.getLabel = function () {
|
||||||
return this.name || this.type;
|
return this.name || this.type;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Key.prototype.toXML = function () {
|
SQL.Key.prototype.toXML = function () {
|
||||||
var xml = "";
|
var xml = "";
|
||||||
xml += '<key type="'+this.getType()+'" name="'+this.getName()+'">\n';
|
xml +=
|
||||||
|
'<key type="' + this.getType() + '" name="' + this.getName() + '">\n';
|
||||||
for (var i = 0; i < this.rows.length; i++) {
|
for (var i = 0; i < this.rows.length; i++) {
|
||||||
var r = this.rows[i];
|
var r = this.rows[i];
|
||||||
xml += '<part>'+r.getTitle()+'</part>\n';
|
xml += "<part>" + r.getTitle() + "</part>\n";
|
||||||
}
|
}
|
||||||
xml += '</key>\n';
|
xml += "</key>\n";
|
||||||
return xml;
|
return xml;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Key.prototype.fromXML = function (node) {
|
SQL.Key.prototype.fromXML = function (node) {
|
||||||
this.setType(node.getAttribute("type"));
|
this.setType(node.getAttribute("type"));
|
||||||
@@ -69,4 +78,4 @@ SQL.Key.prototype.fromXML = function(node) {
|
|||||||
var row = this.owner.findNamedRow(name);
|
var row = this.owner.findNamedRow(name);
|
||||||
this.addRow(row);
|
this.addRow(row);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
+53
-31
@@ -3,10 +3,10 @@
|
|||||||
SQL.KeyManager = function (owner) {
|
SQL.KeyManager = function (owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.dom = {
|
this.dom = {
|
||||||
container:OZ.$("keys")
|
container: OZ.$("keys"),
|
||||||
}
|
};
|
||||||
this.build();
|
this.build();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.build = function () {
|
SQL.KeyManager.prototype.build = function () {
|
||||||
this.dom.list = OZ.$("keyslist");
|
this.dom.list = OZ.$("keyslist");
|
||||||
@@ -26,7 +26,13 @@ SQL.KeyManager.prototype.build = function() {
|
|||||||
elm.value = _(id);
|
elm.value = _(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ids = ["keyedit","keytypelabel","keynamelabel","keyfieldslabel","keyavaillabel"];
|
var ids = [
|
||||||
|
"keyedit",
|
||||||
|
"keytypelabel",
|
||||||
|
"keynamelabel",
|
||||||
|
"keyfieldslabel",
|
||||||
|
"keyavaillabel",
|
||||||
|
];
|
||||||
for (var i = 0; i < ids.length; i++) {
|
for (var i = 0; i < ids.length; i++) {
|
||||||
var id = ids[i];
|
var id = ids[i];
|
||||||
var elm = OZ.$(id);
|
var elm = OZ.$(id);
|
||||||
@@ -53,54 +59,63 @@ SQL.KeyManager.prototype.build = function() {
|
|||||||
OZ.Event.add(this.dom.right, "click", this.right.bind(this));
|
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);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.listchange = function (e) {
|
SQL.KeyManager.prototype.listchange = function (e) {
|
||||||
this.switchTo(this.dom.list.selectedIndex);
|
this.switchTo(this.dom.list.selectedIndex);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.typechange = function (e) {
|
SQL.KeyManager.prototype.typechange = function (e) {
|
||||||
this.key.setType(this.dom.type.value);
|
this.key.setType(this.dom.type.value);
|
||||||
this.redrawListItem();
|
this.redrawListItem();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.namechange = function (e) {
|
SQL.KeyManager.prototype.namechange = function (e) {
|
||||||
this.key.setName(this.dom.name.value);
|
this.key.setName(this.dom.name.value);
|
||||||
this.redrawListItem();
|
this.redrawListItem();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.add = function (e) {
|
SQL.KeyManager.prototype.add = function (e) {
|
||||||
var type = (this.table.keys.length ? "INDEX" : "PRIMARY");
|
var type = this.table.keys.length ? "INDEX" : "PRIMARY";
|
||||||
this.table.addKey(type);
|
this.table.addKey(type);
|
||||||
this.sync(this.table);
|
this.sync(this.table);
|
||||||
this.switchTo(this.table.keys.length - 1);
|
this.switchTo(this.table.keys.length - 1);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.remove = function (e) {
|
SQL.KeyManager.prototype.remove = function (e) {
|
||||||
var index = this.dom.list.selectedIndex;
|
var index = this.dom.list.selectedIndex;
|
||||||
if (index == -1) { return; }
|
if (index == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var r = this.table.keys[index];
|
var r = this.table.keys[index];
|
||||||
this.table.removeKey(r);
|
this.table.removeKey(r);
|
||||||
this.sync(this.table);
|
this.sync(this.table);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.purge = function() { /* remove empty keys */
|
SQL.KeyManager.prototype.purge = function () {
|
||||||
|
/* remove empty keys */
|
||||||
for (var i = this.table.keys.length - 1; i >= 0; i--) {
|
for (var i = this.table.keys.length - 1; i >= 0; i--) {
|
||||||
var k = this.table.keys[i];
|
var k = this.table.keys[i];
|
||||||
if (!k.rows.length) { this.table.removeKey(k); }
|
if (!k.rows.length) {
|
||||||
|
this.table.removeKey(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.sync = function(table) { /* sync content with given table */
|
SQL.KeyManager.prototype.sync = function (table) {
|
||||||
|
/* sync content with given table */
|
||||||
this.table = table;
|
this.table = table;
|
||||||
this.dom.listlabel.innerHTML = _("keyslistlabel").replace(/%s/,table.getTitle());
|
this.dom.listlabel.innerHTML = _("keyslistlabel").replace(
|
||||||
|
/%s/,
|
||||||
|
table.getTitle()
|
||||||
|
);
|
||||||
|
|
||||||
OZ.DOM.clear(this.dom.list);
|
OZ.DOM.clear(this.dom.list);
|
||||||
for (var i = 0; i < table.keys.length; i++) {
|
for (var i = 0; i < table.keys.length; i++) {
|
||||||
var k = table.keys[i];
|
var k = table.keys[i];
|
||||||
var o = OZ.DOM.elm("option");
|
var o = OZ.DOM.elm("option");
|
||||||
this.dom.list.appendChild(o);
|
this.dom.list.appendChild(o);
|
||||||
var str = (i+1)+": "+k.getLabel();
|
var str = i + 1 + ": " + k.getLabel();
|
||||||
o.innerHTML = str;
|
o.innerHTML = str;
|
||||||
}
|
}
|
||||||
if (table.keys.length) {
|
if (table.keys.length) {
|
||||||
@@ -108,14 +123,15 @@ SQL.KeyManager.prototype.sync = function(table) { /* sync content with given tab
|
|||||||
} else {
|
} else {
|
||||||
this.disable();
|
this.disable();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.redrawListItem = function () {
|
SQL.KeyManager.prototype.redrawListItem = function () {
|
||||||
var index = this.table.keys.indexOf(this.key);
|
var index = this.table.keys.indexOf(this.key);
|
||||||
this.option.innerHTML = (index+1)+": "+this.key.getLabel();
|
this.option.innerHTML = index + 1 + ": " + this.key.getLabel();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.switchTo = function(index) { /* show Nth key */
|
SQL.KeyManager.prototype.switchTo = function (index) {
|
||||||
|
/* show Nth key */
|
||||||
this.enable();
|
this.enable();
|
||||||
var k = this.table.keys[index];
|
var k = this.table.keys[index];
|
||||||
this.key = k;
|
this.key = k;
|
||||||
@@ -126,7 +142,9 @@ SQL.KeyManager.prototype.switchTo = function(index) { /* show Nth key */
|
|||||||
|
|
||||||
var opts = this.dom.type.getElementsByTagName("option");
|
var opts = this.dom.type.getElementsByTagName("option");
|
||||||
for (var i = 0; i < opts.length; i++) {
|
for (var i = 0; i < opts.length; i++) {
|
||||||
if (opts[i].value == k.getType()) { this.dom.type.selectedIndex = i; }
|
if (opts[i].value == k.getType()) {
|
||||||
|
this.dom.type.selectedIndex = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OZ.DOM.clear(this.dom.fields);
|
OZ.DOM.clear(this.dom.fields);
|
||||||
@@ -140,13 +158,15 @@ SQL.KeyManager.prototype.switchTo = function(index) { /* show Nth key */
|
|||||||
OZ.DOM.clear(this.dom.avail);
|
OZ.DOM.clear(this.dom.avail);
|
||||||
for (var i = 0; i < this.table.rows.length; i++) {
|
for (var i = 0; i < this.table.rows.length; i++) {
|
||||||
var r = this.table.rows[i];
|
var r = this.table.rows[i];
|
||||||
if (k.rows.indexOf(r) != -1) { continue; }
|
if (k.rows.indexOf(r) != -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var o = OZ.DOM.elm("option");
|
var o = OZ.DOM.elm("option");
|
||||||
o.innerHTML = r.getTitle();
|
o.innerHTML = r.getTitle();
|
||||||
o.value = o.innerHTML;
|
o.value = o.innerHTML;
|
||||||
this.dom.avail.appendChild(o);
|
this.dom.avail.appendChild(o);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.disable = function () {
|
SQL.KeyManager.prototype.disable = function () {
|
||||||
OZ.DOM.clear(this.dom.fields);
|
OZ.DOM.clear(this.dom.fields);
|
||||||
@@ -159,7 +179,7 @@ SQL.KeyManager.prototype.disable = function() {
|
|||||||
this.dom.type.disabled = true;
|
this.dom.type.disabled = true;
|
||||||
this.dom.fields.disabled = true;
|
this.dom.fields.disabled = true;
|
||||||
this.dom.avail.disabled = true;
|
this.dom.avail.disabled = true;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.enable = function () {
|
SQL.KeyManager.prototype.enable = function () {
|
||||||
this.dom.keyremove.disabled = false;
|
this.dom.keyremove.disabled = false;
|
||||||
@@ -170,9 +190,10 @@ SQL.KeyManager.prototype.enable = function() {
|
|||||||
this.dom.type.disabled = false;
|
this.dom.type.disabled = false;
|
||||||
this.dom.fields.disabled = false;
|
this.dom.fields.disabled = false;
|
||||||
this.dom.avail.disabled = false;
|
this.dom.avail.disabled = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.left = function(e) { /* add field to index */
|
SQL.KeyManager.prototype.left = function (e) {
|
||||||
|
/* add field to index */
|
||||||
var opts = this.dom.avail.getElementsByTagName("option");
|
var opts = this.dom.avail.getElementsByTagName("option");
|
||||||
for (var i = 0; i < opts.length; i++) {
|
for (var i = 0; i < opts.length; i++) {
|
||||||
var o = opts[i];
|
var o = opts[i];
|
||||||
@@ -182,9 +203,10 @@ SQL.KeyManager.prototype.left = function(e) { /* add field to index */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.switchTo(this.dom.list.selectedIndex);
|
this.switchTo(this.dom.list.selectedIndex);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.right = function(e) { /* remove field from index */
|
SQL.KeyManager.prototype.right = function (e) {
|
||||||
|
/* remove field from index */
|
||||||
var opts = this.dom.fields.getElementsByTagName("option");
|
var opts = this.dom.fields.getElementsByTagName("option");
|
||||||
for (var i = 0; i < opts.length; i++) {
|
for (var i = 0; i < opts.length; i++) {
|
||||||
var o = opts[i];
|
var o = opts[i];
|
||||||
@@ -194,9 +216,9 @@ SQL.KeyManager.prototype.right = function(e) { /* remove field from index */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.switchTo(this.dom.list.selectedIndex);
|
this.switchTo(this.dom.list.selectedIndex);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.KeyManager.prototype.open = function (table) {
|
SQL.KeyManager.prototype.open = function (table) {
|
||||||
this.sync(table);
|
this.sync(table);
|
||||||
this.owner.window.open(_("tablekeys"), this.dom.container, this.purge);
|
this.owner.window.open(_("tablekeys"), this.dom.container, this.purge);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ SQL.Map = function(owner) {
|
|||||||
OZ.Event.add(this.dom.container, "mousedown", this.down.bind(this));
|
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, "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 = 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;
|
||||||
this.dom.container.style.cursor = "move";
|
this.dom.container.style.cursor = "move";
|
||||||
var pos = OZ.DOM.pos(this.dom.container);
|
var pos = OZ.DOM.pos(this.dom.container);
|
||||||
@@ -41,14 +42,19 @@ SQL.Map.prototype.down = function(e) { /* mousedown - move view and start drag *
|
|||||||
|
|
||||||
this.documentMove = OZ.Event.add(document, eventMove, this.move.bind(this));
|
this.documentMove = OZ.Event.add(document, eventMove, this.move.bind(this));
|
||||||
this.documentUp = OZ.Event.add(document, eventUp, this.up.bind(this));
|
this.documentUp = OZ.Event.add(document, eventUp, this.up.bind(this));
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Map.prototype.move = function(e) { /* mousemove */
|
SQL.Map.prototype.move = function (e) {
|
||||||
if (!this.flag) { return; }
|
/* mousemove */
|
||||||
|
if (!this.flag) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
OZ.Event.prevent(e);
|
OZ.Event.prevent(e);
|
||||||
|
|
||||||
if (e.type.match(/touch/)) {
|
if (e.type.match(/touch/)) {
|
||||||
if (e.touches.length > 1) { return; }
|
if (e.touches.length > 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var event = e.touches[0];
|
var event = e.touches[0];
|
||||||
} else {
|
} else {
|
||||||
var event = e;
|
var event = e;
|
||||||
@@ -56,11 +62,18 @@ SQL.Map.prototype.move = function(e) { /* mousemove */
|
|||||||
|
|
||||||
var dx = event.clientX - this.x;
|
var dx = event.clientX - this.x;
|
||||||
var dy = event.clientY - this.y;
|
var dy = event.clientY - this.y;
|
||||||
if (this.l + dx < 0) { dx = -this.l; }
|
if (this.l + dx < 0) {
|
||||||
if (this.t + dy < 0) { dy = -this.t; }
|
dx = -this.l;
|
||||||
if (this.l + this.w + 4 + dx > this.width) { dx = this.width - 4 - this.l - this.w; }
|
}
|
||||||
if (this.t + this.h + 4 + dy > this.height) { dy = this.height - 4 - this.t - this.h; }
|
if (this.t + dy < 0) {
|
||||||
|
dy = -this.t;
|
||||||
|
}
|
||||||
|
if (this.l + this.w + 4 + dx > this.width) {
|
||||||
|
dx = this.width - 4 - this.l - this.w;
|
||||||
|
}
|
||||||
|
if (this.t + this.h + 4 + dy > this.height) {
|
||||||
|
dy = this.height - 4 - this.t - this.h;
|
||||||
|
}
|
||||||
|
|
||||||
this.x += dx;
|
this.x += dx;
|
||||||
this.y += dy;
|
this.y += dy;
|
||||||
@@ -77,16 +90,18 @@ SQL.Map.prototype.move = function(e) { /* mousemove */
|
|||||||
document.documentElement.scrollTop = Math.round(top);
|
document.documentElement.scrollTop = Math.round(top);
|
||||||
|
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Map.prototype.up = function(e) { /* mouseup */
|
SQL.Map.prototype.up = function (e) {
|
||||||
|
/* mouseup */
|
||||||
this.flag = false;
|
this.flag = false;
|
||||||
this.dom.container.style.cursor = "";
|
this.dom.container.style.cursor = "";
|
||||||
OZ.Event.remove(this.documentMove);
|
OZ.Event.remove(this.documentMove);
|
||||||
OZ.Event.remove(this.documentUp);
|
OZ.Event.remove(this.documentUp);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Map.prototype.sync = function() { /* when window changes, adjust map */
|
SQL.Map.prototype.sync = function () {
|
||||||
|
/* when window changes, adjust map */
|
||||||
var dims = OZ.DOM.win();
|
var dims = OZ.DOM.win();
|
||||||
var scroll = OZ.DOM.scroll();
|
var scroll = OZ.DOM.scroll();
|
||||||
var scaleX = this.width / this.owner.width;
|
var scaleX = this.width / this.owner.width;
|
||||||
@@ -103,11 +118,11 @@ SQL.Map.prototype.sync = function() { /* when window changes, adjust map */
|
|||||||
this.t = Math.round(y);
|
this.t = Math.round(y);
|
||||||
|
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Map.prototype.redraw = function () {
|
SQL.Map.prototype.redraw = function () {
|
||||||
this.dom.port.style.width = this.w + "px";
|
this.dom.port.style.width = this.w + "px";
|
||||||
this.dom.port.style.height = this.h + "px";
|
this.dom.port.style.height = this.h + "px";
|
||||||
this.dom.port.style.left = this.l + "px";
|
this.dom.port.style.left = this.l + "px";
|
||||||
this.dom.port.style.top = this.t + "px";
|
this.dom.port.style.top = this.t + "px";
|
||||||
}
|
};
|
||||||
|
|||||||
+37
-13
@@ -4,12 +4,12 @@ SQL.Options = 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.save.bind(this);
|
this.save = this.save.bind(this);
|
||||||
this.build();
|
this.build();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Options.prototype.build = function () {
|
SQL.Options.prototype.build = function () {
|
||||||
this.dom.optionlocale = OZ.$("optionlocale");
|
this.dom.optionlocale = OZ.$("optionlocale");
|
||||||
@@ -22,7 +22,20 @@ SQL.Options.prototype.build = function() {
|
|||||||
this.dom.optionshowsize = OZ.$("optionshowsize");
|
this.dom.optionshowsize = OZ.$("optionshowsize");
|
||||||
this.dom.optionshowtype = OZ.$("optionshowtype");
|
this.dom.optionshowtype = OZ.$("optionshowtype");
|
||||||
|
|
||||||
var ids = ["language","db","snap","pattern","style","hide","vector","showsize","showtype","optionsnapnotice","optionpatternnotice","optionsnotice"];
|
var ids = [
|
||||||
|
"language",
|
||||||
|
"db",
|
||||||
|
"snap",
|
||||||
|
"pattern",
|
||||||
|
"style",
|
||||||
|
"hide",
|
||||||
|
"vector",
|
||||||
|
"showsize",
|
||||||
|
"showtype",
|
||||||
|
"optionsnapnotice",
|
||||||
|
"optionpatternnotice",
|
||||||
|
"optionsnotice",
|
||||||
|
];
|
||||||
for (var i = 0; i < ids.length; i++) {
|
for (var i = 0; i < ids.length; i++) {
|
||||||
var id = ids[i];
|
var id = ids[i];
|
||||||
var elm = OZ.$(id);
|
var elm = OZ.$(id);
|
||||||
@@ -36,7 +49,9 @@ SQL.Options.prototype.build = function() {
|
|||||||
o.value = ls[i];
|
o.value = ls[i];
|
||||||
o.innerHTML = ls[i];
|
o.innerHTML = ls[i];
|
||||||
this.dom.optionlocale.appendChild(o);
|
this.dom.optionlocale.appendChild(o);
|
||||||
if (this.owner.getOption("locale") == ls[i]) { this.dom.optionlocale.selectedIndex = i; }
|
if (this.owner.getOption("locale") == ls[i]) {
|
||||||
|
this.dom.optionlocale.selectedIndex = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var dbs = CONFIG.AVAILABLE_DBS;
|
var dbs = CONFIG.AVAILABLE_DBS;
|
||||||
@@ -46,7 +61,9 @@ SQL.Options.prototype.build = function() {
|
|||||||
o.value = dbs[i];
|
o.value = dbs[i];
|
||||||
o.innerHTML = dbs[i];
|
o.innerHTML = dbs[i];
|
||||||
this.dom.optiondb.appendChild(o);
|
this.dom.optiondb.appendChild(o);
|
||||||
if (this.owner.getOption("db") == dbs[i]) { this.dom.optiondb.selectedIndex = i; }
|
if (this.owner.getOption("db") == dbs[i]) {
|
||||||
|
this.dom.optiondb.selectedIndex = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var styles = CONFIG.STYLES;
|
var styles = CONFIG.STYLES;
|
||||||
@@ -56,14 +73,15 @@ SQL.Options.prototype.build = function() {
|
|||||||
o.value = styles[i];
|
o.value = styles[i];
|
||||||
o.innerHTML = styles[i];
|
o.innerHTML = styles[i];
|
||||||
this.dom.optionstyle.appendChild(o);
|
this.dom.optionstyle.appendChild(o);
|
||||||
if (this.owner.getOption("style") == styles[i]) { this.dom.optionstyle.selectedIndex = i; }
|
if (this.owner.getOption("style") == styles[i]) {
|
||||||
|
this.dom.optionstyle.selectedIndex = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OZ.Event.add(this.dom.btn, "click", this.click.bind(this));
|
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);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Options.prototype.save = function () {
|
SQL.Options.prototype.save = function () {
|
||||||
this.owner.setOption("locale", this.dom.optionlocale.value);
|
this.owner.setOption("locale", this.dom.optionlocale.value);
|
||||||
@@ -73,9 +91,15 @@ SQL.Options.prototype.save = function() {
|
|||||||
this.owner.setOption("style", this.dom.optionstyle.value);
|
this.owner.setOption("style", this.dom.optionstyle.value);
|
||||||
this.owner.setOption("hide", this.dom.optionhide.checked ? "1" : "");
|
this.owner.setOption("hide", this.dom.optionhide.checked ? "1" : "");
|
||||||
this.owner.setOption("vector", this.dom.optionvector.checked ? "1" : "");
|
this.owner.setOption("vector", this.dom.optionvector.checked ? "1" : "");
|
||||||
this.owner.setOption("showsize",this.dom.optionshowsize.checked ? "1" : "");
|
this.owner.setOption(
|
||||||
this.owner.setOption("showtype",this.dom.optionshowtype.checked ? "1" : "");
|
"showsize",
|
||||||
}
|
this.dom.optionshowsize.checked ? "1" : ""
|
||||||
|
);
|
||||||
|
this.owner.setOption(
|
||||||
|
"showtype",
|
||||||
|
this.dom.optionshowtype.checked ? "1" : ""
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Options.prototype.click = function () {
|
SQL.Options.prototype.click = function () {
|
||||||
this.owner.window.open(_("options"), this.dom.container, this.save);
|
this.owner.window.open(_("options"), this.dom.container, this.save);
|
||||||
@@ -85,4 +109,4 @@ SQL.Options.prototype.click = function() {
|
|||||||
this.dom.optionvector.checked = this.owner.getOption("vector");
|
this.dom.optionvector.checked = this.owner.getOption("vector");
|
||||||
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");
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
/* (c) 2007 - now() Ondrej Zara, 1.7 */
|
/* (c) 2007 - now() Ondrej Zara, 1.7 */
|
||||||
var OZ = {
|
var OZ = {
|
||||||
$:function(x) { return typeof(x) == "string" ? document.getElementById(x) : x; },
|
$: function (x) {
|
||||||
select: function(x) { return document.querySelectorAll(x); },
|
return typeof x == "string" ? document.getElementById(x) : x;
|
||||||
|
},
|
||||||
|
select: function (x) {
|
||||||
|
return document.querySelectorAll(x);
|
||||||
|
},
|
||||||
opera: !!window.opera,
|
opera: !!window.opera,
|
||||||
ie: !!document.attachEvent && !window.opera,
|
ie: !!document.attachEvent && !window.opera,
|
||||||
gecko: !!document.getAnonymousElementByAttribute,
|
gecko: !!document.getAnonymousElementByAttribute,
|
||||||
webkit: !!navigator.userAgent.match(/webkit/i),
|
webkit: !!navigator.userAgent.match(/webkit/i),
|
||||||
khtml:!!navigator.userAgent.match(/khtml/i) || !!navigator.userAgent.match(/konqueror/i),
|
khtml:
|
||||||
|
!!navigator.userAgent.match(/khtml/i) ||
|
||||||
|
!!navigator.userAgent.match(/konqueror/i),
|
||||||
Event: {
|
Event: {
|
||||||
_id: 0,
|
_id: 0,
|
||||||
_byName: {},
|
_byName: {},
|
||||||
@@ -14,7 +20,12 @@ var OZ = {
|
|||||||
add: function (elm, event, cb) {
|
add: function (elm, event, cb) {
|
||||||
var id = OZ.Event._id++;
|
var id = OZ.Event._id++;
|
||||||
var element = OZ.$(elm);
|
var element = OZ.$(elm);
|
||||||
var fnc = (element && element.attachEvent ? function() { return cb.apply(element,arguments); } : cb);
|
var fnc =
|
||||||
|
element && element.attachEvent
|
||||||
|
? function () {
|
||||||
|
return cb.apply(element, arguments);
|
||||||
|
}
|
||||||
|
: cb;
|
||||||
var rec = [element, event, fnc];
|
var rec = [element, event, fnc];
|
||||||
var parts = event.split(" ");
|
var parts = event.split(" ");
|
||||||
while (parts.length) {
|
while (parts.length) {
|
||||||
@@ -26,7 +37,9 @@ var OZ = {
|
|||||||
element.attachEvent("on" + e, fnc);
|
element.attachEvent("on" + e, fnc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(e in OZ.Event._byName)) { OZ.Event._byName[e] = {}; }
|
if (!(e in OZ.Event._byName)) {
|
||||||
|
OZ.Event._byName[e] = {};
|
||||||
|
}
|
||||||
OZ.Event._byName[e][id] = rec;
|
OZ.Event._byName[e][id] = rec;
|
||||||
}
|
}
|
||||||
OZ.Event._byID[id] = rec;
|
OZ.Event._byID[id] = rec;
|
||||||
@@ -34,7 +47,9 @@ var OZ = {
|
|||||||
},
|
},
|
||||||
remove: function (id) {
|
remove: function (id) {
|
||||||
var rec = OZ.Event._byID[id];
|
var rec = OZ.Event._byID[id];
|
||||||
if (!rec) { return; }
|
if (!rec) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var elm = rec[0];
|
var elm = rec[0];
|
||||||
var parts = rec[1].split(" ");
|
var parts = rec[1].split(" ");
|
||||||
while (parts.length) {
|
while (parts.length) {
|
||||||
@@ -50,17 +65,27 @@ var OZ = {
|
|||||||
}
|
}
|
||||||
delete OZ.Event._byID[id];
|
delete OZ.Event._byID[id];
|
||||||
},
|
},
|
||||||
stop:function(e) { e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; },
|
stop: function (e) {
|
||||||
prevent:function(e) { e.preventDefault ? e.preventDefault() : e.returnValue = false; },
|
e.stopPropagation ? e.stopPropagation() : (e.cancelBubble = true);
|
||||||
target:function(e) { return e.target || e.srcElement; }
|
},
|
||||||
|
prevent: function (e) {
|
||||||
|
e.preventDefault ? e.preventDefault() : (e.returnValue = false);
|
||||||
|
},
|
||||||
|
target: function (e) {
|
||||||
|
return e.target || e.srcElement;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Class: function () {
|
Class: function () {
|
||||||
var c = function () {
|
var c = function () {
|
||||||
var init = arguments.callee.prototype.init;
|
var init = arguments.callee.prototype.init;
|
||||||
if (init) { init.apply(this,arguments); }
|
if (init) {
|
||||||
|
init.apply(this, arguments);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
c.implement = function (parent) {
|
c.implement = function (parent) {
|
||||||
for (var p in parent.prototype) { this.prototype[p] = parent.prototype[p]; }
|
for (var p in parent.prototype) {
|
||||||
|
this.prototype[p] = parent.prototype[p];
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
c.extend = function (parent) {
|
c.extend = function (parent) {
|
||||||
@@ -70,23 +95,29 @@ var OZ = {
|
|||||||
this.prototype.constructor = this;
|
this.prototype.constructor = this;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
c.prototype.bind = function(fnc) { return fnc.bind(this); };
|
c.prototype.bind = function (fnc) {
|
||||||
|
return fnc.bind(this);
|
||||||
|
};
|
||||||
c.prototype.dispatch = function (type, data) {
|
c.prototype.dispatch = function (type, data) {
|
||||||
var obj = {
|
var obj = {
|
||||||
type: type,
|
type: type,
|
||||||
target: this,
|
target: this,
|
||||||
timeStamp:(new Date()).getTime(),
|
timeStamp: new Date().getTime(),
|
||||||
data:data
|
data: data,
|
||||||
}
|
};
|
||||||
var tocall = [];
|
var tocall = [];
|
||||||
var list = OZ.Event._byName[type];
|
var list = OZ.Event._byName[type];
|
||||||
for (var id in list) {
|
for (var id in list) {
|
||||||
var item = list[id];
|
var item = list[id];
|
||||||
if (!item[0] || item[0] == this) { tocall.push(item[2]); }
|
if (!item[0] || item[0] == this) {
|
||||||
|
tocall.push(item[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var len = tocall.length;
|
var len = tocall.length;
|
||||||
for (var i=0;i<len;i++) { tocall[i](obj); }
|
for (var i = 0; i < len; i++) {
|
||||||
|
tocall[i](obj);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
return c;
|
return c;
|
||||||
},
|
},
|
||||||
DOM: {
|
DOM: {
|
||||||
@@ -94,20 +125,33 @@ var OZ = {
|
|||||||
var elm = document.createElement(name);
|
var elm = document.createElement(name);
|
||||||
for (var p in opts) {
|
for (var p in opts) {
|
||||||
var val = opts[p];
|
var val = opts[p];
|
||||||
if (p == "class") { p = "className"; }
|
if (p == "class") {
|
||||||
if (p in elm) { elm[p] = val; }
|
p = "className";
|
||||||
|
}
|
||||||
|
if (p in elm) {
|
||||||
|
elm[p] = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OZ.Style.set(elm, opts);
|
OZ.Style.set(elm, opts);
|
||||||
return elm;
|
return elm;
|
||||||
},
|
},
|
||||||
text:function(str) { return document.createTextNode(str); },
|
text: function (str) {
|
||||||
clear:function(node) { while (node.firstChild) {node.removeChild(node.firstChild);} },
|
return document.createTextNode(str);
|
||||||
pos:function(elm) { /* relative to _viewport_ */
|
},
|
||||||
|
clear: function (node) {
|
||||||
|
while (node.firstChild) {
|
||||||
|
node.removeChild(node.firstChild);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pos: function (elm) {
|
||||||
|
/* relative to _viewport_ */
|
||||||
var cur = OZ.$(elm);
|
var cur = OZ.$(elm);
|
||||||
var html = cur.ownerDocument.documentElement;
|
var html = cur.ownerDocument.documentElement;
|
||||||
var parent = cur.parentNode;
|
var parent = cur.parentNode;
|
||||||
var x = y = 0;
|
var x = (y = 0);
|
||||||
if (cur == html) { return [x,y]; }
|
if (cur == html) {
|
||||||
|
return [x, y];
|
||||||
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
if (OZ.Style.get(cur, "position") == "fixed") {
|
if (OZ.Style.get(cur, "position") == "fixed") {
|
||||||
x += cur.offsetLeft;
|
x += cur.offsetLeft;
|
||||||
@@ -115,7 +159,11 @@ var OZ = {
|
|||||||
return [x, y];
|
return [x, y];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OZ.opera && (parent == html || OZ.Style.get(cur,"display") != "block")) { } else {
|
if (
|
||||||
|
OZ.opera &&
|
||||||
|
(parent == html || OZ.Style.get(cur, "display") != "block")
|
||||||
|
) {
|
||||||
|
} else {
|
||||||
x -= parent.scrollLeft;
|
x -= parent.scrollLeft;
|
||||||
y -= parent.scrollTop;
|
y -= parent.scrollTop;
|
||||||
}
|
}
|
||||||
@@ -125,54 +173,83 @@ var OZ = {
|
|||||||
cur = parent;
|
cur = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent == html) { return [x,y]; }
|
if (parent == html) {
|
||||||
|
return [x, y];
|
||||||
|
}
|
||||||
parent = parent.parentNode;
|
parent = parent.parentNode;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scroll: function () {
|
scroll: function () {
|
||||||
var x = document.documentElement.scrollLeft || document.body.scrollLeft || 0;
|
var x =
|
||||||
var y = document.documentElement.scrollTop || document.body.scrollTop || 0;
|
document.documentElement.scrollLeft ||
|
||||||
|
document.body.scrollLeft ||
|
||||||
|
0;
|
||||||
|
var y =
|
||||||
|
document.documentElement.scrollTop ||
|
||||||
|
document.body.scrollTop ||
|
||||||
|
0;
|
||||||
return [x, y];
|
return [x, y];
|
||||||
},
|
},
|
||||||
win: function (avail) {
|
win: function (avail) {
|
||||||
return (avail ? [window.innerWidth,window.innerHeight] : [document.documentElement.clientWidth,document.documentElement.clientHeight]);
|
return avail
|
||||||
|
? [window.innerWidth, window.innerHeight]
|
||||||
|
: [
|
||||||
|
document.documentElement.clientWidth,
|
||||||
|
document.documentElement.clientHeight,
|
||||||
|
];
|
||||||
},
|
},
|
||||||
hasClass: function (node, className) {
|
hasClass: function (node, className) {
|
||||||
var cn = OZ.$(node).className;
|
var cn = OZ.$(node).className;
|
||||||
var arr = (cn ? cn.split(" ") : []);
|
var arr = cn ? cn.split(" ") : [];
|
||||||
return (arr.indexOf(className) != -1);
|
return arr.indexOf(className) != -1;
|
||||||
},
|
},
|
||||||
addClass: function (node, className) {
|
addClass: function (node, className) {
|
||||||
if (OZ.DOM.hasClass(node, className)) { return; }
|
if (OZ.DOM.hasClass(node, className)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var cn = OZ.$(node).className;
|
var cn = OZ.$(node).className;
|
||||||
var arr = (cn ? cn.split(" ") : []);
|
var arr = cn ? cn.split(" ") : [];
|
||||||
arr.push(className);
|
arr.push(className);
|
||||||
OZ.$(node).className = arr.join(" ");
|
OZ.$(node).className = arr.join(" ");
|
||||||
},
|
},
|
||||||
removeClass: function (node, className) {
|
removeClass: function (node, className) {
|
||||||
if (!OZ.DOM.hasClass(node, className)) { return; }
|
if (!OZ.DOM.hasClass(node, className)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var cn = OZ.$(node).className;
|
var cn = OZ.$(node).className;
|
||||||
var arr = (cn ? cn.split(" ") : []);
|
var arr = cn ? cn.split(" ") : [];
|
||||||
var arr = arr.filter(function($){ return $ != className; });
|
var arr = arr.filter(function ($) {
|
||||||
|
return $ != className;
|
||||||
|
});
|
||||||
OZ.$(node).className = arr.join(" ");
|
OZ.$(node).className = arr.join(" ");
|
||||||
},
|
},
|
||||||
append: function () {
|
append: function () {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
var arr = arguments[0];
|
var arr = arguments[0];
|
||||||
var root = OZ.$(arr[0]);
|
var root = OZ.$(arr[0]);
|
||||||
for (var i=1;i<arr.length;i++) { root.appendChild(OZ.$(arr[i])); }
|
for (var i = 1; i < arr.length; i++) {
|
||||||
} else for (var i=0;i<arguments.length;i++) { OZ.DOM.append(arguments[i]); }
|
root.appendChild(OZ.$(arr[i]));
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
|
OZ.DOM.append(arguments[i]);
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Style: {
|
Style: {
|
||||||
get: function (elm, prop) {
|
get: function (elm, prop) {
|
||||||
if (document.defaultView && document.defaultView.getComputedStyle) {
|
if (document.defaultView && document.defaultView.getComputedStyle) {
|
||||||
try {
|
try {
|
||||||
var cs = elm.ownerDocument.defaultView.getComputedStyle(elm,"");
|
var cs = elm.ownerDocument.defaultView.getComputedStyle(
|
||||||
|
elm,
|
||||||
|
""
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!cs) { return false; }
|
if (!cs) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return cs[prop];
|
return cs[prop];
|
||||||
} else {
|
} else {
|
||||||
return elm.currentStyle[prop];
|
return elm.currentStyle[prop];
|
||||||
@@ -186,120 +263,167 @@ var OZ = {
|
|||||||
val = "alpha(opacity=" + Math.round(100 * val) + ")";
|
val = "alpha(opacity=" + Math.round(100 * val) + ")";
|
||||||
elm.style.zoom = 1;
|
elm.style.zoom = 1;
|
||||||
} else if (p == "float") {
|
} else if (p == "float") {
|
||||||
p = (OZ.ie ? "styleFloat" : "cssFloat");
|
p = OZ.ie ? "styleFloat" : "cssFloat";
|
||||||
}
|
}
|
||||||
if (p in elm.style) { elm.style[p] = val; }
|
if (p in elm.style) {
|
||||||
|
elm.style[p] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
Request: function (url, callback, options) {
|
Request: function (url, callback, options) {
|
||||||
var o = {data:false, method:"get", headers:{}, xml:false}
|
var o = { data: false, method: "get", headers: {}, xml: false };
|
||||||
for (var p in options) { o[p] = options[p]; }
|
for (var p in options) {
|
||||||
|
o[p] = options[p];
|
||||||
|
}
|
||||||
o.method = o.method.toUpperCase();
|
o.method = o.method.toUpperCase();
|
||||||
|
|
||||||
var xhr = false;
|
var xhr = false;
|
||||||
if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); }
|
if (window.XMLHttpRequest) {
|
||||||
else if (window.ActiveXObject) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
|
xhr = new XMLHttpRequest();
|
||||||
else { return false; }
|
} else if (window.ActiveXObject) {
|
||||||
|
xhr = new ActiveXObject("Microsoft.XMLHTTP");
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
xhr.open(o.method, url, true);
|
xhr.open(o.method, url, true);
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState != 4) { return; }
|
if (xhr.readyState != 4) {
|
||||||
if (!callback) { return; }
|
return;
|
||||||
var data = (o.xml ? xhr.responseXML : xhr.responseText);
|
}
|
||||||
|
if (!callback) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var data = o.xml ? xhr.responseXML : xhr.responseText;
|
||||||
var headers = {};
|
var headers = {};
|
||||||
var h = xhr.getAllResponseHeaders();
|
var h = xhr.getAllResponseHeaders();
|
||||||
if (h) {
|
if (h) {
|
||||||
h = h.split(/[\r\n]/);
|
h = h.split(/[\r\n]/);
|
||||||
for (var i=0;i<h.length;i++) if (h[i]) {
|
for (var i = 0; i < h.length; i++)
|
||||||
|
if (h[i]) {
|
||||||
var v = h[i].match(/^([^:]+): *(.*)$/);
|
var v = h[i].match(/^([^:]+): *(.*)$/);
|
||||||
headers[v[1]] = v[2];
|
headers[v[1]] = v[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback(data, xhr.status, headers);
|
callback(data, xhr.status, headers);
|
||||||
};
|
};
|
||||||
if (o.method == "POST") { xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); }
|
if (o.method == "POST") {
|
||||||
for (var p in o.headers) { xhr.setRequestHeader(p,o.headers[p]); }
|
xhr.setRequestHeader(
|
||||||
|
"Content-Type",
|
||||||
|
"application/x-www-form-urlencoded"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (var p in o.headers) {
|
||||||
|
xhr.setRequestHeader(p, o.headers[p]);
|
||||||
|
}
|
||||||
xhr.send(o.data || null);
|
xhr.send(o.data || null);
|
||||||
return xhr;
|
return xhr;
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
if (!Function.prototype.bind) {
|
if (!Function.prototype.bind) {
|
||||||
Function.prototype.bind = function (thisObj) {
|
Function.prototype.bind = function (thisObj) {
|
||||||
var fn = this;
|
var fn = this;
|
||||||
var args = Array.prototype.slice.call(arguments, 1);
|
var args = Array.prototype.slice.call(arguments, 1);
|
||||||
return function () {
|
return function () {
|
||||||
return fn.apply(thisObj, args.concat(Array.prototype.slice.call(arguments)));
|
return fn.apply(
|
||||||
}
|
thisObj,
|
||||||
}
|
args.concat(Array.prototype.slice.call(arguments))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (!Array.prototype.indexOf) {
|
if (!Array.prototype.indexOf) {
|
||||||
Array.prototype.indexOf = function (item, from) {
|
Array.prototype.indexOf = function (item, from) {
|
||||||
var len = this.length;
|
var len = this.length;
|
||||||
var i = from || 0;
|
var i = from || 0;
|
||||||
if (i < 0) { i += len; }
|
if (i < 0) {
|
||||||
|
i += len;
|
||||||
|
}
|
||||||
for (; i < len; i++) {
|
for (; i < len; i++) {
|
||||||
if (i in this && this[i] === item) { return i; }
|
if (i in this && this[i] === item) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
if (!Array.indexOf) {
|
if (!Array.indexOf) {
|
||||||
Array.indexOf = function(obj, item, from) { return Array.prototype.indexOf.call(obj, item, from); }
|
Array.indexOf = function (obj, item, from) {
|
||||||
|
return Array.prototype.indexOf.call(obj, item, from);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.prototype.lastIndexOf) {
|
if (!Array.prototype.lastIndexOf) {
|
||||||
Array.prototype.lastIndexOf = function (item, from) {
|
Array.prototype.lastIndexOf = function (item, from) {
|
||||||
var len = this.length;
|
var len = this.length;
|
||||||
var i = from || len - 1;
|
var i = from || len - 1;
|
||||||
if (i < 0) { i += len; }
|
if (i < 0) {
|
||||||
|
i += len;
|
||||||
|
}
|
||||||
for (; i > -1; i--) {
|
for (; i > -1; i--) {
|
||||||
if (i in this && this[i] === item) { return i; }
|
if (i in this && this[i] === item) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
if (!Array.lastIndexOf) {
|
if (!Array.lastIndexOf) {
|
||||||
Array.lastIndexOf = function(obj, item, from) { return Array.prototype.lastIndexOf.call(obj, item, from); }
|
Array.lastIndexOf = function (obj, item, from) {
|
||||||
|
return Array.prototype.lastIndexOf.call(obj, item, from);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.prototype.forEach) {
|
if (!Array.prototype.forEach) {
|
||||||
Array.prototype.forEach = function (cb, _this) {
|
Array.prototype.forEach = function (cb, _this) {
|
||||||
var len = this.length;
|
var len = this.length;
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
if (i in this) { cb.call(_this, this[i], i, this); }
|
if (i in this) {
|
||||||
|
cb.call(_this, this[i], i, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
if (!Array.forEach) {
|
if (!Array.forEach) {
|
||||||
Array.forEach = function(obj, cb, _this) { Array.prototype.forEach.call(obj, cb, _this); }
|
Array.forEach = function (obj, cb, _this) {
|
||||||
|
Array.prototype.forEach.call(obj, cb, _this);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.prototype.every) {
|
if (!Array.prototype.every) {
|
||||||
Array.prototype.every = function (cb, _this) {
|
Array.prototype.every = function (cb, _this) {
|
||||||
var len = this.length;
|
var len = this.length;
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
if (i in this && !cb.call(_this, this[i], i, this)) { return false; }
|
if (i in this && !cb.call(_this, this[i], i, this)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
if (!Array.every) {
|
if (!Array.every) {
|
||||||
Array.every = function(obj, cb, _this) { return Array.prototype.every.call(obj, cb, _this); }
|
Array.every = function (obj, cb, _this) {
|
||||||
|
return Array.prototype.every.call(obj, cb, _this);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.prototype.some) {
|
if (!Array.prototype.some) {
|
||||||
Array.prototype.some = function (cb, _this) {
|
Array.prototype.some = function (cb, _this) {
|
||||||
var len = this.length;
|
var len = this.length;
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
if (i in this && cb.call(_this, this[i], i, this)) { return true; }
|
if (i in this && cb.call(_this, this[i], i, this)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
if (!Array.some) {
|
if (!Array.some) {
|
||||||
Array.some = function(obj, cb, _this) { return Array.prototype.some.call(obj, cb, _this); }
|
Array.some = function (obj, cb, _this) {
|
||||||
|
return Array.prototype.some.call(obj, cb, _this);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.prototype.map) {
|
if (!Array.prototype.map) {
|
||||||
@@ -307,13 +431,17 @@ if (!Array.prototype.map) {
|
|||||||
var len = this.length;
|
var len = this.length;
|
||||||
var res = new Array(len);
|
var res = new Array(len);
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
if (i in this) { res[i] = cb.call(_this, this[i], i, this); }
|
if (i in this) {
|
||||||
|
res[i] = cb.call(_this, this[i], i, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
if (!Array.map) {
|
if (!Array.map) {
|
||||||
Array.map = function(obj, cb, _this) { return Array.prototype.map.call(obj, cb, _this); }
|
Array.map = function (obj, cb, _this) {
|
||||||
|
return Array.prototype.map.call(obj, cb, _this);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.prototype.filter) {
|
if (!Array.prototype.filter) {
|
||||||
@@ -323,12 +451,16 @@ if (!Array.prototype.filter) {
|
|||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
if (i in this) {
|
if (i in this) {
|
||||||
var val = this[i];
|
var val = this[i];
|
||||||
if (cb.call(_this, val, i, this)) { res.push(val); }
|
if (cb.call(_this, val, i, this)) {
|
||||||
|
res.push(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
if (!Array.filter) {
|
if (!Array.filter) {
|
||||||
Array.filter = function(obj, cb, _this) { return Array.prototype.filter.call(obj, cb, _this); }
|
Array.filter = function (obj, cb, _this) {
|
||||||
|
return Array.prototype.filter.call(obj, cb, _this);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+83
-35
@@ -22,11 +22,14 @@ SQL.Relation = function(owner, row1, row2) {
|
|||||||
|
|
||||||
/* 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);
|
||||||
if (all.length) { /* inherit */
|
if (all.length) {
|
||||||
|
/* inherit */
|
||||||
this.color = all[0].getColor();
|
this.color = all[0].getColor();
|
||||||
} else if (this.relationColors) { /* pick next */
|
} else if (this.relationColors) {
|
||||||
|
/* pick next */
|
||||||
SQL.Relation._counter++;
|
SQL.Relation._counter++;
|
||||||
var colorIndex = (SQL.Relation._counter - 1) % this.relationColors.length;
|
var colorIndex =
|
||||||
|
(SQL.Relation._counter - 1) % this.relationColors.length;
|
||||||
this.color = this.relationColors[colorIndex];
|
this.color = this.relationColors[colorIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,11 +46,17 @@ SQL.Relation = function(owner, row1, row2) {
|
|||||||
this.dom.push(path);
|
this.dom.push(path);
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < 3; i++) {
|
for (var i = 0; i < 3; i++) {
|
||||||
var div = OZ.DOM.elm("div",{position:"absolute",className:"relation",backgroundColor:this.color});
|
var div = OZ.DOM.elm("div", {
|
||||||
|
position: "absolute",
|
||||||
|
className: "relation",
|
||||||
|
backgroundColor: this.color,
|
||||||
|
});
|
||||||
this.dom.push(div);
|
this.dom.push(div);
|
||||||
if (i & 1) { /* middle */
|
if (i & 1) {
|
||||||
|
/* middle */
|
||||||
OZ.Style.set(div, { width: CONFIG.RELATION_THICKNESS + "px" });
|
OZ.Style.set(div, { width: CONFIG.RELATION_THICKNESS + "px" });
|
||||||
} else { /* first & last */
|
} else {
|
||||||
|
/* first & last */
|
||||||
OZ.Style.set(div, { height: CONFIG.RELATION_THICKNESS + "px" });
|
OZ.Style.set(div, { height: CONFIG.RELATION_THICKNESS + "px" });
|
||||||
}
|
}
|
||||||
this.owner.dom.container.appendChild(div);
|
this.owner.dom.container.appendChild(div);
|
||||||
@@ -55,63 +64,80 @@ SQL.Relation = function(owner, row1, row2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
SQL.Relation._counter = 0;
|
SQL.Relation._counter = 0;
|
||||||
SQL.Relation.prototype = Object.create(SQL.Visual.prototype);
|
SQL.Relation.prototype = Object.create(SQL.Visual.prototype);
|
||||||
|
|
||||||
SQL.Relation.prototype.getColor = function () {
|
SQL.Relation.prototype.getColor = function () {
|
||||||
return this.color;
|
return this.color;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Relation.prototype.highlight = function () {
|
SQL.Relation.prototype.highlight = function () {
|
||||||
if (this.highlighted) { return; }
|
if (this.highlighted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.highlighted = true;
|
this.highlighted = true;
|
||||||
this.dom[0].setAttribute("stroke", CONFIG.RELATION_HIGHLIGHTED_COLOR);
|
this.dom[0].setAttribute("stroke", CONFIG.RELATION_HIGHLIGHTED_COLOR);
|
||||||
this.dom[0].setAttribute("stroke-width", CONFIG.RELATION_HIGHLIGHTED_THICKNESS);
|
this.dom[0].setAttribute(
|
||||||
|
"stroke-width",
|
||||||
|
CONFIG.RELATION_HIGHLIGHTED_THICKNESS
|
||||||
|
);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Relation.prototype.dehighlight = function () {
|
SQL.Relation.prototype.dehighlight = function () {
|
||||||
if (!this.highlighted) { return; }
|
if (!this.highlighted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.highlighted = false;
|
this.highlighted = false;
|
||||||
this.dom[0].setAttribute("stroke", this.color);
|
this.dom[0].setAttribute("stroke", this.color);
|
||||||
this.dom[0].setAttribute("stroke-width", CONFIG.RELATION_THICKNESS);
|
this.dom[0].setAttribute("stroke-width", CONFIG.RELATION_THICKNESS);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Relation.prototype.show = function () {
|
SQL.Relation.prototype.show = function () {
|
||||||
this.hidden = false;
|
this.hidden = false;
|
||||||
for (var i = 0; i < this.dom.length; i++) {
|
for (var i = 0; i < this.dom.length; i++) {
|
||||||
this.dom[i].style.visibility = "";
|
this.dom[i].style.visibility = "";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Relation.prototype.hide = function () {
|
SQL.Relation.prototype.hide = function () {
|
||||||
this.hidden = true;
|
this.hidden = true;
|
||||||
for (var i = 0; i < this.dom.length; i++) {
|
for (var i = 0; i < this.dom.length; i++) {
|
||||||
this.dom[i].style.visibility = "hidden";
|
this.dom[i].style.visibility = "hidden";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Relation.prototype.redrawNormal = function (p1, p2, half) {
|
SQL.Relation.prototype.redrawNormal = function (p1, p2, half) {
|
||||||
if (this.owner.vector) {
|
if (this.owner.vector) {
|
||||||
var str = "M "+p1[0]+" "+p1[1]+" C "+(p1[0] + half)+" "+p1[1]+" ";
|
var str =
|
||||||
str += (p2[0]-half)+" "+p2[1]+" "+p2[0]+" "+p2[1];
|
"M " +
|
||||||
|
p1[0] +
|
||||||
|
" " +
|
||||||
|
p1[1] +
|
||||||
|
" C " +
|
||||||
|
(p1[0] + half) +
|
||||||
|
" " +
|
||||||
|
p1[1] +
|
||||||
|
" ";
|
||||||
|
str += p2[0] - half + " " + p2[1] + " " + p2[0] + " " + p2[1];
|
||||||
this.dom[0].setAttribute("d", str);
|
this.dom[0].setAttribute("d", str);
|
||||||
} else {
|
} else {
|
||||||
this.dom[0].style.left = p1[0] + "px";
|
this.dom[0].style.left = p1[0] + "px";
|
||||||
this.dom[0].style.top = p1[1] + "px";
|
this.dom[0].style.top = p1[1] + "px";
|
||||||
this.dom[0].style.width = half + "px";
|
this.dom[0].style.width = half + "px";
|
||||||
|
|
||||||
this.dom[1].style.left = (p1[0] + half) + "px";
|
this.dom[1].style.left = p1[0] + half + "px";
|
||||||
this.dom[1].style.top = Math.min(p1[1], p2[1]) + "px";
|
this.dom[1].style.top = Math.min(p1[1], p2[1]) + "px";
|
||||||
this.dom[1].style.height = (Math.abs(p1[1] - p2[1])+CONFIG.RELATION_THICKNESS)+"px";
|
this.dom[1].style.height =
|
||||||
|
Math.abs(p1[1] - p2[1]) + CONFIG.RELATION_THICKNESS + "px";
|
||||||
|
|
||||||
this.dom[2].style.left = (p1[0]+half+1)+"px";
|
this.dom[2].style.left = p1[0] + half + 1 + "px";
|
||||||
this.dom[2].style.top = p2[1] + "px";
|
this.dom[2].style.top = p2[1] + "px";
|
||||||
this.dom[2].style.width = half + "px";
|
this.dom[2].style.width = half + "px";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Relation.prototype.redrawSide = function (p1, p2, x) {
|
SQL.Relation.prototype.redrawSide = function (p1, p2, x) {
|
||||||
if (this.owner.vector) {
|
if (this.owner.vector) {
|
||||||
@@ -125,16 +151,20 @@ SQL.Relation.prototype.redrawSide = function(p1, p2, x) {
|
|||||||
|
|
||||||
this.dom[1].style.left = x + "px";
|
this.dom[1].style.left = x + "px";
|
||||||
this.dom[1].style.top = Math.min(p1[1], p2[1]) + "px";
|
this.dom[1].style.top = Math.min(p1[1], p2[1]) + "px";
|
||||||
this.dom[1].style.height = (Math.abs(p1[1] - p2[1])+CONFIG.RELATION_THICKNESS)+"px";
|
this.dom[1].style.height =
|
||||||
|
Math.abs(p1[1] - p2[1]) + CONFIG.RELATION_THICKNESS + "px";
|
||||||
|
|
||||||
this.dom[2].style.left = Math.min(x, p2[0]) + "px";
|
this.dom[2].style.left = Math.min(x, p2[0]) + "px";
|
||||||
this.dom[2].style.top = p2[1] + "px";
|
this.dom[2].style.top = p2[1] + "px";
|
||||||
this.dom[2].style.width = Math.abs(p2[0] - x) + "px";
|
this.dom[2].style.width = Math.abs(p2[0] - x) + "px";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Relation.prototype.redraw = function() { /* draw connector */
|
SQL.Relation.prototype.redraw = function () {
|
||||||
if (this.hidden) { return; }
|
/* draw connector */
|
||||||
|
if (this.hidden) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var t1 = this.row1.owner.dom.container;
|
var t1 = this.row1.owner.dom.container;
|
||||||
var t2 = this.row2.owner.dom.container;
|
var t2 = this.row2.owner.dom.container;
|
||||||
|
|
||||||
@@ -142,16 +172,31 @@ SQL.Relation.prototype.redraw = function() { /* draw connector */
|
|||||||
var l2 = t2.offsetLeft;
|
var l2 = t2.offsetLeft;
|
||||||
var r1 = l1 + t1.offsetWidth;
|
var r1 = l1 + t1.offsetWidth;
|
||||||
var r2 = l2 + t2.offsetWidth;
|
var r2 = l2 + t2.offsetWidth;
|
||||||
var t1 = t1.offsetTop + this.row1.dom.container.offsetTop + Math.round(this.row1.dom.container.offsetHeight/2);
|
var t1 =
|
||||||
var t2 = t2.offsetTop + this.row2.dom.container.offsetTop + Math.round(this.row2.dom.container.offsetHeight/2);
|
t1.offsetTop +
|
||||||
|
this.row1.dom.container.offsetTop +
|
||||||
|
Math.round(this.row1.dom.container.offsetHeight / 2);
|
||||||
|
var t2 =
|
||||||
|
t2.offsetTop +
|
||||||
|
this.row2.dom.container.offsetTop +
|
||||||
|
Math.round(this.row2.dom.container.offsetHeight / 2);
|
||||||
|
|
||||||
if (this.row1.owner.selected) { t1++; l1++; r1--; }
|
if (this.row1.owner.selected) {
|
||||||
if (this.row2.owner.selected) { t2++; l2++; r2--; }
|
t1++;
|
||||||
|
l1++;
|
||||||
|
r1--;
|
||||||
|
}
|
||||||
|
if (this.row2.owner.selected) {
|
||||||
|
t2++;
|
||||||
|
l2++;
|
||||||
|
r2--;
|
||||||
|
}
|
||||||
|
|
||||||
var p1 = [0, 0];
|
var p1 = [0, 0];
|
||||||
var p2 = [0, 0];
|
var p2 = [0, 0];
|
||||||
|
|
||||||
if (r1 < l2 || r2 < l1) { /* between tables */
|
if (r1 < l2 || r2 < l1) {
|
||||||
|
/* between tables */
|
||||||
if (Math.abs(r1 - l2) < Math.abs(r2 - l1)) {
|
if (Math.abs(r1 - l2) < Math.abs(r2 - l1)) {
|
||||||
p1 = [r1, t1];
|
p1 = [r1, t1];
|
||||||
p2 = [l2, t2];
|
p2 = [l2, t2];
|
||||||
@@ -161,21 +206,24 @@ SQL.Relation.prototype.redraw = function() { /* draw connector */
|
|||||||
}
|
}
|
||||||
var half = Math.floor((p2[0] - p1[0]) / 2);
|
var half = Math.floor((p2[0] - p1[0]) / 2);
|
||||||
this.redrawNormal(p1, p2, half);
|
this.redrawNormal(p1, p2, half);
|
||||||
} else { /* next to tables */
|
} else {
|
||||||
|
/* next to tables */
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var l = 0;
|
var l = 0;
|
||||||
if (Math.abs(l1 - l2) < Math.abs(r1 - r2)) { /* left of tables */
|
if (Math.abs(l1 - l2) < Math.abs(r1 - r2)) {
|
||||||
|
/* left of tables */
|
||||||
p1 = [l1, t1];
|
p1 = [l1, t1];
|
||||||
p2 = [l2, t2];
|
p2 = [l2, t2];
|
||||||
x = Math.min(l1, l2) - CONFIG.RELATION_SPACING;
|
x = Math.min(l1, l2) - CONFIG.RELATION_SPACING;
|
||||||
} else { /* right of tables */
|
} else {
|
||||||
|
/* right of tables */
|
||||||
p1 = [r1, t1];
|
p1 = [r1, t1];
|
||||||
p2 = [r2, t2];
|
p2 = [r2, t2];
|
||||||
x = Math.max(r1, r2) + CONFIG.RELATION_SPACING;
|
x = Math.max(r1, r2) + CONFIG.RELATION_SPACING;
|
||||||
}
|
}
|
||||||
this.redrawSide(p1, p2, x);
|
this.redrawSide(p1, p2, x);
|
||||||
} /* line next to tables */
|
} /* line next to tables */
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Relation.prototype.destroy = function () {
|
SQL.Relation.prototype.destroy = function () {
|
||||||
this.row1.removeRelation(this);
|
this.row1.removeRelation(this);
|
||||||
@@ -183,4 +231,4 @@ SQL.Relation.prototype.destroy = function() {
|
|||||||
for (var i = 0; i < this.dom.length; i++) {
|
for (var i = 0; i < this.dom.length; i++) {
|
||||||
this.dom[i].parentNode.removeChild(this.dom[i]);
|
this.dom[i].parentNode.removeChild(this.dom[i]);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -15,16 +15,21 @@ SQL.Row = function(owner, title, data) {
|
|||||||
this.data.ai = false;
|
this.data.ai = false;
|
||||||
this.data.comment = "";
|
this.data.comment = "";
|
||||||
|
|
||||||
if (data) { this.update(data); }
|
if (data) {
|
||||||
this.setTitle(title);
|
this.update(data);
|
||||||
}
|
}
|
||||||
|
this.setTitle(title);
|
||||||
|
};
|
||||||
SQL.Row.prototype = Object.create(SQL.Visual.prototype);
|
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");
|
||||||
|
|
||||||
this.dom.content = OZ.DOM.elm("tr");
|
this.dom.content = OZ.DOM.elm("tr");
|
||||||
this.dom.selected = OZ.DOM.elm("div", {className:"selected",innerHTML:"» "});
|
this.dom.selected = OZ.DOM.elm("div", {
|
||||||
|
className: "selected",
|
||||||
|
innerHTML: "» ",
|
||||||
|
});
|
||||||
this.dom.title = OZ.DOM.elm("div", { className: "title" });
|
this.dom.title = OZ.DOM.elm("div", { className: "title" });
|
||||||
var td1 = OZ.DOM.elm("td");
|
var td1 = OZ.DOM.elm("td");
|
||||||
var td2 = OZ.DOM.elm("td", { className: "typehint" });
|
var td2 = OZ.DOM.elm("td", { className: "typehint" });
|
||||||
@@ -41,80 +46,118 @@ SQL.Row.prototype._build = function() {
|
|||||||
|
|
||||||
OZ.Event.add(this.dom.container, "click", this.click.bind(this));
|
OZ.Event.add(this.dom.container, "click", this.click.bind(this));
|
||||||
OZ.Event.add(this.dom.container, "dblclick", this.dblclick.bind(this));
|
OZ.Event.add(this.dom.container, "dblclick", this.dblclick.bind(this));
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.select = function () {
|
SQL.Row.prototype.select = function () {
|
||||||
if (this.selected) { return; }
|
if (this.selected) {
|
||||||
this.selected = true;
|
return;
|
||||||
for (var i = 0; i < this.relations.length; i++) { this.relations[i].highlight(); }
|
|
||||||
this.redraw();
|
|
||||||
}
|
}
|
||||||
|
this.selected = true;
|
||||||
|
for (var i = 0; i < this.relations.length; i++) {
|
||||||
|
this.relations[i].highlight();
|
||||||
|
}
|
||||||
|
this.redraw();
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.deselect = function () {
|
SQL.Row.prototype.deselect = function () {
|
||||||
if (!this.selected) { return; }
|
if (!this.selected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.selected = false;
|
this.selected = false;
|
||||||
for (var i = 0; i < this.relations.length; i++) { this.relations[i].dehighlight(); }
|
for (var i = 0; i < this.relations.length; i++) {
|
||||||
|
this.relations[i].dehighlight();
|
||||||
|
}
|
||||||
this.redraw();
|
this.redraw();
|
||||||
this.collapse();
|
this.collapse();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.setTitle = function (t) {
|
SQL.Row.prototype.setTitle = function (t) {
|
||||||
var old = this.getTitle();
|
var old = this.getTitle();
|
||||||
for (var i = 0; i < this.relations.length; i++) {
|
for (var i = 0; i < this.relations.length; i++) {
|
||||||
var r = this.relations[i];
|
var r = this.relations[i];
|
||||||
if (r.row1 != this) { continue; }
|
if (r.row1 != this) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var tt = r.row2.getTitle().replace(new RegExp(old, "g"), t);
|
var tt = r.row2.getTitle().replace(new RegExp(old, "g"), t);
|
||||||
if (tt != r.row2.getTitle()) { r.row2.setTitle(tt); }
|
if (tt != r.row2.getTitle()) {
|
||||||
|
r.row2.setTitle(tt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SQL.Visual.prototype.setTitle.apply(this, [t]);
|
SQL.Visual.prototype.setTitle.apply(this, [t]);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.click = function(e) { /* clicked on row */
|
SQL.Row.prototype.click = function (e) {
|
||||||
|
/* clicked on row */
|
||||||
SQL.publish("rowclick", this);
|
SQL.publish("rowclick", this);
|
||||||
this.owner.owner.rowManager.select(this);
|
this.owner.owner.rowManager.select(this);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.dblclick = function(e) { /* dblclicked on row */
|
SQL.Row.prototype.dblclick = function (e) {
|
||||||
|
/* dblclicked on row */
|
||||||
OZ.Event.prevent(e);
|
OZ.Event.prevent(e);
|
||||||
OZ.Event.stop(e);
|
OZ.Event.stop(e);
|
||||||
this.expand();
|
this.expand();
|
||||||
|
};
|
||||||
|
|
||||||
|
SQL.Row.prototype.update = function (data) {
|
||||||
|
/* update subset of row data */
|
||||||
|
var des = SQL.Designer;
|
||||||
|
if (data.nll && data.def && data.def.match(/^null$/i)) {
|
||||||
|
data.def = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQL.Row.prototype.update = function(data) { /* update subset of row data */
|
for (var p in data) {
|
||||||
var des = SQL.Designer;
|
this.data[p] = data[p];
|
||||||
if (data.nll && data.def && data.def.match(/^null$/i)) { data.def = null; }
|
}
|
||||||
|
if (!this.data.nll && this.data.def === null) {
|
||||||
for (var p in data) { this.data[p] = data[p]; }
|
this.data.def = "";
|
||||||
if (!this.data.nll && this.data.def === null) { this.data.def = ""; }
|
}
|
||||||
|
|
||||||
var elm = this.getDataType();
|
var elm = this.getDataType();
|
||||||
for (var i = 0; i < this.relations.length; i++) {
|
for (var i = 0; i < this.relations.length; i++) {
|
||||||
var r = this.relations[i];
|
var r = this.relations[i];
|
||||||
if (r.row1 == this) { r.row2.update({type:des.getFKTypeFor(this.data.type),size:this.data.size}); }
|
if (r.row1 == this) {
|
||||||
|
r.row2.update({
|
||||||
|
type: des.getFKTypeFor(this.data.type),
|
||||||
|
size: this.data.size,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.up = function() { /* shift up */
|
SQL.Row.prototype.up = function () {
|
||||||
|
/* shift up */
|
||||||
var r = this.owner.rows;
|
var r = this.owner.rows;
|
||||||
var idx = r.indexOf(this);
|
var idx = r.indexOf(this);
|
||||||
if (!idx) { return; }
|
if (!idx) {
|
||||||
r[idx-1].dom.container.parentNode.insertBefore(this.dom.container,r[idx-1].dom.container);
|
return;
|
||||||
|
}
|
||||||
|
r[idx - 1].dom.container.parentNode.insertBefore(
|
||||||
|
this.dom.container,
|
||||||
|
r[idx - 1].dom.container
|
||||||
|
);
|
||||||
r.splice(idx, 1);
|
r.splice(idx, 1);
|
||||||
r.splice(idx - 1, 0, this);
|
r.splice(idx - 1, 0, this);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.down = function() { /* shift down */
|
SQL.Row.prototype.down = function () {
|
||||||
|
/* shift down */
|
||||||
var r = this.owner.rows;
|
var r = this.owner.rows;
|
||||||
var idx = r.indexOf(this);
|
var idx = r.indexOf(this);
|
||||||
if (idx+1 == this.owner.rows.length) { return; }
|
if (idx + 1 == this.owner.rows.length) {
|
||||||
r[idx].dom.container.parentNode.insertBefore(this.dom.container,r[idx+1].dom.container.nextSibling);
|
return;
|
||||||
|
}
|
||||||
|
r[idx].dom.container.parentNode.insertBefore(
|
||||||
|
this.dom.container,
|
||||||
|
r[idx + 1].dom.container.nextSibling
|
||||||
|
);
|
||||||
r.splice(idx, 1);
|
r.splice(idx, 1);
|
||||||
r.splice(idx + 1, 0, this);
|
r.splice(idx + 1, 0, this);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.buildEdit = function () {
|
SQL.Row.prototype.buildEdit = function () {
|
||||||
OZ.DOM.clear(this.dom.container);
|
OZ.DOM.clear(this.dom.container);
|
||||||
@@ -150,7 +193,7 @@ SQL.Row.prototype.buildEdit = function() {
|
|||||||
|
|
||||||
this.dom.commentbtn = OZ.DOM.elm("input");
|
this.dom.commentbtn = OZ.DOM.elm("input");
|
||||||
this.dom.commentbtn.type = "button";
|
this.dom.commentbtn.type = "button";
|
||||||
this.dom.commentbtn.id = "commentbtn"
|
this.dom.commentbtn.id = "commentbtn";
|
||||||
this.dom.commentbtn.value = _("comment");
|
this.dom.commentbtn.value = _("comment");
|
||||||
|
|
||||||
OZ.Event.add(this.dom.commentbtn, "click", this.changeComment);
|
OZ.Event.add(this.dom.commentbtn, "click", this.changeComment);
|
||||||
@@ -161,11 +204,7 @@ SQL.Row.prototype.buildEdit = function() {
|
|||||||
var td1 = OZ.DOM.elm("td");
|
var td1 = OZ.DOM.elm("td");
|
||||||
var td2 = OZ.DOM.elm("td");
|
var td2 = OZ.DOM.elm("td");
|
||||||
var l = OZ.DOM.text(_(row[0]) + ": ");
|
var l = OZ.DOM.text(_(row[0]) + ": ");
|
||||||
OZ.DOM.append(
|
OZ.DOM.append([tr, td1, td2], [td1, l], [td2, row[1]]);
|
||||||
[tr, td1, td2],
|
|
||||||
[td1, l],
|
|
||||||
[td2, row[1]]
|
|
||||||
);
|
|
||||||
this.dom.container.appendChild(tr);
|
this.dom.container.appendChild(tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,57 +217,66 @@ SQL.Row.prototype.buildEdit = function() {
|
|||||||
[td2, this.dom.commentbtn]
|
[td2, this.dom.commentbtn]
|
||||||
);
|
);
|
||||||
this.dom.container.appendChild(tr);
|
this.dom.container.appendChild(tr);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.changeComment = function (e) {
|
SQL.Row.prototype.changeComment = function (e) {
|
||||||
var c = prompt(_("commenttext"), this.data.comment);
|
var c = prompt(_("commenttext"), this.data.comment);
|
||||||
if (c === null) { return; }
|
if (c === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.data.comment = c;
|
this.data.comment = c;
|
||||||
this.dom.comment.innerHTML = "";
|
this.dom.comment.innerHTML = "";
|
||||||
this.dom.comment.appendChild(document.createTextNode(this.data.comment));
|
this.dom.comment.appendChild(document.createTextNode(this.data.comment));
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.expand = function () {
|
SQL.Row.prototype.expand = function () {
|
||||||
if (this.expanded) { return; }
|
if (this.expanded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.expanded = true;
|
this.expanded = true;
|
||||||
this.buildEdit();
|
this.buildEdit();
|
||||||
this.load();
|
this.load();
|
||||||
this.redraw();
|
this.redraw();
|
||||||
this.dom.container.classList.add('expanded');
|
this.dom.container.classList.add("expanded");
|
||||||
this.dom.name.focus();
|
this.dom.name.focus();
|
||||||
this.dom.name.select();
|
this.dom.name.select();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.collapse = function () {
|
SQL.Row.prototype.collapse = function () {
|
||||||
if (!this.expanded) { return; }
|
if (!this.expanded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.expanded = false;
|
this.expanded = false;
|
||||||
this.dom.container.classList.remove('expanded');
|
this.dom.container.classList.remove("expanded");
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
type: this.dom.type.selectedIndex,
|
type: this.dom.type.selectedIndex,
|
||||||
def: this.dom.def.value,
|
def: this.dom.def.value,
|
||||||
size: this.dom.size.value,
|
size: this.dom.size.value,
|
||||||
nll: this.dom.nll.checked,
|
nll: this.dom.nll.checked,
|
||||||
ai: this.dom.ai.checked
|
ai: this.dom.ai.checked,
|
||||||
}
|
};
|
||||||
|
|
||||||
OZ.DOM.clear(this.dom.container);
|
OZ.DOM.clear(this.dom.container);
|
||||||
this.dom.container.appendChild(this.dom.content);
|
this.dom.container.appendChild(this.dom.content);
|
||||||
|
|
||||||
this.update(data);
|
this.update(data);
|
||||||
this.setTitle(this.dom.name.value);
|
this.setTitle(this.dom.name.value);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.load = function() { /* put data to expanded form */
|
SQL.Row.prototype.load = function () {
|
||||||
|
/* put data to expanded form */
|
||||||
this.dom.name.value = this.getTitle();
|
this.dom.name.value = this.getTitle();
|
||||||
var def = this.data.def;
|
var def = this.data.def;
|
||||||
if (def === null) { def = "NULL"; }
|
if (def === null) {
|
||||||
|
def = "NULL";
|
||||||
|
}
|
||||||
|
|
||||||
this.dom.def.value = def;
|
this.dom.def.value = def;
|
||||||
this.dom.size.value = this.data.size;
|
this.dom.size.value = this.data.size;
|
||||||
this.dom.nll.checked = this.data.nll;
|
this.dom.nll.checked = this.data.nll;
|
||||||
this.dom.ai.checked = this.data.ai;
|
this.dom.ai.checked = this.data.ai;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.redraw = function () {
|
SQL.Row.prototype.redraw = function () {
|
||||||
var color = this.getColor();
|
var color = this.getColor();
|
||||||
@@ -236,9 +284,13 @@ SQL.Row.prototype.redraw = function() {
|
|||||||
this.dom.container.style.borderColor = color;
|
this.dom.container.style.borderColor = color;
|
||||||
OZ.DOM.removeClass(this.dom.title, "primary");
|
OZ.DOM.removeClass(this.dom.title, "primary");
|
||||||
OZ.DOM.removeClass(this.dom.title, "key");
|
OZ.DOM.removeClass(this.dom.title, "key");
|
||||||
if (this.isPrimary()) { OZ.DOM.addClass(this.dom.title, "primary"); }
|
if (this.isPrimary()) {
|
||||||
if (this.isKey()) { OZ.DOM.addClass(this.dom.title, "key"); }
|
OZ.DOM.addClass(this.dom.title, "primary");
|
||||||
this.dom.selected.style.display = (this.selected ? "" : "none");
|
}
|
||||||
|
if (this.isKey()) {
|
||||||
|
OZ.DOM.addClass(this.dom.title, "key");
|
||||||
|
}
|
||||||
|
this.dom.selected.style.display = this.selected ? "" : "none";
|
||||||
this.dom.container.title = this.data.comment;
|
this.dom.container.title = this.data.comment;
|
||||||
|
|
||||||
var typehint = [];
|
var typehint = [];
|
||||||
@@ -254,43 +306,48 @@ SQL.Row.prototype.redraw = function() {
|
|||||||
this.dom.typehint.innerHTML = typehint.join(" ");
|
this.dom.typehint.innerHTML = typehint.join(" ");
|
||||||
this.owner.redraw();
|
this.owner.redraw();
|
||||||
this.owner.owner.rowManager.redraw();
|
this.owner.owner.rowManager.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.addRelation = function (r) {
|
SQL.Row.prototype.addRelation = function (r) {
|
||||||
this.relations.push(r);
|
this.relations.push(r);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.removeRelation = function (r) {
|
SQL.Row.prototype.removeRelation = function (r) {
|
||||||
var idx = this.relations.indexOf(r);
|
var idx = this.relations.indexOf(r);
|
||||||
if (idx == -1) { return; }
|
if (idx == -1) {
|
||||||
this.relations.splice(idx,1);
|
return;
|
||||||
}
|
}
|
||||||
|
this.relations.splice(idx, 1);
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.addKey = function (k) {
|
SQL.Row.prototype.addKey = function (k) {
|
||||||
this.keys.push(k);
|
this.keys.push(k);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.removeKey = function (k) {
|
SQL.Row.prototype.removeKey = function (k) {
|
||||||
var idx = this.keys.indexOf(k);
|
var idx = this.keys.indexOf(k);
|
||||||
if (idx == -1) { return; }
|
if (idx == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.keys.splice(idx, 1);
|
this.keys.splice(idx, 1);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.getDataType = function () {
|
SQL.Row.prototype.getDataType = function () {
|
||||||
var type = this.data.type;
|
var type = this.data.type;
|
||||||
var elm = DATATYPES.getElementsByTagName("type")[type];
|
var elm = DATATYPES.getElementsByTagName("type")[type];
|
||||||
return elm;
|
return elm;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.getColor = function () {
|
SQL.Row.prototype.getColor = function () {
|
||||||
var elm = this.getDataType();
|
var elm = this.getDataType();
|
||||||
var g = this.getDataType().parentNode;
|
var g = this.getDataType().parentNode;
|
||||||
return elm.getAttribute("color") || g.getAttribute("color") || "#fff";
|
return elm.getAttribute("color") || g.getAttribute("color") || "#fff";
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.buildTypeSelect = function(id) { /* build selectbox with avail datatypes */
|
SQL.Row.prototype.buildTypeSelect = function (id) {
|
||||||
|
/* build selectbox with avail datatypes */
|
||||||
var s = OZ.DOM.elm("select");
|
var s = OZ.DOM.elm("select");
|
||||||
var gs = DATATYPES.getElementsByTagName("group");
|
var gs = DATATYPES.getElementsByTagName("group");
|
||||||
for (var i = 0; i < gs.length; i++) {
|
for (var i = 0; i < gs.length; i++) {
|
||||||
@@ -303,15 +360,19 @@ SQL.Row.prototype.buildTypeSelect = function(id) { /* build selectbox with avail
|
|||||||
for (var j = 0; j < ts.length; j++) {
|
for (var j = 0; j < ts.length; j++) {
|
||||||
var t = ts[j];
|
var t = ts[j];
|
||||||
var o = OZ.DOM.elm("option");
|
var o = OZ.DOM.elm("option");
|
||||||
if (t.getAttribute("color")) { o.style.backgroundColor = t.getAttribute("color"); }
|
if (t.getAttribute("color")) {
|
||||||
if (t.getAttribute("note")) { o.title = t.getAttribute("note"); }
|
o.style.backgroundColor = t.getAttribute("color");
|
||||||
|
}
|
||||||
|
if (t.getAttribute("note")) {
|
||||||
|
o.title = t.getAttribute("note");
|
||||||
|
}
|
||||||
o.innerHTML = t.getAttribute("label");
|
o.innerHTML = t.getAttribute("label");
|
||||||
og.appendChild(o);
|
og.appendChild(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.selectedIndex = id;
|
s.selectedIndex = id;
|
||||||
return s;
|
return s;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.destroy = function () {
|
SQL.Row.prototype.destroy = function () {
|
||||||
SQL.Visual.prototype.destroy.apply(this);
|
SQL.Visual.prototype.destroy.apply(this);
|
||||||
@@ -321,19 +382,22 @@ SQL.Row.prototype.destroy = function() {
|
|||||||
for (var i = 0; i < this.keys.length; i++) {
|
for (var i = 0; i < this.keys.length; i++) {
|
||||||
this.keys[i].removeRow(this);
|
this.keys[i].removeRow(this);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.toXML = function () {
|
SQL.Row.prototype.toXML = function () {
|
||||||
var xml = "";
|
var xml = "";
|
||||||
|
|
||||||
var t = this.getTitle().replace(/"/g, """);
|
var t = this.getTitle().replace(/"/g, """);
|
||||||
var nn = (this.data.nll ? "1" : "0");
|
var nn = this.data.nll ? "1" : "0";
|
||||||
var ai = (this.data.ai ? "1" : "0");
|
var ai = this.data.ai ? "1" : "0";
|
||||||
xml += '<row name="'+t+'" null="'+nn+'" autoincrement="'+ai+'">\n';
|
xml +=
|
||||||
|
'<row name="' + t + '" null="' + nn + '" autoincrement="' + ai + '">\n';
|
||||||
|
|
||||||
var elm = this.getDataType();
|
var elm = this.getDataType();
|
||||||
var t = elm.getAttribute("sql");
|
var t = elm.getAttribute("sql");
|
||||||
if (this.data.size.length) { t += "("+this.data.size+")"; }
|
if (this.data.size.length) {
|
||||||
|
t += "(" + this.data.size + ")";
|
||||||
|
}
|
||||||
xml += "<datatype>" + t + "</datatype>\n";
|
xml += "<datatype>" + t + "</datatype>\n";
|
||||||
|
|
||||||
if (this.data.def || this.data.def === null) {
|
if (this.data.def || this.data.def === null) {
|
||||||
@@ -349,8 +413,15 @@ SQL.Row.prototype.toXML = function() {
|
|||||||
|
|
||||||
for (var i = 0; i < this.relations.length; i++) {
|
for (var i = 0; i < this.relations.length; i++) {
|
||||||
var r = this.relations[i];
|
var r = this.relations[i];
|
||||||
if (r.row2 != this) { continue; }
|
if (r.row2 != this) {
|
||||||
xml += '<relation table="'+r.row1.owner.getTitle()+'" row="'+r.row1.getTitle()+'" />\n';
|
continue;
|
||||||
|
}
|
||||||
|
xml +=
|
||||||
|
'<relation table="' +
|
||||||
|
r.row1.owner.getTitle() +
|
||||||
|
'" row="' +
|
||||||
|
r.row1.getTitle() +
|
||||||
|
'" />\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.data.comment) {
|
if (this.data.comment) {
|
||||||
@@ -359,29 +430,35 @@ SQL.Row.prototype.toXML = function() {
|
|||||||
|
|
||||||
xml += "</row>\n";
|
xml += "</row>\n";
|
||||||
return xml;
|
return xml;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.fromXML = function (node) {
|
SQL.Row.prototype.fromXML = function (node) {
|
||||||
var name = node.getAttribute("name");
|
var name = node.getAttribute("name");
|
||||||
|
|
||||||
var obj = { type: 0, size: "" };
|
var obj = { type: 0, size: "" };
|
||||||
obj.nll = (node.getAttribute("null") == "1");
|
obj.nll = node.getAttribute("null") == "1";
|
||||||
obj.ai = (node.getAttribute("autoincrement") == "1");
|
obj.ai = node.getAttribute("autoincrement") == "1";
|
||||||
|
|
||||||
var cs = node.getElementsByTagName("comment");
|
var cs = node.getElementsByTagName("comment");
|
||||||
if (cs.length && cs[0].firstChild) { obj.comment = cs[0].firstChild.nodeValue; }
|
if (cs.length && cs[0].firstChild) {
|
||||||
|
obj.comment = cs[0].firstChild.nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
var d = node.getElementsByTagName("datatype");
|
var d = node.getElementsByTagName("datatype");
|
||||||
if (d.length && d[0].firstChild) {
|
if (d.length && d[0].firstChild) {
|
||||||
var s = d[0].firstChild.nodeValue;
|
var s = d[0].firstChild.nodeValue;
|
||||||
var r = s.match(/^([^\(]+)(\((.*)\))?.*$/);
|
var r = s.match(/^([^\(]+)(\((.*)\))?.*$/);
|
||||||
var type = r[1];
|
var type = r[1];
|
||||||
if (r[3]) { obj.size = r[3]; }
|
if (r[3]) {
|
||||||
|
obj.size = r[3];
|
||||||
|
}
|
||||||
var types = window.DATATYPES.getElementsByTagName("type");
|
var types = window.DATATYPES.getElementsByTagName("type");
|
||||||
for (var i = 0; i < types.length; i++) {
|
for (var i = 0; i < types.length; i++) {
|
||||||
var sql = types[i].getAttribute("sql");
|
var sql = types[i].getAttribute("sql");
|
||||||
var re = types[i].getAttribute("re");
|
var re = types[i].getAttribute("re");
|
||||||
if (sql == type || (re && new RegExp(re).exec(type)) ) { obj.type = i; }
|
if (sql == type || (re && new RegExp(re).exec(type))) {
|
||||||
|
obj.type = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,37 +471,43 @@ SQL.Row.prototype.fromXML = function(node) {
|
|||||||
if (q) {
|
if (q) {
|
||||||
var re = new RegExp("^" + q + "(.*)" + q + "$");
|
var re = new RegExp("^" + q + "(.*)" + q + "$");
|
||||||
var r = def.match(re);
|
var r = def.match(re);
|
||||||
if (r) { obj.def = r[1]; }
|
if (r) {
|
||||||
|
obj.def = r[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update(obj);
|
this.update(obj);
|
||||||
this.setTitle(name);
|
this.setTitle(name);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.isPrimary = function () {
|
SQL.Row.prototype.isPrimary = function () {
|
||||||
for (var i = 0; i < this.keys.length; i++) {
|
for (var i = 0; i < this.keys.length; i++) {
|
||||||
var k = this.keys[i];
|
var k = this.keys[i];
|
||||||
if (k.getType() == "PRIMARY") { return true; }
|
if (k.getType() == "PRIMARY") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.isUnique = function () {
|
SQL.Row.prototype.isUnique = function () {
|
||||||
for (var i = 0; i < this.keys.length; i++) {
|
for (var i = 0; i < this.keys.length; i++) {
|
||||||
var k = this.keys[i];
|
var k = this.keys[i];
|
||||||
var t = k.getType();
|
var t = k.getType();
|
||||||
if (t == "PRIMARY" || t == "UNIQUE") { return true; }
|
if (t == "PRIMARY" || t == "UNIQUE") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.isKey = function () {
|
SQL.Row.prototype.isKey = function () {
|
||||||
return this.keys.length > 0;
|
return this.keys.length > 0;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Row.prototype.enter = function (e) {
|
SQL.Row.prototype.enter = function (e) {
|
||||||
if (e.keyCode == 13) {
|
if (e.keyCode == 13) {
|
||||||
this.collapse();
|
this.collapse();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
+97
-46
@@ -6,7 +6,15 @@ SQL.RowManager = function(owner) {
|
|||||||
this.creating = false;
|
this.creating = false;
|
||||||
this.connecting = false;
|
this.connecting = false;
|
||||||
|
|
||||||
var ids = ["editrow","removerow","uprow","downrow","foreigncreate","foreignconnect","foreigndisconnect"];
|
var ids = [
|
||||||
|
"editrow",
|
||||||
|
"removerow",
|
||||||
|
"uprow",
|
||||||
|
"downrow",
|
||||||
|
"foreigncreate",
|
||||||
|
"foreignconnect",
|
||||||
|
"foreigndisconnect",
|
||||||
|
];
|
||||||
for (var i = 0; i < ids.length; i++) {
|
for (var i = 0; i < ids.length; i++) {
|
||||||
var id = ids[i];
|
var id = ids[i];
|
||||||
var elm = OZ.$(id);
|
var elm = OZ.$(id);
|
||||||
@@ -20,26 +28,48 @@ SQL.RowManager = function(owner) {
|
|||||||
OZ.Event.add(this.dom.uprow, "click", this.up.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.downrow, "click", this.down.bind(this));
|
||||||
OZ.Event.add(this.dom.removerow, "click", this.remove.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(
|
||||||
OZ.Event.add(this.dom.foreignconnect, "click", this.foreignconnect.bind(this));
|
this.dom.foreigncreate,
|
||||||
OZ.Event.add(this.dom.foreigndisconnect, "click", this.foreigndisconnect.bind(this));
|
"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));
|
OZ.Event.add(document, "keydown", this.press.bind(this));
|
||||||
|
|
||||||
SQL.subscribe("tableclick", this.tableClick.bind(this));
|
SQL.subscribe("tableclick", this.tableClick.bind(this));
|
||||||
SQL.subscribe("rowclick", this.rowClick.bind(this));
|
SQL.subscribe("rowclick", this.rowClick.bind(this));
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.select = function(row) { /* activate a row */
|
SQL.RowManager.prototype.select = function (row) {
|
||||||
if (this.selected === row) { return; }
|
/* activate a row */
|
||||||
if (this.selected) { this.selected.deselect(); }
|
if (this.selected === row) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.selected) {
|
||||||
|
this.selected.deselect();
|
||||||
|
}
|
||||||
|
|
||||||
this.selected = row;
|
this.selected = row;
|
||||||
if (this.selected) { this.selected.select(); }
|
if (this.selected) {
|
||||||
this.redraw();
|
this.selected.select();
|
||||||
}
|
}
|
||||||
|
this.redraw();
|
||||||
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.tableClick = function(e) { /* create relation after clicking target table */
|
SQL.RowManager.prototype.tableClick = function (e) {
|
||||||
if (!this.creating) { return; }
|
/* create relation after clicking target table */
|
||||||
|
if (!this.creating) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var r1 = this.selected;
|
var r1 = this.selected;
|
||||||
var t2 = e.target;
|
var t2 = e.target;
|
||||||
@@ -50,23 +80,29 @@ SQL.RowManager.prototype.tableClick = function(e) { /* create relation after cli
|
|||||||
p = p.replace(/%R/g, r1.getTitle());
|
p = p.replace(/%R/g, r1.getTitle());
|
||||||
|
|
||||||
var r2 = t2.addRow(p, r1.data);
|
var r2 = t2.addRow(p, r1.data);
|
||||||
r2.update({"type":SQL.Designer.getFKTypeFor(r1.data.type)});
|
r2.update({ type: SQL.Designer.getFKTypeFor(r1.data.type) });
|
||||||
r2.update({"ai":false});
|
r2.update({ ai: false });
|
||||||
this.owner.addRelation(r1, r2);
|
this.owner.addRelation(r1, r2);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.rowClick = function(e) { /* draw relation after clicking target row */
|
SQL.RowManager.prototype.rowClick = function (e) {
|
||||||
if (!this.connecting) { return; }
|
/* draw relation after clicking target row */
|
||||||
|
if (!this.connecting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var r1 = this.selected;
|
var r1 = this.selected;
|
||||||
var r2 = e.target;
|
var r2 = e.target;
|
||||||
|
|
||||||
if (r1 == r2) { return; }
|
if (r1 == r2) {
|
||||||
|
return;
|
||||||
this.owner.addRelation(r1, r2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SQL.RowManager.prototype.foreigncreate = function(e) { /* start creating fk */
|
this.owner.addRelation(r1, r2);
|
||||||
|
};
|
||||||
|
|
||||||
|
SQL.RowManager.prototype.foreigncreate = function (e) {
|
||||||
|
/* start creating fk */
|
||||||
this.endConnect();
|
this.endConnect();
|
||||||
if (this.creating) {
|
if (this.creating) {
|
||||||
this.endCreate();
|
this.endCreate();
|
||||||
@@ -74,9 +110,10 @@ SQL.RowManager.prototype.foreigncreate = function(e) { /* start creating fk */
|
|||||||
this.creating = true;
|
this.creating = true;
|
||||||
this.dom.foreigncreate.value = "[" + _("foreignpending") + "]";
|
this.dom.foreigncreate.value = "[" + _("foreignpending") + "]";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.foreignconnect = function(e) { /* start drawing fk */
|
SQL.RowManager.prototype.foreignconnect = function (e) {
|
||||||
|
/* start drawing fk */
|
||||||
this.endCreate();
|
this.endCreate();
|
||||||
if (this.connecting) {
|
if (this.connecting) {
|
||||||
this.endConnect();
|
this.endConnect();
|
||||||
@@ -84,47 +121,56 @@ SQL.RowManager.prototype.foreignconnect = function(e) { /* start drawing fk */
|
|||||||
this.connecting = true;
|
this.connecting = true;
|
||||||
this.dom.foreignconnect.value = "[" + _("foreignconnectpending") + "]";
|
this.dom.foreignconnect.value = "[" + _("foreignconnectpending") + "]";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.foreigndisconnect = function(e) { /* remove connector */
|
SQL.RowManager.prototype.foreigndisconnect = function (e) {
|
||||||
|
/* remove connector */
|
||||||
var rels = this.selected.relations;
|
var rels = this.selected.relations;
|
||||||
for (var i = rels.length - 1; i >= 0; i--) {
|
for (var i = rels.length - 1; i >= 0; i--) {
|
||||||
var r = rels[i];
|
var r = rels[i];
|
||||||
if (r.row2 == this.selected) { this.owner.removeRelation(r); }
|
if (r.row2 == this.selected) {
|
||||||
|
this.owner.removeRelation(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.endCreate = function () {
|
SQL.RowManager.prototype.endCreate = function () {
|
||||||
this.creating = false;
|
this.creating = false;
|
||||||
this.dom.foreigncreate.value = _("foreigncreate");
|
this.dom.foreigncreate.value = _("foreigncreate");
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.endConnect = function () {
|
SQL.RowManager.prototype.endConnect = function () {
|
||||||
this.connecting = false;
|
this.connecting = false;
|
||||||
this.dom.foreignconnect.value = _("foreignconnect");
|
this.dom.foreignconnect.value = _("foreignconnect");
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.up = function (e) {
|
SQL.RowManager.prototype.up = function (e) {
|
||||||
this.selected.up();
|
this.selected.up();
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.down = function (e) {
|
SQL.RowManager.prototype.down = function (e) {
|
||||||
this.selected.down();
|
this.selected.down();
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.remove = function (e) {
|
SQL.RowManager.prototype.remove = function (e) {
|
||||||
var result = confirm(_("confirmrow")+" '"+this.selected.getTitle()+"' ?");
|
var result = confirm(
|
||||||
if (!result) { return; }
|
_("confirmrow") + " '" + this.selected.getTitle() + "' ?"
|
||||||
|
);
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var t = this.selected.owner;
|
var t = this.selected.owner;
|
||||||
this.selected.owner.removeRow(this.selected);
|
this.selected.owner.removeRow(this.selected);
|
||||||
|
|
||||||
var next = false;
|
var next = false;
|
||||||
if (t.rows) { next = t.rows[t.rows.length-1]; }
|
if (t.rows) {
|
||||||
this.select(next);
|
next = t.rows[t.rows.length - 1];
|
||||||
}
|
}
|
||||||
|
this.select(next);
|
||||||
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.redraw = function () {
|
SQL.RowManager.prototype.redraw = function () {
|
||||||
this.endCreate();
|
this.endCreate();
|
||||||
@@ -132,20 +178,21 @@ SQL.RowManager.prototype.redraw = function() {
|
|||||||
if (this.selected) {
|
if (this.selected) {
|
||||||
var table = this.selected.owner;
|
var table = this.selected.owner;
|
||||||
var rows = table.rows;
|
var rows = table.rows;
|
||||||
this.dom.uprow.disabled = (rows[0] == this.selected);
|
this.dom.uprow.disabled = rows[0] == this.selected;
|
||||||
this.dom.downrow.disabled = (rows[rows.length-1] == this.selected);
|
this.dom.downrow.disabled = rows[rows.length - 1] == this.selected;
|
||||||
this.dom.removerow.disabled = false;
|
this.dom.removerow.disabled = false;
|
||||||
this.dom.editrow.disabled = false;
|
this.dom.editrow.disabled = false;
|
||||||
this.dom.foreigncreate.disabled = !(this.selected.isUnique());
|
this.dom.foreigncreate.disabled = !this.selected.isUnique();
|
||||||
this.dom.foreignconnect.disabled = !(this.selected.isUnique());
|
this.dom.foreignconnect.disabled = !this.selected.isUnique();
|
||||||
|
|
||||||
this.dom.foreigndisconnect.disabled = true;
|
this.dom.foreigndisconnect.disabled = true;
|
||||||
var rels = this.selected.relations;
|
var rels = this.selected.relations;
|
||||||
for (var i = 0; i < rels.length; i++) {
|
for (var i = 0; i < rels.length; i++) {
|
||||||
var r = rels[i];
|
var r = rels[i];
|
||||||
if (r.row2 == this.selected) { this.dom.foreigndisconnect.disabled = false; }
|
if (r.row2 == this.selected) {
|
||||||
|
this.dom.foreigndisconnect.disabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.dom.uprow.disabled = true;
|
this.dom.uprow.disabled = true;
|
||||||
this.dom.downrow.disabled = true;
|
this.dom.downrow.disabled = true;
|
||||||
@@ -155,13 +202,17 @@ SQL.RowManager.prototype.redraw = function() {
|
|||||||
this.dom.foreignconnect.disabled = true;
|
this.dom.foreignconnect.disabled = true;
|
||||||
this.dom.foreigndisconnect.disabled = true;
|
this.dom.foreigndisconnect.disabled = true;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.press = function (e) {
|
SQL.RowManager.prototype.press = function (e) {
|
||||||
if (!this.selected) { return; }
|
if (!this.selected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var target = OZ.Event.target(e).nodeName.toLowerCase();
|
var target = OZ.Event.target(e).nodeName.toLowerCase();
|
||||||
if (target == "textarea" || target == "input") { return; } /* not when in form field */
|
if (target == "textarea" || target == "input") {
|
||||||
|
return;
|
||||||
|
} /* not when in form field */
|
||||||
|
|
||||||
switch (e.keyCode) {
|
switch (e.keyCode) {
|
||||||
case 38:
|
case 38:
|
||||||
@@ -181,8 +232,8 @@ SQL.RowManager.prototype.press = function(e) {
|
|||||||
this.selected.collapse();
|
this.selected.collapse();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.RowManager.prototype.edit = function (e) {
|
SQL.RowManager.prototype.edit = function (e) {
|
||||||
this.selected.expand();
|
this.selected.expand();
|
||||||
}
|
};
|
||||||
|
|||||||
+20
-8
@@ -5,7 +5,7 @@ SQL.Rubberband = function(owner) {
|
|||||||
SQL.Visual.apply(this);
|
SQL.Visual.apply(this);
|
||||||
this.dom.container = OZ.$("rubberband");
|
this.dom.container = OZ.$("rubberband");
|
||||||
OZ.Event.add("area", "mousedown", this.down.bind(this));
|
OZ.Event.add("area", "mousedown", this.down.bind(this));
|
||||||
}
|
};
|
||||||
SQL.Rubberband.prototype = Object.create(SQL.Visual.prototype);
|
SQL.Rubberband.prototype = Object.create(SQL.Visual.prototype);
|
||||||
|
|
||||||
SQL.Rubberband.prototype.down = function (e) {
|
SQL.Rubberband.prototype.down = function (e) {
|
||||||
@@ -16,9 +16,13 @@ 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.move.bind(this));
|
this.documentMove = OZ.Event.add(
|
||||||
|
document,
|
||||||
|
"mousemove",
|
||||||
|
this.move.bind(this)
|
||||||
|
);
|
||||||
this.documentUp = OZ.Event.add(document, "mouseup", this.up.bind(this));
|
this.documentUp = OZ.Event.add(document, "mouseup", this.up.bind(this));
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Rubberband.prototype.move = function (e) {
|
SQL.Rubberband.prototype.move = function (e) {
|
||||||
var scroll = OZ.DOM.scroll();
|
var scroll = OZ.DOM.scroll();
|
||||||
@@ -26,11 +30,19 @@ SQL.Rubberband.prototype.move = function(e) {
|
|||||||
var y = e.clientY + scroll[1];
|
var y = e.clientY + scroll[1];
|
||||||
this.width = Math.abs(x - this.x0);
|
this.width = Math.abs(x - this.x0);
|
||||||
this.height = Math.abs(y - this.y0);
|
this.height = Math.abs(y - this.y0);
|
||||||
if (x<this.x0) { this.x = x; } else { this.x = this.x0; }
|
if (x < this.x0) {
|
||||||
if (y<this.y0) { this.y = y; } else { this.y = this.y0; }
|
this.x = x;
|
||||||
|
} else {
|
||||||
|
this.x = this.x0;
|
||||||
|
}
|
||||||
|
if (y < this.y0) {
|
||||||
|
this.y = y;
|
||||||
|
} else {
|
||||||
|
this.y = this.y0;
|
||||||
|
}
|
||||||
this.redraw();
|
this.redraw();
|
||||||
this.dom.container.style.visibility = "visible";
|
this.dom.container.style.visibility = "visible";
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Rubberband.prototype.up = function (e) {
|
SQL.Rubberband.prototype.up = function (e) {
|
||||||
OZ.Event.prevent(e);
|
OZ.Event.prevent(e);
|
||||||
@@ -38,11 +50,11 @@ SQL.Rubberband.prototype.up = function(e) {
|
|||||||
OZ.Event.remove(this.documentMove);
|
OZ.Event.remove(this.documentMove);
|
||||||
OZ.Event.remove(this.documentUp);
|
OZ.Event.remove(this.documentUp);
|
||||||
this.owner.tableManager.selectRect(this.x, this.y, this.width, this.height);
|
this.owner.tableManager.selectRect(this.x, this.y, this.width, this.height);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Rubberband.prototype.redraw = function () {
|
SQL.Rubberband.prototype.redraw = function () {
|
||||||
this.dom.container.style.left = this.x + "px";
|
this.dom.container.style.left = this.x + "px";
|
||||||
this.dom.container.style.top = this.y + "px";
|
this.dom.container.style.top = this.y + "px";
|
||||||
this.dom.container.style.width = this.width + "px";
|
this.dom.container.style.width = this.width + "px";
|
||||||
this.dom.container.style.height = this.height + "px";
|
this.dom.container.style.height = this.height + "px";
|
||||||
}
|
};
|
||||||
|
|||||||
+100
-50
@@ -16,7 +16,7 @@ SQL.Table = function(owner, name, x, y, z) {
|
|||||||
this.y = y || 0;
|
this.y = y || 0;
|
||||||
this.setZ(z);
|
this.setZ(z);
|
||||||
this.snap();
|
this.snap();
|
||||||
}
|
};
|
||||||
SQL.Table.prototype = Object.create(SQL.Visual.prototype);
|
SQL.Table.prototype = Object.create(SQL.Visual.prototype);
|
||||||
|
|
||||||
SQL.Table.prototype._build = function () {
|
SQL.Table.prototype._build = function () {
|
||||||
@@ -36,12 +36,22 @@ 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.click.bind(this)));
|
this._ec.push(
|
||||||
this._ec.push(OZ.Event.add(this.dom.container, "dblclick", this.dblclick.bind(this)));
|
OZ.Event.add(this.dom.container, "click", this.click.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(
|
||||||
this._ec.push(OZ.Event.add(this.dom.container, "touchmove", OZ.Event.prevent));
|
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)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.setTitle = function (t) {
|
SQL.Table.prototype.setTitle = function (t) {
|
||||||
var old = this.getTitle();
|
var old = this.getTitle();
|
||||||
@@ -49,13 +59,17 @@ SQL.Table.prototype.setTitle = function(t) {
|
|||||||
var row = this.rows[i];
|
var row = this.rows[i];
|
||||||
for (var j = 0; j < row.relations.length; j++) {
|
for (var j = 0; j < row.relations.length; j++) {
|
||||||
var r = row.relations[j];
|
var r = row.relations[j];
|
||||||
if (r.row1 != row) { continue; }
|
if (r.row1 != row) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var tt = row.getTitle().replace(new RegExp(old, "g"), t);
|
var tt = row.getTitle().replace(new RegExp(old, "g"), t);
|
||||||
if (tt != row.getTitle()) { row.setTitle(tt); }
|
if (tt != row.getTitle()) {
|
||||||
|
row.setTitle(tt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SQL.Visual.prototype.setTitle.apply(this, [t]);
|
SQL.Visual.prototype.setTitle.apply(this, [t]);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.getRelations = function () {
|
SQL.Table.prototype.getRelations = function () {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
@@ -63,53 +77,67 @@ SQL.Table.prototype.getRelations = function() {
|
|||||||
var row = this.rows[i];
|
var row = this.rows[i];
|
||||||
for (var j = 0; j < row.relations.length; j++) {
|
for (var j = 0; j < row.relations.length; j++) {
|
||||||
var r = row.relations[j];
|
var r = row.relations[j];
|
||||||
if (arr.indexOf(r) == -1) { arr.push(r); }
|
if (arr.indexOf(r) == -1) {
|
||||||
|
arr.push(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.showRelations = function () {
|
SQL.Table.prototype.showRelations = function () {
|
||||||
var rs = this.getRelations();
|
var rs = this.getRelations();
|
||||||
for (var i=0;i<rs.length;i++) { rs[i].show(); }
|
for (var i = 0; i < rs.length; i++) {
|
||||||
|
rs[i].show();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.hideRelations = function () {
|
SQL.Table.prototype.hideRelations = function () {
|
||||||
var rs = this.getRelations();
|
var rs = this.getRelations();
|
||||||
for (var i=0;i<rs.length;i++) { rs[i].hide(); }
|
for (var i = 0; i < rs.length; i++) {
|
||||||
|
rs[i].hide();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.click = function (e) {
|
SQL.Table.prototype.click = function (e) {
|
||||||
OZ.Event.stop(e);
|
OZ.Event.stop(e);
|
||||||
var t = OZ.Event.target(e);
|
var t = OZ.Event.target(e);
|
||||||
this.owner.tableManager.select(this);
|
this.owner.tableManager.select(this);
|
||||||
|
|
||||||
if (t != this.dom.title) { return; } /* click on row */
|
if (t != this.dom.title) {
|
||||||
|
return;
|
||||||
|
} /* click on row */
|
||||||
|
|
||||||
SQL.publish("tableclick", this);
|
SQL.publish("tableclick", this);
|
||||||
this.owner.rowManager.select(false);
|
this.owner.rowManager.select(false);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.dblclick = function (e) {
|
SQL.Table.prototype.dblclick = function (e) {
|
||||||
var t = OZ.Event.target(e);
|
var t = OZ.Event.target(e);
|
||||||
if (t == this.dom.title) { this.owner.tableManager.edit(); }
|
if (t == this.dom.title) {
|
||||||
|
this.owner.tableManager.edit();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.select = function () {
|
SQL.Table.prototype.select = function () {
|
||||||
if (this.selected) { return; }
|
if (this.selected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.selected = true;
|
this.selected = true;
|
||||||
OZ.DOM.addClass(this.dom.container, "selected");
|
OZ.DOM.addClass(this.dom.container, "selected");
|
||||||
OZ.DOM.addClass(this.dom.mini, "mini_selected");
|
OZ.DOM.addClass(this.dom.mini, "mini_selected");
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.deselect = function () {
|
SQL.Table.prototype.deselect = function () {
|
||||||
if (!this.selected) { return; }
|
if (!this.selected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.selected = false;
|
this.selected = false;
|
||||||
OZ.DOM.removeClass(this.dom.container, "selected");
|
OZ.DOM.removeClass(this.dom.container, "selected");
|
||||||
OZ.DOM.removeClass(this.dom.mini, "mini_selected");
|
OZ.DOM.removeClass(this.dom.mini, "mini_selected");
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.addRow = function (title, data) {
|
SQL.Table.prototype.addRow = function (title, data) {
|
||||||
var r = new SQL.Row(this, title, data);
|
var r = new SQL.Row(this, title, data);
|
||||||
@@ -117,33 +145,40 @@ SQL.Table.prototype.addRow = function(title, data) {
|
|||||||
this.dom.content.appendChild(r.dom.container);
|
this.dom.content.appendChild(r.dom.container);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
return r;
|
return r;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.removeRow = function (r) {
|
SQL.Table.prototype.removeRow = function (r) {
|
||||||
var idx = this.rows.indexOf(r);
|
var idx = this.rows.indexOf(r);
|
||||||
if (idx == -1) { return; }
|
if (idx == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
r.destroy();
|
r.destroy();
|
||||||
this.rows.splice(idx, 1);
|
this.rows.splice(idx, 1);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.addKey = function (name) {
|
SQL.Table.prototype.addKey = function (name) {
|
||||||
var k = new SQL.Key(this, name);
|
var k = new SQL.Key(this, name);
|
||||||
this.keys.push(k);
|
this.keys.push(k);
|
||||||
return k;
|
return k;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.removeKey = function (k) {
|
SQL.Table.prototype.removeKey = function (k) {
|
||||||
var idx = this.keys.indexOf(k);
|
var idx = this.keys.indexOf(k);
|
||||||
if (idx == -1) { return; }
|
if (idx == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
k.destroy();
|
k.destroy();
|
||||||
this.keys.splice(idx, 1);
|
this.keys.splice(idx, 1);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.redraw = function () {
|
SQL.Table.prototype.redraw = function () {
|
||||||
var x = this.x;
|
var x = this.x;
|
||||||
var y = this.y;
|
var y = this.y;
|
||||||
if (this.selected) { x--; y--; }
|
if (this.selected) {
|
||||||
|
x--;
|
||||||
|
y--;
|
||||||
|
}
|
||||||
this.dom.container.style.left = x + "px";
|
this.dom.container.style.left = x + "px";
|
||||||
this.dom.container.style.top = y + "px";
|
this.dom.container.style.top = y + "px";
|
||||||
|
|
||||||
@@ -164,8 +199,10 @@ SQL.Table.prototype.redraw = function() {
|
|||||||
this.height = this.dom.container.offsetHeight;
|
this.height = this.dom.container.offsetHeight;
|
||||||
|
|
||||||
var rs = this.getRelations();
|
var rs = this.getRelations();
|
||||||
for (var i=0;i<rs.length;i++) { rs[i].redraw(); }
|
for (var i = 0; i < rs.length; i++) {
|
||||||
|
rs[i].redraw();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.moveBy = function (dx, dy) {
|
SQL.Table.prototype.moveBy = function (dx, dy) {
|
||||||
this.x += dx;
|
this.x += dx;
|
||||||
@@ -173,7 +210,7 @@ SQL.Table.prototype.moveBy = function(dx, dy) {
|
|||||||
|
|
||||||
this.snap();
|
this.snap();
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.moveTo = function (x, y) {
|
SQL.Table.prototype.moveTo = function (x, y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@@ -181,7 +218,7 @@ SQL.Table.prototype.moveTo = function(x, y) {
|
|||||||
|
|
||||||
this.snap();
|
this.snap();
|
||||||
this.redraw();
|
this.redraw();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.snap = function () {
|
SQL.Table.prototype.snap = function () {
|
||||||
var snap = parseInt(SQL.Designer.getOption("snap"));
|
var snap = parseInt(SQL.Designer.getOption("snap"));
|
||||||
@@ -189,12 +226,15 @@ SQL.Table.prototype.snap = function() {
|
|||||||
this.x = Math.round(this.x / snap) * snap;
|
this.x = Math.round(this.x / snap) * snap;
|
||||||
this.y = Math.round(this.y / snap) * snap;
|
this.y = Math.round(this.y / snap) * snap;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.down = function(e) { /* mousedown - start drag */
|
SQL.Table.prototype.down = function (e) {
|
||||||
|
/* mousedown - start drag */
|
||||||
OZ.Event.stop(e);
|
OZ.Event.stop(e);
|
||||||
var t = OZ.Event.target(e);
|
var t = OZ.Event.target(e);
|
||||||
if (t != this.dom.title) { return; } /* on a row */
|
if (t != this.dom.title) {
|
||||||
|
return;
|
||||||
|
} /* on a row */
|
||||||
|
|
||||||
/* touch? */
|
/* touch? */
|
||||||
if (e.type == "touchstart") {
|
if (e.type == "touchstart") {
|
||||||
@@ -231,7 +271,7 @@ SQL.Table.prototype.down = function(e) { /* mousedown - start drag */
|
|||||||
|
|
||||||
this.documentMove = OZ.Event.add(document, moveEvent, this.move.bind(this));
|
this.documentMove = OZ.Event.add(document, moveEvent, this.move.bind(this));
|
||||||
this.documentUp = OZ.Event.add(document, upEvent, this.up.bind(this));
|
this.documentUp = OZ.Event.add(document, upEvent, this.up.bind(this));
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.toXML = function () {
|
SQL.Table.prototype.toXML = function () {
|
||||||
var t = this.getTitle().replace(/"/g, """);
|
var t = this.getTitle().replace(/"/g, """);
|
||||||
@@ -249,7 +289,7 @@ SQL.Table.prototype.toXML = function() {
|
|||||||
}
|
}
|
||||||
xml += "</table>\n";
|
xml += "</table>\n";
|
||||||
return xml;
|
return xml;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.fromXML = function (node) {
|
SQL.Table.prototype.fromXML = function (node) {
|
||||||
var name = node.getAttribute("name");
|
var name = node.getAttribute("name");
|
||||||
@@ -271,42 +311,52 @@ SQL.Table.prototype.fromXML = function(node) {
|
|||||||
}
|
}
|
||||||
for (var i = 0; i < node.childNodes.length; i++) {
|
for (var i = 0; i < node.childNodes.length; i++) {
|
||||||
var ch = node.childNodes[i];
|
var ch = node.childNodes[i];
|
||||||
if (ch.tagName && ch.tagName.toLowerCase() == "comment" && ch.firstChild) {
|
if (
|
||||||
|
ch.tagName &&
|
||||||
|
ch.tagName.toLowerCase() == "comment" &&
|
||||||
|
ch.firstChild
|
||||||
|
) {
|
||||||
this.setComment(ch.firstChild.nodeValue);
|
this.setComment(ch.firstChild.nodeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.getZ = function () {
|
SQL.Table.prototype.getZ = function () {
|
||||||
return this.zIndex;
|
return this.zIndex;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.setZ = function (z) {
|
SQL.Table.prototype.setZ = function (z) {
|
||||||
this.zIndex = z;
|
this.zIndex = z;
|
||||||
this.dom.container.style.zIndex = z;
|
this.dom.container.style.zIndex = z;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.findNamedRow = function(n) { /* return row with a given name */
|
SQL.Table.prototype.findNamedRow = function (n) {
|
||||||
|
/* return row with a given name */
|
||||||
for (var i = 0; i < this.rows.length; i++) {
|
for (var i = 0; i < this.rows.length; i++) {
|
||||||
if (this.rows[i].getTitle() == n) { return this.rows[i]; }
|
if (this.rows[i].getTitle() == n) {
|
||||||
|
return this.rows[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.setComment = function (c) {
|
SQL.Table.prototype.setComment = function (c) {
|
||||||
this.data.comment = c;
|
this.data.comment = c;
|
||||||
this.dom.title.title = this.data.comment;
|
this.dom.title.title = this.data.comment;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.getComment = function () {
|
SQL.Table.prototype.getComment = function () {
|
||||||
return this.data.comment;
|
return this.data.comment;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.move = function(e) { /* mousemove */
|
SQL.Table.prototype.move = function (e) {
|
||||||
|
/* mousemove */
|
||||||
var t = SQL.Table;
|
var t = SQL.Table;
|
||||||
SQL.Designer.removeSelection();
|
SQL.Designer.removeSelection();
|
||||||
if (e.type == "touchmove") {
|
if (e.type == "touchmove") {
|
||||||
if (e.touches.length > 1) { return; }
|
if (e.touches.length > 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var event = e.touches[0];
|
var event = e.touches[0];
|
||||||
} else {
|
} else {
|
||||||
var event = e;
|
var event = e;
|
||||||
@@ -319,7 +369,7 @@ SQL.Table.prototype.move = function(e) { /* mousemove */
|
|||||||
y = Math.max(y, 0);
|
y = Math.max(y, 0);
|
||||||
t.active[i].moveTo(x, y);
|
t.active[i].moveTo(x, y);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.up = function (e) {
|
SQL.Table.prototype.up = function (e) {
|
||||||
var t = SQL.Table;
|
var t = SQL.Table;
|
||||||
@@ -334,7 +384,7 @@ SQL.Table.prototype.up = function(e) {
|
|||||||
OZ.Event.remove(this.documentMove);
|
OZ.Event.remove(this.documentMove);
|
||||||
OZ.Event.remove(this.documentUp);
|
OZ.Event.remove(this.documentUp);
|
||||||
this.owner.sync();
|
this.owner.sync();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Table.prototype.destroy = function () {
|
SQL.Table.prototype.destroy = function () {
|
||||||
SQL.Visual.prototype.destroy.apply(this);
|
SQL.Visual.prototype.destroy.apply(this);
|
||||||
@@ -343,4 +393,4 @@ SQL.Table.prototype.destroy = function() {
|
|||||||
this.removeRow(this.rows[0]);
|
this.removeRow(this.rows[0]);
|
||||||
}
|
}
|
||||||
this._ec.forEach(OZ.Event.remove, OZ.Event);
|
this._ec.forEach(OZ.Event.remove, OZ.Event);
|
||||||
}
|
};
|
||||||
|
|||||||
+88
-40
@@ -5,12 +5,20 @@ SQL.TableManager = function(owner) {
|
|||||||
this.dom = {
|
this.dom = {
|
||||||
container: OZ.$("table"),
|
container: OZ.$("table"),
|
||||||
name: OZ.$("tablename"),
|
name: OZ.$("tablename"),
|
||||||
comment:OZ.$("tablecomment")
|
comment: OZ.$("tablecomment"),
|
||||||
};
|
};
|
||||||
this.selection = [];
|
this.selection = [];
|
||||||
this.adding = false;
|
this.adding = false;
|
||||||
|
|
||||||
var ids = ["addtable","removetable","aligntables","cleartables","addrow","edittable","tablekeys"];
|
var ids = [
|
||||||
|
"addtable",
|
||||||
|
"removetable",
|
||||||
|
"aligntables",
|
||||||
|
"cleartables",
|
||||||
|
"addrow",
|
||||||
|
"edittable",
|
||||||
|
"tablekeys",
|
||||||
|
];
|
||||||
for (var i = 0; i < ids.length; i++) {
|
for (var i = 0; i < ids.length; i++) {
|
||||||
var id = ids[i];
|
var id = ids[i];
|
||||||
var elm = OZ.$(id);
|
var elm = OZ.$(id);
|
||||||
@@ -25,7 +33,6 @@ SQL.TableManager = function(owner) {
|
|||||||
elm.innerHTML = _(id);
|
elm.innerHTML = _(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.select(false);
|
this.select(false);
|
||||||
|
|
||||||
this.save = this.save.bind(this);
|
this.save = this.save.bind(this);
|
||||||
@@ -35,21 +42,26 @@ SQL.TableManager = function(owner) {
|
|||||||
OZ.Event.add(this.dom.removetable, "click", this.remove.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.cleartables, "click", this.clear.bind(this));
|
||||||
OZ.Event.add(this.dom.addrow, "click", this.addRow.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.aligntables,
|
||||||
|
"click",
|
||||||
|
this.owner.alignTables.bind(this.owner)
|
||||||
|
);
|
||||||
OZ.Event.add(this.dom.edittable, "click", this.edit.bind(this));
|
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(this.dom.tablekeys, "click", this.keys.bind(this));
|
||||||
OZ.Event.add(document, "keydown", this.press.bind(this));
|
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);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.addRow = function (e) {
|
SQL.TableManager.prototype.addRow = function (e) {
|
||||||
var newrow = this.selection[0].addRow(_("newrow"));
|
var newrow = this.selection[0].addRow(_("newrow"));
|
||||||
this.owner.rowManager.select(newrow);
|
this.owner.rowManager.select(newrow);
|
||||||
newrow.expand();
|
newrow.expand();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.select = function(table, multi) { /* activate table */
|
SQL.TableManager.prototype.select = function (table, multi) {
|
||||||
|
/* activate table */
|
||||||
if (table) {
|
if (table) {
|
||||||
if (multi) {
|
if (multi) {
|
||||||
var i = this.selection.indexOf(table);
|
var i = this.selection.indexOf(table);
|
||||||
@@ -59,14 +71,16 @@ SQL.TableManager.prototype.select = function(table, multi) { /* activate table *
|
|||||||
this.selection.splice(i, 1);
|
this.selection.splice(i, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.selection[0] === table) { return; }
|
if (this.selection[0] === table) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.selection = [table];
|
this.selection = [table];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.selection = [];
|
this.selection = [];
|
||||||
}
|
}
|
||||||
this.processSelection();
|
this.processSelection();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.processSelection = function () {
|
SQL.TableManager.prototype.processSelection = function () {
|
||||||
var tables = this.owner.tables;
|
var tables = this.owner.tables;
|
||||||
@@ -85,7 +99,9 @@ SQL.TableManager.prototype.processSelection = function() {
|
|||||||
}
|
}
|
||||||
if (this.selection.length) {
|
if (this.selection.length) {
|
||||||
this.dom.removetable.disabled = false;
|
this.dom.removetable.disabled = false;
|
||||||
if (this.selection.length > 1) { this.dom.removetable.value = _("removetables"); }
|
if (this.selection.length > 1) {
|
||||||
|
this.dom.removetable.value = _("removetables");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.dom.removetable.disabled = true;
|
this.dom.removetable.disabled = true;
|
||||||
this.dom.removetable.value = _("removetable");
|
this.dom.removetable.value = _("removetable");
|
||||||
@@ -95,9 +111,10 @@ SQL.TableManager.prototype.processSelection = function() {
|
|||||||
t.owner.raise(t);
|
t.owner.raise(t);
|
||||||
t.select();
|
t.select();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.selectRect = function(x,y,width,height) { /* select all tables intersecting a rectangle */
|
SQL.TableManager.prototype.selectRect = function (x, y, width, height) {
|
||||||
|
/* select all tables intersecting a rectangle */
|
||||||
this.selection = [];
|
this.selection = [];
|
||||||
var tables = this.owner.tables;
|
var tables = this.owner.tables;
|
||||||
var x1 = x + width;
|
var x1 = x + width;
|
||||||
@@ -108,14 +125,22 @@ SQL.TableManager.prototype.selectRect = function(x,y,width,height) { /* select a
|
|||||||
var tx1 = t.x + t.width;
|
var tx1 = t.x + t.width;
|
||||||
var ty = t.y;
|
var ty = t.y;
|
||||||
var ty1 = t.y + t.height;
|
var ty1 = t.y + t.height;
|
||||||
if (((tx>=x && tx<x1) || (tx1>=x && tx1<x1) || (tx<x && tx1>x1)) &&
|
if (
|
||||||
((ty>=y && ty<y1) || (ty1>=y && ty1<y1) || (ty<y && ty1>y1)))
|
((tx >= x && tx < x1) ||
|
||||||
{ this.selection.push(t); }
|
(tx1 >= x && tx1 < x1) ||
|
||||||
|
(tx < x && tx1 > x1)) &&
|
||||||
|
((ty >= y && ty < y1) ||
|
||||||
|
(ty1 >= y && ty1 < y1) ||
|
||||||
|
(ty < y && ty1 > y1))
|
||||||
|
) {
|
||||||
|
this.selection.push(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.processSelection();
|
this.processSelection();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.click = function(e) { /* finish adding new table */
|
SQL.TableManager.prototype.click = function (e) {
|
||||||
|
/* finish adding new table */
|
||||||
var newtable = false;
|
var newtable = false;
|
||||||
if (this.adding) {
|
if (this.adding) {
|
||||||
this.adding = false;
|
this.adding = false;
|
||||||
@@ -131,10 +156,13 @@ SQL.TableManager.prototype.click = function(e) { /* finish adding new table */
|
|||||||
}
|
}
|
||||||
this.select(newtable);
|
this.select(newtable);
|
||||||
this.owner.rowManager.select(false);
|
this.owner.rowManager.select(false);
|
||||||
if (this.selection.length == 1) { this.edit(e); }
|
if (this.selection.length == 1) {
|
||||||
|
this.edit(e);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.preAdd = function(e) { /* click add new table */
|
SQL.TableManager.prototype.preAdd = function (e) {
|
||||||
|
/* click add new table */
|
||||||
if (this.adding) {
|
if (this.adding) {
|
||||||
this.adding = false;
|
this.adding = false;
|
||||||
OZ.DOM.removeClass("area", "adding");
|
OZ.DOM.removeClass("area", "adding");
|
||||||
@@ -145,60 +173,80 @@ SQL.TableManager.prototype.preAdd = function(e) { /* click add new table */
|
|||||||
this.oldvalue = this.dom.addtable.value;
|
this.oldvalue = this.dom.addtable.value;
|
||||||
this.dom.addtable.value = "[" + _("addpending") + "]";
|
this.dom.addtable.value = "[" + _("addpending") + "]";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.clear = function(e) { /* remove all tables */
|
SQL.TableManager.prototype.clear = function (e) {
|
||||||
if (!this.owner.tables.length) { return; }
|
/* remove all tables */
|
||||||
var result = confirm(_("confirmall")+" ?");
|
if (!this.owner.tables.length) {
|
||||||
if (!result) { return; }
|
return;
|
||||||
this.owner.clearTables();
|
|
||||||
}
|
}
|
||||||
|
var result = confirm(_("confirmall") + " ?");
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.owner.clearTables();
|
||||||
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.remove = function (e) {
|
SQL.TableManager.prototype.remove = function (e) {
|
||||||
var titles = this.selection.slice(0);
|
var titles = this.selection.slice(0);
|
||||||
for (var i=0;i<titles.length;i++) { titles[i] = "'"+titles[i].getTitle()+"'"; }
|
for (var i = 0; i < titles.length; i++) {
|
||||||
var result = confirm(_("confirmtable")+" "+titles.join(", ")+"?");
|
titles[i] = "'" + titles[i].getTitle() + "'";
|
||||||
if (!result) { return; }
|
|
||||||
var sel = this.selection.slice(0);
|
|
||||||
for (var i=0;i<sel.length;i++) { this.owner.removeTable(sel[i]); }
|
|
||||||
}
|
}
|
||||||
|
var result = confirm(_("confirmtable") + " " + titles.join(", ") + "?");
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var sel = this.selection.slice(0);
|
||||||
|
for (var i = 0; i < sel.length; i++) {
|
||||||
|
this.owner.removeTable(sel[i]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.edit = function (e) {
|
SQL.TableManager.prototype.edit = function (e) {
|
||||||
this.owner.window.open(_("edittable"), this.dom.container, this.save);
|
this.owner.window.open(_("edittable"), this.dom.container, this.save);
|
||||||
|
|
||||||
var title = this.selection[0].getTitle();
|
var title = this.selection[0].getTitle();
|
||||||
this.dom.name.value = title;
|
this.dom.name.value = title;
|
||||||
try { /* throws in ie6 */
|
try {
|
||||||
|
/* throws in ie6 */
|
||||||
this.dom.comment.value = this.selection[0].getComment();
|
this.dom.comment.value = this.selection[0].getComment();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
/* pre-select table name */
|
/* pre-select table name */
|
||||||
this.dom.name.focus();
|
this.dom.name.focus();
|
||||||
if (OZ.ie) {
|
if (OZ.ie) {
|
||||||
try { /* throws in ie6 */
|
try {
|
||||||
|
/* throws in ie6 */
|
||||||
this.dom.name.select();
|
this.dom.name.select();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
} else {
|
} else {
|
||||||
this.dom.name.setSelectionRange(0, title.length);
|
this.dom.name.setSelectionRange(0, title.length);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.keys = function(e) { /* open keys dialog */
|
SQL.TableManager.prototype.keys = function (e) {
|
||||||
|
/* open keys dialog */
|
||||||
this.owner.keyManager.open(this.selection[0]);
|
this.owner.keyManager.open(this.selection[0]);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.save = function () {
|
SQL.TableManager.prototype.save = function () {
|
||||||
this.selection[0].setTitle(this.dom.name.value);
|
this.selection[0].setTitle(this.dom.name.value);
|
||||||
this.selection[0].setComment(this.dom.comment.value);
|
this.selection[0].setComment(this.dom.comment.value);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.TableManager.prototype.press = function (e) {
|
SQL.TableManager.prototype.press = function (e) {
|
||||||
var target = OZ.Event.target(e).nodeName.toLowerCase();
|
var target = OZ.Event.target(e).nodeName.toLowerCase();
|
||||||
if (target == "textarea" || target == "input") { return; } /* not when in form field */
|
if (target == "textarea" || target == "input") {
|
||||||
|
return;
|
||||||
|
} /* not when in form field */
|
||||||
|
|
||||||
if (this.owner.rowManager.selected) { return; } /* do not process keypresses if a row is selected */
|
if (this.owner.rowManager.selected) {
|
||||||
|
return;
|
||||||
|
} /* do not process keypresses if a row is selected */
|
||||||
|
|
||||||
if (!this.selection.length) { return; } /* nothing if selection is active */
|
if (!this.selection.length) {
|
||||||
|
return;
|
||||||
|
} /* nothing if selection is active */
|
||||||
|
|
||||||
switch (e.keyCode) {
|
switch (e.keyCode) {
|
||||||
case 46:
|
case 46:
|
||||||
@@ -206,4 +254,4 @@ SQL.TableManager.prototype.press = function(e) {
|
|||||||
OZ.Event.prevent(e);
|
OZ.Event.prevent(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
+7
-5
@@ -6,13 +6,15 @@ SQL.Toggle = function(elm) {
|
|||||||
OZ.Event.add(elm, "click", this._click.bind(this));
|
OZ.Event.add(elm, "click", this._click.bind(this));
|
||||||
|
|
||||||
var defaultState = true;
|
var defaultState = true;
|
||||||
if (document.location.href.match(/toolbar=hidden/)) { defaultState = false; }
|
if (document.location.href.match(/toolbar=hidden/)) {
|
||||||
this._switch(defaultState);
|
defaultState = false;
|
||||||
}
|
}
|
||||||
|
this._switch(defaultState);
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Toggle.prototype._click = function (e) {
|
SQL.Toggle.prototype._click = function (e) {
|
||||||
this._switch(!this._state);
|
this._switch(!this._state);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Toggle.prototype._switch = function (state) {
|
SQL.Toggle.prototype._switch = function (state) {
|
||||||
this._state = state;
|
this._state = state;
|
||||||
@@ -22,5 +24,5 @@ SQL.Toggle.prototype._switch = function(state) {
|
|||||||
OZ.$("bar").style.overflow = "hidden";
|
OZ.$("bar").style.overflow = "hidden";
|
||||||
OZ.$("bar").style.maxHeight = this._elm.offsetHeight + "px";
|
OZ.$("bar").style.maxHeight = this._elm.offsetHeight + "px";
|
||||||
}
|
}
|
||||||
this._elm.className = (this._state ? "on" : "off");
|
this._elm.className = this._state ? "on" : "off";
|
||||||
}
|
};
|
||||||
|
|||||||
+17
-14
@@ -2,39 +2,42 @@
|
|||||||
SQL.Visual = function () {
|
SQL.Visual = function () {
|
||||||
this._init();
|
this._init();
|
||||||
this._build();
|
this._build();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Visual.prototype._init = function () {
|
SQL.Visual.prototype._init = function () {
|
||||||
this.dom = {
|
this.dom = {
|
||||||
container: null,
|
container: null,
|
||||||
title: null
|
title: null,
|
||||||
};
|
};
|
||||||
this.data = {
|
this.data = {
|
||||||
title:""
|
title: "",
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Visual.prototype._build = function() {}
|
SQL.Visual.prototype._build = function () {};
|
||||||
|
|
||||||
SQL.Visual.prototype.toXML = function() {}
|
SQL.Visual.prototype.toXML = function () {};
|
||||||
|
|
||||||
SQL.Visual.prototype.fromXML = function(node) {}
|
SQL.Visual.prototype.fromXML = function (node) {};
|
||||||
|
|
||||||
SQL.Visual.prototype.destroy = function() { /* "destructor" */
|
SQL.Visual.prototype.destroy = function () {
|
||||||
|
/* "destructor" */
|
||||||
var p = this.dom.container.parentNode;
|
var p = this.dom.container.parentNode;
|
||||||
if (p && p.nodeType == 1) {
|
if (p && p.nodeType == 1) {
|
||||||
p.removeChild(this.dom.container);
|
p.removeChild(this.dom.container);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Visual.prototype.setTitle = function (text) {
|
SQL.Visual.prototype.setTitle = function (text) {
|
||||||
if (!text) { return; }
|
if (!text) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.data.title = text;
|
this.data.title = text;
|
||||||
this.dom.title.innerHTML = text;
|
this.dom.title.innerHTML = text;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Visual.prototype.getTitle = function () {
|
SQL.Visual.prototype.getTitle = function () {
|
||||||
return this.data.title;
|
return this.data.title;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Visual.prototype.redraw = function() {}
|
SQL.Visual.prototype.redraw = function () {};
|
||||||
|
|||||||
+37
-20
@@ -9,8 +9,8 @@ SQL.Window = function(owner) {
|
|||||||
cancel: OZ.$("windowcancel"),
|
cancel: OZ.$("windowcancel"),
|
||||||
title: OZ.$("windowtitle"),
|
title: OZ.$("windowtitle"),
|
||||||
content: OZ.$("windowcontent"),
|
content: OZ.$("windowcontent"),
|
||||||
throbber:OZ.$("throbber")
|
throbber: OZ.$("throbber"),
|
||||||
}
|
};
|
||||||
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");
|
||||||
@@ -26,20 +26,22 @@ SQL.Window = function(owner) {
|
|||||||
this.hideThrobber();
|
this.hideThrobber();
|
||||||
|
|
||||||
this.sync();
|
this.sync();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Window.prototype.showThrobber = function () {
|
SQL.Window.prototype.showThrobber = function () {
|
||||||
this.dom.throbber.style.visibility = "";
|
this.dom.throbber.style.visibility = "";
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Window.prototype.hideThrobber = function () {
|
SQL.Window.prototype.hideThrobber = function () {
|
||||||
this.dom.throbber.style.visibility = "hidden";
|
this.dom.throbber.style.visibility = "hidden";
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Window.prototype.open = function (title, content, callback) {
|
SQL.Window.prototype.open = function (title, content, callback) {
|
||||||
this.state = 1;
|
this.state = 1;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
while (this.dom.title.childNodes.length > 1) { this.dom.title.removeChild(this.dom.title.childNodes[1]); }
|
while (this.dom.title.childNodes.length > 1) {
|
||||||
|
this.dom.title.removeChild(this.dom.title.childNodes[1]);
|
||||||
|
}
|
||||||
|
|
||||||
var txt = OZ.DOM.text(title);
|
var txt = OZ.DOM.text(title);
|
||||||
this.dom.title.appendChild(txt);
|
this.dom.title.appendChild(txt);
|
||||||
@@ -49,10 +51,14 @@ SQL.Window.prototype.open = function(title, content, callback) {
|
|||||||
|
|
||||||
var win = OZ.DOM.win();
|
var win = OZ.DOM.win();
|
||||||
var scroll = OZ.DOM.scroll();
|
var scroll = OZ.DOM.scroll();
|
||||||
this.dom.container.style.left = Math.round(scroll[0] + (win[0] - this.dom.container.offsetWidth)/2)+"px";
|
this.dom.container.style.left =
|
||||||
this.dom.container.style.top = Math.round(scroll[1] + (win[1] - this.dom.container.offsetHeight)/2)+"px";
|
Math.round(scroll[0] + (win[0] - this.dom.container.offsetWidth) / 2) +
|
||||||
|
"px";
|
||||||
|
this.dom.container.style.top =
|
||||||
|
Math.round(scroll[1] + (win[1] - this.dom.container.offsetHeight) / 2) +
|
||||||
|
"px";
|
||||||
|
|
||||||
this.dom.cancel.style.visibility = (this.callback ? "" : "hidden");
|
this.dom.cancel.style.visibility = this.callback ? "" : "hidden";
|
||||||
this.dom.container.style.visibility = "visible";
|
this.dom.container.style.visibility = "visible";
|
||||||
|
|
||||||
var formElements = ["input", "select", "textarea"];
|
var formElements = ["input", "select", "textarea"];
|
||||||
@@ -63,31 +69,42 @@ SQL.Window.prototype.open = function(title, content, callback) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Window.prototype.key = function (e) {
|
SQL.Window.prototype.key = function (e) {
|
||||||
if (!this.state) { return; }
|
if (!this.state) {
|
||||||
if (e.keyCode == 13) { this.ok(e); }
|
return;
|
||||||
if (e.keyCode == 27) { this.close(); }
|
|
||||||
}
|
}
|
||||||
|
if (e.keyCode == 13) {
|
||||||
SQL.Window.prototype.ok = function(e) {
|
this.ok(e);
|
||||||
if (this.callback) { this.callback(); }
|
}
|
||||||
|
if (e.keyCode == 27) {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SQL.Window.prototype.ok = function (e) {
|
||||||
|
if (this.callback) {
|
||||||
|
this.callback();
|
||||||
|
}
|
||||||
|
this.close();
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Window.prototype.close = function () {
|
SQL.Window.prototype.close = function () {
|
||||||
if (!this.state) { return; }
|
if (!this.state) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.state = 0;
|
this.state = 0;
|
||||||
this.dom.background.style.visibility = "hidden";
|
this.dom.background.style.visibility = "hidden";
|
||||||
this.dom.container.style.visibility = "hidden";
|
this.dom.container.style.visibility = "hidden";
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Window.prototype.sync = function() { /* adjust background position */
|
SQL.Window.prototype.sync = function () {
|
||||||
|
/* adjust background position */
|
||||||
var dims = OZ.DOM.win();
|
var dims = OZ.DOM.win();
|
||||||
var scroll = OZ.DOM.scroll();
|
var scroll = OZ.DOM.scroll();
|
||||||
this.dom.background.style.width = dims[0] + "px";
|
this.dom.background.style.width = dims[0] + "px";
|
||||||
this.dom.background.style.height = dims[1] + "px";
|
this.dom.background.style.height = dims[1] + "px";
|
||||||
this.dom.background.style.left = scroll[0] + "px";
|
this.dom.background.style.left = scroll[0] + "px";
|
||||||
this.dom.background.style.top = scroll[1] + "px";
|
this.dom.background.style.top = scroll[1] + "px";
|
||||||
}
|
};
|
||||||
|
|||||||
+149
-76
@@ -12,7 +12,7 @@ SQL.Designer = function() {
|
|||||||
this.dom.container = OZ.$("area");
|
this.dom.container = OZ.$("area");
|
||||||
this.minSize = [
|
this.minSize = [
|
||||||
this.dom.container.offsetWidth,
|
this.dom.container.offsetWidth,
|
||||||
this.dom.container.offsetHeight
|
this.dom.container.offsetHeight,
|
||||||
];
|
];
|
||||||
this.width = this.minSize[0];
|
this.width = this.minSize[0];
|
||||||
this.height = this.minSize[1];
|
this.height = this.minSize[1];
|
||||||
@@ -31,7 +31,7 @@ SQL.Designer = function() {
|
|||||||
this.requestLanguage();
|
this.requestLanguage();
|
||||||
this.requestDB();
|
this.requestDB();
|
||||||
this.applyStyle();
|
this.applyStyle();
|
||||||
}
|
};
|
||||||
SQL.Designer.prototype = Object.create(SQL.Visual.prototype);
|
SQL.Designer.prototype = Object.create(SQL.Visual.prototype);
|
||||||
|
|
||||||
/* update area size */
|
/* update area size */
|
||||||
@@ -52,14 +52,18 @@ SQL.Designer.prototype.sync = function() {
|
|||||||
this.dom.svg.setAttribute("width", this.width);
|
this.dom.svg.setAttribute("width", this.width);
|
||||||
this.dom.svg.setAttribute("height", this.height);
|
this.dom.svg.setAttribute("height", this.height);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.requestLanguage = function() { /* get locale file */
|
SQL.Designer.prototype.requestLanguage = function () {
|
||||||
var lang = this.getOption("locale")
|
/* get locale file */
|
||||||
|
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.languageResponse.bind(this), {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) {
|
||||||
if (xmlDoc) {
|
if (xmlDoc) {
|
||||||
@@ -71,36 +75,48 @@ SQL.Designer.prototype.languageResponse = function(xmlDoc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.flag--;
|
this.flag--;
|
||||||
if (!this.flag) { this.init2(); }
|
if (!this.flag) {
|
||||||
|
this.init2();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.requestDB = function() { /* get datatypes file */
|
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.dbResponse.bind(this), { 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) {
|
||||||
if (xmlDoc) {
|
if (xmlDoc) {
|
||||||
window.DATATYPES = xmlDoc.documentElement;
|
window.DATATYPES = xmlDoc.documentElement;
|
||||||
}
|
}
|
||||||
this.flag--;
|
this.flag--;
|
||||||
if (!this.flag) { this.init2(); }
|
if (!this.flag) {
|
||||||
|
this.init2();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.applyStyle = function() { /* apply style */
|
SQL.Designer.prototype.applyStyle = function () {
|
||||||
|
/* apply style */
|
||||||
var style = this.getOption("style");
|
var style = this.getOption("style");
|
||||||
var i, link_elms = document.querySelectorAll("link");
|
var i,
|
||||||
|
link_elms = document.querySelectorAll("link");
|
||||||
for (i = 0; i < link_elms.length; i++) {
|
for (i = 0; i < link_elms.length; i++) {
|
||||||
if (link_elms[i].getAttribute("rel").indexOf("style") != -1 && link_elms[i].getAttribute("title")) {
|
if (
|
||||||
|
link_elms[i].getAttribute("rel").indexOf("style") != -1 &&
|
||||||
|
link_elms[i].getAttribute("title")
|
||||||
|
) {
|
||||||
link_elms[i].disabled = true;
|
link_elms[i].disabled = true;
|
||||||
if (link_elms[i].getAttribute("title") == style) link_elms[i].disabled = false;
|
if (link_elms[i].getAttribute("title") == style)
|
||||||
}
|
link_elms[i].disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.init2 = function() { /* secondary init, after locale & datatypes were retrieved */
|
SQL.Designer.prototype.init2 = function () {
|
||||||
|
/* secondary init, after locale & datatypes were retrieved */
|
||||||
this.map = new SQL.Map(this);
|
this.map = new SQL.Map(this);
|
||||||
this.rubberband = new SQL.Rubberband(this);
|
this.rubberband = new SQL.Rubberband(this);
|
||||||
this.tableManager = new SQL.TableManager(this);
|
this.tableManager = new SQL.TableManager(this);
|
||||||
@@ -121,18 +137,21 @@ SQL.Designer.prototype.init2 = function() { /* secondary init, after locale & da
|
|||||||
this.io.serverload(false, keyword);
|
this.io.serverload(false, keyword);
|
||||||
}
|
}
|
||||||
document.body.style.visibility = "visible";
|
document.body.style.visibility = "visible";
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.getMaxZ = function() { /* find max zIndex */
|
SQL.Designer.prototype.getMaxZ = function () {
|
||||||
|
/* find max zIndex */
|
||||||
var max = 0;
|
var max = 0;
|
||||||
for (var i = 0; i < this.tables.length; i++) {
|
for (var i = 0; i < this.tables.length; i++) {
|
||||||
var z = this.tables[i].getZ();
|
var z = this.tables[i].getZ();
|
||||||
if (z > max) { max = z; }
|
if (z > max) {
|
||||||
|
max = z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OZ.$("controls").style.zIndex = max + 5;
|
OZ.$("controls").style.zIndex = max + 5;
|
||||||
return max;
|
return max;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.addTable = function (name, x, y) {
|
SQL.Designer.prototype.addTable = function (name, x, y) {
|
||||||
var max = this.getMaxZ();
|
var max = this.getMaxZ();
|
||||||
@@ -140,29 +159,33 @@ SQL.Designer.prototype.addTable = function(name, x, y) {
|
|||||||
this.tables.push(t);
|
this.tables.push(t);
|
||||||
this.dom.container.appendChild(t.dom.container);
|
this.dom.container.appendChild(t.dom.container);
|
||||||
return t;
|
return t;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.removeTable = function (t) {
|
SQL.Designer.prototype.removeTable = function (t) {
|
||||||
this.tableManager.select(false);
|
this.tableManager.select(false);
|
||||||
this.rowManager.select(false);
|
this.rowManager.select(false);
|
||||||
var idx = this.tables.indexOf(t);
|
var idx = this.tables.indexOf(t);
|
||||||
if (idx == -1) { return; }
|
if (idx == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
t.destroy();
|
t.destroy();
|
||||||
this.tables.splice(idx, 1);
|
this.tables.splice(idx, 1);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.addRelation = function (row1, row2) {
|
SQL.Designer.prototype.addRelation = function (row1, row2) {
|
||||||
var r = new SQL.Relation(this, row1, row2);
|
var r = new SQL.Relation(this, row1, row2);
|
||||||
this.relations.push(r);
|
this.relations.push(r);
|
||||||
return r;
|
return r;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.removeRelation = function (r) {
|
SQL.Designer.prototype.removeRelation = function (r) {
|
||||||
var idx = this.relations.indexOf(r);
|
var idx = this.relations.indexOf(r);
|
||||||
if (idx == -1) { return; }
|
if (idx == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
r.destroy();
|
r.destroy();
|
||||||
this.relations.splice(idx, 1);
|
this.relations.splice(idx, 1);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.getCookie = function () {
|
SQL.Designer.prototype.getCookie = function () {
|
||||||
var c = document.cookie;
|
var c = document.cookie;
|
||||||
@@ -171,10 +194,12 @@ SQL.Designer.prototype.getCookie = function() {
|
|||||||
for (var i = 0; i < parts.length; i++) {
|
for (var i = 0; i < parts.length; i++) {
|
||||||
var part = parts[i];
|
var part = parts[i];
|
||||||
var r = part.match(/wwwsqldesigner=({.*?})/);
|
var r = part.match(/wwwsqldesigner=({.*?})/);
|
||||||
if (r) { obj = eval("("+r[1]+")"); }
|
if (r) {
|
||||||
|
obj = eval("(" + r[1] + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.setCookie = function (obj) {
|
SQL.Designer.prototype.setCookie = function (obj) {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
@@ -183,33 +208,47 @@ SQL.Designer.prototype.setCookie = function(obj) {
|
|||||||
}
|
}
|
||||||
var str = "{" + arr.join(",") + "}";
|
var str = "{" + arr.join(",") + "}";
|
||||||
document.cookie = "wwwsqldesigner=" + str + "; path=/";
|
document.cookie = "wwwsqldesigner=" + str + "; path=/";
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.getOption = function (name) {
|
SQL.Designer.prototype.getOption = function (name) {
|
||||||
var c = this.getCookie();
|
var c = this.getCookie();
|
||||||
if (name in c) { return c[name]; }
|
if (name in c) {
|
||||||
|
return c[name];
|
||||||
|
}
|
||||||
/* defaults */
|
/* defaults */
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "locale": return CONFIG.DEFAULT_LOCALE;
|
case "locale":
|
||||||
case "db": return CONFIG.DEFAULT_DB;
|
return CONFIG.DEFAULT_LOCALE;
|
||||||
case "staticpath": return CONFIG.STATIC_PATH || "";
|
case "db":
|
||||||
case "xhrpath": return CONFIG.XHR_PATH || "";
|
return CONFIG.DEFAULT_DB;
|
||||||
case "snap": return 0;
|
case "staticpath":
|
||||||
case "showsize": return 0;
|
return CONFIG.STATIC_PATH || "";
|
||||||
case "showtype": return 0;
|
case "xhrpath":
|
||||||
case "pattern": return "%R_%T";
|
return CONFIG.XHR_PATH || "";
|
||||||
case "hide": return false;
|
case "snap":
|
||||||
case "vector": return true;
|
return 0;
|
||||||
case "style": return "material-inspired";
|
case "showsize":
|
||||||
default: return null;
|
return 0;
|
||||||
}
|
case "showtype":
|
||||||
|
return 0;
|
||||||
|
case "pattern":
|
||||||
|
return "%R_%T";
|
||||||
|
case "hide":
|
||||||
|
return false;
|
||||||
|
case "vector":
|
||||||
|
return true;
|
||||||
|
case "style":
|
||||||
|
return "material-inspired";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.setOption = function (name, value) {
|
SQL.Designer.prototype.setOption = function (name, value) {
|
||||||
var obj = this.getCookie();
|
var obj = this.getCookie();
|
||||||
obj[name] = value;
|
obj[name] = value;
|
||||||
this.setCookie(obj);
|
this.setCookie(obj);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.getXhrHeaders = function (value) {
|
SQL.Designer.prototype.getXhrHeaders = function (value) {
|
||||||
return this.xhrheaders;
|
return this.xhrheaders;
|
||||||
@@ -219,23 +258,30 @@ SQL.Designer.prototype.setXhrHeaders = function (value) {
|
|||||||
this.xhrheaders = value;
|
this.xhrheaders = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.raise = function(table) { /* raise a table */
|
SQL.Designer.prototype.raise = function (table) {
|
||||||
|
/* raise a table */
|
||||||
var old = table.getZ();
|
var old = table.getZ();
|
||||||
var max = this.getMaxZ();
|
var max = this.getMaxZ();
|
||||||
table.setZ(max);
|
table.setZ(max);
|
||||||
for (var i = 0; i < this.tables.length; i++) {
|
for (var i = 0; i < this.tables.length; i++) {
|
||||||
var t = this.tables[i];
|
var t = this.tables[i];
|
||||||
if (t == table) { continue; }
|
if (t == table) {
|
||||||
if (t.getZ() > old) { t.setZ(t.getZ()-1); }
|
continue;
|
||||||
|
}
|
||||||
|
if (t.getZ() > old) {
|
||||||
|
t.setZ(t.getZ() - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var m = table.dom.mini;
|
var m = table.dom.mini;
|
||||||
m.parentNode.appendChild(m);
|
m.parentNode.appendChild(m);
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.clearTables = function () {
|
SQL.Designer.prototype.clearTables = function () {
|
||||||
while (this.tables.length) { this.removeTable(this.tables[0]); }
|
while (this.tables.length) {
|
||||||
this.setTitle(false);
|
this.removeTable(this.tables[0]);
|
||||||
}
|
}
|
||||||
|
this.setTitle(false);
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.alignTables = function () {
|
SQL.Designer.prototype.alignTables = function () {
|
||||||
var win = OZ.DOM.win();
|
var win = OZ.DOM.win();
|
||||||
@@ -259,23 +305,29 @@ SQL.Designer.prototype.alignTables = function() {
|
|||||||
}
|
}
|
||||||
t.moveTo(x, y);
|
t.moveTo(x, y);
|
||||||
x += 10 + w;
|
x += 10 + w;
|
||||||
if (h > max) { max = h; }
|
if (h > max) {
|
||||||
|
max = h;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sync();
|
this.sync();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.findNamedTable = function(name) { /* find row specified as table(row) */
|
SQL.Designer.prototype.findNamedTable = function (name) {
|
||||||
|
/* find row specified as table(row) */
|
||||||
for (var i = 0; i < this.tables.length; i++) {
|
for (var i = 0; i < this.tables.length; i++) {
|
||||||
if (this.tables[i].getTitle() == name) { return this.tables[i]; }
|
if (this.tables[i].getTitle() == name) {
|
||||||
|
return this.tables[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.toXML = function () {
|
SQL.Designer.prototype.toXML = function () {
|
||||||
var xml = '<?xml version="1.0" encoding="utf-8" ?>\n';
|
var xml = '<?xml version="1.0" encoding="utf-8" ?>\n';
|
||||||
xml += '<!-- SQL XML created by WWW SQL Designer, https://github.com/ondras/wwwsqldesigner/ -->\n';
|
xml +=
|
||||||
xml += '<!-- Active URL: ' + location.href + ' -->\n';
|
"<!-- SQL XML created by WWW SQL Designer, https://github.com/ondras/wwwsqldesigner/ -->\n";
|
||||||
xml += '<sql>\n';
|
xml += "<!-- Active URL: " + location.href + " -->\n";
|
||||||
|
xml += "<sql>\n";
|
||||||
|
|
||||||
/* serialize datatypes */
|
/* serialize datatypes */
|
||||||
if (window.XMLSerializer) {
|
if (window.XMLSerializer) {
|
||||||
@@ -284,7 +336,7 @@ SQL.Designer.prototype.toXML = function() {
|
|||||||
} else if (window.DATATYPES.xml) {
|
} else if (window.DATATYPES.xml) {
|
||||||
xml += window.DATATYPES.xml;
|
xml += window.DATATYPES.xml;
|
||||||
} else {
|
} else {
|
||||||
alert(_("errorxml")+': '+e.message);
|
alert(_("errorxml") + ": " + e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < this.tables.length; i++) {
|
for (var i = 0; i < this.tables.length; i++) {
|
||||||
@@ -292,19 +344,22 @@ SQL.Designer.prototype.toXML = function() {
|
|||||||
}
|
}
|
||||||
xml += "</sql>\n";
|
xml += "</sql>\n";
|
||||||
return xml;
|
return xml;
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.fromXML = function (node) {
|
SQL.Designer.prototype.fromXML = function (node) {
|
||||||
this.clearTables();
|
this.clearTables();
|
||||||
var types = node.getElementsByTagName("datatypes");
|
var types = node.getElementsByTagName("datatypes");
|
||||||
if (types.length) { window.DATATYPES = types[0]; }
|
if (types.length) {
|
||||||
|
window.DATATYPES = types[0];
|
||||||
|
}
|
||||||
var tables = node.getElementsByTagName("table");
|
var tables = node.getElementsByTagName("table");
|
||||||
for (var i = 0; i < tables.length; i++) {
|
for (var i = 0; i < tables.length; i++) {
|
||||||
var t = this.addTable("", 0, 0);
|
var t = this.addTable("", 0, 0);
|
||||||
t.fromXML(tables[i]);
|
t.fromXML(tables[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i=0;i<this.tables.length;i++) { /* ff one-pixel shift hack */
|
for (var i = 0; i < this.tables.length; i++) {
|
||||||
|
/* ff one-pixel shift hack */
|
||||||
this.tables[i].select();
|
this.tables[i].select();
|
||||||
this.tables[i].deselect();
|
this.tables[i].deselect();
|
||||||
}
|
}
|
||||||
@@ -317,33 +372,47 @@ SQL.Designer.prototype.fromXML = function(node) {
|
|||||||
var rname = rel.getAttribute("row");
|
var rname = rel.getAttribute("row");
|
||||||
|
|
||||||
var t1 = this.findNamedTable(tname);
|
var t1 = this.findNamedTable(tname);
|
||||||
if (!t1) { continue; }
|
if (!t1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var r1 = t1.findNamedRow(rname);
|
var r1 = t1.findNamedRow(rname);
|
||||||
if (!r1) { continue; }
|
if (!r1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
tname = rel.parentNode.parentNode.getAttribute("name");
|
tname = rel.parentNode.parentNode.getAttribute("name");
|
||||||
rname = rel.parentNode.getAttribute("name");
|
rname = rel.parentNode.getAttribute("name");
|
||||||
var t2 = this.findNamedTable(tname);
|
var t2 = this.findNamedTable(tname);
|
||||||
if (!t2) { continue; }
|
if (!t2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var r2 = t2.findNamedRow(rname);
|
var r2 = t2.findNamedRow(rname);
|
||||||
if (!r2) { continue; }
|
if (!r2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
this.addRelation(r1, r2);
|
this.addRelation(r1, r2);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sync();
|
this.sync();
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.setTitle = function (t) {
|
SQL.Designer.prototype.setTitle = function (t) {
|
||||||
document.title = this.title + (t ? " - " + t : "");
|
document.title = this.title + (t ? " - " + t : "");
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.removeSelection = function () {
|
SQL.Designer.prototype.removeSelection = function () {
|
||||||
var sel = (window.getSelection ? window.getSelection() : document.selection);
|
var sel = window.getSelection ? window.getSelection() : document.selection;
|
||||||
if (!sel) { return; }
|
if (!sel) {
|
||||||
if (sel.empty) { sel.empty(); }
|
return;
|
||||||
if (sel.removeAllRanges) { sel.removeAllRanges(); }
|
|
||||||
}
|
}
|
||||||
|
if (sel.empty) {
|
||||||
|
sel.empty();
|
||||||
|
}
|
||||||
|
if (sel.removeAllRanges) {
|
||||||
|
sel.removeAllRanges();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.getTypeIndex = function (label) {
|
SQL.Designer.prototype.getTypeIndex = function (label) {
|
||||||
if (!this.typeIndex) {
|
if (!this.typeIndex) {
|
||||||
@@ -351,11 +420,13 @@ SQL.Designer.prototype.getTypeIndex = function(label) {
|
|||||||
var types = window.DATATYPES.getElementsByTagName("type");
|
var types = window.DATATYPES.getElementsByTagName("type");
|
||||||
for (var i = 0; i < types.length; i++) {
|
for (var i = 0; i < types.length; i++) {
|
||||||
var l = types[i].getAttribute("label");
|
var l = types[i].getAttribute("label");
|
||||||
if (l) { this.typeIndex[l] = i; }
|
if (l) {
|
||||||
|
this.typeIndex[l] = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.typeIndex[label];
|
return this.typeIndex[label];
|
||||||
}
|
};
|
||||||
|
|
||||||
SQL.Designer.prototype.getFKTypeFor = function (typeIndex) {
|
SQL.Designer.prototype.getFKTypeFor = function (typeIndex) {
|
||||||
if (!this.fkTypeFor) {
|
if (!this.fkTypeFor) {
|
||||||
@@ -364,8 +435,10 @@ SQL.Designer.prototype.getFKTypeFor = function(typeIndex) {
|
|||||||
for (var i = 0; i < types.length; i++) {
|
for (var i = 0; i < types.length; i++) {
|
||||||
this.fkTypeFor[i] = i;
|
this.fkTypeFor[i] = i;
|
||||||
var fk = types[i].getAttribute("fk");
|
var fk = types[i].getAttribute("fk");
|
||||||
if (fk) { this.fkTypeFor[i] = this.getTypeIndex(fk); }
|
if (fk) {
|
||||||
|
this.fkTypeFor[i] = this.getTypeIndex(fk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.fkTypeFor[typeIndex];
|
return this.fkTypeFor[typeIndex];
|
||||||
}
|
};
|
||||||
|
|||||||
+20
-10
@@ -33,11 +33,16 @@ body {
|
|||||||
right: 0px;
|
right: 0px;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
padding: 0px 5px 5px;
|
padding: 0px 5px 5px;
|
||||||
-moz-box-shadow: -4px 4px 8px #888; /* FF 3.5+ */
|
-moz-box-shadow: -4px 4px 8px #888;
|
||||||
-webkit-box-shadow: -4px 4px 8px #888; /* Safari 3.0+, Chrome */
|
/* FF 3.5+ */
|
||||||
box-shadow: -4px 4px 8px #888; /* Opera 10.5, IE 9.0 */
|
-webkit-box-shadow: -4px 4px 8px #888;
|
||||||
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=215, Color='#888888'); /* IE 6, IE 7 */
|
/* Safari 3.0+, Chrome */
|
||||||
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=215, Color='#888888')"; /* IE 8 */
|
box-shadow: -4px 4px 8px #888;
|
||||||
|
/* Opera 10.5, IE 9.0 */
|
||||||
|
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=215, Color='#888888');
|
||||||
|
/* IE 6, IE 7 */
|
||||||
|
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=215, Color='#888888')";
|
||||||
|
/* IE 8 */
|
||||||
}
|
}
|
||||||
|
|
||||||
#bar input {
|
#bar input {
|
||||||
@@ -106,11 +111,16 @@ body {
|
|||||||
border: 1px solid #000;
|
border: 1px solid #000;
|
||||||
background-color: #ddd;
|
background-color: #ddd;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
-moz-box-shadow: 4px 4px 8px #888; /* FF 3.5+ */
|
-moz-box-shadow: 4px 4px 8px #888;
|
||||||
-webkit-box-shadow: 4px 4px 8px #888; /* Safari 3.0+, Chrome */
|
/* FF 3.5+ */
|
||||||
box-shadow: 4px 4px 8px #888; /* Opera 10.5, IE 9.0 */
|
-webkit-box-shadow: 4px 4px 8px #888;
|
||||||
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='#888888'); /* IE 6, IE 7 */
|
/* Safari 3.0+, Chrome */
|
||||||
-ms-filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='#888888'); /* IE 8 */
|
box-shadow: 4px 4px 8px #888;
|
||||||
|
/* Opera 10.5, IE 9.0 */
|
||||||
|
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='#888888');
|
||||||
|
/* IE 6, IE 7 */
|
||||||
|
-ms-filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='#888888');
|
||||||
|
/* IE 8 */
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,3 @@
|
|||||||
font-size: 115%;
|
font-size: 115%;
|
||||||
background-color: none;
|
background-color: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user