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

Author: Lars Michelsen <[email protected]>
Date:   Thu Oct 14 19:28:58 2010 +0200

#372 re-implemented the hover_delay function

---

 share/frontend/nagvis-js/js/frontendHover.js |   19 ++++++++++++-------
 share/frontend/nagvis-js/js/hover.js         |   16 ++++++++++++----
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/share/frontend/nagvis-js/js/frontendHover.js 
b/share/frontend/nagvis-js/js/frontendHover.js
index a712a98..cb58b0b 100644
--- a/share/frontend/nagvis-js/js/frontendHover.js
+++ b/share/frontend/nagvis-js/js/frontendHover.js
@@ -28,6 +28,7 @@
 // replace the system context menu?
 var _showHover = false;
 var _openHoverMenus = [];
+var _hoverTimer = null;
 
 /**
  * Checks if a hover menu is open at the moment
@@ -50,19 +51,23 @@ function hoverHide() {
                _openHoverMenus[0] = null;
                _openHoverMenus.splice(0,1);
        }
+
+       // Remove the hover timer
+       clearTimeout(_hoverTimer);
+       _hoverTimer = null;
        
        // Change cursor to auto when hiding hover menu
        document.body.style.cursor = 'auto';
 }
 
-function hoverShow(event, id) {
-       // IE is evil and doesn't pass the event object
-       if (event === null || typeof event === 'undefined')
-               event = window.event;
-       
+function hoverShow(x, y, id) {
        // Hide all other hover menus
        hoverHide();
 
+       // Remove the hover timer
+       clearTimeout(_hoverTimer);
+       _hoverTimer = null;
+
        var hoverSpacer = 5;
 
        // document.body.scrollTop does not work in IE
@@ -84,8 +89,8 @@ function hoverShow(event, id) {
 
        // hide the menu first to avoid an "up-then-over" visual effect
        hoverMenu.style.display = 'none';
-       hoverMenu.style.left = event.clientX + scrollLeft + hoverSpacer + 'px';
-       hoverMenu.style.top = event.clientY + scrollTop + hoverSpacer - 
getHeaderHeight() + 'px';
+       hoverMenu.style.left = x + scrollLeft + hoverSpacer + 'px';
+       hoverMenu.style.top = y + scrollTop + hoverSpacer - getHeaderHeight() + 
'px';
        hoverMenu.style.display = '';
 
        // Check if the context menu is "in screen".
diff --git a/share/frontend/nagvis-js/js/hover.js 
b/share/frontend/nagvis-js/js/hover.js
index c174f1f..0be14cc 100644
--- a/share/frontend/nagvis-js/js/hover.js
+++ b/share/frontend/nagvis-js/js/hover.js
@@ -350,9 +350,17 @@ function replaceHoverTemplateMacros(replaceChild, oObj, 
sTemplateCode) {
                   replaceHoverTemplateStaticMacros(replaceChild, oObj, 
sTemplateCode));
 }
 
-function displayHoverMenu(e, objId, iHoverDelay) {
+function displayHoverMenu(event, objId, iHoverDelay) {
+       // IE is evil and doesn't pass the event object
+       if (event === null || typeof event === 'undefined')
+               event = window.event;
+       
        // Only show up hover menu when no context menu is opened
-       // FIXME: Re-implement the delay
-       if(!contextOpen())
-               hoverShow(e, objId);
+       // and only handle the events when no timer is in schedule at the 
moment to
+       // prevent strange movement effects when the timer has finished
+       if(!contextOpen() && _hoverTimer === null)
+               if(iHoverDelay && iHoverDelay != "0" && !hoverOpen())
+                       _hoverTimer = setTimeout('hoverShow('+event.clientX+', 
'+event.clientY+', '+objId+')', parseInt(iHoverDelay)*1000);
+               else
+                       hoverShow(event.clientX, event.clientY, objId);
 }


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to