Author:   Lars Michelsen <[email protected]>
Date:     Sat Apr 16 23:17:05 2011 +0200
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Sat Apr 16 23:17:05 2011 +0200

Removed use of chrome incompatible syntax; Fixed grid aligns of relative objects

---

 share/frontend/nagvis-js/js/NagVisObject.js        |   34 ++++++++++++++++---
 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |    4 ++-
 share/frontend/nagvis-js/js/edit.js                |   14 ++++----
 3 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/share/frontend/nagvis-js/js/NagVisObject.js 
b/share/frontend/nagvis-js/js/NagVisObject.js
index 54317db..17e86ff 100644
--- a/share/frontend/nagvis-js/js/NagVisObject.js
+++ b/share/frontend/nagvis-js/js/NagVisObject.js
@@ -526,15 +526,25 @@ var NagVisObject = Base.extend({
 
                if(isRelativeCoord(x) && isRelativeCoord(y)) {
                        // Skip this when already relative to the same object
-                 if(xParent == oParent.conf.object_id
+                       if(xParent == oParent.conf.object_id
                          && yParent == oParent.conf.object_id)
                                return;
 
                        // If this object was attached to another parent 
before, remove the attachment
-                       if(xParent != oParent.conf.object_id)
-                               getMapObjByDomObjId(xParent).delChild(this);
-                       if(yParent != oParent.conf.object_id)
-                               getMapObjByDomObjId(yParent).delChild(this);
+                       if(xParent != oParent.conf.object_id) {
+                               var o = getMapObjByDomObjId(xParent);
+                               if(o) {
+                                   o.delChild(this);
+                                   o = null;
+                               }
+                       }
+                       if(yParent != oParent.conf.object_id) {
+                               var o = getMapObjByDomObjId(yParent);
+                               if(o) {
+                                   o.delChild(this);
+                                   o = null;
+                               }
+                       }
                }
 
                // Add this object to the new parent
@@ -1014,7 +1024,19 @@ var NagVisObject = Base.extend({
 
                // Honor the enabled grid and reposition the object after 
dropping
                if(oViewProperties.grid_show === 1) {
-                   [ jsObj.conf.x, jsObj.conf.y ] = coordsToGrid(jsObj.conf.x, 
jsObj.conf.y);
+                   if(viewType === 'line') {
+                       var pos = coordsToGrid(jsObj.parseCoords(jsObj.conf.x, 
'x')[anchorId],
+                                              jsObj.parseCoords(jsObj.conf.y, 
'y')[anchorId]);
+                       jsObj.conf.x = jsObj.calcNewCoord(pos[0], 'x', 
anchorId);
+                       jsObj.conf.y = jsObj.calcNewCoord(pos[1], 'y', 
anchorId);
+                       pos = null;
+                   } else {
+                       var pos = coordsToGrid(jsObj.parseCoord(jsObj.conf.x, 
'x'),
+                                              jsObj.parseCoord(jsObj.conf.y, 
'y'));
+                       jsObj.conf.x = jsObj.calcNewCoord(pos[0], 'x');
+                       jsObj.conf.y = jsObj.calcNewCoord(pos[1], 'y');
+                       pos = null;
+                   }
                    jsObj.reposition();
                }
 
diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index 8d7c699..f04fb09 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -313,6 +313,9 @@ var NagVisStatefulObject = NagVisObject.extend({
                        // Remove object from DOM
                        oMap.removeChild(this.parsedObject);
                        
+                       if(!this.bIsLocked)
+                           this.removeControls();
+                       
                        // Remove object reference
                        this.parsedObject = null;
                        
@@ -888,7 +891,6 @@ var NagVisStatefulObject = NagVisObject.extend({
        },
 
        parseIconControls: function () {
-               this.getObjWidth();
                var size = 10;
                this.parseControlDrag(0, this.parseCoord(this.conf.x, 'x'), 
this.parseCoord(this.conf.y, 'y'),
                                         this.getObjWidth() + 5, - size / 2, 
size);
diff --git a/share/frontend/nagvis-js/js/edit.js 
b/share/frontend/nagvis-js/js/edit.js
index 6840d40..dec5228 100644
--- a/share/frontend/nagvis-js/js/edit.js
+++ b/share/frontend/nagvis-js/js/edit.js
@@ -353,11 +353,11 @@ function addClick(e) {
     if(!adding())
        return;
 
-    var x, y;
-    [ x, y ] = getEventMousePos(e);
-    addX.push(x);
-    addY.push(y);
+    var pos = getEventMousePos(e);
+    addX.push(pos[0]);
+    addY.push(pos[1]);
     addNumLeft -= 1;
+    pos = null;
     
     // Draw a line to illustrate the progress of drawing the current line
     if(addViewType === 'line' || addObjType === 'textbox') {
@@ -424,14 +424,14 @@ function addFollowing(e) {
     if(!addFollow)
        return;
 
-    [ x, y ] = getEventMousePos(e);
+    var pos = getEventMousePos(e);
 
     addShape.clear();
 
     if(addViewType === 'line')
-       addShape.drawLine(addX[0], addY[0], x, y);
+       addShape.drawLine(addX[0], addY[0], pos[0], pos[1]);
     else
-       addShape.drawRect(addX[0], addY[0], (x - addX[0]), (y - addY[0]));
+       addShape.drawRect(addX[0], addY[0], (pos[0] - addX[0]), (pos[1] - 
addY[0]));
 
     addShape.paint();
 }


------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to