| 5 |
lars |
1 |
/*!
|
|
|
2 |
* jQuery twitter bootstrap wizard plugin
|
|
|
3 |
* Examples and documentation at: http://github.com/VinceG/twitter-bootstrap-wizard
|
|
|
4 |
* version 1.0
|
|
|
5 |
* Requires jQuery v1.3.2 or later
|
|
|
6 |
* Supports Bootstrap 2.2.x, 2.3.x, 3.0
|
|
|
7 |
* Dual licensed under the MIT and GPL licenses:
|
|
|
8 |
* http://www.opensource.org/licenses/mit-license.php
|
|
|
9 |
* http://www.gnu.org/licenses/gpl.html
|
|
|
10 |
* Authors: Vadim Vincent Gabriel (http://vadimg.com), Jason Gill (www.gilluminate.com)
|
|
|
11 |
*/
|
|
|
12 |
(function (e) {
|
|
|
13 |
var k = function (d, g) {
|
|
|
14 |
d = e(d);
|
|
|
15 |
var a = this,
|
|
|
16 |
b = e.extend({}, e.fn.bootstrapWizard.defaults, g),
|
|
|
17 |
f = null,
|
|
|
18 |
c = null;
|
|
|
19 |
this.rebindClick = function (b, a) {
|
|
|
20 |
b.unbind("click", a).bind("click", a)
|
|
|
21 |
};
|
|
|
22 |
this.fixNavigationButtons = function () {
|
|
|
23 |
f.length || (c.find("a:first").tab("show"), f = c.find('li:has([data-toggle="tab"]):first'));
|
|
|
24 |
e(b.previousSelector, d).toggleClass("disabled", a.firstIndex() >= a.currentIndex());
|
|
|
25 |
e(b.nextSelector, d).toggleClass("disabled", a.currentIndex() >= a.navigationLength());
|
|
|
26 |
a.rebindClick(e(b.nextSelector, d),
|
|
|
27 |
a.next);
|
|
|
28 |
a.rebindClick(e(b.previousSelector, d), a.previous);
|
|
|
29 |
a.rebindClick(e(b.lastSelector, d), a.last);
|
|
|
30 |
a.rebindClick(e(b.firstSelector, d), a.first);
|
|
|
31 |
if (b.onTabShow && "function" === typeof b.onTabShow && !1 === b.onTabShow(f, c, a.currentIndex())) return !1
|
|
|
32 |
};
|
|
|
33 |
this.next = function (h) {
|
|
|
34 |
if (d.hasClass("last") || b.onNext && "function" === typeof b.onNext && !1 === b.onNext(f, c, a.nextIndex())) return !1;
|
|
|
35 |
$index = a.nextIndex();
|
|
|
36 |
$index > a.navigationLength() || c.find('li:has([data-toggle="tab"]):eq(' + $index + ") a").tab("show")
|
|
|
37 |
};
|
|
|
38 |
this.previous =
|
|
|
39 |
function (h) {
|
|
|
40 |
if (d.hasClass("first") || b.onPrevious && "function" === typeof b.onPrevious && !1 === b.onPrevious(f, c, a.previousIndex())) return !1;
|
|
|
41 |
$index = a.previousIndex();
|
|
|
42 |
|
|
|
43 |
};
|
|
|
44 |
this.first = function (h) {
|
|
|
45 |
if (b.onFirst && "function" === typeof b.onFirst && !1 === b.onFirst(f, c, a.firstIndex()) || d.hasClass("disabled")) return !1;
|
|
|
46 |
c.find('li:has([data-toggle="tab"]):eq(0) a').tab("show")
|
|
|
47 |
};
|
|
|
48 |
this.last = function (h) {
|
|
|
49 |
if (b.onLast && "function" === typeof b.onLast && !1 ===
|
|
|
50 |
b.onLast(f, c, a.lastIndex()) || d.hasClass("disabled")) return !1;
|
|
|
51 |
c.find('li:has([data-toggle="tab"]):eq(' + a.navigationLength() + ") a").tab("show")
|
|
|
52 |
};
|
|
|
53 |
this.currentIndex = function () {
|
|
|
54 |
return c.find('li:has([data-toggle="tab"])').index(f)
|
|
|
55 |
};
|
|
|
56 |
this.firstIndex = function () {
|
|
|
57 |
return 0
|
|
|
58 |
};
|
|
|
59 |
this.lastIndex = function () {
|
|
|
60 |
return a.navigationLength()
|
|
|
61 |
};
|
|
|
62 |
this.getIndex = function (a) {
|
|
|
63 |
return c.find('li:has([data-toggle="tab"])').index(a)
|
|
|
64 |
};
|
|
|
65 |
this.nextIndex = function () {
|
|
|
66 |
return c.find('li:has([data-toggle="tab"])').index(f) + 1
|
|
|
67 |
};
|
|
|
68 |
this.previousIndex =
|
|
|
69 |
function () {
|
|
|
70 |
return c.find('li:has([data-toggle="tab"])').index(f) - 1
|
|
|
71 |
};
|
|
|
72 |
this.navigationLength = function () {
|
|
|
73 |
return c.find('li:has([data-toggle="tab"])').length - 1
|
|
|
74 |
};
|
|
|
75 |
this.activeTab = function () {
|
|
|
76 |
return f
|
|
|
77 |
};
|
|
|
78 |
this.nextTab = function () {
|
|
|
79 |
return c.find('li:has([data-toggle="tab"]):eq(' + (a.currentIndex() + 1) + ")").length ? c.find('li:has([data-toggle="tab"]):eq(' + (a.currentIndex() + 1) + ")") : null
|
|
|
80 |
};
|
|
|
81 |
this.previousTab = function () {
|
|
|
82 |
return 0 >= a.currentIndex() ? null : c.find('li:has([data-toggle="tab"]):eq(' + parseInt(a.currentIndex() - 1) + ")")
|
|
|
83 |
};
|
|
|
84 |
this.show = function (a) {
|
|
|
85 |
return d.find('li:has([data-toggle="tab"]):eq(' + a + ") a").tab("show")
|
|
|
86 |
};
|
|
|
87 |
this.disable = function (a) {
|
|
|
88 |
c.find('li:has([data-toggle="tab"]):eq(' + a + ")").addClass("disabled")
|
|
|
89 |
};
|
|
|
90 |
this.enable = function (a) {
|
|
|
91 |
c.find('li:has([data-toggle="tab"]):eq(' + a + ")").removeClass("disabled")
|
|
|
92 |
};
|
|
|
93 |
this.hide = function (a) {
|
|
|
94 |
c.find('li:has([data-toggle="tab"]):eq(' + a + ")").hide()
|
|
|
95 |
};
|
|
|
96 |
this.display = function (a) {
|
|
|
97 |
c.find('li:has([data-toggle="tab"]):eq(' + a + ")").show()
|
|
|
98 |
};
|
|
|
99 |
this.remove = function (a) {
|
|
|
100 |
var b = "undefined" != typeof a[1] ? a[1] :
|
|
|
101 |
!1;
|
|
|
102 |
a = c.find('li:has([data-toggle="tab"]):eq(' + a[0] + ")");
|
|
|
103 |
b && (b = a.find("a").attr("href"), e(b).remove());
|
|
|
104 |
a.remove()
|
|
|
105 |
};
|
|
|
106 |
c = d.find("ul:first", d);
|
|
|
107 |
f = c.find('li:has([data-toggle="tab"]).active', d);
|
|
|
108 |
c.hasClass(b.tabClass) || c.addClass(b.tabClass);
|
|
|
109 |
if (b.onInit && "function" === typeof b.onInit) b.onInit(f, c, 0);
|
|
|
110 |
if (b.onShow && "function" === typeof b.onShow) b.onShow(f, c, a.nextIndex());
|
|
|
111 |
a.fixNavigationButtons();
|
|
|
112 |
e('a[data-toggle="tab"]', c).on("click", function (d) {
|
|
|
113 |
d = c.find('li:has([data-toggle="tab"])').index(e(d.currentTarget).parent('li:has([data-toggle="tab"])'));
|
|
|
114 |
if (b.onTabClick && "function" === typeof b.onTabClick && !1 === b.onTabClick(f, c, a.currentIndex(), d)) return !1
|
|
|
115 |
});
|
|
|
116 |
e('a[data-toggle="tab"]', c).on("shown shown.bs.tab", function (d) {
|
|
|
117 |
$element = e(d.target).parent();
|
|
|
118 |
d = c.find('li:has([data-toggle="tab"])').index($element);
|
|
|
119 |
if ($element.hasClass("disabled") || b.onTabChange && "function" === typeof b.onTabChange && !1 === b.onTabChange(f, c, a.currentIndex(), d)) return !1;
|
|
|
120 |
f = $element;
|
|
|
121 |
a.fixNavigationButtons()
|
|
|
122 |
})
|
|
|
123 |
};
|
|
|
124 |
e.fn.bootstrapWizard = function (d) {
|
|
|
125 |
if ("string" == typeof d) {
|
|
|
126 |
var g = Array.prototype.slice.call(arguments,
|
|
|
127 |
1);
|
|
|
128 |
1 === g.length && g.toString();
|
|
|
129 |
return this.data("bootstrapWizard")[d](g)
|
|
|
130 |
}
|
|
|
131 |
return this.each(function (a) {
|
|
|
132 |
a = e(this);
|
|
|
133 |
if (!a.data("bootstrapWizard")) {
|
|
|
134 |
var b = new k(a, d);
|
|
|
135 |
a.data("bootstrapWizard", b)
|
|
|
136 |
}
|
|
|
137 |
})
|
|
|
138 |
};
|
|
|
139 |
e.fn.bootstrapWizard.defaults = {
|
|
|
140 |
tabClass: "nav nav-pills",
|
|
|
141 |
nextSelector: ".wizard li.next",
|
|
|
142 |
previousSelector: ".wizard li.previous",
|
|
|
143 |
firstSelector: ".wizard li.first",
|
|
|
144 |
lastSelector: ".wizard li.last",
|
|
|
145 |
onShow: null,
|
|
|
146 |
onInit: null,
|
|
|
147 |
onNext: null,
|
|
|
148 |
onPrevious: null,
|
|
|
149 |
onLast: null,
|
|
|
150 |
onFirst: null,
|
|
|
151 |
onTabChange: null,
|
|
|
152 |
onTabClick: null,
|
|
|
153 |
onTabShow: null
|
|
|
154 |
}
|
|
|
155 |
})(jQuery);
|