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 2011/02/15 10:32:37 UTC

svn commit: r1070822 - in /myfaces/tobago/trunk/tobago-theme: tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/st...

Author: lofwyr
Date: Tue Feb 15 09:32:37 2011
New Revision: 1070822

URL: http://svn.apache.org/viewvc?rev=1070822&view=rev
Log:
TOBAGO-881: fix "hover" for toolBar variants
TOBAGO-943: cleanup initialization

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
    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-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java?rev=1070822&r1=1070821&r2=1070822&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java Tue Feb 15 09:32:37 2011
@@ -176,7 +176,7 @@ public abstract class ToolBarRendererBas
           checked = false;
         }
 
-        String onClick = "tobago_toolBarSetRadioValue('" + radioId + "', '" + formattedValue + "');" + suffix;
+        String onClick = "Tobago.ToolBar.setRadioValue('" + radioId + "', '" + formattedValue + "');" + suffix;
         width = renderToolbarButton(facesContext, toolBar, command, writer, checked, onClick, null, width);
       }
 
@@ -208,7 +208,7 @@ public abstract class ToolBarRendererBas
     if (onClick == null) {
       onClick = "";
     }
-    onClick = "tobago_toolBarCheckToggle('" + clientId + "');" + onClick;
+    onClick = "Tobago.ToolBar.checkToggle('" + clientId + "');" + onClick;
 
     width = renderToolbarButton(facesContext, toolBar, command, writer, checked, onClick, null, width);
 

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=1070822&r1=1070821&r2=1070822&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 Tue Feb 15 09:32:37 2011
@@ -2506,27 +2506,30 @@ Tobago.Updater = {
 };
 
 // -------- ToolBar ----------------------------------------------------
-// todo: namespace etc.
 
-// todo: what is with initialisation of elements which are loaded with AJAX?
-$(document).ready(function() {
+Tobago.ToolBar = {};
+
+/**
+ * Initializes the tool bars.
+ * @param elements  a jQuery object to initialize (ajax) or null for initializing the whole document (full load).
+ */
+Tobago.ToolBar.init = function(elements) {
 
   // doing the same for 3 renderer names
-  var rendererNames = new Array('toolBar', 'boxToolBar', 'tabGroupToolBar');
-  for (var i = 0; i < rendererNames.length; i++) {
-    var renderer = rendererNames[i];
-    jQuery('.tobago-' + renderer + '-item')
-        .not('.tobago-' + renderer + '-item-markup-disabled')
+  // XXX put this in a loop (the first try doesn't work, because we can't use local variables in a anonymous function)
+
+    Tobago.selectWidthJQuery(elements, ".tobago-toolBar").find('.tobago-toolBar-item')
+        .not('.tobago-toolBar-item-markup-disabled')
         .mouseenter(function() {
-      jQuery(this).addClass('tobago-' + renderer + '-item-markup-hover');
+      jQuery(this).addClass('tobago-toolBar-item-markup-hover');
     })
         .mouseleave(function() {
-      jQuery(this).removeClass('tobago-' + renderer + '-item-markup-hover');
+      jQuery(this).removeClass('tobago-toolBar-item-markup-hover');
     })
-        .children('.tobago-' + renderer + '-button, .tobago-' + renderer + '-menu')
+        .children('.tobago-toolBar-button, .tobago-toolBar-menu')
         .mouseenter(function() {
       jQuery(this)
-          .addClass('tobago-' + renderer + '-button-markup-hover').children('img')
+          .addClass('tobago-toolBar-button-markup-hover').children('img')
           .each(function() {
         // set the src to the hover src url.
         var hover = jQuery(this).attr('srchover');
@@ -2537,7 +2540,40 @@ $(document).ready(function() {
     })
         .mouseleave(function() {
       jQuery(this)
-          .removeClass('tobago-' + renderer + '-button-markup-hover')
+          .removeClass('tobago-toolBar-button-markup-hover')
+          .children('img')
+          .each(function() {
+        // restore the original/normal src url.
+        var normal = jQuery(this).attr('srcdefault');
+        if (normal) {
+          jQuery(this).attr('src', normal);
+        }
+      });
+    });
+
+    Tobago.selectWidthJQuery(elements, ".tobago-boxToolBar").find('.tobago-boxToolBar-item')
+        .not('.tobago-boxToolBar-item-markup-disabled')
+        .mouseenter(function() {
+      jQuery(this).addClass('tobago-boxToolBar-item-markup-hover');
+    })
+        .mouseleave(function() {
+      jQuery(this).removeClass('tobago-boxToolBar-item-markup-hover');
+    })
+        .children('.tobago-boxToolBar-button, .tobago-boxToolBar-menu')
+        .mouseenter(function() {
+      jQuery(this)
+          .addClass('tobago-boxToolBar-button-markup-hover').children('img')
+          .each(function() {
+        // set the src to the hover src url.
+        var hover = jQuery(this).attr('srchover');
+        if (hover) {
+          jQuery(this).attr('src', hover);
+        }
+      });
+    })
+        .mouseleave(function() {
+      jQuery(this)
+          .removeClass('tobago-boxToolBar-button-markup-hover')
           .children('img')
           .each(function() {
         // restore the original/normal src url.
@@ -2547,24 +2583,57 @@ $(document).ready(function() {
         }
       });
     });
-  }
-});
 
-function tobago_toolBarCheckToggle(id) {
+    Tobago.selectWidthJQuery(elements, ".tobago-tabGroupToolBar").find('.tobago-tabGroupToolBar-item')
+        .not('.tobago-tabGroupToolBar-item-markup-disabled')
+        .mouseenter(function() {
+      jQuery(this).addClass('tobago-tabGroupToolBar-item-markup-hover');
+    })
+        .mouseleave(function() {
+      jQuery(this).removeClass('tobago-tabGroupToolBar-item-markup-hover');
+    })
+        .children('.tobago-tabGroupToolBar-button, .tobago-tabGroupToolBar-menu')
+        .mouseenter(function() {
+      jQuery(this)
+          .addClass('tobago-tabGroupToolBar-button-markup-hover').children('img')
+          .each(function() {
+        // set the src to the hover src url.
+        var hover = jQuery(this).attr('srchover');
+        if (hover) {
+          jQuery(this).attr('src', hover);
+        }
+      });
+    })
+        .mouseleave(function() {
+      jQuery(this)
+          .removeClass('tobago-tabGroupToolBar-button-markup-hover')
+          .children('img')
+          .each(function() {
+        // restore the original/normal src url.
+        var normal = jQuery(this).attr('srcdefault');
+        if (normal) {
+          jQuery(this).attr('src', normal);
+        }
+      });
+    });
+};
+
+Tobago.ToolBar.checkToggle = function(id) {
   var element = document.getElementById(id);
   element.value = 'true' == element.value ? 'false' : 'true';
-}
+};
 
-function tobago_toolBarSetRadioValue(id, value) {
+Tobago.ToolBar.setRadioValue = function(id, value) {
   var element = document.getElementById(id);
   element.value = value;
-}
+};
 
 // XXX write initialization
 
 function xxx_tobagoInit(elements) {
   Tobago.Menu.init(elements);
   Tobago.TabGroup.init(elements);
+  Tobago.ToolBar.init(elements);
   Tobago.fixPngAlphaAll(elements);
 }