From 4988e8d42309ef38576ce91362b1b33276e9175a Mon Sep 17 00:00:00 2001 From: "ondrej.zara" Date: Sun, 3 Jan 2010 19:19:32 +0000 Subject: [PATCH] #54 --HG-- extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%4072 --- js/wwwsqldesigner.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/js/wwwsqldesigner.js b/js/wwwsqldesigner.js index 1d8a04b..3a3b36c 100644 --- a/js/wwwsqldesigner.js +++ b/js/wwwsqldesigner.js @@ -813,6 +813,9 @@ SQL.Table.prototype.down = function(e) { /* mousedown - start drag */ } if (this.owner.getOption("hide")) { this.hideRelations(); } + + this.documentMove = OZ.Event.add(document, "mousemove", this.bind(this.move)); + this.documentUp = OZ.Event.add(document, "mouseup", this.bind(this.up)); } SQL.Table.prototype.toXML = function() { @@ -897,9 +900,8 @@ SQL.Table.prototype.getComment = function() { return this.data.comment; } -SQL.Table.move = function(e) { /* mousemove */ +SQL.Table.prototype.move = function(e) { /* mousemove */ var t = SQL.Table; - if (!t.active) { return; } SQL.Designer.removeSelection(); for (var i in t.active) { var x = t.x[i] + e.clientX; @@ -908,17 +910,15 @@ SQL.Table.move = function(e) { /* mousemove */ } } -SQL.Table.up = function(e) { +SQL.Table.prototype.up = function(e) { var t = SQL.Table; var d = SQL.Designer; - if (!t.active) { return; } if (d.getOption("hide")) { t.active.showRelations(); } t.active = false; + OZ.Event.remove(this.documentMove); + OZ.Event.remove(this.documentUp); } -OZ.Event.add(document, "mousemove", SQL.Table.move); -OZ.Event.add(document, "mouseup", SQL.Table.up); - SQL.Table.prototype.destroy = function() { SQL.Visual.prototype.destroy.apply(this); this.dom.mini.parentNode.removeChild(this.dom.mini); @@ -1023,8 +1023,6 @@ SQL.Map.prototype.init = function(owner) { OZ.Event.add(window, "resize", this.sync); OZ.Event.add(window, "scroll", this.sync); OZ.Event.add(this.dom.container, "mousedown", this.bind(this.down)); - OZ.Event.add(document, "mousemove", this.bind(this.move)); - OZ.Event.add(document, "mouseup", this.bind(this.up)); } SQL.Map.prototype.down = function(e) { /* mousedown - move view and start drag */ @@ -1035,6 +1033,9 @@ SQL.Map.prototype.down = function(e) { /* mousedown - move view and start drag * this.x = Math.round(pos[0] + this.l + this.w/2); this.y = Math.round(pos[1] + this.t + this.h/2); this.move(e); + + this.documentMove = OZ.Event.add(document, "mousemove", this.bind(this.move)); + this.documentUp = OZ.Event.add(document, "mouseup", this.bind(this.up)); } SQL.Map.prototype.move = function(e) { /* mousemove */ @@ -1074,6 +1075,8 @@ SQL.Map.prototype.move = function(e) { /* mousemove */ SQL.Map.prototype.up = function(e) { /* mouseup */ this.flag = false; this.dom.container.style.cursor = ""; + OZ.Event.remove(this.documentMove); + OZ.Event.remove(this.documentUp); } SQL.Map.prototype.sync = function() { /* when window changes, adjust map */