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/06/10 14:28:58 UTC
svn commit: r1134292 -
/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Author: lofwyr
Date: Fri Jun 10 12:28:57 2011
New Revision: 1134292
URL: http://svn.apache.org/viewvc?rev=1134292&view=rev
Log:
TOBAGO-889: New TabGroup
- in case of the tabs needs too much space, the tabs has to scroll to view the selected tab
Modified:
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/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=1134292&r1=1134291&r2=1134292&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 Jun 10 12:28:57 2011
@@ -3062,8 +3062,11 @@ Tobago.TabGroup.init = function(elements
jQuery(this).addClass("tobago-tab-markup-selected");
var tabGroup = jQuery(this).parents(".tobago-tabGroup:first");
tabGroup.children(".tobago-tab-content-markup-selected").removeClass("tobago-tab-content-markup-selected");
- tabGroup.children(".tobago-tab-content[tabgroupindex=" + activeIndex
- + "]").addClass("tobago-tab-content-markup-selected");
+ tabGroup.children(".tobago-tab-content[tabgroupindex=" + activeIndex + "]")
+ .addClass("tobago-tab-content-markup-selected");
+ // scroll the tabs, if necessary
+ var header = jQuery(this).parents(".tobago-tabGroup-header:first");
+ Tobago.TabGroup.ensureScrollPosition(header);
});
// initialize the tab header elements
@@ -3102,6 +3105,12 @@ Tobago.TabGroup.init = function(elements
selected.nextAll(":not(.tobago-tab-markup-disabled):first").click();
});
+ // init scroll position
+ var header = tabGroups.find(".tobago-tabGroup-header");
+ header.each(function() {
+ Tobago.TabGroup.ensureScrollPosition(jQuery(this));
+ });
+
// initialize menu
// XXX ":last" is dangerous, please define e.g. a unique class for "menu"
// tabGroups.find(".tobago-tabGroupToolBar-button:last").find(".tobago-menu").click(function() {
@@ -3127,6 +3136,18 @@ Tobago.TabGroup.updateHidden = function(
return activeIndex;
};
+Tobago.TabGroup.ensureScrollPosition = function (header) {
+ var tab = header.find(".tobago-tab-markup-selected");
+ var tabRight = tab.position().left + tab.outerWidth() - header.outerWidth();
+ if (tabRight > 0) {
+ header.scrollLeft(header.scrollLeft() + tabRight + 1); // +1 to avoid rounding problems
+ }
+ var tabLeft = tab.position().left;
+ if (tabLeft < 0) {
+ header.scrollLeft(header.scrollLeft() + tabLeft);
+ }
+};
+
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TbgTimer.endTbgJs = new Date(); // @DEV_ONLY