Module: nagvis
Branch: master
Commit: cacbc8fd384f91541d418a6fdadf6e734aceb82e
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=cacbc8fd384f91541d418a6fdadf6e734aceb82e

Author: Lars Michelsen <[email protected]>
Date:   Sat Dec 18 23:40:29 2010 +0100

Fixed control show/hiding

---

 share/frontend/nagvis-js/js/NagVisObject.js        |   10 +---
 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |   21 ++++++++-
 share/frontend/nagvis-js/js/ajaxActions.js         |    9 ----
 share/frontend/nagvis-js/js/frontend.js            |   43 ++++++-------------
 4 files changed, 35 insertions(+), 48 deletions(-)

diff --git a/share/frontend/nagvis-js/js/NagVisObject.js 
b/share/frontend/nagvis-js/js/NagVisObject.js
index 02b5cc4..d759a5f 100644
--- a/share/frontend/nagvis-js/js/NagVisObject.js
+++ b/share/frontend/nagvis-js/js/NagVisObject.js
@@ -354,13 +354,9 @@ var NagVisObject = Base.extend({
         * @author  Lars Michelsen <[email protected]>
         */
        toggleObjControls: function() {
-               if(this.objControls.length == 0) {
+               if(!this.bIsLocked)
                        this.parseControls();
-                       this.bIsLocked = false;
-               } else {
-                       for(var i = 0, len = this.objControls.length; i < len; 
i++)
-                                       this.removeControls();
-                       this.bIsLocked = true;
-               }
+               else
+                       this.removeControls();
        },
 });
diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index f5a2907..84e1373 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -803,6 +803,18 @@ var NagVisStatefulObject = NagVisObject.extend({
                doc = null;
                return oIconDiv;
        },
+
+       /**
+        * Moves the icon to it's location as described by this js object
+        *
+        * @author      Lars Michelsen <[email protected]>
+        */
+       moveIcon: function () {
+               var container = document.getElementById(this.conf.object_id + 
'-icondiv');
+               container.style.top  = this.conf.y + 'px';
+               container.style.left = this.conf.x + 'px';
+               container = null;
+       },
        
        /**
         * Parses the HTML-Code of a label
@@ -921,15 +933,18 @@ var NagVisStatefulObject = NagVisObject.extend({
                        
                        oldX  = null;
                        oldY  = null;
+               } else {
+                       newPos = [ obj.x, obj.y ];
                }
 
-               // FIXME ICON GET POS
-
                jsObj.conf.x = newPos[0];
                jsObj.conf.y = newPos[1];
 
-               if(viewType === 'line')
+               if(viewType === 'line') {
                        jsObj.drawLine();
+               } else {
+                       jsObj.moveIcon();
+               }
 
                jsObj      = null;      
                objId      = null;
diff --git a/share/frontend/nagvis-js/js/ajaxActions.js 
b/share/frontend/nagvis-js/js/ajaxActions.js
index c78cc9f..83cd907 100644
--- a/share/frontend/nagvis-js/js/ajaxActions.js
+++ b/share/frontend/nagvis-js/js/ajaxActions.js
@@ -11,15 +11,6 @@ function getDomObjType(id) {
        return 'service';
 }
 
-function getMapObjByDomObjId(id) {
-       var iIndex = -1;
-       for(var i = 0, len = aMapObjects.length; i < len && iIndex < 0; i++)
-               if(aMapObjects[i].conf.object_id == id)
-                       iIndex = i;
-
-       return aMapObjects[iIndex];
-}
-
 function getMidOfAnchor(oObj) {
        return [ oObj.x + parseInt(oObj.style.width)  / 2,
                 oObj.y + parseInt(oObj.style.height) / 2 ];
diff --git a/share/frontend/nagvis-js/js/frontend.js 
b/share/frontend/nagvis-js/js/frontend.js
index 2b791d3..842848a 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -784,19 +784,17 @@ function updateObjects(aMapObjectInformations, aObjs, 
sType) {
        return bStateChanged;
 }
 
-function toggleMapObjectLock(objectId) {
+function getMapObjByDomObjId(id) {
        var iIndex = -1;
        for(var i = 0, len = aMapObjects.length; i < len && iIndex < 0; i++)
-               if(aMapObjects[i].conf.object_id == objectId)
+               if(aMapObjects[i].conf.object_id == id)
                        iIndex = i;
-       
-       // Object not found
-       if(iIndex === -1) {
-               eventlog("refreshMapObject", "critical", "Could not find an 
object with the id "+objectId+" in object array");
-               return false;
-       }
-       
-       var oObj = aMapObjects[iIndex];
+
+       return aMapObjects[iIndex];
+}
+
+function toggleMapObjectLock(objectId) {
+       var oObj = getMapObjByDomObjId(objectId);
        oObj.bIsLocked = !oObj.bIsLocked;
        oObj.toggleObjControls();
   oObj = null;
@@ -810,28 +808,15 @@ function toggleMapObjectLock(objectId) {
  * @author     Lars Michelsen <[email protected]>
  */
 function refreshMapObject(objectId) {
-       var iIndex = -1;
+       var oObj = getMapObjByDomObjId(objectId);
        
-       for(var i = 0, len = aMapObjects.length; i < len && iIndex < 0; i++) {
-               if(aMapObjects[i].conf.object_id == objectId) { 
-                       iIndex = i;
-               }
-       }
+       var name = oObj.conf.name;
        
-       // Object not found
-       if(iIndex === -1) {
-               eventlog("refreshMapObject", "critical", "Could not find an 
object with the id "+objectId+" in object array");
-               return false;
-       }
-       
-       var name = aMapObjects[iIndex].conf.name;
-       
-       var type = aMapObjects[iIndex].conf.type;
-       var obj_id = aMapObjects[iIndex].conf.object_id;
-       var service_description = aMapObjects[iIndex].conf.service_description;
+       var type = oObj.conf.type;
+       var obj_id = oObj.conf.object_id;
+       var service_description = oObj.conf.service_description;
        var map = oPageProperties.map_name;
-       
-       iIndex = null;
+       oObj = null;
        
        // Only append map param if it is a known map
        var sMapPart = '';


------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to