mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Tabs: Refactored spinner implementation. Fixes #7134 - Tabs: Deprecate spinner option.
This commit is contained in:
parent
0546cd57bb
commit
5ae44f8a3b
@ -106,34 +106,19 @@ test('cookie', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
asyncTest( "spinner", function() {
|
||||||
|
expect( 2 );
|
||||||
|
|
||||||
test('spinner', function() {
|
var element = $( "#tabs2" ).tabs();
|
||||||
expect(4);
|
|
||||||
stop();
|
|
||||||
|
|
||||||
el = $('#tabs2');
|
element.one( "tabsbeforeload", function( event, ui ) {
|
||||||
|
equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 1, "beforeload" );
|
||||||
el.tabs({
|
});
|
||||||
selected: 2,
|
element.one( "tabsload", function( event, ui ) {
|
||||||
load: function() {
|
equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 0, "load" );
|
||||||
// spinner: default spinner
|
|
||||||
setTimeout(function() {
|
|
||||||
equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed");
|
|
||||||
equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed");
|
|
||||||
el.tabs('destroy');
|
|
||||||
el.tabs({
|
|
||||||
selected: 2,
|
|
||||||
spinner: '<img src="spinner.gif" alt="">',
|
|
||||||
load: function() {
|
|
||||||
// spinner: image
|
|
||||||
equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed");
|
|
||||||
equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed");
|
|
||||||
start();
|
start();
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
element.tabs( "option", "active", 2 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "selected", function() {
|
test( "selected", function() {
|
||||||
|
38
ui/jquery.ui.tabs.js
vendored
38
ui/jquery.ui.tabs.js
vendored
@ -743,34 +743,28 @@ if ( $.uiBackCompat !== false ) {
|
|||||||
}( jQuery, jQuery.ui.tabs.prototype ) );
|
}( jQuery, jQuery.ui.tabs.prototype ) );
|
||||||
|
|
||||||
// spinner
|
// spinner
|
||||||
(function( $, prototype ) {
|
$.widget( "ui.tabs", $.ui.tabs, {
|
||||||
$.extend( prototype.options, {
|
options: {
|
||||||
spinner: "<em>Loading…</em>"
|
spinner: "<em>Loading…</em>"
|
||||||
});
|
},
|
||||||
|
_create: function() {
|
||||||
var _create = prototype._create;
|
this._super( "_create" );
|
||||||
prototype._create = function() {
|
this._bind({
|
||||||
_create.call( this );
|
tabsbeforeload: function( event, ui ) {
|
||||||
var self = this;
|
if ( !this.options.spinner ) {
|
||||||
|
return;
|
||||||
this.element.bind( "tabsbeforeload", function( event, ui ) {
|
|
||||||
if ( self.options.spinner ) {
|
|
||||||
var span = $( "span", ui.tab );
|
|
||||||
if ( span.length ) {
|
|
||||||
span.data( "label.tabs", span.html() ).html( self.options.spinner );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var span = ui.tab.find( "span" ),
|
||||||
|
html = span.html();
|
||||||
|
span.html( this.options.spinner );
|
||||||
ui.jqXHR.complete(function() {
|
ui.jqXHR.complete(function() {
|
||||||
if ( self.options.spinner ) {
|
span.html( html );
|
||||||
var span = $( "span", ui.tab );
|
});
|
||||||
if ( span.length ) {
|
|
||||||
span.html( span.data( "label.tabs" ) ).removeData( "label.tabs" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
}( jQuery, jQuery.ui.tabs.prototype ) );
|
|
||||||
|
|
||||||
// enable/disable events
|
// enable/disable events
|
||||||
(function( $, prototype ) {
|
(function( $, prototype ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user