Skip to content
Permalink
Browse files

Tabs: Removed ajaxOptions and cache options. Fixes #7147 - Tabs: Remo…

…ve ajaxOptions and cache options.
  • Loading branch information...
scottgonzalez committed Oct 25, 2012
1 parent 974e5f8 commit 52a184e31c0ca5618e6d4873625bf3b7716944b3
Showing with 0 additions and 120 deletions.
  1. +0 −2 tests/unit/tabs/tabs_common_deprecated.js
  2. +0 −53 tests/unit/tabs/tabs_deprecated.js
  3. +0 −65 ui/jquery.ui.tabs.js
@@ -1,8 +1,6 @@
TestHelpers.commonWidgetTests( "tabs", {
defaults: {
active: null,
ajaxOptions: null,
cache: false,
collapsible: false,
cookie: null,
disabled: false,
@@ -24,59 +24,6 @@ test( "panel ids", function() {

module( "tabs (deprecated): options" );

asyncTest( "ajaxOptions", function() {
expect( 2 );

var element = $( "#tabs2" ).tabs({
ajaxOptions: {
data: "foo=bar",
converters: {
"text html": function() {
return "test";
}
}
}
});
element.one( "tabsbeforeload", function( event, ui ) {
equal( ui.ajaxSettings.url.replace( /^[^\?]+/, "" ), "?foo=bar", "ajaxOptions.data" );
});
element.one( "tabsload", function( event, ui ) {
equal( $( ui.panel ).html(), "test" );
start();
});
element.tabs( "option", "active", 2 );
});

asyncTest( "cache", function() {
expect( 5 );

var element = $( "#tabs2" ).tabs({
cache: true
});
element.one( "tabsshow", function() {
state( element, 0, 0, 1, 0, 0 );
});
element.one( "tabsload", function() {
ok( true, "tabsload" );

setTimeout(function() {
element.tabs( "option", "active", 0 );
state( element, 1, 0, 0, 0, 0 );

element.one( "tabsshow", function() {
state( element, 0, 0, 1, 0, 0 );
});
element.one( "tabsload", function() {
ok( false, "should be cached" );
});
element.tabs( "option", "active", 2 );
start();
}, 1 );
});
element.tabs( "option", "active", 2 );
state( element, 0, 0, 1, 0, 0 );
});

test( "idPrefix", function() {
expect( 1 );

@@ -825,7 +825,6 @@ $.widget( "ui.tabs", {
}
},

// TODO: Remove this function in 1.10 when ajaxOptions is removed
_ajaxSettings: function( anchor, event, eventData ) {
var that = this;
return {
@@ -862,70 +861,6 @@ if ( $.uiBackCompat !== false ) {
}
});

// TODO: Remove _ajaxSettings() method when removing this extension
// ajaxOptions and cache options
$.widget( "ui.tabs", $.ui.tabs, {
options: {
ajaxOptions: null,
cache: false
},

_create: function() {
this._super();

var that = this;

this._on({ tabsbeforeload: function( event, ui ) {
// tab is already cached
if ( $.data( ui.tab[ 0 ], "cache.tabs" ) ) {
event.preventDefault();
return;
}

ui.jqXHR.success(function() {
if ( that.options.cache ) {
$.data( ui.tab[ 0 ], "cache.tabs", true );
}
});
}});
},

_ajaxSettings: function( anchor, event, ui ) {
var ajaxOptions = this.options.ajaxOptions;
return $.extend( {}, ajaxOptions, {
error: function( xhr, status ) {
try {
// Passing index avoid a race condition when this method is
// called after the user has selected another tab.
// Pass the anchor that initiated this request allows
// loadError to manipulate the tab content panel via $(a.hash)
ajaxOptions.error(
xhr, status, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
}
catch ( error ) {}
}
}, this._superApply( arguments ) );
},

_setOption: function( key, value ) {
// reset cache if switching from cached to not cached
if ( key === "cache" && value === false ) {
this.anchors.removeData( "cache.tabs" );
}
this._super( key, value );
},

_destroy: function() {
this.anchors.removeData( "cache.tabs" );
this._super();
},

url: function( index ){
this.anchors.eq( index ).removeData( "cache.tabs" );
this._superApply( arguments );
}
});

// abort method
$.widget( "ui.tabs", $.ui.tabs, {
abort: function() {

0 comments on commit 52a184e

Please sign in to comment.
You can’t perform that action at this time.