You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/08/02 14:12:14 UTC

svn commit: r981476 - in /myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard: msie/script/tobago.js standard/script/tobago.js

Author: lofwyr
Date: Mon Aug  2 12:12:14 2010
New Revision: 981476

URL: http://svn.apache.org/viewvc?rev=981476&view=rev
Log:
TOBAGO-509: images doesn't show when in a tabbed pane not visible at page display
 - change implementation of the PNG fix

Modified:
    myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js
    myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js?rev=981476&r1=981475&r2=981476&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js Mon Aug  2 12:12:14 2010
@@ -16,17 +16,24 @@
  */
 
 Tobago.loadPngFix = function() {
-  var images = document.getElementsByTagName("img");
-  var supported = /MSIE (5\.5)|[6789]/.test(navigator.userAgent)
-      && navigator.platform == "Win32"
-      && Tobago.isActiveXEnabled();
-  if (! supported) {
-    return;
+  if (this.getBrowser().type == "msie" && this.getBrowser().version <= 6) {
+    var images = document.images;
+    for (var i = 0; i < images.length; i++) {
+      Tobago.fixPngAlpha(images[i]);
+    }
   }
-  for (var i = 0; i < images.length; i++) {
-    var image = images[i];
-    Tobago.fixImage(image);
-    Tobago.addEventListener(image, 'propertyChanged', Tobago.propertyChanged);
+};
+
+Tobago.fixPngAlpha = function(element) {
+  if (element.fixPngAlphaApplied != "applied") {
+    element.fixPngAlphaApplied = "applied";
+    if (this.getBrowser().type == "msie"
+        && this.getBrowser().version <= 6
+        && element.src.toLowerCase().match(/.*png/)
+        && Tobago.isActiveXEnabled()) {
+      Tobago.addEventListener(element, 'propertychange', Tobago.propertyChange);
+      Tobago.fixImage(element);
+    }
   }
 };
 
@@ -39,53 +46,24 @@ Tobago.isActiveXEnabled = function () {
   return true;
 };
 
-Tobago.propertyChanged = function() {
-  var pName = event.propertyName;
-  if (pName != "src") return;
-  // if not set to blank
-  if (! new RegExp(Tobago.pngFixBlankImage).test(src)) {
-    Tobago.fixImage(this);
+Tobago.propertyChange = function() {
+  if (event.propertyName != "src") {
+    return;
+  }
+  // if not set to blank (to avoid endless loop)
+  if (! new RegExp(Tobago.pngFixBlankImage).test(event.srcElement.src)) {
+    Tobago.fixImage(event.srcElement);
   }
 };
 
 Tobago.fixImage = function(element) {
-  // get src
-  var src = element.src;
-  // check for real change
-
-  if (src == element.realSrc) {
-    element.src = Tobago.pngFixBlankImage;
-    return;
-  }
-
-  if (! new RegExp(Tobago.pngFixBlankImage).test(src)) {
-    // backup old src
-    element.realSrc = src;
-  }
-
-  // test for png
-  if (element.realSrc != null &&
-      /\.png$/.test(element.realSrc.toLowerCase())) {
-    // get width and height of old src
-    var origWidth = element.clientWidth;
-    var origHeight = element.clientHeight;
-
-    // set blank image
-    element.src = Tobago.pngFixBlankImage;
-    // set filter
-
-    element.runtimeStyle.filter
-        = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
-        + src + "',sizingMethod='scale')";
-    element.style.width = origWidth + 'px';
-    element.style.height = origHeight + 'px';
-
-  } else {
-    // remove filter
-    element.runtimeStyle.filter = "";
-  }
+  element.runtimeStyle.backgroundImage = "none";
+  element.runtimeStyle.filter
+      = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + element.src + "', sizingMethod='scale')";
+  element.src = Tobago.pngFixBlankImage;
 };
 
+/* TOBAGO-789 */
 Tobago.fixSelectionOnFocusIn = function() {
   try {
     var src = window.event.srcElement;
@@ -93,17 +71,18 @@ Tobago.fixSelectionOnFocusIn = function(
       src.tmpIndex = src.selectedIndex;
     }
   } catch (e) {
-     // ignore
+    // ignore
   }
 };
 
+/* TOBAGO-789 */
 Tobago.fixSelectionOnFocus = function() {
   try {
     var src = window.event.srcElement;
     if (src) {
       src.selectedIndex = src.tmpIndex;
-     }
+    }
   } catch (e) {
     // ignore
   }
-};
\ No newline at end of file
+};

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=981476&r1=981475&r2=981476&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Mon Aug  2 12:12:14 2010
@@ -340,16 +340,10 @@ var Tobago = {
     var overlay = Tobago.element(Tobago.page.id + "-overlay");
     if (overlay) {
       var img = document.createElement("IMG");
-      img.style.width = overlay.clientWidth;
-      img.style.height = overlay.clientHeight;
-      if (!Tobago.fixImage) { // is not IE
-        img.src = Tobago.OVERLAY_BACKGROUND;
-      } else {
-        // todo: not needed for IE 7
-        img.src = Tobago.pngFixBlankImage;
-        img.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
-            + Tobago.OVERLAY_BACKGROUND + "',sizingMethod='scale')";
-      }
+      img.style.width = "100%";
+      img.style.height = "100%";
+      img.src = Tobago.OVERLAY_BACKGROUND;
+      Tobago.fixPngAlpha(img);
       overlay.appendChild(img);
     }
   },
@@ -1757,6 +1751,10 @@ var Tobago = {
   loadPngFix: function() {
   },
 
+  fixPngAlpha: function(element) {
+    // we need only an implementation in the IE6 file.
+  },
+
   getBrowser: function() {
     if (!this.browser) {
       var agent = navigator.userAgent.toLowerCase();
@@ -2284,6 +2282,7 @@ Tobago.Updater = {
         if (Tobago.isFunction(onComplete)) {
           try {
             onComplete(transport, json);
+            Tobago.loadPngFix();
           } catch(e) {
             LOG.show();
             LOG.warn(e);