Tooltip: Use this instead of that when possible. Saves 24 bytes :-)

This commit is contained in:
Scott González 2012-05-22 13:46:33 -04:00
parent 1339c1850f
commit 9b37ed24ce

43
ui/jquery.ui.tabs.js vendored
View File

@ -47,19 +47,19 @@ $.widget( "ui.tabs", {
_create: function() { _create: function() {
var panel, var panel,
that = this, that = this,
options = that.options, options = this.options,
active = options.active; active = options.active;
that.running = false; this.running = false;
that.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" ); this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
that._processTabs(); this._processTabs();
if ( active === null ) { if ( active === null ) {
// check the fragment identifier in the URL // check the fragment identifier in the URL
if ( location.hash ) { if ( location.hash ) {
that.anchors.each(function( i, anchor ) { this.anchors.each(function( i, anchor ) {
if ( anchor.hash === location.hash ) { if ( anchor.hash === location.hash ) {
active = i; active = i;
return false; return false;
@ -69,12 +69,12 @@ $.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 = that.lis.filter( ".ui-tabs-active" ).index(); active = this.lis.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 = that.lis.length ? 0 : false; active = this.lis.length ? 0 : false;
} }
} }
@ -110,7 +110,7 @@ $.widget( "ui.tabs", {
// check for length avoids error when initializing empty list // check for length avoids error when initializing empty list
if ( options.active !== false && this.anchors.length ) { if ( options.active !== false && this.anchors.length ) {
this.active = this._findActive( options.active ); this.active = this._findActive( options.active );
panel = that._getPanelForTab( this.active ); panel = this._getPanelForTab( this.active );
panel.show(); panel.show();
this.lis.eq( options.active ).addClass( "ui-tabs-active ui-state-active" ); this.lis.eq( options.active ).addClass( "ui-tabs-active ui-state-active" );
@ -293,15 +293,14 @@ $.widget( "ui.tabs", {
}, },
_eventHandler: function( event ) { _eventHandler: function( event ) {
var that = this, var options = this.options,
options = that.options, active = this.active,
active = that.active,
anchor = $( event.currentTarget ), anchor = $( event.currentTarget ),
tab = anchor.closest( "li" ), tab = anchor.closest( "li" ),
clickedIsActive = tab[ 0 ] === active[ 0 ], clickedIsActive = tab[ 0 ] === active[ 0 ],
collapsing = clickedIsActive && options.collapsible, collapsing = clickedIsActive && options.collapsible,
toShow = collapsing ? $() : that._getPanelForTab( tab ), toShow = collapsing ? $() : this._getPanelForTab( tab ),
toHide = !active.length ? $() : that._getPanelForTab( active ), toHide = !active.length ? $() : this._getPanelForTab( active ),
eventData = { eventData = {
oldTab: active, oldTab: active,
oldPanel: toHide, oldPanel: toHide,
@ -315,20 +314,20 @@ $.widget( "ui.tabs", {
// tab is already loading // tab is already loading
tab.hasClass( "ui-tabs-loading" ) || tab.hasClass( "ui-tabs-loading" ) ||
// can't switch durning an animation // can't switch durning an animation
that.running || this.running ||
// click on active header, but not collapsible // click on active header, but not collapsible
( clickedIsActive && !options.collapsible ) || ( clickedIsActive && !options.collapsible ) ||
// allow canceling activation // allow canceling activation
( that._trigger( "beforeActivate", event, eventData ) === false ) ) { ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
anchor[ 0 ].blur(); anchor[ 0 ].blur();
return; return;
} }
options.active = collapsing ? false : that.lis.index( tab ); options.active = collapsing ? false : this.lis.index( tab );
that.active = clickedIsActive ? $() : tab; this.active = clickedIsActive ? $() : tab;
if ( that.xhr ) { if ( this.xhr ) {
that.xhr.abort(); this.xhr.abort();
} }
if ( !toHide.length && !toShow.length ) { if ( !toHide.length && !toShow.length ) {
@ -337,10 +336,10 @@ $.widget( "ui.tabs", {
if ( toShow.length ) { if ( toShow.length ) {
// TODO make passing in node possible // TODO make passing in node possible
that.load( that.lis.index( tab ), event ); this.load( this.lis.index( tab ), event );
anchor[ 0 ].blur(); anchor[ 0 ].blur();
} }
that._toggle( event, eventData ); this._toggle( event, eventData );
}, },
// handles show/hide for selecting tabs // handles show/hide for selecting tabs
@ -506,7 +505,7 @@ $.widget( "ui.tabs", {
var that = this, var that = this,
tab = this.lis.eq( index ), tab = this.lis.eq( index ),
anchor = tab.find( ".ui-tabs-anchor" ), anchor = tab.find( ".ui-tabs-anchor" ),
panel = that._getPanelForTab( tab ), panel = this._getPanelForTab( tab ),
eventData = { eventData = {
tab: tab, tab: tab,
panel: panel panel: panel