summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Zara <ondrej.zara@gmail.com>2013-01-10 13:49:42 +0100
committerOndrej Zara <ondrej.zara@gmail.com>2013-01-10 13:49:42 +0100
commit1e62cdc8d05a3c0256c81f29d7e74248ceb04384 (patch)
tree4f840f25ef4dfdb1f057ad48d67b9a38d36df522
parent29815e159ad57f31e8acc7f5355f097ca1e0593f (diff)
parentbe5609fe13b7f4f7d694cf929dd1622c8b3fb2a9 (diff)
downloadwwwsqldesigner-1e62cdc8d05a3c0256c81f29d7e74248ceb04384.zip
wwwsqldesigner-1e62cdc8d05a3c0256c81f29d7e74248ceb04384.tar.gz
wwwsqldesigner-1e62cdc8d05a3c0256c81f29d7e74248ceb04384.tar.bz2
merge
-rw-r--r--images/ScreenLayout.pngbin0 -> 16405 bytes
-rw-r--r--images/addingKeys.pngbin0 -> 16727 bytes
-rw-r--r--images/columnDetail.pngbin0 -> 8210 bytes
-rw-r--r--images/constrained.pngbin0 -> 7283 bytes
-rw-r--r--images/editTable.pngbin0 -> 10908 bytes
-rw-r--r--images/finalExample.pngbin0 -> 337149 bytes
-rw-r--r--images/selectedColumn.pngbin0 -> 3885 bytes
-rw-r--r--js/wwwsqldesigner.js31
8 files changed, 19 insertions, 12 deletions
diff --git a/images/ScreenLayout.png b/images/ScreenLayout.png
new file mode 100644
index 0000000..310cb4f
--- /dev/null
+++ b/images/ScreenLayout.png
Binary files differ
diff --git a/images/addingKeys.png b/images/addingKeys.png
new file mode 100644
index 0000000..ddb5be9
--- /dev/null
+++ b/images/addingKeys.png
Binary files differ
diff --git a/images/columnDetail.png b/images/columnDetail.png
new file mode 100644
index 0000000..4eb9ba7
--- /dev/null
+++ b/images/columnDetail.png
Binary files differ
diff --git a/images/constrained.png b/images/constrained.png
new file mode 100644
index 0000000..04a6133
--- /dev/null
+++ b/images/constrained.png
Binary files differ
diff --git a/images/editTable.png b/images/editTable.png
new file mode 100644
index 0000000..1d8dfe6
--- /dev/null
+++ b/images/editTable.png
Binary files differ
diff --git a/images/finalExample.png b/images/finalExample.png
new file mode 100644
index 0000000..72203c2
--- /dev/null
+++ b/images/finalExample.png
Binary files differ
diff --git a/images/selectedColumn.png b/images/selectedColumn.png
new file mode 100644
index 0000000..ac0a388
--- /dev/null
+++ b/images/selectedColumn.png
Binary files differ
diff --git a/js/wwwsqldesigner.js b/js/wwwsqldesigner.js
index 7df7811..5451e34 100644
--- a/js/wwwsqldesigner.js
+++ b/js/wwwsqldesigner.js
@@ -481,27 +481,30 @@ SQL.Row.prototype.enter = function(e) {
SQL.Relation = OZ.Class().extend(SQL.Visual);
SQL.Relation._counter = 0;
SQL.Relation.prototype.init = function(owner, row1, row2) {
- this.constructor._counter++;
this.owner = owner;
this.row1 = row1;
this.row2 = row2;
+ this.color = "#000";
this.hidden = false;
SQL.Visual.prototype.init.apply(this);
-
+
+ /* if one of the rows already has relations, inherit color */
+ var all = row1.relations.concat(row2.relations);
+ if (all.length) { /* inherit */
+ this.color = all[0].getColor();
+ } else if (CONFIG.RELATION_COLORS) { /* pick next */
+ this.constructor._counter++;
+ var colorIndex = this.constructor._counter - 1;
+ this.color = CONFIG.RELATION_COLORS[colorIndex % CONFIG.RELATION_COLORS.length];
+ }
+
this.row1.addRelation(this);
this.row2.addRelation(this);
-
this.dom = [];
- if (CONFIG.RELATION_COLORS) {
- var colorIndex = this.constructor._counter - 1;
- var color = CONFIG.RELATION_COLORS[colorIndex % CONFIG.RELATION_COLORS.length];
- } else {
- var color = "#000";
- }
if (this.owner.vector) {
var path = document.createElementNS(this.owner.svgNS, "path");
- path.setAttribute("stroke", color);
+ path.setAttribute("stroke", this.color);
path.setAttribute("stroke-width", CONFIG.RELATION_THICKNESS);
path.setAttribute("fill", "none");
this.owner.dom.svg.appendChild(path);
@@ -511,9 +514,9 @@ SQL.Relation.prototype.init = function(owner, row1, row2) {
var div = OZ.DOM.elm("div",{position:"absolute",className:"relation",backgroundColor:color});
this.dom.push(div);
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 */
- OZ.Style.set(div,{height:CONFIG.RELATION_THICKNESS+"px"});
+ OZ.Style.set(div, {height:CONFIG.RELATION_THICKNESS+"px"});
}
this.owner.dom.container.appendChild(div);
}
@@ -522,6 +525,10 @@ SQL.Relation.prototype.init = function(owner, row1, row2) {
this.redraw();
}
+SQL.Relation.prototype.getColor = function() {
+ return this.color;
+}
+
SQL.Relation.prototype.show = function() {
this.hidden = false;
for (var i=0;i<this.dom.length;i++) {