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/19 17:56:20 UTC

svn commit: r987201 - in /myfaces/tobago/trunk: tobago-example/tobago-example-demo/src/main/webapp/reference/ tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/ tobago-theme/to...

Author: lofwyr
Date: Thu Aug 19 15:56:19 2010
New Revision: 987201

URL: http://svn.apache.org/viewvc?rev=987201&view=rev
Log:
clean up initialization of javascript for normal load and AJAX load
 - png fix for ie6
 - using util method to select the whole DOM or the partial rendered sub tree

Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie_6_0/script/tobago.js
    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-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml?rev=987201&r1=987200&r2=987201&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml Thu Aug 19 15:56:19 2010
@@ -68,8 +68,8 @@
                 <f:selectItem itemLabel="B" itemValue="b"/>
               </tc:selectOneChoice>
               <tc:selectBooleanCheckbox value="#{reference.bool}"/>
-              <tc:in value="#{reference.text}" required="true"/>
-              <tx:date>
+              <tx:in label="In" value="#{reference.text}" required="true"/>
+              <tx:date label="Date">
                 <f:convertDateTime pattern="dd/MM/yyyy"/>
               </tx:date>
               <tc:image value="image/feather-leaf.png" width="16px" height="16px"/>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js?rev=987201&r1=987200&r2=987201&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js Thu Aug 19 15:56:19 2010
@@ -213,9 +213,7 @@ function xxx_tobagoMenuSwitchOff(menuBar
  */
 function xxx_tobagoMenuInit(elements) {
 
-  var menus = elements == null
-      ? jQuery(".tobago-menu-markup-top")
-      : elements.find(".tobago-menu-markup-top");
+  var menus = Tobago.selectWidthJQuery(elements, ".tobago-menu-markup-top");
 
   // a click on the top menu make the complete menu active or inactive respectively.
   menus.click(function(event) {
@@ -247,9 +245,8 @@ function xxx_tobagoMenuInit(elements) {
 
   jQuery(".tobago-page-menuStore").append(menus.children("ol"));
 
-  var toolBarMenu = elements == null
-      ? jQuery(".tobago-toolBar-menu .tobago-boxToolBar-menu .tobago-tabGroupToolBar-menu")
-      : elements.find(".tobago-toolBar-menu .tobago-boxToolBar-menu .tobago-tabGroupToolBar-menu");
+  var toolBarMenu = Tobago.selectWidthJQuery(
+      elements, ".tobago-toolBar-menu .tobago-boxToolBar-menu .tobago-tabGroupToolBar-menu");
   // a click on toolBar menu opener -> forward to .tobago-menu-markup-top
   toolBarMenu.click(function(event) {
     $(this).next().find('a').click();
@@ -257,9 +254,7 @@ function xxx_tobagoMenuInit(elements) {
   });
 
   // init context menus
-  var contextMenu = elements == null
-      ? jQuery(".tobago-menu-contextMenu")
-      : elements.find(".tobago-menu-contextMenu");
+  var contextMenu = Tobago.selectWidthJQuery(elements, ".tobago-menu-contextMenu");
   contextMenu.parent().bind("contextmenu", function(event) {
     jQuery(this).children(".tobago-menu-contextMenu").find('a').click();
     event.stopPropagation();

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie_6_0/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/msie_6_0/script/tobago.js?rev=987201&r1=987200&r2=987201&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie_6_0/script/tobago.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie_6_0/script/tobago.js Thu Aug 19 15:56:19 2010
@@ -20,19 +20,20 @@
  * agent: msie_6_0
  */
 
-Tobago.fixPngAlphaAll = function() {
+Tobago.fixPngAlphaAll = function(elements) {
   if (jQuery.browser.msie && parseInt(jQuery.browser.version) <= 6) {
     // fix png images
-    jQuery("img[src$='.png']").each(function() {
+    var images = Tobago.selectWidthJQuery(elements, "img[src$='.png']");
+    images.each(function() {
       Tobago.fixPngAlpha(this);
     });
 
     // fix png backgrounds of the labels
-    jQuery("label.tobago-label-markup-fatal, label.tobago-label-markup-error, "
-        + "label.tobago-label-markup-warn, label.tobago-label-markup-info").each(function() {
+    Tobago.selectWidthJQuery(elements,
+        "label.tobago-label-markup-fatal, label.tobago-label-markup-error, " +
+        "label.tobago-label-markup-warn, label.tobago-label-markup-info").each(function() {
       Tobago.fixBackgroundPngAlpha(this);
     });
-
   }
 };
 
@@ -92,9 +93,3 @@ Tobago.fixSelectionOnFocus = function() 
     // ignore
   }
 };
-
-// init /////////////////////////////////////////////////////////////////////////////////////////////
-
-$(document).ready(function() {
-  Tobago.fixPngAlphaAll();
-});

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=987201&r1=987200&r2=987201&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 Thu Aug 19 15:56:19 2010
@@ -1049,6 +1049,18 @@ var Tobago = {
     return "#" + id.replace(/:/g,"\\:");
   },
 
+  /**
+   * Helps to select either elements from the whole DOM or only find in sub trees
+   * (in the case of AJAX partial rendering)
+   * @param elements a jQuery object to initialize (ajax) or null for initializing the whole document (full load).
+   * @param selector a jQuery selector
+   */
+  selectWidthJQuery : function(elements, selector) {
+    return elements == null
+        ? jQuery(selector)
+        : elements.find(selector);
+  },
+
   calculateScrollbarWeights : function(id) {
     var hidden = jQuery(Tobago.escapeClientId(id));
     var outer = hidden.prev();
@@ -2291,7 +2303,6 @@ Tobago.Updater = {
         eval("updateScript = " + data.script);
         updateScript();
         xxx_tobagoInit(newElement);
-        Tobago.fixPngAlphaAll();
       } catch (e) {
         LOG.error("Error in doUpdate: " + e);
       }
@@ -2474,4 +2485,5 @@ TbgTimer.endTbgJs = new Date();
 
 function xxx_tobagoInit(elements) {
   xxx_tobagoMenuInit(elements);
+  Tobago.fixPngAlphaAll(elements);
 }