beforeload: null,
collapsible: false,
cookie: null,
- disable: null,
disabled: false,
- enable: null,
event: "click",
fx: null,
idPrefix: "ui-tabs-",
});
});
+module("tabs (deprecated): enable/disable events");
+
+test('enable', function() {
+ expect(4);
+
+ var uiObj;
+ el = $('#tabs1').tabs({
+ disabled: [ 0, 1 ],
+ enable: function (event, ui) {
+ uiObj = ui;
+ }
+ });
+ 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');
+});
+
+test('disable', function() {
+ expect(4);
+
+ var uiObj;
+ el = $('#tabs1').tabs({
+ disable: function (event, ui) {
+ uiObj = ui;
+ }
+ });
+ 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');
+});
+
}( jQuery ) );
ok(false, "missing test - untested code is broken code.");
});
-test('enable', function() {
- expect(4);
-
- var uiObj;
- el = $('#tabs1').tabs({
- disabled: [ 0, 1 ],
- enable: function (event, ui) {
- uiObj = ui;
- }
- });
- 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');
-});
-
-test('disable', function() {
- expect(4);
-
- var uiObj;
- el = $('#tabs1').tabs({
- disable: function (event, ui) {
- uiObj = ui;
- }
- });
- 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');
-});
-
})(jQuery);
beforeload: null,
cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
collapsible: false,
- disable: null,
disabled: false,
- enable: null,
event: "click",
fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
idPrefix: "ui-tabs-",
o.disabled = false;
}
- this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
return this;
},
o.disabled = true;
}
- this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
}
return this;
});
};
}( jQuery, jQuery.ui.tabs.prototype ) );
+
+ // enable/disable events
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ enable: null,
+ disable: null
+ });
+
+ var enable = prototype.enable,
+ disable = prototype.disable;
+
+ prototype.enable = function( index ) {
+ var o = this.options,
+ trigger;
+
+ if ( index && o.disabled || ($.isArray( o.disabled ) && $.inArray( index, o.disabled ) !== -1 ) ) {
+ trigger = true;
+ }
+
+ enable.apply( this, arguments );
+
+ if ( trigger ) {
+ this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
+ }
+ };
+
+ prototype.disable = function( index ) {
+ var o = this.options,
+ trigger;
+
+ if ( index && !o.disabled || ($.isArray( o.disabled ) && $.inArray( index, o.disabled ) == -1 ) ) {
+ trigger = true;
+ }
+
+ disable.apply( this, arguments );
+
+ if ( trigger ) {
+ this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
+ }
+ };
+ }( jQuery, jQuery.ui.tabs.prototype ) );
}
})( jQuery );