info@54
|
1 |
$(function () {
|
info@54
|
2 |
|
info@54
|
3 |
module("tabs")
|
info@54
|
4 |
|
info@54
|
5 |
test("should provide no conflict", function () {
|
info@54
|
6 |
var tab = $.fn.tab.noConflict()
|
info@54
|
7 |
ok(!$.fn.tab, 'tab was set back to undefined (org value)')
|
info@54
|
8 |
$.fn.tab = tab
|
info@54
|
9 |
})
|
info@54
|
10 |
|
info@54
|
11 |
test("should be defined on jquery object", function () {
|
info@54
|
12 |
ok($(document.body).tab, 'tabs method is defined')
|
info@54
|
13 |
})
|
info@54
|
14 |
|
info@54
|
15 |
test("should return element", function () {
|
info@54
|
16 |
ok($(document.body).tab()[0] == document.body, 'document.body returned')
|
info@54
|
17 |
})
|
info@54
|
18 |
|
info@54
|
19 |
test("should activate element by tab id", function () {
|
info@54
|
20 |
var tabsHTML =
|
info@54
|
21 |
'<ul class="tabs">'
|
info@54
|
22 |
+ '<li><a href="#home">Home</a></li>'
|
info@54
|
23 |
+ '<li><a href="#profile">Profile</a></li>'
|
info@54
|
24 |
+ '</ul>'
|
info@54
|
25 |
|
info@54
|
26 |
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture")
|
info@54
|
27 |
|
info@54
|
28 |
$(tabsHTML).find('li:last a').tab('show')
|
info@54
|
29 |
equal($("#qunit-fixture").find('.active').attr('id'), "profile")
|
info@54
|
30 |
|
info@54
|
31 |
$(tabsHTML).find('li:first a').tab('show')
|
info@54
|
32 |
equal($("#qunit-fixture").find('.active').attr('id'), "home")
|
info@54
|
33 |
})
|
info@54
|
34 |
|
info@54
|
35 |
test("should activate element by tab id", function () {
|
info@54
|
36 |
var pillsHTML =
|
info@54
|
37 |
'<ul class="pills">'
|
info@54
|
38 |
+ '<li><a href="#home">Home</a></li>'
|
info@54
|
39 |
+ '<li><a href="#profile">Profile</a></li>'
|
info@54
|
40 |
+ '</ul>'
|
info@54
|
41 |
|
info@54
|
42 |
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture")
|
info@54
|
43 |
|
info@54
|
44 |
$(pillsHTML).find('li:last a').tab('show')
|
info@54
|
45 |
equal($("#qunit-fixture").find('.active').attr('id'), "profile")
|
info@54
|
46 |
|
info@54
|
47 |
$(pillsHTML).find('li:first a').tab('show')
|
info@54
|
48 |
equal($("#qunit-fixture").find('.active').attr('id'), "home")
|
info@54
|
49 |
})
|
info@54
|
50 |
|
info@54
|
51 |
|
info@54
|
52 |
test("should not fire closed when close is prevented", function () {
|
info@54
|
53 |
$.support.transition = false
|
info@54
|
54 |
stop();
|
info@54
|
55 |
$('<div class="tab"/>')
|
info@54
|
56 |
.on('show.bs.tab', function (e) {
|
info@54
|
57 |
e.preventDefault();
|
info@54
|
58 |
ok(true);
|
info@54
|
59 |
start();
|
info@54
|
60 |
})
|
info@54
|
61 |
.on('shown.bs.tab', function () {
|
info@54
|
62 |
ok(false);
|
info@54
|
63 |
})
|
info@54
|
64 |
.tab('show')
|
info@54
|
65 |
})
|
info@54
|
66 |
|
info@54
|
67 |
test("show and shown events should reference correct relatedTarget", function () {
|
info@54
|
68 |
var dropHTML =
|
info@54
|
69 |
'<ul class="drop">'
|
info@54
|
70 |
+ '<li class="dropdown"><a data-toggle="dropdown" href="#">1</a>'
|
info@54
|
71 |
+ '<ul class="dropdown-menu">'
|
info@54
|
72 |
+ '<li><a href="#1-1" data-toggle="tab">1-1</a></li>'
|
info@54
|
73 |
+ '<li><a href="#1-2" data-toggle="tab">1-2</a></li>'
|
info@54
|
74 |
+ '</ul>'
|
info@54
|
75 |
+ '</li>'
|
info@54
|
76 |
+ '</ul>'
|
info@54
|
77 |
|
info@54
|
78 |
$(dropHTML).find('ul>li:first a').tab('show').end()
|
info@54
|
79 |
.find('ul>li:last a').on('show', function(event){
|
info@54
|
80 |
equal(event.relatedTarget.hash, "#1-1")
|
info@54
|
81 |
}).on('shown', function(event){
|
info@54
|
82 |
equal(event.relatedTarget.hash, "#1-1")
|
info@54
|
83 |
}).tab('show')
|
info@54
|
84 |
})
|
info@54
|
85 |
|
info@54
|
86 |
})
|