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

Author: LaMi <[email protected]>
Date:   Wed Jan 27 12:45:42 2010 +0100

Extracted code to render textboxes and labels to function drawNagVisTextbox

---

 .../frontend/nagvis-js/js/NagVisStatefulObject.js  |   38 +--------------
 share/frontend/nagvis-js/js/NagVisTextbox.js       |   41 +----------------
 share/frontend/nagvis-js/js/nagvis.js              |   49 ++++++++++++++++++++
 3 files changed, 52 insertions(+), 76 deletions(-)

diff --git a/share/frontend/nagvis-js/js/NagVisStatefulObject.js 
b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
index 9c6252e..245136b 100644
--- a/share/frontend/nagvis-js/js/NagVisStatefulObject.js
+++ b/share/frontend/nagvis-js/js/NagVisStatefulObject.js
@@ -634,41 +634,7 @@ var NagVisStatefulObject = NagVisObject.extend({
                if(!this.conf.label_y || this.conf.label_y === '' || 
this.conf.label_y === '0') {
                        this.conf.label_y = this.conf.y;
                }
-               
-               if(this.conf.label_width && this.conf.label_width !== 'auto') {
-                       this.conf.label_width += 'px';  
-               }
-               
-               oLabelDiv = document.createElement('div');
-               oLabelDiv.setAttribute('id', this.conf.object_id + '-label');
-               oLabelDiv.setAttribute('class', 'object_label');
-               oLabelDiv.setAttribute('className', 'object_label');
-               oLabelDiv.style.background = this.conf.label_background;
-               oLabelDiv.style.borderColor = this.conf.label_border;
-               
-               oLabelDiv.style.position = 'absolute';
-               oLabelDiv.style.left = this.conf.label_x + 'px';
-               oLabelDiv.style.top = this.conf.label_y + 'px';
-               oLabelDiv.style.width = this.conf.label_width;
-               oLabelDiv.style.zIndex = this.conf.z+1;
-               oLabelDiv.style.overflow= 'visible';
-               
-               /**
-                * IE workaround: The transparent for the color is not enough. 
The border
-                * has really to be hidden.
-                */
-               if(this.conf.label_border === 'transparent') {
-                       oLabelDiv.style.borderStyle = 'none';
-               } else {
-                       oLabelDiv.style.borderStyle = 'solid';
-               }
-               
-               // Create span for text and add label text
-               var oLabelSpan = document.createElement('span');
-               oLabelSpan.innerHTML = this.replaceLabelTextDynamicMacros();
-               oLabelDiv.appendChild(oLabelSpan);
-               oLabelSpan = null;
-               
-               return oLabelDiv;
+
+               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, this.conf.label_width, '', 
this.replaceLabelTextDynamicMacros());
        }
 });
diff --git a/share/frontend/nagvis-js/js/NagVisTextbox.js 
b/share/frontend/nagvis-js/js/NagVisTextbox.js
index c91fa33..31f647a 100644
--- a/share/frontend/nagvis-js/js/NagVisTextbox.js
+++ b/share/frontend/nagvis-js/js/NagVisTextbox.js
@@ -81,45 +81,6 @@ var NagVisTextbox = NagVisStatelessObject.extend({
         * @author      Lars Michelsen <[email protected]>
         */
        parseTextbox: function () {
-               var oLabelDiv = document.createElement('div');
-               oLabelDiv.setAttribute('id', this.conf.object_id+'label');
-               oLabelDiv.setAttribute('class', 'box');
-               oLabelDiv.setAttribute('className', 'box');
-               oLabelDiv.style.background = this.conf.background_color;
-               oLabelDiv.style.borderColor = this.conf.border_color;
-               
-               oLabelDiv.style.position = 'absolute';
-               oLabelDiv.style.left = this.conf.x + 'px';
-               oLabelDiv.style.top = this.conf.y + 'px';
-               
-               if(this.conf.w && this.conf.w !== '' && this.conf.h !== 'auto') 
{
-                       oLabelDiv.style.width = this.conf.w+'px';
-               }
-               
-               if(this.conf.h && this.conf.h !== '' && this.conf.h !== 'auto') 
{
-                       oLabelDiv.style.height = this.conf.h+'px';
-               }
-               
-               oLabelDiv.style.zIndex = this.conf.z + 1;
-               oLabelDiv.style.overflow = 'visible';
-               
-               /**
-                * IE workaround: The transparent for the color is not enough. 
The border
-                * has really to be hidden.
-                */
-               if(this.conf.border_color == 'transparent') {
-                       oLabelDiv.style.borderStyle = 'none';
-               } else {
-                       oLabelDiv.style.borderStyle = 'solid';
-               }
-               
-               // Create span for text and add label text
-               var oLabelSpan = document.createElement('span');
-               oLabelSpan.innerHTML = this.conf.text;
-               
-               oLabelDiv.appendChild(oLabelSpan);
-               oLabelSpan = null;
-               
-               return oLabelDiv;
+               return drawNagVisTextbox(this.conf.object_id+'label', 'box', 
this.conf.background_color, this.conf.border_color, this.conf.x, this.conf.y, 
this.conf.z, this.conf.w, this.conf.h, this.conf.text);
        }
 });
diff --git a/share/frontend/nagvis-js/js/nagvis.js 
b/share/frontend/nagvis-js/js/nagvis.js
index ac42c42..0684632 100644
--- a/share/frontend/nagvis-js/js/nagvis.js
+++ b/share/frontend/nagvis-js/js/nagvis.js
@@ -903,3 +903,52 @@ function hideStatusMessage() {
        }
 }
 
+/**
+ * Creates a html box on the map. Used by textbox objects, labels and line 
labels
+ *
+ * @return  Object  Returns the div object of the textbox
+ * @author  Lars Michelsen <[email protected]>
+ */
+function drawNagVisTextbox(id, class, bgColor, borderColor, x, y, z, w, h, 
text) {
+               var oLabelDiv = document.createElement('div');
+               oLabelDiv.setAttribute('id', id);
+               oLabelDiv.setAttribute('class', class);
+               oLabelDiv.setAttribute('className', class);
+               oLabelDiv.style.background = bgColor;
+               oLabelDiv.style.borderColor = borderColor;
+               
+               oLabelDiv.style.position = 'absolute';
+               oLabelDiv.style.left = x + 'px';
+               oLabelDiv.style.top = y + 'px';
+               
+               if(w && w !== '' && w !== 'auto') {
+                       oLabelDiv.style.width = w+'px';
+               }
+               
+               if(h && h !== '' && h !== 'auto') {
+                       oLabelDiv.style.height = h+'px';
+               }
+               
+               oLabelDiv.style.zIndex = z + 1;
+               oLabelDiv.style.overflow = 'visible';
+               
+               /**
+                * IE workaround: The transparent for the color is not enough. 
The border
+                * has really to be hidden.
+                */
+               if(borderColor == 'transparent') {
+                       oLabelDiv.style.borderStyle = 'none';
+               } else {
+                       oLabelDiv.style.borderStyle = 'solid';
+               }
+               
+               // Create span for text and add label text
+               var oLabelSpan = document.createElement('span');
+               oLabelSpan.innerHTML = text;
+               
+               oLabelDiv.appendChild(oLabelSpan);
+               oLabelSpan = null;
+               
+               return oLabelDiv;
+}
+


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to