You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2009/09/07 13:45:44 UTC

svn commit: r812095 - /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js

Author: werpu
Date: Mon Sep  7 11:45:43 2009
New Revision: 812095

URL: http://svn.apache.org/viewvc?rev=812095&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2348

Fixed the eval issue, eval should now behave the same for evaluated
scripts over all platforms and browsers, thanks to scoping the eval itself
before actually calling eval.
(This is mostly a fix for browser bugs instead of a fix in our codebase)


Modified:
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js?rev=812095&r1=812094&r2=812095&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js Mon Sep  7 11:45:43 2009
@@ -330,7 +330,14 @@
             var styleEntries = value.split(";");
             for (var loop = 0; loop < styleEntries.length; loop++) {
                 var keyVal = styleEntries[loop].split(":");
-                if (keyVal[0] != "") {
+                if (keyVal[0] != "" && keyVal[0] == "opacity") {
+                  //special ie quirks handling for opacity
+                    
+                  var opacityVal = Math.max(100, Math.round(parseFloat( keyVal[1] ) * 10)); 
+                  domNode.style.setAttribute("filter","alpha(opacity="+opacityVal+")");
+                  //if you need more hacks I would recommend
+                  //to use the class attribute and conditional ie includes!
+                } else if (keyVal[0] != "") {
                     domNode.style.setAttribute(keyVal[0], keyVal[1]);
                 }
             }
@@ -514,13 +521,32 @@
      *
      */
     myfaces._impl._util._Utils.globalEval = function(code) {
-
-        if (window.execScript) {
+        //chrome as a diferent global eval, thanks for pointing this out
+        //TODO add a config param which allows to evaluate global scripts even if the call
+        //is embedded in an iframe
+        if (myfaces._impl._util._Utils.browser.isIE && window.execScript) {
+            //execScript definitely only for IE otherwise we might have a custom
+            //window extension with undefined behavior on our necks
             window.execScript(code);
             return;
-        }
-
-        eval.call(null, code);
+        } else if (undefined != typeof (window.eval) && null != window.eval) {
+            myfaces._impl._util._LangUtils.hitch (window, function() {
+            //even if we eval under a different scope the function this references
+            // another function instead of the window object on firefox in the evaled code
+            //Scoping the outer function ensures that the evaluated this points towards
+            //the window object instead of the calling function
+
+            //The funny thing is chrome references window as this without scoping the outer function
+            //Firefox does not and references the calling function as this pointer
+             window.eval.call(this, code);
+            })();
+            return;
+       }
+       myfaces._impl._util._LangUtils.hitch (window, function() {
+            //even if we eval under a different scope the function this references
+            // another function instead of the window object on firefox
+             eval.call(this, code);
+       })(); 
     }
 
     /**