mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
Tabs: cleanup.
This commit is contained in:
parent
1fc91f90d0
commit
995518c10f
@ -1,17 +1,13 @@
|
||||
/*
|
||||
* tabs_defaults.js
|
||||
*/
|
||||
|
||||
var tabs_defaults = {
|
||||
activate: null,
|
||||
beforeload: null,
|
||||
beforeActivate: null,
|
||||
collapsible: false,
|
||||
disabled: false,
|
||||
event: "click",
|
||||
fx: null,
|
||||
load: null
|
||||
};
|
||||
|
||||
// FAIL: falsy values break the cookie option
|
||||
commonWidgetTests( "tabs", { defaults: tabs_defaults } );
|
||||
commonWidgetTests( "tabs", {
|
||||
defaults: {
|
||||
activate: null,
|
||||
// active: null,
|
||||
beforeLoad: null,
|
||||
beforeActivate: null,
|
||||
collapsible: false,
|
||||
disabled: false,
|
||||
event: "click",
|
||||
fx: null,
|
||||
load: null
|
||||
}
|
||||
});
|
||||
|
@ -1,30 +1,26 @@
|
||||
/*
|
||||
* tabs_defaults.js
|
||||
*/
|
||||
|
||||
var tabs_defaults = {
|
||||
activate: null,
|
||||
add: null,
|
||||
ajaxOptions: null,
|
||||
beforeload: null,
|
||||
beforeActivate: null,
|
||||
cache: false,
|
||||
collapsible: false,
|
||||
cookie: null,
|
||||
disable: null,
|
||||
disabled: false,
|
||||
enable: null,
|
||||
event: "click",
|
||||
fx: null,
|
||||
idPrefix: "ui-tabs-",
|
||||
load: null,
|
||||
panelTemplate: "<div></div>",
|
||||
remove: null,
|
||||
select: null,
|
||||
show: null,
|
||||
spinner: "<em>Loading…</em>",
|
||||
tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
|
||||
};
|
||||
|
||||
// FAIL: falsy values break the cookie option
|
||||
commonWidgetTests( "tabs", { defaults: tabs_defaults } );
|
||||
commonWidgetTests( "tabs", {
|
||||
defaults: {
|
||||
activate: null,
|
||||
// active: null,
|
||||
add: null,
|
||||
ajaxOptions: null,
|
||||
beforeLoad: null,
|
||||
beforeActivate: null,
|
||||
cache: false,
|
||||
collapsible: false,
|
||||
cookie: null,
|
||||
disable: null,
|
||||
disabled: false,
|
||||
enable: null,
|
||||
event: "click",
|
||||
fx: null,
|
||||
idPrefix: "ui-tabs-",
|
||||
load: null,
|
||||
panelTemplate: "<div></div>",
|
||||
remove: null,
|
||||
select: null,
|
||||
show: null,
|
||||
spinner: "<em>Loading…</em>",
|
||||
tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
|
||||
}
|
||||
});
|
||||
|
@ -7,7 +7,7 @@ test( "#4581 - title attribute for remote tabs does not support foreign language
|
||||
|
||||
$( "#tabs2" ).tabs({
|
||||
selected: 3,
|
||||
beforeload: function( event, ui ) {
|
||||
beforeLoad: function( event, ui ) {
|
||||
event.preventDefault();
|
||||
equal( ui.panel.id, "∫ßáö_Սե", "proper title" );
|
||||
}
|
||||
|
@ -139,14 +139,14 @@ test( "activate", function() {
|
||||
element.tabs( "option", "active", 1 );
|
||||
});
|
||||
|
||||
test('beforeload', function() {
|
||||
test( "beforeLoad", function() {
|
||||
expect( 5 );
|
||||
|
||||
el = $('#tabs2');
|
||||
el = $( "#tabs2" );
|
||||
|
||||
el.tabs({
|
||||
active: 2,
|
||||
beforeload: function( event, ui ) {
|
||||
beforeLoad: function( event, ui ) {
|
||||
ok( $.isFunction( ui.jqXHR.promise ), 'contain jqXHR object');
|
||||
equals( ui.settings.url, "data/test.html", 'contain ajax settings url');
|
||||
equals( ui.tab, el.find('a')[ 2 ], 'contain tab as DOM anchor element');
|
||||
@ -155,7 +155,6 @@ test('beforeload', function() {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('load', function() {
|
||||
|
@ -44,7 +44,7 @@ test('#3627 - Ajax tab with url containing a fragment identifier fails to load',
|
||||
|
||||
el = $('#tabs2').tabs({
|
||||
active: 2,
|
||||
beforeload: function( event, ui ) {
|
||||
beforeLoad: function( event, ui ) {
|
||||
event.preventDefault();
|
||||
ok(/test.html$/.test( ui.settings.url ), 'should ignore fragment identifier');
|
||||
}
|
||||
@ -58,7 +58,7 @@ test('#4033 - IE expands hash to full url and misinterprets tab as ajax', functi
|
||||
el = $('<div><ul><li><a href="#tab">Tab</a></li></ul><div id="tab"></div></div>');
|
||||
el.appendTo('#main');
|
||||
el.tabs({
|
||||
beforeload: function( event, ui ) {
|
||||
beforeLoad: function( event, ui ) {
|
||||
event.preventDefault();
|
||||
ok( false, 'should not be an ajax tab');
|
||||
}
|
||||
|
27
ui/jquery.ui.tabs.js
vendored
27
ui/jquery.ui.tabs.js
vendored
@ -27,10 +27,11 @@ function getNextListId() {
|
||||
$.widget( "ui.tabs", {
|
||||
options: {
|
||||
activate: null,
|
||||
beforeload: null,
|
||||
// TODO: uncomment (requires fixing code related to active option)
|
||||
// active: null,
|
||||
beforeLoad: null,
|
||||
beforeActivate: null,
|
||||
collapsible: false,
|
||||
disabled: false,
|
||||
event: "click",
|
||||
fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
|
||||
load: null
|
||||
@ -118,13 +119,13 @@ $.widget( "ui.tabs", {
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
if ( key == "active" ) {
|
||||
// _activate() will handle invalid values and update this.option
|
||||
// _activate() will handle invalid values and update this.options
|
||||
this._activate( value );
|
||||
return
|
||||
} else {
|
||||
this.options[ key ] = value;
|
||||
this.refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
this.options[ key ] = value;
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
_tabId: function( a ) {
|
||||
@ -573,8 +574,9 @@ $.widget( "ui.tabs", {
|
||||
this.xhr = $.ajax({
|
||||
url: url,
|
||||
beforeSend: function( jqXHR, settings ) {
|
||||
return self._trigger( "beforeload", null,
|
||||
$.extend( { jqXHR: jqXHR, settings: settings }, eventData ) );
|
||||
// TODO: pass relevant event
|
||||
return self._trigger( "beforeLoad", null,
|
||||
$.extend( { jqXHR : jqXHR, settings: settings }, eventData ) );
|
||||
}
|
||||
});
|
||||
|
||||
@ -609,8 +611,12 @@ $.widget( "ui.tabs", {
|
||||
self.element.dequeue( "tabs" );
|
||||
|
||||
return this;
|
||||
}
|
||||
},
|
||||
|
||||
_getPanelForTab: function( tab ) {
|
||||
var id = $( tab ).attr( "aria-controls" );
|
||||
return this.element.find( this._sanitizeSelector( "#" + id ) );
|
||||
}
|
||||
});
|
||||
|
||||
$.extend( $.ui.tabs, {
|
||||
@ -619,7 +625,6 @@ $.extend( $.ui.tabs, {
|
||||
|
||||
// DEPRECATED
|
||||
if ( $.uiBackCompat !== false ) {
|
||||
|
||||
// ajaxOptions and cache options
|
||||
(function( $, prototype ) {
|
||||
$.extend( prototype.options, {
|
||||
|
Loading…
Reference in New Issue
Block a user