Skip to content
Permalink
Browse files

Tabs: few fixes required in destroy method, removed ol as tabifyable …

…element
  • Loading branch information...
Klaus Hartl
Klaus Hartl committed Mar 1, 2009
1 parent 676ea7f commit 240a588bce03e72ca48527f3f7887261f505999b
Showing with 23 additions and 18 deletions.
  1. +5 −3 tests/unit/tabs/tabs_methods.js
  2. +18 −15 ui/ui.tabs.js
@@ -22,16 +22,18 @@ test('init', function() {
});

test('destroy', function() {
expect(5);
expect(6);

el = $('#tabs1').tabs();
el = $('#tabs1').tabs({ collapsible: true });
$('li:eq(2)', el).simulate('mouseover').find('a').focus();
el.tabs('destroy');

ok( el.is(':not(.ui-tabs, .ui-widget, .ui-widget-content, .ui-corner-all)'), 'remove classes from container');
ok( el.is(':not(.ui-tabs, .ui-widget, .ui-widget-content, .ui-corner-all, .ui-tabs-collapsible)'), 'remove classes from container');
ok( $('ul', el).is(':not(.ui-tabs-nav, .ui-helper-reset, .ui-helper-clearfix, .ui-widget-header, .ui-corner-all)'), 'remove classes from list' );
ok( $('div:eq(1)', el).is(':not(.ui-tabs-panel, .ui-widget-content, .ui-corner-bottom, .ui-tabs-hide)'), 'remove classes to panel' );
ok( $('li:eq(0)', el).is(':not(.ui-tabs-selected, .ui-state-active, .ui-corner-top)'), 'remove classes from active li');
ok( $('li:eq(1)', el).is(':not(.ui-state-default, .ui-corner-top)'), 'remove classes from inactive li');
ok( $('li:eq(2)', el).is(':not(.ui-state-hover, .ui-state-focus)'), 'remove classes from mouseovered or focused li');
});

test('enable', function() {
@@ -65,13 +65,13 @@ $.widget("ui.tabs", {
.find('span:data(label.tabs)')
.each(function() {
var el = $(this);
el.html(el.data('label.tabs'));
el.html(el.data('label.tabs')).removeData('label.tabs');
});
},

_tabify: function(init) {

this.list = this.element.children('ul:first, ol:first').eq(0);
this.list = this.element.children('ul:first');
this.lis = $('li:has(a[href])', this.list);
this.anchors = this.lis.map(function() { return $('a', this)[0]; });
this.panels = $([]);
@@ -391,8 +391,10 @@ $.widget("ui.tabs", {
destroy: function() {
var o = this.options;

this.abort();

this.element.unbind('.tabs')
.removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all')
.removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible')
.removeData('tabs');

this.list.removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all');
@@ -413,18 +415,19 @@ $.widget("ui.tabs", {
$(this).remove();
}
else {
$(this).removeClass(
'ui-state-default ' +
'ui-corner-top ' +
'ui-tabs-selected ' +
'ui-state-active ' +
'ui-state-hover ' +
'ui-tabs-collapsible ' +
'ui-state-disabled ' +
'ui-tabs-panel ' +
'ui-widget-content ' +
'ui-corner-bottom ' +
'ui-tabs-hide');
$(this).removeClass([
'ui-state-default',
'ui-corner-top',
'ui-tabs-selected',
'ui-state-active',
'ui-state-hover',
'ui-state-focus',
'ui-state-disabled',
'ui-tabs-panel',
'ui-widget-content',
'ui-corner-bottom',
'ui-tabs-hide'
].join(' '));
}
});

0 comments on commit 240a588

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