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

Author: Lars Michelsen <[email protected]>
Date:   Sat Aug 28 10:36:13 2010 +0200

#349 The weathermap lines have context menus now; Line links dont use the 
onclick event for the link areas (middle mouse click allowed now)

---

 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |   16 ++++++----------
 share/frontend/nagvis-js/js/frontendContext.js     |   11 +++--------
 share/frontend/nagvis-js/js/lines.js               |   15 ++++++---------
 3 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index 1aeb7af..a9825cc 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -453,17 +453,13 @@ var NagVisStatefulObject = NagVisObject.extend({
                
                // Parse hover/link area only when needed
                if((this.conf.url && this.conf.url !== '') || 
(this.conf.hover_menu && this.conf.hover_menu !== '')) {
-                       var oLinkDiv = document.createElement('div');
+                       var oLink = document.createElement('a');
+                       oLink.setAttribute('id', 
this.conf.object_id+'-linelinkdiv');
+                       oLink.href = this.conf.url;
+                       oLink.target = this.conf.url_target;
                        
-                       oLinkDiv.setAttribute('id', 
this.conf.object_id+'-linelinkdiv');
-                       oLinkDiv.style.zIndex = (this.conf.z+1);
-                       
-                       var sUrl = this.conf.url;
-                       var sUrlTarget = this.conf.url_target;
-                       oLinkDiv.onclick = function() { window.open(sUrl, 
sUrlTarget, ""); sUrl = null; sUrlTarget = null; };
-                       
-                       oContainerDiv.appendChild(oLinkDiv);
-                       oLinkDiv = null;
+                       oContainerDiv.appendChild(oLink);
+                       oLink = null;
                }
                
                return oContainerDiv;
diff --git a/share/frontend/nagvis-js/js/frontendContext.js 
b/share/frontend/nagvis-js/js/frontendContext.js
index 692ec07..d6cc852 100644
--- a/share/frontend/nagvis-js/js/frontendContext.js
+++ b/share/frontend/nagvis-js/js/frontendContext.js
@@ -117,16 +117,11 @@ function contextShow(event) {
                        document.documentElement.scrollTop;
                var scrollLeft = document.body.scrollLeft ? 
document.body.scrollLeft :
                        document.documentElement.scrollLeft;
-               
+
                // Maybe the event is triggered by a child si try to get the 
right object
                // id from a parent element
-               if(typeof target.id == 'undefined' || target.id == '') {
-                       // Take the first parent
-                       if(target.parentNode != null && typeof 
target.parentNode.id != 'undefined' && target.parentNode.id !== '')
-                               target = target.parentNode;
-                       
-                       // At the moment there is no need to loop more layers. 
Maybe this is
-                       // needed in the future?
+               while(target && (typeof target.id === 'undefined' || target.id 
=== '')) {
+                       target = target.parentNode;
                }
 
                // Workaround for the different structure of targets on 
lines/icons
diff --git a/share/frontend/nagvis-js/js/lines.js 
b/share/frontend/nagvis-js/js/lines.js
index 53888a7..c200c7d 100644
--- a/share/frontend/nagvis-js/js/lines.js
+++ b/share/frontend/nagvis-js/js/lines.js
@@ -77,8 +77,6 @@ function drawPolygonBasedObject(objectId, lineType, xCoord, 
yCoord, z, w, colorF
        //        than using the jsGraphics library
        var oCanvas = document.createElement('canvas');
        if(oCanvas.getContext) {
-               var oLineContainer = document.getElementById(objectId+'-line');
-               
                // Draw the line
                oCanvas.setAttribute('id', objectId+'-canvas');
                oCanvas.style.position = 'absolute';
@@ -101,13 +99,13 @@ function drawPolygonBasedObject(objectId, lineType, 
xCoord, yCoord, z, w, colorF
                
                ctx.fill();
                
-               oLineContainer.appendChild(oCanvas);
+               var oLineContainer = document.getElementById(objectId+'-line');
+               if(oLineContainer)
+                       oLineContainer.appendChild(oCanvas);
                ctx = null;
                oCanvas = null;
                oLineContainer = null;
        } else {
-               var oLineContainer = document.getElementById(objectId+'-line');
-               
                // Fallback to old line style
                var oLine = new 
jsGraphics(document.getElementById(objectId+'-line'));
                oLine.setColor(colorFill);
@@ -115,7 +113,6 @@ function drawPolygonBasedObject(objectId, lineType, xCoord, 
yCoord, z, w, colorF
                oLine.paint();
                
                oLine = null;
-               oLineContainer = null;
        }
        
        oCanvas = null;
@@ -133,14 +130,14 @@ function drawPolygonBasedObject(objectId, lineType, 
xCoord, yCoord, z, w, colorF
                }
 
                if(lineType == '13') {
-                       var label = drawNagVisTextbox(objectId, 'box', 
'#ffffff', '#000000', (lx-labelShift), (ly-10), z, 'auto', 'auto', '<b>' + 
perfdataA + '</b>');
+                       var label = drawNagVisTextbox(objectId+'-link', 'box', 
'#ffffff', '#000000', (lx-labelShift), (ly-10), z, 'auto', 'auto', '<b>' + 
perfdataA + '</b>');
                        oLinkContainer.appendChild(label);
                        label = null;
                } else if(lineType == '14') {
-                       var label = drawNagVisTextbox(objectId, 'box', 
'#ffffff', '#000000', (lx-labelShift), (ly-10), z, 'auto', 'auto', '<b>' + 
perfdataA + '</b>');
+                       var label = drawNagVisTextbox(objectId+'-link', 'box', 
'#ffffff', '#000000', (lx-labelShift), (ly-10), z, 'auto', 'auto', '<b>' + 
perfdataA + '</b>');
                        oLinkContainer.appendChild(label);
                        labelShift = getLabelShift(perfdataB);
-                       label = drawNagVisTextbox(objectId, 'box', '#ffffff', 
'#000000', (lx-labelShift), (ly+10), z, 'auto', 'auto', '<b>' + perfdataB + 
'</b>');
+                       label = drawNagVisTextbox(objectId+'-link1', 'box', 
'#ffffff', '#000000', (lx-labelShift), (ly+10), z, 'auto', 'auto', '<b>' + 
perfdataB + '</b>');
                        oLinkContainer.appendChild(label);
                        label = null;
                } else {


------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to