Skip to content

Commit 995518c

Browse files
committed
Tabs: cleanup.
1 parent 1fc91f9 commit 995518c

File tree

6 files changed

+61
-65
lines changed

6 files changed

+61
-65
lines changed

tests/unit/tabs/tabs_defaults.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
/*
2-
* tabs_defaults.js
3-
*/
4-
5-
var tabs_defaults = {
6-
activate: null,
7-
beforeload: null,
8-
beforeActivate: null,
9-
collapsible: false,
10-
disabled: false,
11-
event: "click",
12-
fx: null,
13-
load: null
14-
};
15-
16-
// FAIL: falsy values break the cookie option
17-
commonWidgetTests( "tabs", { defaults: tabs_defaults } );
1+
commonWidgetTests( "tabs", {
2+
defaults: {
3+
activate: null,
4+
// active: null,
5+
beforeLoad: null,
6+
beforeActivate: null,
7+
collapsible: false,
8+
disabled: false,
9+
event: "click",
10+
fx: null,
11+
load: null
12+
}
13+
});
Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
/*
2-
* tabs_defaults.js
3-
*/
4-
5-
var tabs_defaults = {
6-
activate: null,
7-
add: null,
8-
ajaxOptions: null,
9-
beforeload: null,
10-
beforeActivate: null,
11-
cache: false,
12-
collapsible: false,
13-
cookie: null,
14-
disable: null,
15-
disabled: false,
16-
enable: null,
17-
event: "click",
18-
fx: null,
19-
idPrefix: "ui-tabs-",
20-
load: null,
21-
panelTemplate: "<div></div>",
22-
remove: null,
23-
select: null,
24-
show: null,
25-
spinner: "<em>Loading&#8230;</em>",
26-
tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
27-
};
28-
29-
// FAIL: falsy values break the cookie option
30-
commonWidgetTests( "tabs", { defaults: tabs_defaults } );
1+
commonWidgetTests( "tabs", {
2+
defaults: {
3+
activate: null,
4+
// active: null,
5+
add: null,
6+
ajaxOptions: null,
7+
beforeLoad: null,
8+
beforeActivate: null,
9+
cache: false,
10+
collapsible: false,
11+
cookie: null,
12+
disable: null,
13+
disabled: false,
14+
enable: null,
15+
event: "click",
16+
fx: null,
17+
idPrefix: "ui-tabs-",
18+
load: null,
19+
panelTemplate: "<div></div>",
20+
remove: null,
21+
select: null,
22+
show: null,
23+
spinner: "<em>Loading&#8230;</em>",
24+
tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
25+
}
26+
});

tests/unit/tabs/tabs_deprecated.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test( "#4581 - title attribute for remote tabs does not support foreign language
77

88
$( "#tabs2" ).tabs({
99
selected: 3,
10-
beforeload: function( event, ui ) {
10+
beforeLoad: function( event, ui ) {
1111
event.preventDefault();
1212
equal( ui.panel.id, "∫ßáö_Սե", "proper title" );
1313
}

tests/unit/tabs/tabs_events.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ test( "activate", function() {
139139
element.tabs( "option", "active", 1 );
140140
});
141141

142-
test('beforeload', function() {
142+
test( "beforeLoad", function() {
143143
expect( 5 );
144144

145-
el = $('#tabs2');
145+
el = $( "#tabs2" );
146146

147147
el.tabs({
148148
active: 2,
149-
beforeload: function( event, ui ) {
149+
beforeLoad: function( event, ui ) {
150150
ok( $.isFunction( ui.jqXHR.promise ), 'contain jqXHR object');
151151
equals( ui.settings.url, "data/test.html", 'contain ajax settings url');
152152
equals( ui.tab, el.find('a')[ 2 ], 'contain tab as DOM anchor element');
@@ -155,7 +155,6 @@ test('beforeload', function() {
155155
event.preventDefault();
156156
}
157157
});
158-
159158
});
160159

161160
test('load', function() {

tests/unit/tabs/tabs_tickets.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ test('#3627 - Ajax tab with url containing a fragment identifier fails to load',
4444

4545
el = $('#tabs2').tabs({
4646
active: 2,
47-
beforeload: function( event, ui ) {
47+
beforeLoad: function( event, ui ) {
4848
event.preventDefault();
4949
ok(/test.html$/.test( ui.settings.url ), 'should ignore fragment identifier');
5050
}
@@ -58,7 +58,7 @@ test('#4033 - IE expands hash to full url and misinterprets tab as ajax', functi
5858
el = $('<div><ul><li><a href="#tab">Tab</a></li></ul><div id="tab"></div></div>');
5959
el.appendTo('#main');
6060
el.tabs({
61-
beforeload: function( event, ui ) {
61+
beforeLoad: function( event, ui ) {
6262
event.preventDefault();
6363
ok( false, 'should not be an ajax tab');
6464
}

ui/jquery.ui.tabs.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ function getNextListId() {
2727
$.widget( "ui.tabs", {
2828
options: {
2929
activate: null,
30-
beforeload: null,
30+
// TODO: uncomment (requires fixing code related to active option)
31+
// active: null,
32+
beforeLoad: null,
3133
beforeActivate: null,
3234
collapsible: false,
33-
disabled: false,
3435
event: "click",
3536
fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
3637
load: null
@@ -118,13 +119,13 @@ $.widget( "ui.tabs", {
118119

119120
_setOption: function( key, value ) {
120121
if ( key == "active" ) {
121-
// _activate() will handle invalid values and update this.option
122+
// _activate() will handle invalid values and update this.options
122123
this._activate( value );
123-
return
124-
} else {
125-
this.options[ key ] = value;
126-
this.refresh();
124+
return;
127125
}
126+
127+
this.options[ key ] = value;
128+
this.refresh();
128129
},
129130

130131
_tabId: function( a ) {
@@ -573,8 +574,9 @@ $.widget( "ui.tabs", {
573574
this.xhr = $.ajax({
574575
url: url,
575576
beforeSend: function( jqXHR, settings ) {
576-
return self._trigger( "beforeload", null,
577-
$.extend( { jqXHR: jqXHR, settings: settings }, eventData ) );
577+
// TODO: pass relevant event
578+
return self._trigger( "beforeLoad", null,
579+
$.extend( { jqXHR : jqXHR, settings: settings }, eventData ) );
578580
}
579581
});
580582

@@ -609,8 +611,12 @@ $.widget( "ui.tabs", {
609611
self.element.dequeue( "tabs" );
610612

611613
return this;
612-
}
614+
},
613615

616+
_getPanelForTab: function( tab ) {
617+
var id = $( tab ).attr( "aria-controls" );
618+
return this.element.find( this._sanitizeSelector( "#" + id ) );
619+
}
614620
});
615621

616622
$.extend( $.ui.tabs, {
@@ -619,7 +625,6 @@ $.extend( $.ui.tabs, {
619625

620626
// DEPRECATED
621627
if ( $.uiBackCompat !== false ) {
622-
623628
// ajaxOptions and cache options
624629
(function( $, prototype ) {
625630
$.extend( prototype.options, {

0 commit comments

Comments
 (0)