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/06/04 09:12:46 UTC

svn commit: r1489302 - in /myfaces/tobago/branches/tobago-1.5.x/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: Tue Jun  4 07:12:46 2013
New Revision: 1489302

URL: http://svn.apache.org/r1489302
Log:
TOBAGO-1271: Javascript failure by partial reload of an tc:in with IE8 
 - backport from trunk

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

Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/pom.xml?rev=1489302&r1=1489301&r2=1489302&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/pom.xml (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/pom.xml Tue Jun  4 07:12:46 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,calendar.js,dateConverter.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,calendar.js,dateConverter.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/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml?rev=1489302&r1=1489301&r2=1489302&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml Tue Jun  4 07:12:46 2013
@@ -376,6 +376,7 @@
         <script name="script/dateConverter.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/branches/tobago-1.5.x/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/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-overlay.js?rev=1489302&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-overlay.js (added)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-overlay.js Tue Jun  4 07:12:46 2013
@@ -0,0 +1,135 @@
+/*
+ * 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.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/branches/tobago-1.5.x/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/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=1489302&r1=1489301&r2=1489302&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Tue Jun  4 07:12:46 2013
@@ -42,7 +42,7 @@ var TbgTimer = {
     LOG.debug('until appOnload ' + (this.startAppOnload.getTime() - this.startOnload.getTime())); // @DEV_ONLY
     LOG.debug('until scriptLoaders ' + (this.startScriptLoaders.getTime() - this.startOnload.getTime())); // @DEV_ONLY
     LOG.debug('time scriptLoaders ' + (this.endScriptLoaders.getTime() - this.startScriptLoaders.getTime())); // @DEV_ONLY
-    LOG.debug('until nach onload ' + (this.endOnload.getTime() - this.startTbgJs.getTime())); // @DEV_ONLY
+    LOG.debug('until after onload ' + (this.endOnload.getTime() - this.startTbgJs.getTime())); // @DEV_ONLY
     LOG.debug('total ' + totaljs); // @DEV_ONLY
   }
 };
@@ -257,10 +257,10 @@ var Tobago = {
   // -------- Functions -------------------------------------------------------
 
   /**
-   * Register a function to be excecuted on certain events.
+   * Register a function to be executed on certain events.
    * @param listener Function to be executed.
-   * @param phase The phase when code should be excecuted (e. g. Tobago.Phase.DOCUMENT_READY).
-   * @param order An optinal order to sort function they depent on others (default: Tobago.Phase.Order.NORMAL).
+   * @param phase The phase when code should be executed (e. g. Tobago.Phase.DOCUMENT_READY).
+   * @param order An optional order to sort function they depend on others (default: Tobago.Phase.Order.NORMAL).
    */
   registerListener: function(listener, phase, order) {
 
@@ -351,7 +351,7 @@ var Tobago = {
     Tobago.registerCurrentScripts();
     if (TbgTimer.endBody) { // @DEV_ONLY
       TbgTimer.startScriptLoaders = new Date(); // @DEV_ONLY
-  } // @DEV_ONLY
+    } // @DEV_ONLY
     Tobago.startScriptLoaders();
     if (TbgTimer.endBody) { // @DEV_ONLY
       TbgTimer.endScriptLoaders = new Date(); // @DEV_ONLY
@@ -407,126 +407,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();
-    overlay.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");
   },
 
   /**
@@ -543,7 +440,7 @@ var Tobago = {
       }
     }
 
-    // old:
+    // deprecated:
     if (this.isSubmit && this.applicationOnunload) {
       this.applicationOnunload();
     } else if (!this.isSubmit && this.applicationOnexit) {
@@ -670,7 +567,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
           }
@@ -1655,7 +1552,6 @@ Tobago.Config = {
   }
 };
 
-
 Tobago.Config.set("Tobago", "themeConfig", "standard/standard");
 
 Tobago.In = function(inId, required, requiredClass, maxLength) {
@@ -1810,7 +1706,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);
@@ -2163,9 +2059,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});
           }
         }
       }
@@ -2381,7 +2277,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') {
@@ -2389,12 +2285,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;
     }
   }