Skip to content
Permalink
Browse files

Tabs: Fixed enabled and disabled methods. Fixes #7142 - Tabs: Depreca…

…te enable and disable events.
  • Loading branch information...
scottgonzalez committed May 3, 2011
1 parent 5e44b3c commit 45c727d75e411d0330027162646bbb26c4f671f1
Showing with 27 additions and 27 deletions.
  1. +21 −23 tests/unit/tabs/tabs_deprecated.js
  2. +6 −4 ui/jquery.ui.tabs.js
@@ -152,39 +152,37 @@ test('selected', function() {
equals(el.tabs('option', 'selected'), 1, 'should select tab');
});

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

test('enable', function() {
expect(4);
test( "enable", function() {
expect( 3 );

var uiObj;
el = $('#tabs1').tabs({
var element = $( "#tabs1" ).tabs({
disabled: [ 0, 1 ],
enable: function (event, ui) {
uiObj = ui;
enable: function ( event, ui ) {
equals( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
equals( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
equals( ui.index, 1, "ui.index" );
}
});
el.tabs('enable', 1);
ok(uiObj !== undefined, 'trigger callback');
equals(uiObj.tab, $('a', el)[1], 'contain tab as DOM anchor element');
equals(uiObj.panel, $('div', el)[1], 'contain panel as DOM div element');
equals(uiObj.index, 1, 'contain index');
element.tabs( "enable", 1 );
// shouldn't trigger event
element.tabs( "enable", 2 );
});

test('disable', function() {
expect(4);
test( "disable", function() {
expect( 3 );

var uiObj;
el = $('#tabs1').tabs({
disable: function (event, ui) {
uiObj = ui;
var element = $( "#tabs1" ).tabs({
disable: function ( event, ui ) {
equals( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
equals( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
equals( ui.index, 1, "ui.index" );
}
});
el.tabs('disable', 1);
ok(uiObj !== undefined, 'trigger callback');
equals(uiObj.tab, $('a', el)[1], 'contain tab as DOM anchor element');
equals(uiObj.panel, $('div', el)[1], 'contain panel as DOM div element');
equals(uiObj.index, 1, 'contain index');
element.tabs( "disable", 1 );
// shouldn't trigger event
element.tabs( "disable", 1 );
});

test('show', function() {
@@ -783,10 +783,11 @@ if ( $.uiBackCompat !== false ) {
disable = prototype.disable;

prototype.enable = function( index ) {
var o = this.options,
var options = this.options,
trigger;

if ( index && o.disabled || ($.isArray( o.disabled ) && $.inArray( index, o.disabled ) !== -1 ) ) {
if ( index && options.disabled === true ||
( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) !== -1 ) ) {
trigger = true;
}

@@ -798,10 +799,11 @@ if ( $.uiBackCompat !== false ) {
};

prototype.disable = function( index ) {
var o = this.options,
var options = this.options,
trigger;

if ( index && !o.disabled || ($.isArray( o.disabled ) && $.inArray( index, o.disabled ) == -1 ) ) {
if ( index && options.disabled === false ||
( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) === -1 ) ) {
trigger = true;
}

0 comments on commit 45c727d

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