aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.tabs.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-04-28 14:38:57 -0400
committerScott González <scott.gonzalez@gmail.com>2011-04-28 14:38:57 -0400
commit09faa7c9fa6d16313485d727e3943303c0181ebf (patch)
treed777b12906dd4b40cd18dca183bd1ed8acc7b7e9 /ui/jquery.ui.tabs.js
parent5d23e8eacd95b0bcb859c4303a39709ef8a4dc86 (diff)
downloadjquery-ui-09faa7c9fa6d16313485d727e3943303c0181ebf.tar.gz
jquery-ui-09faa7c9fa6d16313485d727e3943303c0181ebf.zip
Tabs: Added more tests for refresh method and changed the implementation a bit.
Diffstat (limited to 'ui/jquery.ui.tabs.js')
-rwxr-xr-xui/jquery.ui.tabs.js36
1 files changed, 14 insertions, 22 deletions
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index c7483e0de..490ca71a3 100755
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -172,51 +172,43 @@ $.widget( "ui.tabs", {
refresh: function() {
var self = this,
options = this.options,
- lis = $( " > li:has(a[href])", this.list );
+ lis = this.list.children( ":has(a[href])" );
- // Get disabled tabs from class attribute from HTML
- options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( n ) {
- return lis.index( n );
+ // get disabled tabs from class attribute from HTML
+ // this will get converted to a boolean if needed in _refresh()
+ options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
+ return lis.index( tab );
});
this._processTabs();
-
this._refresh();
-
- // Remove panels that we created that are missing their tab
- this.element.find(".ui-tabs-panel:data(destroy.tabs)").each( function( index, panel ) {
- var anchor = self.anchors.filter( "[aria-controls='" + panel.id + "']");
- if ( !anchor.length ) {
- $( panel ).remove();
- }
- });
-
this.panels.not( this._getPanelForTab( this.active ) ).hide();
- if ( !this.anchors.length ) {
+ // was collapsed or no tabs
+ if ( options.active === false || !this.anchors.length ) {
options.active = false;
this.active = $();
- } else if ( !this.active || ( this.active && !$.contains( this.list[ 0 ], this.active[ 0 ] ) ) ) {
- // Activate previous tab
+ // was active, but active tab is gone
+ } else if ( this.active.length && !$.contains( this.list[ 0 ], this.active[ 0 ] ) ) {
+ // activate previous tab
var next = options.active - 1;
this._activate( next >= 0 ? next : 0 );
+ // was active, active tab still exists
} else {
- // Make sure active index is correct
+ // make sure active index is correct
options.active = this.anchors.index( this.active );
}
},
_refresh: function() {
- var that = this,
- options = that.options;
+ var options = this.options;
this.element.toggleClass( "ui-tabs-collapsible", options.collapsible );
- this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
+ this.list.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
this.lis.addClass( "ui-state-default ui-corner-top" );
this.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" );
this._setupDisabled( options.disabled );
-
this._setupEvents( options.event );
// remove all handlers, may run on existing tabs