[fusion-commits] r1787 - trunk/widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Feb 13 17:26:13 EST 2009


Author: pdeschamps
Date: 2009-02-13 17:26:13 -0500 (Fri, 13 Feb 2009)
New Revision: 1787

Modified:
   trunk/widgets/Maptip.js
Log:
equalized maptips for mapserver / mapguide


Modified: trunk/widgets/Maptip.js
===================================================================
--- trunk/widgets/Maptip.js	2009-02-12 19:24:01 UTC (rev 1786)
+++ trunk/widgets/Maptip.js	2009-02-13 22:26:13 UTC (rev 1787)
@@ -59,9 +59,13 @@
     offset: new OpenLayers.Pixel(2,20),
     szTip: '',
     szHref:'',
+    szLabel:'',
+    aTextFields: null,
+    mapTipFired: false,
     
     initializeWidget: function(widgetTag) {
-        var json = widgetTag.extension;
+        //var json = widgetTag.extension;
+        var json = widgetTag.widgetSet.getWidgetByName(this.name).extension;
         
         this.sTarget = json.Target ? json.Target[0] : "MaptipWindow";
         if (json.WinFeatures) {
@@ -70,15 +74,20 @@
         this.delay = json.Delay ? parseInt(json.Delay[0]) : 350;
         this.nTolerance = json.Tolerance ? parseInt(json.Tolerance[0]) : 2;
 
-        this.customURL =  json.CustomURL;
-        this.textField = json.TextField;
+        this.aCustomURL =   [];
+        this.aTextFields = []; 
         this.aLayers = [];
-        if (json.Layer) {
-            for (var i=0; i<json.Layer.length; i++) {
-                this.aLayers.push(json.Layer[i]);
+        this.aLabels = [];
+        
+        if (json.Maptip) {
+            for (var i=0; i<json.Maptip.length; i++) {
+                this.aLayers.push(json.Maptip[i].Layer);
+                this.aTextFields.push(json.Maptip[i].TextField);
+                this.aLabels.push(json.Maptip[i].Label);
+                this.aCustomURL.push(json.Maptip[i].CustomURL);
             }
         }
-        
+
         //prepare the container div for the maptips
         Fusion.addWidgetStyleSheet(widgetTag.location + 'Maptip/Maptip.css');
         if (this.domObj) {
@@ -142,7 +151,7 @@
         this.oCurrentPosition = p;
         this.oMapTipPosition = p;
 
-        if (this.oCurrentPosition) {
+        if(typeof( this.nTimer) == "number") {
             window.clearTimeout(this.nTimer);
             this.nTimer = null;
         }
@@ -161,13 +170,11 @@
     },
     
     showMaptip: function() {
-        //console.log("MAPTIP: showMaptip");
         this.getMap().getMapTip(this);
-       
+        this.mapTipFired = true;
     },
     
     _display: function(eventID,oMapTip) {
-        //console.log("MAPTIP: _display");
         if (typeof(oMapTip) == "undefined" || oMapTip.t == '') {
             return;
         }
@@ -178,33 +185,53 @@
             this.domObj.appendChild(contentDiv);
             var empty = true;
             this.bIsVisible = true;
-            var t = oMapTip.t;
-            this.szTip = t;
-            this.szHref = h;
-            if (t) {
-                contentDiv.innerHTML = t.replace(/\n/g, "<br>");
-                empty = false;
+            
+            var tip = oMapTip.t;
+            var hyperlink =oMapTip.h;
+            var label =oMapTip.l;
+            
+            this.szTip = tip;
+            this.szHref = hyperlink;
+            this.label = label;
+            
+            if(typeof(tip) == "object"){
+                for(var i=0;i<tip.length;i++){
+                    var t = tip[i];
+                    var h = hyperlink[i];
+                    var l = label[i];
+                    var oLinkDom = this.addMapTipDomObj(h,t);
+                    var mapTipContent = document.createElement('DIV');
+                    mapTipContent.className = "mapTipContentDIV";
+                    // has a label with the maptip
+                    if(l != ""){
+                        mapTipContent.innerHTML = l+" : ";
+                        contentDiv.appendChild(mapTipContent);
+                        mapTipContent.appendChild(oLinkDom);
+                        empty = false;
+                    }
+                    else
+                    {
+                        contentDiv.appendChild(mapTipContent);
+                        contentDiv.appendChild(oLinkDom);
+                        empty = false;
+                    }
+                }
             }
-            var h =oMapTip.h;
-            if (h) {
-                var a, linkURL;
-                var linkDiv = document.createElement('div');
-                if (h.indexOf('href=') > 0) {   //MGOS allows complete anchor tags as the hyperlink
-                linkDiv.innerHTML = h;
-                a = linkDiv.firstChild;
-                linkURL = a.href;
-                } else {
-                a = document.createElement('a');
-                a.innerHTML = h;
-                linkURL = h;
-                linkDiv.appendChild(a);
+            else
+            {
+                if (t) {
+                    contentDiv.innerHTML = t.replace(/\n/g, "<br>");
+                    empty = false;
                 }
-                a.href = 'javascript:void(0)';
-                var openLink = OpenLayers.Function.bind(this.openLink, this, linkURL);
-                a.onclick = OpenLayers.Function.bindAsEventListener(openLink, this);
-                contentDiv.appendChild(linkDiv);
-                empty = false;
+
+                if (h) {
+
+                    contentDiv.appendChild(linkDiv);
+                    empty = false;
+                }
             }
+
+            
             if (!empty) {
                 var size = $(this.domObj).getBorderBoxSize();
                 this.oMapTipPosition = this.oMapTipPosition.add(this.mapOffset[0], this.mapOffset[1]);
@@ -234,7 +261,38 @@
                 this.hideMaptip();
             }
         }
+        this.mapTipFired = false;
     },
+
+    addMapTipDomObj: function(url,szText){
+        if(url == "undefined" || url == typeof("undefined")  || url ==""){
+                var linkSpan = document.createElement('SPAN');
+                linkSpan.className = "mapTipData";
+                linkSpan.innerHTML = szText;
+                return linkSpan;
+            }
+            else
+            {
+            var a, linkURL;
+            var linkSpan = document.createElement('SPAN');
+            linkSpan.className = "mapTipData"
+            if (url.indexOf('href=') > 0) {   //MGOS allows complete anchor tags as the hyperlink
+            linkSpan.innerHTML = url;
+            a = linkDiv.firstChild;
+            linkURL = a.href;
+            } else {
+            a = document.createElement('a');
+            a.className = "mapTipLink";
+            a.innerHTML = szText;
+            linkURL = url;
+            linkSpan.appendChild(a);
+            }
+            a.href = 'javascript:void(0)';
+            var openLink = OpenLayers.Function.bind(this.openLink, this, linkURL);
+            a.onclick = OpenLayers.Function.bindAsEventListener(openLink, this);
+            return linkSpan;
+            }
+    },
     
     hideMaptip: function() {
       //console.log('hideMaptip');



More information about the fusion-commits mailing list