Skip to content

Commit 463849e

Browse files
committed
Tabs: Removing queue logic, _hideTab, and _showTab - Replaced with _toggle - Fixes #7357 Tabs: Remove queueing logic
1 parent c9e187c commit 463849e

File tree

1 file changed

+50
-68
lines changed

1 file changed

+50
-68
lines changed

ui/jquery.ui.tabs.js

Lines changed: 50 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
(function( $, undefined ) {
1515

16-
var tabId = 0
16+
var tabId = 0;
1717
function getNextTabId() {
1818
return ++tabId;
1919
}
@@ -289,58 +289,14 @@ $.widget( "ui.tabs", {
289289
// Reset certain styles left over from animation
290290
// and prevent IE's ClearType bug...
291291
_resetStyle: function ( $el, fx ) {
292-
$el.css( "display", "" );
292+
$el.css( "display", function( oldValue ) {
293+
return oldValue === "none" ? oldValue : "";
294+
});
293295
if ( !$.support.opacity && fx.opacity ) {
294296
$el[ 0 ].style.removeAttribute( "filter" );
295297
}
296298
},
297299

298-
_showTab: function( event, eventData ) {
299-
var that = this;
300-
301-
$( eventData.newTab ).closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
302-
303-
if ( that.showFx ) {
304-
that.running = true;
305-
eventData.newPanel
306-
// TODO: why are we hiding? old code?
307-
.hide()
308-
.animate( that.showFx, that.showFx.duration || "normal", function() {
309-
that._resetStyle( $( this ), that.showFx );
310-
that.running = false;
311-
that._trigger( "activate", event, eventData );
312-
});
313-
} else {
314-
eventData.newPanel.show();
315-
that._trigger( "activate", event, eventData );
316-
}
317-
},
318-
319-
// TODO: combine with _showTab()
320-
_hideTab: function( event, eventData ) {
321-
var that = this;
322-
323-
if ( that.hideFx ) {
324-
that.running = true;
325-
eventData.oldPanel.animate( that.hideFx, that.hideFx.duration || "normal", function() {
326-
that.running = false;
327-
eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
328-
that._resetStyle( $( this ), that.hideFx );
329-
that.element.dequeue( "tabs" );
330-
if ( !eventData.newPanel.length ) {
331-
that._trigger( "activate", event, eventData );
332-
}
333-
});
334-
} else {
335-
eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
336-
eventData.oldPanel.hide();
337-
that.element.dequeue( "tabs" );
338-
if ( !eventData.newPanel.length ) {
339-
that._trigger( "activate", event, eventData );
340-
}
341-
}
342-
},
343-
344300
_setupEvents: function( event ) {
345301
// attach tab event handler, unbind to avoid duplicates from former tabifying...
346302
this.anchors.unbind( ".tabs" );
@@ -399,22 +355,58 @@ $.widget( "ui.tabs", {
399355
throw "jQuery UI Tabs: Mismatching fragment identifier.";
400356
}
401357

402-
if ( toHide.length ) {
403-
that.element.queue( "tabs", function() {
404-
that._hideTab( event, eventData );
405-
});
406-
}
407358
if ( toShow.length ) {
408-
that.element.queue( "tabs", function() {
409-
that._showTab( event, eventData );
410-
});
411359

412360
// TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
413361
that.load( that.anchors.index( clicked ), event );
414362

415363
clicked[ 0 ].blur();
364+
}
365+
that._toggle( event, eventData );
366+
},
367+
368+
// handles show/hide for selecting tabs
369+
_toggle: function( event, eventData ) {
370+
var that = this,
371+
options = that.options,
372+
toShow = eventData.newPanel,
373+
toHide = eventData.oldPanel;
374+
375+
that.running = true;
376+
377+
function complete() {
378+
that.running = false;
379+
that._trigger( "activate", event, eventData );
380+
}
381+
382+
function show() {
383+
eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
384+
385+
if ( toShow.length && that.showFx ) {
386+
toShow
387+
// TODO: why are we hiding? old code?
388+
.hide()
389+
.animate( that.showFx, that.showFx.duration || "normal", function() {
390+
that._resetStyle( $( this ), that.showFx );
391+
complete();
392+
});
393+
} else {
394+
toShow.show();
395+
complete();
396+
}
397+
}
398+
399+
// start out by hiding, then showing, then completing
400+
if ( toHide.length && that.hideFx ) {
401+
toHide.animate( that.hideFx, that.hideFx.duration || "normal", function() {
402+
eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
403+
that._resetStyle( $( this ), that.hideFx );
404+
show();
405+
});
416406
} else {
417-
that.element.dequeue( "tabs" );
407+
eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
408+
toHide.hide();
409+
show();
418410
}
419411
},
420412

@@ -554,7 +546,6 @@ $.widget( "ui.tabs", {
554546

555547
// not remote
556548
if ( !url ) {
557-
this.element.dequeue( "tabs" );
558549
return;
559550
}
560551

@@ -577,13 +568,7 @@ $.widget( "ui.tabs", {
577568
})
578569
.complete(function( jqXHR, status ) {
579570
if ( status === "abort" ) {
580-
// stop possibly running animations
581-
self.element.queue( [] );
582571
self.panels.stop( false, true );
583-
584-
// "tabs" queue must not contain more than two elements,
585-
// which are the callbacks for the latest clicked tab...
586-
self.element.queue( "tabs", self.element.queue( "tabs" ).splice( -2, 2 ) );
587572
}
588573

589574
self.lis.eq( index ).removeClass( "ui-tabs-loading" );
@@ -592,9 +577,6 @@ $.widget( "ui.tabs", {
592577
});
593578
}
594579

595-
// last, so that load event is fired before show...
596-
self.element.dequeue( "tabs" );
597-
598580
return this;
599581
},
600582

@@ -938,7 +920,7 @@ if ( $.uiBackCompat !== false ) {
938920
this._trigger( "show", null, this._ui(
939921
this.active[ 0 ], this._getPanelForTab( this.active )[ 0 ] ) );
940922
}
941-
}
923+
};
942924
prototype._trigger = function( type, event, data ) {
943925
var ret = _trigger.apply( this, arguments );
944926
if ( !ret ) {

0 commit comments

Comments
 (0)