Author:   Lars Michelsen <[email protected]>
Date:     Mon Nov  5 19:34:46 2012 +0100
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Mon Nov  5 19:34:46 2012 +0100

Bugfix: Only show enabled grid in "edit mode"

---

 ChangeLog                                   |    1 +
 share/frontend/nagvis-js/js/NagVisObject.js |    2 +-
 share/frontend/nagvis-js/js/edit.js         |   20 ++++++++------------
 share/frontend/nagvis-js/js/frontend.js     |    6 ++++++
 4 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index babf050..eb9b9f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@ Frontend:
   * Big performance improvment when rendering object in frontend after
     adding the map zoom feature
   * Bugfix: Re-added "loading..." message on page redering
+  * Bugfix: Only show enabled grid in "edit mode"
 
 Geomap
   * Bugfix: Fixed status updates of objects on geomaps
diff --git a/share/frontend/nagvis-js/js/NagVisObject.js 
b/share/frontend/nagvis-js/js/NagVisObject.js
index 8e77650..bc9f017 100644
--- a/share/frontend/nagvis-js/js/NagVisObject.js
+++ b/share/frontend/nagvis-js/js/NagVisObject.js
@@ -1247,7 +1247,7 @@ var NagVisObject = Base.extend({
             anchorId = -1;
 
         // Honor the enabled grid and reposition the object after dropping
-        if(oViewProperties.grid_show === 1) {
+        if(useGrid()) {
             if(viewType === 'line') {
                var pos = coordsToGrid(jsObj.parseCoords(jsObj.conf.x, 'x', 
false)[anchorId],
                                       jsObj.parseCoords(jsObj.conf.y, 'y', 
false)[anchorId]);
diff --git a/share/frontend/nagvis-js/js/edit.js 
b/share/frontend/nagvis-js/js/edit.js
index 27f5962..41eb365 100644
--- a/share/frontend/nagvis-js/js/edit.js
+++ b/share/frontend/nagvis-js/js/edit.js
@@ -479,14 +479,6 @@ function getEventMousePos(e) {
     // Substract height of header menu here
     posy -= getHeaderHeight();
 
-    // When a grid is enabled align the dragged object in the nearest grid
-    if(oViewProperties.grid_show === 1) {
-        //var a = coordsToGrid(posx, posy);
-        //posx = a[0];
-        //posy = a[1];
-        //a = null;
-    }
-
     // Take the zoom into account. If the map is zoomed this function gathers
     // coordinates where the zoom factor is included. It has to be removed for
     // further processing.
@@ -797,6 +789,10 @@ function validateValue(sName, sValue, sRegex) {
     }
 }
 
+function useGrid() {
+    return oViewProperties.grid_show === 1;
+}
+
 /**
  * Parses a grind to make the alignment of the icons easier
  *
@@ -804,7 +800,7 @@ function validateValue(sName, sValue, sRegex) {
  */
 function gridParse() {
     // Only show when user configured to see a grid
-    if(oViewProperties.grid_show === 1) {
+    if(useGrid()) {
         // Create grid container and append to map
         var oGrid = document.createElement('div');
         oGrid.setAttribute('id', 'grid');
@@ -843,9 +839,9 @@ function gridParse() {
         gridYStart = null;
         gridStep = null;
         grid = null;
-    }
 
-    addEvent(window, "resize", gridRedraw);
+        addEvent(window, "resize", gridRedraw);
+    }
 }
 
 function gridRemove() {
@@ -875,7 +871,7 @@ function gridRedraw() {
  */
 function gridToggle() {
     // Toggle the grid state
-    if(oViewProperties.grid_show === 1) {
+    if(useGrid()) {
         oViewProperties.grid_show = 0;
         gridRemove();
     } else {
diff --git a/share/frontend/nagvis-js/js/frontend.js 
b/share/frontend/nagvis-js/js/frontend.js
index 670c40e..8c8c89a 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -867,17 +867,23 @@ function getMapObjByDomObjId(id) {
 function updateNumUnlocked(num) {
     iNumUnlocked += num;
     if(iNumUnlocked == 0) {
+        // Not in edit mode anymore
         var o = document.getElementById('editIndicator');
         if(o) {
             o.style.display = 'none';
             o = null;
         }
+
+        gridRemove();
     } else {
+        // In edit mode (for at least one object)
         var o = document.getElementById('editIndicator');
         if(o) {
             o.style.display = '';
             o = null;
         }
+
+        gridParse();
     }
 }
 


------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to