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 2013/05/31 15:40:02 UTC

svn commit: r1488212 - in /myfaces/tobago/trunk/tobago-theme/tobago-theme-standard: ./ src/main/resources/META-INF/ src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/

Author: lofwyr
Date: Fri May 31 13:40:02 2013
New Revision: 1488212

URL: http://svn.apache.org/r1488212
Log:
TOBAGO-1271: Javascript failure by partial reload of an tc:in with IE8
 - reimplementation with widget factory

Added:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-overlay.js
Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml?rev=1488212&r1=1488211&r2=1488212&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml Fri May 31 13:40:02 2013
@@ -60,7 +60,7 @@
             <configuration>
               <target>
                 <concat destfile="${project.build.directory}/javascript-min/standard/script/tobago.min.js">
-                  <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script" files="tobago.js,tobago-calendar.js,tobago-converter.js,tobago-in.js,tobago-menu.js,tobago-popup.js,tobago-sheet.js,tobago-tree.js,tobago-utils.js" />
+                  <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script" files="tobago.js,tobago-calendar.js,tobago-converter.js,tobago-in.js,tobago-menu.js,tobago-overlay.js,tobago-popup.js,tobago-sheet.js,tobago-tree.js,tobago-utils.js" />
                 </concat>
                 <concat destfile="${project.build.directory}/javascript-min/msie_6_0/script/tobago.min.js">
                   <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie_6_0/script" files="tobago.js" />

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml?rev=1488212&r1=1488211&r2=1488212&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml Fri May 31 13:40:02 2013
@@ -365,6 +365,9 @@
       </renderers>
       <resources production="true">
         <script name="script/jquery-1.8.2.js"/>
+<!--
+        <script name="script/jquery-1.10.0.js"/>
+-->
         <script name="script/jquery-ui-1.10.3.custom.js"/>
         <script name="script/tobago.js"/>
         <style name="style/tobago.css"/>
@@ -373,12 +376,16 @@
       </resources>
       <resources production="false">
         <script name="script/jquery-1.8.2.js"/>
+<!--
+        <script name="script/jquery-1.10.0.js"/>
+-->
         <script name="script/jquery-ui-1.10.3.custom.js"/>
         <script name="script/tobago.js"/>
         <script name="script/tobago-calendar.js"/>
         <script name="script/tobago-converter.js"/>
         <script name="script/tobago-in.js"/>
         <script name="script/tobago-menu.js"/>
+        <script name="script/tobago-overlay.js"/>
         <script name="script/tobago-popup.js"/>
         <script name="script/tobago-sheet.js"/>
         <script name="script/tobago-tree.js"/>

Added: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-overlay.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-overlay.js?rev=1488212&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-overlay.js (added)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-overlay.js Fri May 31 13:40:02 2013
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Create a overlay barrier and animate it.
+ */
+(function ($) {
+
+  $.widget("tobago.overlay", {
+
+    options: {
+      /**
+       * This boolean indicates, if the overlay is "error" or "wait".
+       */
+      error: false,
+      /**
+       * Is this overlay for an AJAX request, or an normal submit?
+       * We need this information, because AJAX need to clone the animated image, but for a normal submit
+       * we must not clone it, because the animation stops in some browsers.
+       */
+      ajax: false
+    },
+
+    overlay: null,
+
+    _create: function () {
+
+      // create the overlay
+
+      this.overlay = jQuery("<div>").addClass("tobago-page-overlay");
+      if (this.options.error) {
+        this.overlay.addClass("tobago-page-overlay-markup-error");
+      } else {
+        this.overlay.addClass("tobago-page-overlay-markup-wait");
+      }
+
+      //      this.element.data("tobago-overlay", this.overlay);
+
+      this.overlay.outerWidth(this.element.outerWidth());
+      this.overlay.outerHeight(this.element.outerHeight());
+      this.overlay.offset(this.element.offset());
+
+      jQuery(".tobago-page-menuStore").append(this.overlay);
+
+      var wait = jQuery("<div>").addClass("tobago-page-overlayCenter");
+      this.overlay.append(wait);
+
+      var image = jQuery(this.options.error
+          ? "body>.tobago-page-overlayErrorPreloadedImage"
+          : "body>.tobago-page-overlayWaitPreloadedImage");
+
+      // in case of AJAX, we may need more of these objects, on the other side, on an normal submit
+      // the animation stops, if we use the clone (don't know why, seems to be needed only in WebKit)
+      if (this.options.ajax) {
+        image = image.clone();
+      }
+
+      image.appendTo(wait);
+      image.removeClass(this.options.error
+          ? "tobago-page-overlayErrorPreloadedImage"
+          : "tobago-page-overlayWaitPreloadedImage");
+      wait.show();
+
+      this.overlay.css({
+        backgroundColor: jQuery('.tobago-page').css("background-color"),
+        filter: 'alpha(opacity=80)', //IE
+        opacity: 0})
+          .show()
+          .delay(this.options.error ? 0 : 1000)
+          .animate({opacity: '0.8'}, this.options.error ? 0 : 250, "linear", function () {
+
+            // fix for IE6: reset the src attribute to enable animation
+            if (Tobago.browser.isMsie6) {
+              image.attr("src", image.attr("src"));
+            }
+          });
+
+      // create an iframe for IE6
+
+      if (Tobago.browser.isMsie6) {
+        var iframe = jQuery("<iframe>").addClass("tobago-page-overlay-ie6bugfix");
+        iframe.prop("frameBorder", 0);
+        iframe.attr("src", Tobago.blankPage);
+        iframe.css({
+          position: 'absolute',
+          top: '0px',
+          left: '0px',
+          width: this.overlay.width() + 'px',
+          height: this.overlay.height() + 'px'
+        });
+        this.overlay.append(iframe);
+      }
+    },
+
+    _setOption: function (key, value) {
+
+      switch (key) {
+        case "error":
+          // If the error property has been changed, recreate the overlay.
+          var changed = key == 'error' && value != this.options.error;
+          if (changed) {
+            this.options.error = value;
+            this._destroy();
+            this._create();
+          }
+          break;
+        case "ajax":
+          // Changing of the ajax property seems not to make sense and is not supported.
+          break;
+      }
+
+      this._super("_setOption", key, value);
+
+    },
+
+    _destroy: function () {
+      this.overlay.remove();
+      this.overlay = null;
+    }
+
+  });
+
+}(jQuery));

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=1488212&r1=1488211&r2=1488212&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Fri May 31 13:40:02 2013
@@ -413,125 +413,23 @@ var Tobago = {
 
   onBeforeUnload: function() {
     if (Tobago.transition) {
-      Tobago.createOverlay(jQuery("body"), false, false);
+      jQuery("body").overlay();
     }
     Tobago.transition = Tobago.oldTransition;
   },
 
   /**
-   * Create a overlay barrier and animate it.
-   * @param element A jQuery element, must be only one single element.
+   * @deprecated
    */
-  createOverlay:function (element, error, ajax) {
-
-    // is not a jQuery object? XXX Support of non jQuery objects is deprecated since Tobago 1.5.1
-    if (element == null || typeof element.size != "function") {
-      element = Tobago.element(element);
-      if (!element) {
-        LOG.warn('no element to create overlay'); // @DEV_ONLY
-        return;
-      }
-      element = jQuery(element);
-      LOG.warn('Deprecation: Please call createOverlay() with a jQuery object.'); // @DEV_ONLY
-    }
-
-    if (element.children(".tobago-page-overlay").size() > 0) {
-
-      // is this an error overlay?
-      if (element.children(".tobago-page-overlay-markup-error").size() > 0) {
-        Tobago.deleteOverlay(element);
-      } else {
-        LOG.warn('There is already a overlay barrier'); // @DEV_ONLY
-        return;
-      }
-    }
-
-    Tobago.ie6bugfix(element.get(0));
-
-    var overlay = error
-        ? jQuery("<div class='tobago-page-overlay tobago-page-overlay-markup-error'></div>")
-        : jQuery("<div class='tobago-page-overlay tobago-page-overlay-markup-wait'></div>");
-    element.append(overlay);
-    var wait = jQuery("<div class='tobago-page-overlayCenter'></div>");
-    overlay.append(wait);
-    var image = jQuery(error
-        ? "body > .tobago-page-overlayErrorPreloadedImage"
-        : "body > .tobago-page-overlayWaitPreloadedImage");
-    // in case of AJAX, we may need more of these objects, on the other side, on an normal submit
-    // the animation stops, if we use the clone (don't know why, seems to be needed only in WebKit)
-    if (ajax) {
-      image = image.clone();
-    }
-    image.appendTo(wait).removeClass("tobago-page-overlayWaitPreloadedImage tobago-page-overlayErrorPreloadedImage");
-    wait.show();
-
-    if (Tobago.browser.isMsie6) {
-      element.children(".tobago-page-overlay")
-          .css({
-            width:element.css("width"),
-            height:element.css("height")});
-    }
-
-    element.children(".tobago-page-overlay")
-        .css({
-          backgroundColor:jQuery('.tobago-page').css("background-color"),
-          filter:'alpha(opacity=80)', //IE
-          opacity:0})
-        .show()
-        .delay(error ? 0 : 1000)
-        .animate({opacity:'0.8'}, error ? 0 : 250, "linear", function () {
-
-          // fix for IE6: reset the src attribute to enable animation
-          if (Tobago.browser.isMsie6) {
-              image.attr("src", image.attr("src"));
-          }
-        });
+  createOverlay: function (element, error, ajax) {
+    element.overlay({error: error, ajax: ajax});
   },
 
   /**
-   * Removes the overlay barrier.
-   * @param element A jQuery element.
+   * @deprecated
    */
   deleteOverlay:function (element) {
-
-    // is not a jQuery object? XXX Support of non jQuery objects is deprecated since Tobago 1.5.1
-    if (element == null || typeof element.size != "function") {
-      element = Tobago.element(element);
-      if (!element) {
-        LOG.warn('no element to create overlay'); // @DEV_ONLY
-        return;
-      }
-      element = jQuery(element);
-      LOG.warn('Deprecation: Please call deleteOverlay() with a jQuery object.'); // @DEV_ONLY
-    }
-
-    element.children(".tobago-page-overlay").remove();
-
-    element.children(".tobago-page-overlay-ie6bugfix").remove();
-  },
-
-  ie6bugfix: function(element) {
-    if (Tobago.browser.isMsie6) {
-
-      if (jQuery(element).children(".tobago-page-overlay-ie6bugfix").size() > 0) {
-        return; // ignore
-      }
-
-      var iframe = document.createElement('IFRAME');
-      iframe.id = element.id + '-iframe-overlay';
-      iframe.className = 'tobago-page-overlay-ie6bugfix';
-      iframe.style.backgroundColor = 'red';
-      iframe.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
-      iframe.style.zIndex = 9999;
-      iframe.frameBorder = '0';
-      iframe.style.position = 'absolute';
-      iframe.src = Tobago.blankPage;
-      iframe.style.top = '0px';
-      iframe.style.left = '0px';
-      iframe.style.width = element.scrollWidth + 'px';
-      iframe.style.height = element.scrollHeight + 'px';
-      element.appendChild(iframe);
-    }
+    element.overlay("destroy");
   },
 
   /**
@@ -677,7 +575,7 @@ var Tobago = {
               image.appendTo(image.parent());
             }
           } catch (e) {
-            Tobago.deleteOverlay(jQuery("body"));
+            jQuery("body").overlay("destroy");
             Tobago.isSubmit = false;
             alert('Submit failed: ' + e); // XXX localization, better error handling
           }
@@ -1865,7 +1763,7 @@ Tobago.Panel.prototype.reloadWithAction 
 };
 
 Tobago.Panel.prototype.prepareReload = function() {
-  Tobago.createOverlay(jQuery(Tobago.Utils.escapeClientId(this.id)), false, true);
+  jQuery(Tobago.Utils.escapeClientId(this.id)).overlay({error: false, ajax: true});
 };
 
 Tobago.registerListener(Tobago.Panel.init, Tobago.Phase.DOCUMENT_READY);
@@ -2221,9 +2119,9 @@ Tobago.Updater = {
           if (container && typeof container.prepareReload == 'function') {
             container.prepareReload();
           } else if (container) {
-            Tobago.createOverlay(container, false, true);
+            container.overlay({error: false, ajax: true});
           } else {
-            Tobago.createOverlay(jQuery(Tobago.Utils.escapeClientId(id)), false, true);
+            jQuery(Tobago.Utils.escapeClientId(id)).overlay({error: false, ajax: true});
           }
         }
       }
@@ -2445,7 +2343,7 @@ Tobago.Updater = {
         if (typeof this.afterDoUpdateNotModified == 'function') {
           this.afterDoUpdateNotModified();
         }
-        Tobago.deleteOverlay(overlay);
+        overlay.overlay("destroy");
         break;
       case Tobago.Updater.CODE_ERROR:
         if (typeof this.afterDoUpdateError == 'function') {
@@ -2453,12 +2351,12 @@ Tobago.Updater = {
         }
         // XXX Here also a double click will be logged, but "warn" is not appropriate.
         LOG.warn("ERROR 500 when updating component id = '" + data.ajaxId + "'"); // @DEV_ONLY
-        Tobago.deleteOverlay(overlay);
-        Tobago.createOverlay(overlay, true, true); // error overlay
+//        overlay.overlay("destroy");
+        overlay.overlay({error: true, ajax: true});
         break;
       default:
         LOG.error('Unknown response code: ' + data.responseCode + " for component id = '" + data.ajaxId + "'"); // @DEV_ONLY
-        Tobago.deleteOverlay(overlay);
+        overlay.overlay("destroy");
         break;
     }
   }