summaryrefslogtreecommitdiffstats
path: root/js/wwwsqldesigner.js
diff options
context:
space:
mode:
authorondrej.zara <none@none>2010-03-22 13:48:09 +0000
committerondrej.zara <none@none>2010-03-22 13:48:09 +0000
commit451b634f81ec91bf37aae8c1501330224884ab52 (patch)
tree4187b084e920d00f94380408138b6c639539ed9a /js/wwwsqldesigner.js
parentfe01acbf74b0c47dfc0e579a9e30fe4a70c37d3a (diff)
downloadwwwsqldesigner-451b634f81ec91bf37aae8c1501330224884ab52.zip
wwwsqldesigner-451b634f81ec91bf37aae8c1501330224884ab52.tar.gz
wwwsqldesigner-451b634f81ec91bf37aae8c1501330224884ab52.tar.bz2
automatic area expansion, #89
--HG-- extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%4095
Diffstat (limited to 'js/wwwsqldesigner.js')
-rw-r--r--js/wwwsqldesigner.js46
1 files changed, 36 insertions, 10 deletions
diff --git a/js/wwwsqldesigner.js b/js/wwwsqldesigner.js
index 291ad1f..c5f94b1 100644
--- a/js/wwwsqldesigner.js
+++ b/js/wwwsqldesigner.js
@@ -347,7 +347,7 @@ SQL.Row.prototype.destroy = function() {
SQL.Row.prototype.toXML = function() {
var xml = "";
- var t = this.getTitle().replace(/"/g,"&quot;"); //"
+ var t = this.getTitle().replace(/"/g,"&quot;"); // ""
var nn = (this.data.nll ? "1" : "0");
var ai = (this.data.ai ? "1" : "0");
xml += '<row name="'+t+'" null="'+nn+'" autoincrement="'+ai+'">\n';
@@ -926,6 +926,7 @@ SQL.Table.prototype.up = function(e) {
t.active = false;
OZ.Event.remove(this.documentMove);
OZ.Event.remove(this.documentUp);
+ this.owner.sync();
}
SQL.Table.prototype.destroy = function() {
@@ -2165,17 +2166,16 @@ SQL.Designer.prototype.init = function() {
SQL.Visual.prototype.init.apply(this);
this.dom.container = this.dom.content = OZ.$("area");
- this.width = this.dom.container.offsetWidth;
- this.height = this.dom.container.offsetHeight;
-
- this.flag = 2;
+ this.minSize = [
+ this.dom.container.offsetWidth,
+ this.dom.container.offsetHeight
+ ];
+ this.width = this.minSize[0];
+ this.height = this.minSize[1];
this.typeIndex = false;
this.fkTypeFor = false;
- this.requestLanguage();
- this.requestDB();
-
this.vector = this.getOption("vector") && (OZ.gecko || OZ.opera || OZ.webkit || OZ.ie);
if (this.vector) {
this.vector = "svg";
@@ -2184,10 +2184,32 @@ SQL.Designer.prototype.init = function() {
if (this.vector == "svg") {
this.svgNS = "http://www.w3.org/2000/svg";
this.dom.svg = document.createElementNS(this.svgNS, "svg");
- this.dom.svg.setAttribute("width",this.dom.container.offsetWidth);
- this.dom.svg.setAttribute("height",this.dom.container.offsetHeight);
this.dom.content.appendChild(this.dom.svg);
}
+
+ this.flag = 2;
+ this.requestLanguage();
+ this.requestDB();
+}
+
+/* update area size */
+SQL.Designer.prototype.sync = function() {
+ var w = this.minSize[0];
+ var h = this.minSize[0];
+ for (var i=0;i<this.tables.length;i++) {
+ var t = this.tables[i];
+ w = Math.max(w, t.x + t.width);
+ h = Math.max(h, t.y + t.height);
+ }
+
+ this.width = w;
+ this.height = h;
+ this.map.sync();
+
+ if (this.vector == "svg") {
+ this.dom.svg.setAttribute("width", this.width);
+ this.dom.svg.setAttribute("height", this.height);
+ }
}
SQL.Designer.prototype.requestLanguage = function() { /* get locale file */
@@ -2234,6 +2256,8 @@ SQL.Designer.prototype.init2 = function() { /* secondary init, after locale & da
this.io = new SQL.IO(this);
this.options = new SQL.Options(this);
this.window = new SQL.Window(this);
+
+ this.sync();
OZ.$("docs").value = _("docs");
@@ -2374,6 +2398,8 @@ SQL.Designer.prototype.alignTables = function() {
x += 10 + w;
if (h > max) { max = h; }
}
+
+ this.sync();
}
SQL.Designer.prototype.findNamedTable = function(name) { /* find row specified as table(row) */