[mapguide-commits] r5029 - branches/2.2/MgDev/Web/src/viewerfiles

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jul 14 12:22:02 EDT 2010


Author: tomfukushima
Date: 2010-07-14 16:22:02 +0000 (Wed, 14 Jul 2010)
New Revision: 5029

Modified:
   branches/2.2/MgDev/Web/src/viewerfiles/browserdetect.js
   branches/2.2/MgDev/Web/src/viewerfiles/contextmenu.js
   branches/2.2/MgDev/Web/src/viewerfiles/tasklist.templ
Log:
#1274 Right button context menu doesn't work in Opera or Chrome

Submitting patch from Zac Spitzer.  Patch looks good and I tested on Chrome and IE.  Did not test on Safari, Firefox, Opera, etc.

Modified: branches/2.2/MgDev/Web/src/viewerfiles/browserdetect.js
===================================================================
--- branches/2.2/MgDev/Web/src/viewerfiles/browserdetect.js	2010-07-14 16:15:23 UTC (rev 5028)
+++ branches/2.2/MgDev/Web/src/viewerfiles/browserdetect.js	2010-07-14 16:22:02 UTC (rev 5029)
@@ -41,3 +41,14 @@
         msie6minus = true;
     }
 }
+
+function getAttributeNodeValue(obj,attr){
+    try 
+    {   
+        return (opera || chrome || firefox || safari3plus) ? obj.attributes[attr].nodeValue : obj[attr];
+    }
+    catch(e) 
+    {
+        return obj.attributes[attr].nodeValue;
+    } 
+}

Modified: branches/2.2/MgDev/Web/src/viewerfiles/contextmenu.js
===================================================================
--- branches/2.2/MgDev/Web/src/viewerfiles/contextmenu.js	2010-07-14 16:15:23 UTC (rev 5028)
+++ branches/2.2/MgDev/Web/src/viewerfiles/contextmenu.js	2010-07-14 16:22:02 UTC (rev 5029)
@@ -66,7 +66,7 @@
     var menuObj = this.menuObj;
     if(menuObj != null)
     {
-        var name = (chrome || firefox || safari3plus) ? this.attributes["name"].nodeValue : this.name;
+        var name = getAttributeNodeValue(this,"name");
         if(name.indexOf("Sub:") == 0)
         {
             var subMenu = menuObj.subMenus[name.substr(4)];
@@ -105,7 +105,7 @@
                 catch(e) {}
             }
 
-            var enabled = (chrome || firefox || safari3plus) ? this.attributes["state"].nodeValue : this.state;
+            var enabled = getAttributeNodeValue(this,"state");
             if(!enabled || enabled == "false")
                 return true;
         }
@@ -133,10 +133,10 @@
             }
             catch(e) {}
         }
-        var name = (chrome || firefox || safari3plus) ? this.attributes["name"].nodeValue : this.name;
+        var name = getAttributeNodeValue(this,"name");
         if(name.indexOf("Sub:") != 0)
         {
-            var enabled = (chrome || firefox || safari3plus) ? this.attributes["state"].nodeValue : this.state;
+            var enabled = getAttributeNodeValue(this,"state");
             if(!enabled || enabled == "false")
                 return true;
         }
@@ -279,9 +279,9 @@
     var menuObj = tgt == null? null: tgt.menuObj;
     if(menuObj != null)
     {
-        var state = (chrome || firefox || safari3plus) ? tgt.attributes["state"].nodeValue : tgt.state;
+        var state = getAttributeNodeValue(tgt,"state");
        if(!(!state || state == "false"))
-           executeOption(menuObj, (chrome || firefox || safari3plus) ? tgt.attributes["name"].nodeValue : tgt.name);
+           executeOption(menuObj, getAttributeNodeValue(tgt,"name"));
         return true;
     }
     else
@@ -377,10 +377,10 @@
         if(obj == null)
             break;
 
-        var name = (chrome || firefox || safari3plus) ? obj.attributes["name"].nodeValue : obj.name;
+        var name = getAttributeNodeValue(obj,"name");
         if(name.indexOf("Sub:") != 0)
         {
-            var state = (chrome || firefox || safari3plus) ? obj.attributes["state"].nodeValue : obj.state;
+            var state = getAttributeNodeValue(obj,"state");
             var enabled = true;
             if(menuObj.owner)
             {
@@ -399,7 +399,7 @@
                 obj.style.color = enabled? "black": "#b4b4b4";
                 var iconElt = document.getElementById("PMI" + name);
                 if(iconElt)
-                    iconElt.src = enabled ? ((chrome || firefox || safari3plus) ? obj.attributes["icon"].nodeValue : obj.icon) : ((chrome || firefox || safari3plus) ? obj.attributes["icond"].nodeValue : obj.icond);
+                    iconElt.src = enabled ? (getAttributeNodeValue(obj,"icon")) : (getAttributeNodeValue(obj,"icond"));
             }
          }
 

Modified: branches/2.2/MgDev/Web/src/viewerfiles/tasklist.templ
===================================================================
--- branches/2.2/MgDev/Web/src/viewerfiles/tasklist.templ	2010-07-14 16:15:23 UTC (rev 5028)
+++ branches/2.2/MgDev/Web/src/viewerfiles/tasklist.templ	2010-07-14 16:22:02 UTC (rev 5029)
@@ -116,14 +116,14 @@
     var bgcolor = "#dcdcdc";
     var color = "black";
 
-    var name = (chrome || firefox || safari3plus) ? obj.attributes["name"].nodeValue: obj.name;
+    var name = getAttributeNodeValue(obj,"name");
     try
     {
         owner.OnCommandSelected(name);
     }
     catch(e) {}
 
-    var enabled = ((chrome || firefox || safari3plus) ? obj.attributes["state"].nodeValue: obj.state) != "false";
+    var enabled = getAttributeNodeValue(obj,"state") != "false";
     if(!enabled)
     {
         bgcolor = "#f0f0f0";
@@ -150,7 +150,7 @@
         owner.OnCommandSelected(-1);
     } catch(e) {}
 
-    var enabled = ((chrome || firefox || safari3plus) ? obj.attributes["state"].nodeValue: obj.state) != "false";
+    var enabled = getAttributeNodeValue(obj,"state") != "false";
     if(!enabled)
     {
         bgcolor = "#f0f0f0";
@@ -239,7 +239,7 @@
 
 function OnClickItem(obj)
 {
-    var name = (chrome || firefox || safari3plus) ? obj.attributes["name"].nodeValue: obj.name;
+    var name = getAttributeNodeValue(obj,"name");
     try
     {
         owner.ExecuteCommand(name);



More information about the mapguide-commits mailing list