mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Tabs: Rename internal properties.
This commit is contained in:
parent
4aafdfd10b
commit
9e805c0384
74
ui/jquery.ui.tabs.js
vendored
74
ui/jquery.ui.tabs.js
vendored
@ -90,18 +90,18 @@ $.widget( "ui.tabs", {
|
|||||||
|
|
||||||
// check for a tab marked active via a class
|
// check for a tab marked active via a class
|
||||||
if ( active === null ) {
|
if ( active === null ) {
|
||||||
active = this.lis.filter( ".ui-tabs-active" ).index();
|
active = this.tabs.filter( ".ui-tabs-active" ).index();
|
||||||
}
|
}
|
||||||
|
|
||||||
// no active tab, set to false
|
// no active tab, set to false
|
||||||
if ( active === null || active === -1 ) {
|
if ( active === null || active === -1 ) {
|
||||||
active = this.lis.length ? 0 : false;
|
active = this.tabs.length ? 0 : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle numbers: negative, out of range
|
// handle numbers: negative, out of range
|
||||||
if ( active !== false ) {
|
if ( active !== false ) {
|
||||||
active = this.lis.eq( active ).index();
|
active = this.tabs.eq( active ).index();
|
||||||
if ( active === -1 ) {
|
if ( active === -1 ) {
|
||||||
active = options.collapsible ? false : 0;
|
active = options.collapsible ? false : 0;
|
||||||
}
|
}
|
||||||
@ -117,8 +117,8 @@ $.widget( "ui.tabs", {
|
|||||||
// into account and update option properly.
|
// into account and update option properly.
|
||||||
if ( $.isArray( options.disabled ) ) {
|
if ( $.isArray( options.disabled ) ) {
|
||||||
options.disabled = $.unique( options.disabled.concat(
|
options.disabled = $.unique( options.disabled.concat(
|
||||||
$.map( this.lis.filter( ".ui-state-disabled" ), function( li ) {
|
$.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
|
||||||
return that.lis.index( li );
|
return that.tabs.index( li );
|
||||||
})
|
})
|
||||||
) ).sort();
|
) ).sort();
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ $.widget( "ui.tabs", {
|
|||||||
|
|
||||||
_tabKeydown: function( event ) {
|
_tabKeydown: function( event ) {
|
||||||
var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
|
var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
|
||||||
selectedIndex = this.lis.index( focusedTab ),
|
selectedIndex = this.tabs.index( focusedTab ),
|
||||||
goingForward = true;
|
goingForward = true;
|
||||||
|
|
||||||
if ( this._handlePageNav( event ) ) {
|
if ( this._handlePageNav( event ) ) {
|
||||||
@ -197,7 +197,7 @@ $.widget( "ui.tabs", {
|
|||||||
// Otherwise AT may confuse the user by stating that they need to activate the tab,
|
// Otherwise AT may confuse the user by stating that they need to activate the tab,
|
||||||
// but the tab will already be activated by the time the announcement finishes.
|
// but the tab will already be activated by the time the announcement finishes.
|
||||||
focusedTab.attr( "aria-selected", "false" );
|
focusedTab.attr( "aria-selected", "false" );
|
||||||
this.lis.eq( selectedIndex ).attr( "aria-selected", "true" );
|
this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
|
||||||
|
|
||||||
this.activating = this._delay(function() {
|
this.activating = this._delay(function() {
|
||||||
this.option( "active", selectedIndex );
|
this.option( "active", selectedIndex );
|
||||||
@ -230,7 +230,7 @@ $.widget( "ui.tabs", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_focusNextTab: function( index, goingForward ) {
|
_focusNextTab: function( index, goingForward ) {
|
||||||
var lastTabIndex = this.lis.length - 1;
|
var lastTabIndex = this.tabs.length - 1;
|
||||||
|
|
||||||
function constrain() {
|
function constrain() {
|
||||||
if ( index > lastTabIndex ) {
|
if ( index > lastTabIndex ) {
|
||||||
@ -246,7 +246,7 @@ $.widget( "ui.tabs", {
|
|||||||
index = goingForward ? index + 1 : index - 1;
|
index = goingForward ? index + 1 : index - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lis.eq( index ).focus();
|
this.tabs.eq( index ).focus();
|
||||||
return index;
|
return index;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ $.widget( "ui.tabs", {
|
|||||||
refresh: function() {
|
refresh: function() {
|
||||||
var next,
|
var next,
|
||||||
options = this.options,
|
options = this.options,
|
||||||
lis = this.list.children( ":has(a[href])" );
|
lis = this.tablist.children( ":has(a[href])" );
|
||||||
|
|
||||||
// get disabled tabs from class attribute from HTML
|
// get disabled tabs from class attribute from HTML
|
||||||
// this will get converted to a boolean if needed in _refresh()
|
// this will get converted to a boolean if needed in _refresh()
|
||||||
@ -308,14 +308,14 @@ $.widget( "ui.tabs", {
|
|||||||
options.active = false;
|
options.active = false;
|
||||||
this.active = $();
|
this.active = $();
|
||||||
// was active, but active tab is gone
|
// was active, but active tab is gone
|
||||||
} else if ( this.active.length && !$.contains( this.list[ 0 ], this.active[ 0 ] ) ) {
|
} else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
|
||||||
// activate previous tab
|
// activate previous tab
|
||||||
next = options.active - 1;
|
next = options.active - 1;
|
||||||
this._activate( next >= 0 ? next : 0 );
|
this._activate( next >= 0 ? next : 0 );
|
||||||
// was active, active tab still exists
|
// was active, active tab still exists
|
||||||
} else {
|
} else {
|
||||||
// make sure active index is correct
|
// make sure active index is correct
|
||||||
options.active = this.lis.index( this.active );
|
options.active = this.tabs.index( this.active );
|
||||||
}
|
}
|
||||||
|
|
||||||
this._refresh();
|
this._refresh();
|
||||||
@ -326,7 +326,7 @@ $.widget( "ui.tabs", {
|
|||||||
this._setupEvents( this.options.event );
|
this._setupEvents( this.options.event );
|
||||||
this._setupHeightStyle( this.options.heightStyle );
|
this._setupHeightStyle( this.options.heightStyle );
|
||||||
|
|
||||||
this.lis.not( this.active ).attr({
|
this.tabs.not( this.active ).attr({
|
||||||
"aria-selected": "false",
|
"aria-selected": "false",
|
||||||
tabIndex: -1
|
tabIndex: -1
|
||||||
});
|
});
|
||||||
@ -339,7 +339,7 @@ $.widget( "ui.tabs", {
|
|||||||
|
|
||||||
// Make sure one tab is in the tab order
|
// Make sure one tab is in the tab order
|
||||||
if ( !this.active.length ) {
|
if ( !this.active.length ) {
|
||||||
this.lis.eq( 0 ).attr( "tabIndex", 0 );
|
this.tabs.eq( 0 ).attr( "tabIndex", 0 );
|
||||||
} else {
|
} else {
|
||||||
this.active
|
this.active
|
||||||
.addClass( "ui-tabs-active ui-state-active" )
|
.addClass( "ui-tabs-active ui-state-active" )
|
||||||
@ -359,18 +359,18 @@ $.widget( "ui.tabs", {
|
|||||||
_processTabs: function() {
|
_processTabs: function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
this.list = this._getList()
|
this.tablist = this._getList()
|
||||||
.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
|
.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
|
||||||
.attr( "role", "tablist" );
|
.attr( "role", "tablist" );
|
||||||
|
|
||||||
this.lis = this.list.find( "> li:has(a[href])" )
|
this.tabs = this.tablist.find( "> li:has(a[href])" )
|
||||||
.addClass( "ui-state-default ui-corner-top" )
|
.addClass( "ui-state-default ui-corner-top" )
|
||||||
.attr({
|
.attr({
|
||||||
role: "tab",
|
role: "tab",
|
||||||
tabIndex: -1
|
tabIndex: -1
|
||||||
});
|
});
|
||||||
|
|
||||||
this.anchors = this.lis.map(function() {
|
this.anchors = this.tabs.map(function() {
|
||||||
return $( "a", this )[ 0 ];
|
return $( "a", this )[ 0 ];
|
||||||
})
|
})
|
||||||
.addClass( "ui-tabs-anchor" )
|
.addClass( "ui-tabs-anchor" )
|
||||||
@ -398,7 +398,7 @@ $.widget( "ui.tabs", {
|
|||||||
panel = that.element.find( selector );
|
panel = that.element.find( selector );
|
||||||
if ( !panel.length ) {
|
if ( !panel.length ) {
|
||||||
panel = that._createPanel( panelId );
|
panel = that._createPanel( panelId );
|
||||||
panel.insertAfter( that.panels[ i - 1 ] || that.list );
|
panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
|
||||||
}
|
}
|
||||||
panel.attr( "aria-live", "polite" );
|
panel.attr( "aria-live", "polite" );
|
||||||
}
|
}
|
||||||
@ -443,7 +443,7 @@ $.widget( "ui.tabs", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// disable tabs
|
// disable tabs
|
||||||
for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
|
for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
|
||||||
if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
|
if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
|
||||||
$( li )
|
$( li )
|
||||||
.addClass( "ui-state-disabled" )
|
.addClass( "ui-state-disabled" )
|
||||||
@ -470,13 +470,13 @@ $.widget( "ui.tabs", {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.anchors.add( this.lis ).add( this.panels ).unbind( ".tabs" );
|
this.anchors.add( this.tabs ).add( this.panels ).unbind( ".tabs" );
|
||||||
this._bind( this.anchors, events );
|
this._bind( this.anchors, events );
|
||||||
this._bind( this.lis, { keydown: "_tabKeydown" } );
|
this._bind( this.tabs, { keydown: "_tabKeydown" } );
|
||||||
this._bind( this.panels, { keydown: "_panelKeydown" } );
|
this._bind( this.panels, { keydown: "_panelKeydown" } );
|
||||||
|
|
||||||
this._focusable( this.lis );
|
this._focusable( this.tabs );
|
||||||
this._hoverable( this.lis );
|
this._hoverable( this.tabs );
|
||||||
},
|
},
|
||||||
|
|
||||||
_setupHeightStyle: function( heightStyle ) {
|
_setupHeightStyle: function( heightStyle ) {
|
||||||
@ -553,7 +553,7 @@ $.widget( "ui.tabs", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
options.active = collapsing ? false : this.lis.index( tab );
|
options.active = collapsing ? false : this.tabs.index( tab );
|
||||||
|
|
||||||
this.active = clickedIsActive ? $() : tab;
|
this.active = clickedIsActive ? $() : tab;
|
||||||
if ( this.xhr ) {
|
if ( this.xhr ) {
|
||||||
@ -566,7 +566,7 @@ $.widget( "ui.tabs", {
|
|||||||
|
|
||||||
if ( toShow.length ) {
|
if ( toShow.length ) {
|
||||||
// TODO make passing in node possible
|
// TODO make passing in node possible
|
||||||
this.load( this.lis.index( tab ), event );
|
this.load( this.tabs.index( tab ), event );
|
||||||
}
|
}
|
||||||
this._toggle( event, eventData );
|
this._toggle( event, eventData );
|
||||||
},
|
},
|
||||||
@ -618,7 +618,7 @@ $.widget( "ui.tabs", {
|
|||||||
if ( toShow.length && toHide.length ) {
|
if ( toShow.length && toHide.length ) {
|
||||||
eventData.oldTab.attr( "tabIndex", -1 );
|
eventData.oldTab.attr( "tabIndex", -1 );
|
||||||
} else if ( toShow.length ) {
|
} else if ( toShow.length ) {
|
||||||
this.lis.filter(function() {
|
this.tabs.filter(function() {
|
||||||
return $( this ).attr( "tabIndex" ) === 0;
|
return $( this ).attr( "tabIndex" ) === 0;
|
||||||
})
|
})
|
||||||
.attr( "tabIndex", -1 );
|
.attr( "tabIndex", -1 );
|
||||||
@ -657,7 +657,7 @@ $.widget( "ui.tabs", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_findActive: function( index ) {
|
_findActive: function( index ) {
|
||||||
return index === false ? $() : this.lis.eq( index );
|
return index === false ? $() : this.tabs.eq( index );
|
||||||
},
|
},
|
||||||
|
|
||||||
_getIndex: function( index ) {
|
_getIndex: function( index ) {
|
||||||
@ -676,7 +676,7 @@ $.widget( "ui.tabs", {
|
|||||||
|
|
||||||
this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
|
this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
|
||||||
|
|
||||||
this.list
|
this.tablist
|
||||||
.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
|
.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
|
||||||
.removeAttr( "role" );
|
.removeAttr( "role" );
|
||||||
|
|
||||||
@ -689,7 +689,7 @@ $.widget( "ui.tabs", {
|
|||||||
.removeData( "load.tabs" )
|
.removeData( "load.tabs" )
|
||||||
.removeUniqueId();
|
.removeUniqueId();
|
||||||
|
|
||||||
this.lis.unbind( ".tabs" ).add( this.panels ).each(function() {
|
this.tabs.unbind( ".tabs" ).add( this.panels ).each(function() {
|
||||||
if ( $.data( this, "ui-tabs-destroy" ) ) {
|
if ( $.data( this, "ui-tabs-destroy" ) ) {
|
||||||
$( this ).remove();
|
$( this ).remove();
|
||||||
} else {
|
} else {
|
||||||
@ -715,7 +715,7 @@ $.widget( "ui.tabs", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.lis.each(function() {
|
this.tabs.each(function() {
|
||||||
var li = $( this ),
|
var li = $( this ),
|
||||||
prev = li.data( "ui-tabs-aria-controls" );
|
prev = li.data( "ui-tabs-aria-controls" );
|
||||||
if ( prev ) {
|
if ( prev ) {
|
||||||
@ -745,7 +745,7 @@ $.widget( "ui.tabs", {
|
|||||||
return num !== index ? num : null;
|
return num !== index ? num : null;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
disabled = $.map( this.lis, function( li, num ) {
|
disabled = $.map( this.tabs, function( li, num ) {
|
||||||
return num !== index ? num : null;
|
return num !== index ? num : null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -778,7 +778,7 @@ $.widget( "ui.tabs", {
|
|||||||
load: function( index, event ) {
|
load: function( index, event ) {
|
||||||
index = this._getIndex( index );
|
index = this._getIndex( index );
|
||||||
var that = this,
|
var that = this,
|
||||||
tab = this.lis.eq( index ),
|
tab = this.tabs.eq( index ),
|
||||||
anchor = tab.find( ".ui-tabs-anchor" ),
|
anchor = tab.find( ".ui-tabs-anchor" ),
|
||||||
panel = this._getPanelForTab( tab ),
|
panel = this._getPanelForTab( tab ),
|
||||||
eventData = {
|
eventData = {
|
||||||
@ -1016,7 +1016,7 @@ if ( $.uiBackCompat !== false ) {
|
|||||||
li.addClass( "ui-state-default ui-corner-top" ).data( "ui-tabs-destroy", true );
|
li.addClass( "ui-state-default ui-corner-top" ).data( "ui-tabs-destroy", true );
|
||||||
li.attr( "aria-controls", id );
|
li.attr( "aria-controls", id );
|
||||||
|
|
||||||
doInsertAfter = index >= this.lis.length;
|
doInsertAfter = index >= this.tabs.length;
|
||||||
|
|
||||||
// try to find an existing element before creating a new one
|
// try to find an existing element before creating a new one
|
||||||
panel = this.element.find( "#" + id );
|
panel = this.element.find( "#" + id );
|
||||||
@ -1035,9 +1035,9 @@ if ( $.uiBackCompat !== false ) {
|
|||||||
panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
|
panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
|
||||||
|
|
||||||
if ( doInsertAfter ) {
|
if ( doInsertAfter ) {
|
||||||
li.appendTo( this.list );
|
li.appendTo( this.tablist );
|
||||||
} else {
|
} else {
|
||||||
li.insertBefore( this.lis[ index ] );
|
li.insertBefore( this.tabs[ index ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
options.disabled = $.map( options.disabled, function( n ) {
|
options.disabled = $.map( options.disabled, function( n ) {
|
||||||
@ -1045,7 +1045,7 @@ if ( $.uiBackCompat !== false ) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
if ( this.lis.length === 1 && options.active === false ) {
|
if ( this.tabs.length === 1 && options.active === false ) {
|
||||||
this.option( "active", 0 );
|
this.option( "active", 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1056,7 +1056,7 @@ if ( $.uiBackCompat !== false ) {
|
|||||||
remove: function( index ) {
|
remove: function( index ) {
|
||||||
index = this._getIndex( index );
|
index = this._getIndex( index );
|
||||||
var options = this.options,
|
var options = this.options,
|
||||||
tab = this.lis.eq( index ).remove(),
|
tab = this.tabs.eq( index ).remove(),
|
||||||
panel = this._getPanelForTab( tab ).remove();
|
panel = this._getPanelForTab( tab ).remove();
|
||||||
|
|
||||||
// If selected tab was removed focus tab to the right or
|
// If selected tab was removed focus tab to the right or
|
||||||
|
Loading…
Reference in New Issue
Block a user