2011-03-26 19:00:39 +00:00
|
|
|
(function( $ ) {
|
|
|
|
|
2011-03-26 20:29:57 +00:00
|
|
|
module("tabs (deprecated): options");
|
2011-03-26 19:00:39 +00:00
|
|
|
|
|
|
|
test('ajaxOptions', function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test('cache', function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
2011-03-26 19:48:53 +00:00
|
|
|
test('spinner', function() {
|
|
|
|
expect(4);
|
|
|
|
stop();
|
|
|
|
|
|
|
|
el = $('#tabs2');
|
|
|
|
|
|
|
|
el.tabs({
|
|
|
|
selected: 2,
|
|
|
|
load: function() {
|
|
|
|
// spinner: default spinner
|
|
|
|
setTimeout(function() {
|
|
|
|
equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed");
|
|
|
|
equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed");
|
|
|
|
el.tabs('destroy');
|
|
|
|
el.tabs({
|
|
|
|
selected: 2,
|
|
|
|
spinner: '<img src="spinner.gif" alt="">',
|
|
|
|
load: function() {
|
|
|
|
// spinner: image
|
|
|
|
equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed");
|
|
|
|
equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed");
|
|
|
|
start();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, 1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-03-26 20:29:57 +00:00
|
|
|
module("tabs (deprecated): events");
|
2011-03-26 20:12:05 +00:00
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
|
2011-03-26 20:29:57 +00:00
|
|
|
test('add', function() {
|
|
|
|
|
|
|
|
// TODO move to methods, not at all event related...
|
|
|
|
|
|
|
|
var el = $('<div id="tabs"><ul></ul></div>').tabs();
|
|
|
|
equals(el.tabs('option', 'selected'), -1, 'Initially empty, no selected tab');
|
|
|
|
|
|
|
|
el.tabs('add', '#test1', 'Test 1');
|
|
|
|
equals(el.tabs('option', 'selected'), 0, 'First tab added should be auto selected');
|
|
|
|
|
|
|
|
el.tabs('add', '#test2', 'Test 2');
|
|
|
|
equals(el.tabs('option', 'selected'), 0, 'Second tab added should not be auto selected');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
test('remove', function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
module("tabs (deprecated): methods");
|
|
|
|
|
|
|
|
test('add', function() {
|
|
|
|
expect(4);
|
|
|
|
|
|
|
|
el = $('#tabs1').tabs();
|
|
|
|
el.tabs('add', '#new', 'New');
|
|
|
|
|
|
|
|
var added = $('li:last', el).simulate('mouseover');
|
|
|
|
ok(added.is('.ui-state-hover'), 'should add mouseover handler to added tab');
|
|
|
|
added.simulate('mouseout');
|
|
|
|
var other = $('li:first', el).simulate('mouseover');
|
|
|
|
ok(other.is('.ui-state-hover'), 'should not remove mouseover handler from existing tab');
|
|
|
|
other.simulate('mouseout');
|
|
|
|
|
|
|
|
equals($('a', added).attr('href'), '#new', 'should not expand href to full url of current page');
|
|
|
|
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test('remove', function() {
|
|
|
|
expect(4);
|
|
|
|
|
|
|
|
el = $('#tabs1').tabs();
|
|
|
|
|
|
|
|
el.tabs('remove', 0);
|
|
|
|
equals(el.tabs('length'), 2, 'remove tab');
|
|
|
|
equals($('li a[href$="fragment-1"]', el).length, 0, 'remove associated list item');
|
|
|
|
equals($('#fragment-1').length, 0, 'remove associated panel');
|
|
|
|
|
|
|
|
// TODO delete tab -> focus tab to right
|
|
|
|
// TODO delete last tab -> focus tab to left
|
|
|
|
|
|
|
|
el.tabs('select', 1);
|
|
|
|
el.tabs('remove', 1);
|
|
|
|
equals(el.tabs('option', 'selected'), 0, 'update selected property');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('#5069 - ui.tabs.add creates two tab panels when using a full URL', function() {
|
|
|
|
// http://dev.jqueryui.com/ticket/5069
|
|
|
|
expect(2);
|
|
|
|
|
|
|
|
el = $('#tabs2').tabs();
|
|
|
|
equals(el.children('div').length, el.find('> ul > li').length, 'After creation, number of panels should be equal to number of tabs');
|
|
|
|
el.tabs('add', '/ajax_html_echo', 'Test');
|
|
|
|
equals(el.children('div').length, el.find('> ul > li').length, 'After add, number of panels should be equal to number of tabs');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2011-03-26 19:00:39 +00:00
|
|
|
}( jQuery ) );
|