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

Author: Lars Michelsen <[email protected]>
Date:   Mon Feb  7 22:24:11 2011 +0100

Fixed movement of object labels when dragging the object in regular frontend

---

 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |   64 ++++++++++++++------
 1 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index 91a2eda..9082b42 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -828,35 +828,56 @@ var NagVisStatefulObject = NagVisObject.extend({
                container.style.left = this.parseCoord(this.conf.x, 'x') + 'px';
                container = null;
        },
-       
+
        /**
-        * Parses the HTML-Code of a label
+        * Moves the label of the object
         *
-        * @return      String          HTML code of the label
         * @author      Lars Michelsen <[email protected]>
         */
-       parseLabel: function () {
-               var oLabelDiv;
-               
+       moveLabel: function () {
+               var label  = document.getElementById(this.conf.object_id + 
'-label');
+               var coords = this.getLabelPos();
+               label.style.top  = coords[1] + 'px';
+               label.style.left = coords[0] + 'px';
+               coords = null;
+               label  = null;
+       },
+
+       /**
+        * Calculates and returns the positions of the objects label
+        *
+        * @author      Lars Michelsen <[email protected]>
+        */
+       getLabelPos: function () {
+               var x = this.conf.label_x,
+                   y = this.conf.label_y;
+
                // If there is a presign it should be relative to the objects 
x/y
-               if(this.conf.label_x && 
this.conf.label_x.toString().match(/^(?:\+|\-)/)) {
-                       this.conf.label_x = this.parseCoord(this.conf.x, 'x') + 
parseFloat(this.conf.label_x);
-               }
-               if(this.conf.label_y && 
this.conf.label_y.toString().match(/^(?:\+|\-)/)) {
-                       this.conf.label_y = this.parseCoord(this.conf.y, 'y') + 
parseFloat(this.conf.label_y);
-               }
+               if(this.conf.label_x && 
this.conf.label_x.toString().match(/^(?:\+|\-)/)) 
+                       x = this.parseCoord(this.conf.x, 'x') + 
parseFloat(this.conf.label_x);
+               if(this.conf.label_y && 
this.conf.label_y.toString().match(/^(?:\+|\-)/))
+                       y = this.parseCoord(this.conf.y, 'y') + 
parseFloat(this.conf.label_y);
                
                // If no x/y coords set, fallback to object x/y
-               if(!this.conf.label_x || this.conf.label_x === '' || 
this.conf.label_x === '0') {
-                       this.conf.label_x = this.parseCoord(this.conf.x, 'x');
-               }
-               if(!this.conf.label_y || this.conf.label_y === '' || 
this.conf.label_y === '0') {
-                       this.conf.label_y = this.parseCoord(this.conf.y, 'y');
-               }
+               if(!this.conf.label_x || this.conf.label_x === '' || 
this.conf.label_x === '0')
+                       x = this.parseCoord(this.conf.x, 'x');
+               if(!this.conf.label_y || this.conf.label_y === '' || 
this.conf.label_y === '0')
+                       y = this.parseCoord(this.conf.y, 'y');
 
+               return [ x, y ];
+       },
+       
+       /**
+        * Parses the HTML-Code of a label
+        *
+        * @return      String          HTML code of the label
+        * @author      Lars Michelsen <[email protected]>
+        */
+       parseLabel: function () {
+               var coords = this.getLabelPos();
                return drawNagVisTextbox(this.conf.object_id + '-label', 
'object_label',
                                         this.conf.label_background, 
this.conf.label_border,
-                                        this.conf.label_x, this.conf.label_y, 
this.conf.z,
+                                        coords[0], coords[1], this.conf.z,
                                         this.conf.label_width, '', 
this.replaceLabelTextDynamicMacros(),
                                         this.conf.label_style);
        },
@@ -945,6 +966,11 @@ var NagVisStatefulObject = NagVisObject.extend({
                else
                        this.moveIcon();
 
+               // Move the objects label when enabled
+               if(this.conf.label_show && this.conf.label_show == '1')
+                       this.moveLabel();
+
+               // Move child objects
                for(var i = 0, l = this.childs.length; i < l; i++)
                        this.childs[i].reposition();
 


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to