Author:   Lars Michelsen <[email protected]>
Date:     Sun Sep  2 12:33:30 2012 +0200
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Sun Sep  2 12:33:30 2012 +0200

Bugfix: Fixed hover menu positioning in scrolled maps

---

 ChangeLog                                    |    3 ++
 TODO                                         |    1 -
 share/frontend/nagvis-js/js/frontendHover.js |   37 ++++++++++++++++++-------
 3 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c79cee..b825b8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@ Core
     (prevents problems with spaces in hostnames and so on)
   * Added new weathermap line type which shows only the used bandwidth in 
labels
 
+Frontend
+  * Bugfix: Fixed hover menu positioning in scrolled maps
+
 1.7b3
 Core
   * Allowing empty lines in main configuration sections now
diff --git a/TODO b/TODO
index a24d816..f64eea4 100644
--- a/TODO
+++ b/TODO
@@ -16,7 +16,6 @@ Offene Punkte:
     - Automap Migration
 
 - Rotationen: Externe Seiten alternativ in iframe öffnen (z.B. Check_MK Views)
-- Hover-Menu Positionen
 
 Nice2have:
   - Option zum persistieren der Optionen für einen selbst
diff --git a/share/frontend/nagvis-js/js/frontendHover.js 
b/share/frontend/nagvis-js/js/frontendHover.js
index 2715369..ce005d4 100644
--- a/share/frontend/nagvis-js/js/frontendHover.js
+++ b/share/frontend/nagvis-js/js/frontendHover.js
@@ -43,6 +43,7 @@ function hoverOpen() {
  * @author     Lars Michelsen <[email protected]>
  */
 function hoverHide(id) {
+    return;
     // Loop all open hover menus
     while(_openHoverMenus.length > 0) {
         _openHoverMenus[0].style.display = 'none';
@@ -128,10 +129,11 @@ function hoverShow(x, y, id) {
     // Resizing was not enough so try to reposition the menu now
     if(!hoverPosAndSizeOk) {
         // First reposition by real size or by min width
-        if(hoverMenu.clientWidth < minWidth)
-            hoverMenu.style.left = (x - minWidth - hoverSpacer) + 'px';
-        else
-            hoverMenu.style.left = (x - hoverMenu.clientWidth - hoverSpacer) + 
'px';
+        if(hoverMenu.clientWidth < minWidth) {
+            hoverMenu.style.left = (x - minWidth - hoverSpacer + scrollLeft) + 
'px';
+        } else {
+            hoverMenu.style.left = (x - hoverMenu.clientWidth - hoverSpacer + 
scrollLeft) + 'px';
+        }
 
         if(hoverMenuInScreen(hoverMenu, hoverSpacer)) {
             hoverPosAndSizeOk = true;
@@ -150,12 +152,12 @@ function hoverShow(x, y, id) {
         hoverMenu.style.width = pageWidth() - (2*hoverSpacer) + 'px';
     }
 
-    var hoverTop = parseInt(hoverMenu.style.top.replace('px', ''));
-    // Only move the menu to the top when the new top will not be
-    // out of sight
-    if(hoverTop + hoverMenu.clientHeight > pageHeight() && hoverTop - 
hoverMenu.clientHeight >= 0)
-        hoverMenu.style.top = hoverTop - hoverMenu.clientHeight - hoverSpacer 
+ 'px';
-    hoverTop = null;
+    //var hoverTop = parseInt(hoverMenu.style.top.replace('px', ''));
+    //// Only move the menu to the top when the new top will not be
+    //// out of sight
+    //if(hoverTop + hoverMenu.clientHeight > pageHeight() && hoverTop - 
hoverMenu.clientHeight >= 0)
+    //    hoverMenu.style.top = hoverTop - hoverMenu.clientHeight - 
hoverSpacer + 'px';
+    //hoverTop = null;
 
     // Append to visible menus array
     _openHoverMenus.push(hoverMenu);
@@ -169,9 +171,22 @@ function hoverMenuInScreen(hoverMenu, hoverSpacer) {
     var scrollLeft = document.body.scrollLeft ? document.body.scrollLeft :
     document.documentElement.scrollLeft;
 
-    if(hoverLeft + hoverMenu.clientWidth >= pageWidth() - scrollLeft)
+    if(hoverLeft < scrollLeft) {
+        //alert('left border is out of viewport');
         return false;
+    }
+
+    // The most right px of the hover menu
+    var hoverRight = hoverLeft + hoverMenu.clientWidth - scrollLeft;
+    // The most right px of the viewport
+    var viewRight  = pageWidth();
+
+    if(hoverRight > viewRight) {
+        //alert('right border is out of viewport');
+        return false;
+    }
 
+    // There is not enough spacing at the left viewport border
     if(hoverLeft - hoverSpacer < 0)
         return false;
 


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to