Author:   Lars Michelsen <[email protected]>
Date:     Mon Oct 10 20:18:55 2011 +0200
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Mon Oct 10 20:18:55 2011 +0200

Keeping hover menu open during object update

Updating map object information while having the hover menu open does not close 
open hover menus anymore

---

 ChangeLog                                          |    2 ++
 share/frontend/nagvis-js/js/NagVisObject.js        |   17 +++++++++++++++++
 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |   10 ++++++++++
 share/frontend/nagvis-js/js/frontend.js            |    4 +---
 share/frontend/nagvis-js/js/frontendHover.js       |   14 ++++++++------
 5 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 772afc1..28b1627 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@ Frontend
   * Bugfix: Don't hide dependent fiels where the master attribute is not 
available
   * Bugfix: Fixed map global section editing
   * Bugfix: IE8 fixing event registration (javascript errors on page loading)
+  * Updating map object information while having the hover menu open does not 
close 
+    open hover menus anymore
 
 1.6rc1
 
diff --git a/share/frontend/nagvis-js/js/NagVisObject.js 
b/share/frontend/nagvis-js/js/NagVisObject.js
index 80d0965..5b6651f 100644
--- a/share/frontend/nagvis-js/js/NagVisObject.js
+++ b/share/frontend/nagvis-js/js/NagVisObject.js
@@ -37,6 +37,9 @@ var NagVisObject = Base.extend({
     bIsLocked:             true,
     objControls:           null,
     childs:                null,
+    // Current position of the active hover menu
+    hoverX:                null,
+    hoverY:                null,
 
     constructor: function(oConf) {
         // Initialize
@@ -279,6 +282,20 @@ var NagVisObject = Base.extend({
     },
 
     /**
+     * Returns true when the hover menu is displayed at the moment
+     */
+    hoverMenuOpened: function() {
+        var hoverMenu = document.getElementById(this.conf.object_id + 
'-hover');
+        if(hoverMenu) {
+            if(hoverMenu.style.display !== 'none') {
+                return true;
+            }
+            hoverMenu = null;
+        }
+        return false;
+    },
+
+    /**
      * PUBLIC getHoverMenu
      *
      * Creates a hover box for objects
diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index 4a1dd84..4d3ec8a 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -319,6 +319,11 @@ var NagVisStatefulObject = NagVisObject.extend({
         var oHover = doc.getElementById(this.conf.object_id+'-hover');
         if(oHover) {
             try {
+                // Preserve the hover coords when the hover menu is open at 
the moment
+                if(!this.hoverMenuOpened()) {
+                    this.hoverX = null;
+                    this.hoverY = null;
+                }
                 this.parsedObject.removeChild(oHover);
             } catch(e) {}
             oHover = null;
@@ -366,6 +371,11 @@ var NagVisStatefulObject = NagVisObject.extend({
      */
     parseHoverMenu: function () {
         this.getHoverMenu(this.getJsObjId());
+
+        // Display the hover menu when it was open before re-rendering
+        if(this.hoverMenuOpened() && this.hoverX !== null) {
+            hoverShow(this.hoverX, this.hoverY, this.conf.object_id);
+        }
     },
 
     /**
diff --git a/share/frontend/nagvis-js/js/frontend.js 
b/share/frontend/nagvis-js/js/frontend.js
index e84f1b1..ee36f59 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -707,9 +707,7 @@ function updateMapBasics() {
 }
 
 /**
- * updateObjects()
- *
- * Bulk update objects
+ * Bulk update map objects using the given object information
  *
  * @param   Array    Array of objects with new information
  * @param   String   Type of the page
diff --git a/share/frontend/nagvis-js/js/frontendHover.js 
b/share/frontend/nagvis-js/js/frontendHover.js
index 92b90e0..6cc35bf 100644
--- a/share/frontend/nagvis-js/js/frontendHover.js
+++ b/share/frontend/nagvis-js/js/frontendHover.js
@@ -25,8 +25,6 @@
  * @author     Lars Michelsen <[email protected]>
  */
 
-// replace the system context menu?
-var _showHover = false;
 var _openHoverMenus = [];
 var _hoverTimer = null;
 
@@ -40,12 +38,12 @@ function hoverOpen() {
 }
 
 /**
- * Hides all open context menus
+ * Hides all open hover menus
  *
  * @author     Lars Michelsen <[email protected]>
  */
 function hoverHide() {
-    // Loop all open context menus
+    // Loop all open hover menus
     while(_openHoverMenus.length > 0) {
         _openHoverMenus[0].style.display = 'none';
         _openHoverMenus[0] = null;
@@ -69,6 +67,10 @@ function hoverShow(x, y, id) {
     var hoverSpacer = 5;
     var minWidth = 400;
 
+    var obj = getMapObjByDomObjId(id);
+    obj.hoverX = x;
+    obj.hoverY = y;
+
     // document.body.scrollTop does not work in IE
     var scrollTop = document.body.scrollTop ? document.body.scrollTop :
     document.documentElement.scrollTop;
@@ -79,7 +81,7 @@ function hoverShow(x, y, id) {
 
     // Maybe there is no hover menu defined for one object?
     if(hoverMenu === null) {
-        eventlog('hover', 'error', 'Found no hover menu wit the id 
"'+id+'-hover"');
+        eventlog('hover', 'error', 'Found no hover menu with the id 
"'+id+'-hover"');
         return false;
     }
 
@@ -202,4 +204,4 @@ function tryResize(hoverMenu, hoverSpacer, minWidth, 
rightSide) {
     widthAfterResize = null;
   hoverMenu = null;
     reposition = null;
-}
\ No newline at end of file
+}


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to