No regular expressions were active.
|
|
1 |
|
/*
|
|
|
2 |
|
* Tabs 3
- New Wave
Tabs
|
|
|
3 |
|
*
|
|
|
4 |
|
* Copyrig
ht (c) 200
7 Klaus Ha
rtl (stilb
uero.de)
|
|
|
5 |
|
* Dual li
censed und
er the MIT
(MIT-LICE
NSE.txt)
|
|
|
6 |
|
* and GPL
(GPL-LICE
NSE.txt) l
icenses.
|
|
|
7 |
|
*/
|
|
|
8 |
|
|
|
|
9 |
|
(function(
$) {
|
|
|
10 |
|
|
|
|
11 |
|
// if
the UI sco
pe is not
availalabl
e, add it
|
|
|
12 |
|
$.ui =
$.ui || {
};
|
|
|
13 |
|
|
|
|
14 |
|
// tab
s initiali
zation
|
|
|
15 |
|
$.fn.t
abs = func
tion(initi
al, option
s) {
|
|
|
16 |
|
if
(initial
&& initial
.construct
or == Obje
ct) { // s
hift argum
ents
|
|
|
17 |
|
options
= initial;
|
|
|
18 |
|
initial
= null;
|
|
|
19 |
|
}
|
|
|
20 |
|
op
tions = op
tions || {
};
|
|
|
21 |
|
|
|
|
22 |
|
in
itial = in
itial && i
nitial.con
structor =
= Number &
& --initia
l || 0;
|
|
|
23 |
|
|
|
|
24 |
|
re
turn this.
each(funct
ion() {
|
|
|
25 |
|
new $.ui
.tabs(this
, $.extend
(options,
{ initial:
initial }
));
|
|
|
26 |
|
})
;
|
|
|
27 |
|
};
|
|
|
28 |
|
|
|
|
29 |
|
// oth
er chainab
le tabs me
thods
|
|
|
30 |
|
$.each
(['Add', '
Remove', '
Enable', '
Disable',
'Click', '
Load'], fu
nction(i,
method) {
|
|
|
31 |
|
$.
fn['tabs'
+ method]
= function
() {
|
|
|
32 |
|
var args
= argumen
ts;
|
|
|
33 |
|
return t
his.each(f
unction()
{
|
|
|
34 |
|
var
instance =
$.ui.tabs
.getInstan
ce(this);
|
|
|
35 |
|
inst
ance[metho
d.toLowerC
ase()].app
ly(instanc
e, args);
|
|
|
36 |
|
});
|
|
|
37 |
|
};
|
|
|
38 |
|
});
|
|
|
39 |
|
$.fn.t
absSelecte
d = functi
on() {
|
|
|
40 |
|
va
r selected
= -1;
|
|
|
41 |
|
if
(this[0])
{
|
|
|
42 |
|
var inst
ance = $.u
i.tabs.get
Instance(t
his[0]),
|
|
|
43 |
|
$lis
= $('li',
this);
|
|
|
44 |
|
selected
= $lis.in
dex( $lis.
filter('.'
+ instanc
e.options.
selectedCl
ass)[0] );
|
|
|
45 |
|
}
|
|
|
46 |
|
re
turn selec
ted >= 0 ?
++selecte
d : -1;
|
|
|
47 |
|
};
|
|
|
48 |
|
|
|
|
49 |
|
// tab
s class
|
|
|
50 |
|
$.ui.t
abs = func
tion(el, o
ptions) {
|
|
|
51 |
|
|
|
|
52 |
|
th
is.source
= el;
|
|
|
53 |
|
|
|
|
54 |
|
th
is.options
= $.exten
d({
|
|
|
55 |
|
|
|
|
56 |
|
// basic
setup
|
|
|
57 |
|
initial:
0,
|
|
|
58 |
|
event: '
click',
|
|
|
59 |
|
disabled
: [],
|
|
|
60 |
|
// TODO
bookmarkab
le: $.ajax
History ?
true : fal
se,
|
|
|
61 |
|
unselect
ed: false,
|
|
|
62 |
|
unselect
: options.
unselected
? true :
false,
|
|
|
63 |
|
|
|
|
64 |
|
// Ajax
|
|
|
65 |
|
spinner:
'Loading&
#8230;',
|
|
|
66 |
|
cache: f
alse,
|
|
|
67 |
|
idPrefix
: 'tab-',
|
|
|
68 |
|
|
|
|
69 |
|
// anima
tions
|
|
|
70 |
|
/*fxFade
: null,
|
|
|
71 |
|
fxSlide:
null,
|
|
|
72 |
|
fxShow:
null,
|
|
|
73 |
|
fxHide:
null,*/
|
|
|
74 |
|
fxSpeed:
'normal',
|
|
|
75 |
|
/*fxShow
Speed: nul
l,
|
|
|
76 |
|
fxHideSp
eed: null,
*/
|
|
|
77 |
|
|
|
|
78 |
|
// callb
acks
|
|
|
79 |
|
add: fun
ction() {}
,
|
|
|
80 |
|
remove:
function()
{},
|
|
|
81 |
|
enable:
function()
{},
|
|
|
82 |
|
disable:
function(
) {},
|
|
|
83 |
|
click: f
unction()
{},
|
|
|
84 |
|
hide: fu
nction() {
},
|
|
|
85 |
|
show: fu
nction() {
},
|
|
|
86 |
|
load: fu
nction() {
},
|
|
|
87 |
|
|
|
|
88 |
|
// CSS c
lasses
|
|
|
89 |
|
navClass
: 'ui-tabs
-nav',
|
|
|
90 |
|
selected
Class: 'ui
-tabs-sele
cted',
|
|
|
91 |
|
disabled
Class: 'ui
-tabs-disa
bled',
|
|
|
92 |
|
containe
rClass: 'u
i-tabs-con
tainer',
|
|
|
93 |
|
hideClas
s: 'ui-tab
s-hide',
|
|
|
94 |
|
loadingC
lass: 'ui-
tabs-loadi
ng'
|
|
|
95 |
|
|
|
|
96 |
|
},
options);
|
|
|
97 |
|
|
|
|
98 |
|
th
is.tabify(
true);
|
|
|
99 |
|
|
|
|
100 |
|
//
save inst
ance for l
ater
|
|
|
101 |
|
va
r uuid = '
tabs' + $.
ui.tabs.pr
ototype.co
unt++;
|
|
|
102 |
|
$.
ui.tabs.in
stances[uu
id] = this
;
|
|
|
103 |
|
$.
data(el, '
tabsUUID',
uuid);
|
|
|
104 |
|
|
|
|
105 |
|
};
|
|
|
106 |
|
|
|
|
107 |
|
// sta
tic
|
|
|
108 |
|
$.ui.t
abs.instan
ces = {};
|
|
|
109 |
|
$.ui.t
abs.getIns
tance = fu
nction(el)
{
|
|
|
110 |
|
re
turn $.ui.
tabs.insta
nces[$.dat
a(el, 'tab
sUUID')];
|
|
|
111 |
|
};
|
|
|
112 |
|
|
|
|
113 |
|
// ins
tance meth
ods
|
|
|
114 |
|
$.exte
nd($.ui.ta
bs.prototy
pe, {
|
|
|
115 |
|
co
unt: 0,
|
|
|
116 |
|
ta
bify: func
tion(init)
{
|
|
|
117 |
|
|
|
|
118 |
|
this.$ta
bs = $('a:
first-chil
d', this.s
ource);
|
|
|
119 |
|
this.$co
ntainers =
$([]);
|
|
|
120 |
|
|
|
|
121 |
|
var self
= this, o
= this.op
tions;
|
|
|
122 |
|
|
|
|
123 |
|
this.$ta
bs.each(fu
nction(i,
a) {
|
|
|
124 |
|
// i
nline tab
|
|
|
125 |
|
if (
a.hash &&
a.hash.rep
lace('#',
'')) { //
safari 2 r
eports '#'
for an em
pty hash
|
|
|
126 |
|
self.$cont
ainers = s
elf.$conta
iners.add(
a.hash);
|
|
|
127 |
|
}
|
|
|
128 |
|
// r
emote tab
|
|
|
129 |
|
else
{
|
|
|
130 |
|
$.data(a,
'href', a.
href);
|
|
|
131 |
|
var id = a
.title &&
a.title.re
place(/\s/
g, '_') ||
o.idPrefi
x + (self.
count + 1)
+ '-' + (
i + 1);
|
|
|
132 |
|
a.href = '
#' + id;
|
|
|
133 |
|
self.$cont
ainers = s
elf.$conta
iners.add(
|
|
|
134 |
|
$('#'
+ id)[0] |
| $('<div
id="' + id
+ '" clas
s="' + o.c
ontainerCl
ass + '"><
/div>')
|
|
|
135 |
|
.i
nsertAfter
( self.$co
ntainers[i
- 1] || s
elf.source
)
|
|
|
136 |
|
);
|
|
|
137 |
|
}
|
|
|
138 |
|
});
|
|
|
139 |
|
|
|
|
140 |
|
if (init
) {
|
|
|
141 |
|
|
|
|
142 |
|
// T
ry to retr
ieve initi
al tab fro
m fragment
identifie
r in url i
f present,
|
|
|
143 |
|
// o
therwise t
ry to find
selected
class attr
ibute on <
li>.
|
|
|
144 |
|
this
.$tabs.eac
h(function
(i, a) {
|
|
|
145 |
|
if (locati
on.hash) {
|
|
|
146 |
|
if (a.
hash == lo
cation.has
h) {
|
|
|
147 |
|
o.
initial =
i;
|
|
|
148 |
|
//
prevent p
age scroll
to fragme
nt
|
|
|
149 |
|
//
if (($.bro
wser.msie
|| $.brows
er.opera)
&& !o.remo
te) {
|
|
|
150 |
|
if
($.browse
r.msie ||
$.browser.
opera) {
|
|
|
151 |
|
var $toS
how = $(lo
cation.has
h), toShow
Id = $toSh
ow.attr('i
d');
|
|
|
152 |
|
$toShow.
attr('id',
'');
|
|
|
153 |
|
setTimeo
ut(functio
n() {
|
|
|
154 |
|
$toS
how.attr('
id', toSho
wId); // r
estore id
|
|
|
155 |
|
}, 500);
|
|
|
156 |
|
}
|
|
|
157 |
|
sc
rollTo(0,
0);
|
|
|
158 |
|
re
turn false
; // break
|
|
|
159 |
|
}
|
|
|
160 |
|
} else if
( $(a).par
ents('li:e
q(0)').is(
'li.' + o.
selectedCl
ass) ) {
|
|
|
161 |
|
o.init
ial = i;
|
|
|
162 |
|
return
false; //
break
|
|
|
163 |
|
}
|
|
|
164 |
|
});
|
|
|
165 |
|
|
|
|
166 |
|
// a
ttach nece
ssary clas
ses for st
yling if n
ot present
|
|
|
167 |
|
$(th
is.source)
.is('.' +
o.navClass
) || $(thi
s.source).
addClass(o
.navClass)
;
|
|
|
168 |
|
this
.$containe
rs.each(fu
nction() {
|
|
|
169 |
|
var $this
= $(this);
|
|
|
170 |
|
$this.is('
.' + o.con
tainerClas
s) || $thi
s.addClass
(o.contain
erClass);
|
|
|
171 |
|
});
|
|
|
172 |
|
|
|
|
173 |
|
// h
ighlight t
ab
|
|
|
174 |
|
var
$lis = $('
li', this.
source);
|
|
|
175 |
|
this
.$containe
rs.addClas
s(o.hideCl
ass);
|
|
|
176 |
|
$lis
.removeCla
ss(o.selec
tedClass);
|
|
|
177 |
|
if (
!o.unselec
ted) {
|
|
|
178 |
|
this.$cont
ainers.sli
ce(o.initi
al, o.init
ial + 1).s
how();
|
|
|
179 |
|
$lis.slice
(o.initial
, o.initia
l + 1).add
Class(o.se
lectedClas
s);
|
|
|
180 |
|
}
|
|
|
181 |
|
|
|
|
182 |
|
// l
oad if rem
ote tab
|
|
|
183 |
|
if (
$.data(thi
s.$tabs[o.
initial],
'href')) {
|
|
|
184 |
|
this.load(
o.initial
+ 1, $.dat
a(this.$ta
bs[o.initi
al], 'href
'));
|
|
|
185 |
|
if (o.cach
e) {
|
|
|
186 |
|
$.remo
veData(thi
s.$tabs[o.
initial],
'href'); /
/ if loade
d once do
not load t
hem again
|
|
|
187 |
|
}
|
|
|
188 |
|
}
|
|
|
189 |
|
|
|
|
190 |
|
// d
isabled ta
bs
|
|
|
191 |
|
for
(var i = 0
, position
; position
= o.disab
led[i]; i+
+) {
|
|
|
192 |
|
this.disab
le(positio
n);
|
|
|
193 |
|
}
|
|
|
194 |
|
|
|
|
195 |
|
}
|
|
|
196 |
|
|
|
|
197 |
|
// setup
animation
s
|
|
|
198 |
|
var show
Anim = {},
showSpeed
= o.fxSho
wSpeed ||
o.fxSpeed,
|
|
|
199 |
|
hide
Anim = {},
hideSpeed
= o.fxHid
eSpeed ||
o.fxSpeed;
|
|
|
200 |
|
if (o.fx
Slide || o
.fxFade) {
|
|
|
201 |
|
if (
o.fxSlide)
{
|
|
|
202 |
|
showAnim['
height'] =
'show';
|
|
|
203 |
|
hideAnim['
height'] =
'hide';
|
|
|
204 |
|
}
|
|
|
205 |
|
if (
o.fxFade)
{
|
|
|
206 |
|
showAnim['
opacity']
= 'show';
|
|
|
207 |
|
hideAnim['
opacity']
= 'hide';
|
|
|
208 |
|
}
|
|
|
209 |
|
} else {
|
|
|
210 |
|
if (
o.fxShow)
{
|
|
|
211 |
|
showAnim =
o.fxShow;
|
|
|
212 |
|
} el
se { // us
e some kin
d of anima
tion to pr
event brow
ser scroll
ing to the
tab
|
|
|
213 |
|
showAnim['
min-width'
] = 0; //
avoid opac
ity, cause
s flicker
in Firefox
|
|
|
214 |
|
showSpeed
= 1; // as
little as
1 is suff
icient
|
|
|
215 |
|
}
|
|
|
216 |
|
if (
o.fxHide)
{
|
|
|
217 |
|
hideAnim =
o.fxHide;
|
|
|
218 |
|
} el
se { // us
e some kin
d of anima
tion to pr
event brow
ser scroll
ing to the
tab
|
|
|
219 |
|
hideAnim['
min-width'
] = 0; //
avoid opac
ity, cause
s flicker
in Firefox
|
|
|
220 |
|
hideSpeed
= 1; // as
little as
1 is suff
icient
|
|
|
221 |
|
}
|
|
|
222 |
|
}
|
|
|
223 |
|
|
|
|
224 |
|
// reset
some styl
es to main
tain print
style she
ets etc.
|
|
|
225 |
|
var rese
tCSS = { d
isplay: ''
, overflow
: '', heig
ht: '' };
|
|
|
226 |
|
if (!$.b
rowser.msi
e) { // no
t in IE to
prevent C
learType f
ont issue
|
|
|
227 |
|
rese
tCSS['opac
ity'] = ''
;
|
|
|
228 |
|
}
|
|
|
229 |
|
|
|
|
230 |
|
// Hide
a tab, ani
mation pre
vents brow
ser scroll
ing to fra
gment,
|
|
|
231 |
|
// $show
is option
al.
|
|
|
232 |
|
function
hideTab(c
licked, $h
ide, $show
) {
|
|
|
233 |
|
$hid
e.animate(
hideAnim,
hideSpeed,
function(
) { //
|
|
|
234 |
|
$hide.addC
lass(o.hid
eClass).cs
s(resetCSS
); // main
tain flexi
ble height
and acces
sibility i
n print et
c.
|
|
|
235 |
|
if ($.brow
ser.msie)
{
|
|
|
236 |
|
$hide[
0].style.f
ilter = ''
;
|
|
|
237 |
|
}
|
|
|
238 |
|
o.hide(cli
cked, $hid
e[0], $sho
w && $show
[0] || nul
l);
|
|
|
239 |
|
if ($show)
{
|
|
|
240 |
|
showTa
b(clicked,
$show, $h
ide);
|
|
|
241 |
|
}
|
|
|
242 |
|
});
|
|
|
243 |
|
}
|
|
|
244 |
|
|
|
|
245 |
|
// Show
a tab, ani
mation pre
vents brow
ser scroll
ing to fra
gment,
|
|
|
246 |
|
// $hide
is option
al
|
|
|
247 |
|
function
showTab(c
licked, $s
how, $hide
) {
|
|
|
248 |
|
if (
!(o.fxSlid
e || o.fxF
ade || o.f
xShow)) {
|
|
|
249 |
|
$show.css(
'display',
'block');
// preven
t occasion
ally occur
ing flicke
r in Firef
ox cause b
y gap betw
een showin
g and hidi
ng the tab
container
s
|
|
|
250 |
|
}
|
|
|
251 |
|
$sho
w.animate(
showAnim,
showSpeed,
function(
) {
|
|
|
252 |
|
$show.remo
veClass(o.
hideClass)
.css(reset
CSS); // m
aintain fl
exible hei
ght and ac
cessibilit
y in print
etc.
|
|
|
253 |
|
if ($.brow
ser.msie)
{
|
|
|
254 |
|
$show[
0].style.f
ilter = ''
;
|
|
|
255 |
|
}
|
|
|
256 |
|
o.show(cli
cked, $sho
w[0], $hid
e && $hide
[0] || nul
l);
|
|
|
257 |
|
});
|
|
|
258 |
|
}
|
|
|
259 |
|
|
|
|
260 |
|
// switc
h a tab
|
|
|
261 |
|
function
switchTab
(clicked,
$hide, $sh
ow) {
|
|
|
262 |
|
/*if
(o.bookma
rkable &&
trueClick)
{ // add
to history
only if t
rue click
occured, n
ot a trigg
ered click
|
|
|
263 |
|
$.ajaxHist
ory.update
(clicked.h
ash);
|
|
|
264 |
|
}*/
|
|
|
265 |
|
$(cl
icked).par
ents('li:e
q(0)').add
Class(o.se
lectedClas
s)
|
|
|
266 |
|
.siblings(
).removeCl
ass(o.sele
ctedClass)
;
|
|
|
267 |
|
hide
Tab(clicke
d, $hide,
$show);
|
|
|
268 |
|
}
|
|
|
269 |
|
|
|
|
270 |
|
// tab c
lick handl
er
|
|
|
271 |
|
function
tabClick(
e) {
|
|
|
272 |
|
|
|
|
273 |
|
//va
r trueClic
k = e.clie
ntX; // ad
d to histo
ry only if
true clic
k occured,
not a tri
ggered cli
ck
|
|
|
274 |
|
var
$li = $(th
is).parent
s('li:eq(0
)'),
|
|
|
275 |
|
$hide = se
lf.$contai
ners.filte
r(':visibl
e'),
|
|
|
276 |
|
$show = $(
this.hash)
;
|
|
|
277 |
|
|
|
|
278 |
|
// I
f tab is a
lready sel
ected and
not unsele
ctable or
tab disabl
ed or clic
k callback
returns f
alse stop
here.
|
|
|
279 |
|
// C
heck if cl
ick handle
r returns
false last
so that i
t is not e
xecuted fo
r a disabl
ed tab!
|
|
|
280 |
|
if (
($li.is('.
' + o.sele
ctedClass)
&& !o.uns
elect) ||
$li.is('.'
+ o.disab
ledClass)
|
|
|
281 |
|
|| o.click
(this, $sh
ow[0], $hi
de[0]) ===
false) {
|
|
|
282 |
|
this.blur(
);
|
|
|
283 |
|
return fal
se;
|
|
|
284 |
|
}
|
|
|
285 |
|
|
|
|
286 |
|
// i
f tab may
be closed
|
|
|
287 |
|
if (
o.unselect
) {
|
|
|
288 |
|
if ($li.is
('.' + o.s
electedCla
ss)) {
|
|
|
289 |
|
$li.re
moveClass(
o.selected
Class);
|
|
|
290 |
|
self.$
containers
.stop();
|
|
|
291 |
|
hideTa
b(this, $h
ide);
|
|
|
292 |
|
this.b
lur();
|
|
|
293 |
|
return
false;
|
|
|
294 |
|
} else if
(!$hide.le
ngth) {
|
|
|
295 |
|
$li.ad
dClass(o.s
electedCla
ss);
|
|
|
296 |
|
self.$
containers
.stop();
|
|
|
297 |
|
showTa
b(this, $s
how);
|
|
|
298 |
|
this.b
lur();
|
|
|
299 |
|
return
false;
|
|
|
300 |
|
}
|
|
|
301 |
|
}
|
|
|
302 |
|
|
|
|
303 |
|
// s
top possib
ly running
animation
s
|
|
|
304 |
|
self
.$containe
rs.stop();
|
|
|
305 |
|
|
|
|
306 |
|
// s
how new ta
b
|
|
|
307 |
|
if (
$show.leng
th) {
|
|
|
308 |
|
|
|
|
309 |
|
// prevent
scrollbar
scrolling
to 0 and
than back
in IE7, ha
ppens only
if bookma
rking/hist
ory is ena
bled
|
|
|
310 |
|
/*if ($.br
owser.msie
&& o.book
markable)
{
|
|
|
311 |
|
var sh
owId = thi
s.hash.rep
lace('#',
'');
|
|
|
312 |
|
$show.
attr('id',
'');
|
|
|
313 |
|
setTim
eout(funct
ion() {
|
|
|
314 |
|
$s
how.attr('
id', showI
d); // res
tore id
|
|
|
315 |
|
}, 0);
|
|
|
316 |
|
}*/
|
|
|
317 |
|
|
|
|
318 |
|
if ($.data
(this, 'hr
ef')) { //
remote ta
b
|
|
|
319 |
|
var a
= this;
|
|
|
320 |
|
self.l
oad(self.$
tabs.index
(this) + 1
, $.data(t
his, 'href
'), functi
on() {
|
|
|
321 |
|
sw
itchTab(a,
$hide, $s
how);
|
|
|
322 |
|
});
|
|
|
323 |
|
if (o.
cache) {
|
|
|
324 |
|
$.
removeData
(this, 'hr
ef'); // i
f loaded o
nce do not
load them
again
|
|
|
325 |
|
}
|
|
|
326 |
|
} else {
|
|
|
327 |
|
switch
Tab(this,
$hide, $sh
ow);
|
|
|
328 |
|
}
|
|
|
329 |
|
|
|
|
330 |
|
// Set scr
ollbar to
saved posi
tion - nee
d to use t
imeout wit
h 0 to pre
vent brows
er scroll
to target
of hash
|
|
|
331 |
|
/*var scro
llX = wind
ow.pageXOf
fset || do
cument.doc
umentEleme
nt && docu
ment.docum
entElement
.scrollLef
t || docum
ent.body.s
crollLeft
|| 0;
|
|
|
332 |
|
var scroll
Y = window
.pageYOffs
et || docu
ment.docum
entElement
&& docume
nt.documen
tElement.s
crollTop |
| document
.body.scro
llTop || 0
;
|
|
|
333 |
|
setTimeout
(function(
) {
|
|
|
334 |
|
scroll
To(scrollX
, scrollY)
;
|
|
|
335 |
|
}, 0);*/
|
|
|
336 |
|
|
|
|
337 |
|
} el
se {
|
|
|
338 |
|
throw 'jQu
ery UI Tab
s: Mismatc
hing fragm
ent identi
fier.';
|
|
|
339 |
|
}
|
|
|
340 |
|
|
|
|
341 |
|
this
.blur(); /
/ prevent
IE from ke
eping othe
r link foc
ussed when
using the
back butt
on
|
|
|
342 |
|
|
|
|
343 |
|
//re
turn o.boo
kmarkable
&& !!trueC
lick; // c
onvert tru
eClick ==
undefined
to Boolean
required
in IE
|
|
|
344 |
|
retu
rn false;
|
|
|
345 |
|
|
|
|
346 |
|
}
|
|
|
347 |
|
|
|
|
348 |
|
// attac
h click ev
ent, avoid
duplicate
s from for
mer tabify
ing
|
|
|
349 |
|
this.$ta
bs.unbind(
o.event, t
abClick).b
ind(o.even
t, tabClic
k);
|
|
|
350 |
|
|
|
|
351 |
|
},
|
|
|
352 |
|
ad
d: functio
n(url, tex
t, positio
n) {
|
|
|
353 |
|
if (url
&& text) {
|
|
|
354 |
|
var
o = this.o
ptions;
|
|
|
355 |
|
posi
tion = pos
ition || t
his.$tabs.
length; //
append by
default
|
|
|
356 |
|
if (
position >
= this.$ta
bs.length)
{
|
|
|
357 |
|
var method
= 'insert
After';
|
|
|
358 |
|
position =
this.$tab
s.length;
|
|
|
359 |
|
} el
se {
|
|
|
360 |
|
var method
= 'insert
Before';
|
|
|
361 |
|
}
|
|
|
362 |
|
if (
url.indexO
f('#') ==
0) { // aj
ax contain
er is crea
ted by tab
ify automa
tically
|
|
|
363 |
|
var $conta
iner = $(u
rl);
|
|
|
364 |
|
// try to
find an ex
isting ele
ment befor
e creating
a new one
|
|
|
365 |
|
($containe
r.length &
& $contain
er || $('<
div id="'
+ url.repl
ace('#', '
') + '" cl
ass="' + o
.container
Class + '
' + o.hide
Class + '"
></div>'))
|
|
|
366 |
|
[metho
d](this.$c
ontainers[
position -
1]);
|
|
|
367 |
|
}
|
|
|
368 |
|
$('<
li><a href
="' + url
+ '"><span
>' + text
+ '</span>
</a></li>'
)
|
|
|
369 |
|
[method](t
his.$tabs.
slice(posi
tion - 1,
position).
parents('l
i:eq(0)'))
;
|
|
|
370 |
|
this
.tabify();
|
|
|
371 |
|
o.ad
d(this.$ta
bs[positio
n - 1], th
is.$contai
ners[posit
ion - 1]);
// callba
ck
|
|
|
372 |
|
} else {
|
|
|
373 |
|
thro
w 'jQuery
UI Tabs: N
ot enough
arguments
to add tab
.';
|
|
|
374 |
|
}
|
|
|
375 |
|
},
|
|
|
376 |
|
re
move: func
tion(posit
ion) {
|
|
|
377 |
|
if (posi
tion && po
sition.con
structor =
= Number)
{
|
|
|
378 |
|
var
$removedTa
b = this.$
tabs.slice
(position
- 1, posit
ion).paren
ts('li:eq(
0)').remov
e();
|
|
|
379 |
|
var
$removedCo
ntainer =
this.$cont
ainers.sli
ce(positio
n - 1, pos
ition).rem
ove();
|
|
|
380 |
|
this
.tabify();
|
|
|
381 |
|
this
.options.r
emove($rem
ovedTab[0]
, $removed
Container[
0]); // ca
llback
|
|
|
382 |
|
}
|
|
|
383 |
|
},
|
|
|
384 |
|
en
able: func
tion(posit
ion) {
|
|
|
385 |
|
var $li
= this.$ta
bs.slice(p
osition -
1, positio
n).parents
('li:eq(0)
'), o = th
is.options
;
|
|
|
386 |
|
$li.remo
veClass(o.
disabledCl
ass);
|
|
|
387 |
|
if ($.br
owser.safa
ri) { // f
ix disappe
aring tab
after enab
ling in Sa
fari... TO
DO check S
afari 3
|
|
|
388 |
|
$li.
animate({
opacity: 1
}, 1, fun
ction() {
|
|
|
389 |
|
$li.css({
opacity: '
' });
|
|
|
390 |
|
});
|
|
|
391 |
|
}
|
|
|
392 |
|
o.enable
(this.$tab
s[position
- 1], thi
s.$contain
ers[positi
on - 1]);
// callbac
k
|
|
|
393 |
|
},
|
|
|
394 |
|
di
sable: fun
ction(posi
tion) {
|
|
|
395 |
|
var $li
= this.$ta
bs.slice(p
osition -
1, positio
n).parents
('li:eq(0)
'), o = th
is.options
;
|
|
|
396 |
|
if ($.br
owser.safa
ri) { // f
ix opacity
of tab af
ter disabl
ing in Saf
ari... TOD
O check Sa
fari 3
|
|
|
397 |
|
$li.
animate({
opacity: 0
}, 1, fun
ction() {
|
|
|
398 |
|
$
li.css({ o
pacity: ''
});
|
|
|
399 |
|
});
|
|
|
400 |
|
}
|
|
|
401 |
|
$li.addC
lass(this.
options.di
sabledClas
s);
|
|
|
402 |
|
o.disabl
e(this.$ta
bs[positio
n - 1], th
is.$contai
ners[posit
ion - 1]);
// callba
ck
|
|
|
403 |
|
},
|
|
|
404 |
|
cl
ick: funct
ion(positi
on) {
|
|
|
405 |
|
this.$ta
bs.slice(p
osition -
1, positio
n).trigger
('click');
|
|
|
406 |
|
},
|
|
|
407 |
|
lo
ad: functi
on(positio
n, url, ca
llback) {
|
|
|
408 |
|
var self
= this,
|
|
|
409 |
|
o =
this.optio
ns,
|
|
|
410 |
|
$a =
this.$tab
s.slice(po
sition - 1
, position
).addClass
(o.loading
Class),
|
|
|
411 |
|
$spa
n = $('spa
n', $a),
|
|
|
412 |
|
text
= $span.h
tml();
|
|
|
413 |
|
|
|
|
414 |
|
// shift
arguments
|
|
|
415 |
|
if (url
&& url.con
structor =
= Function
) {
|
|
|
416 |
|
call
back = url
;
|
|
|
417 |
|
}
|
|
|
418 |
|
|
|
|
419 |
|
// set n
ew URL
|
|
|
420 |
|
if (url)
{
|
|
|
421 |
|
$.da
ta($a[0],
'href', ur
l);
|
|
|
422 |
|
}
|
|
|
423 |
|
|
|
|
424 |
|
// load
|
|
|
425 |
|
if (o.sp
inner) {
|
|
|
426 |
|
$spa
n.html('<e
m>' + o.sp
inner + '<
/em>');
|
|
|
427 |
|
}
|
|
|
428 |
|
setTimeo
ut(functio
n() { // t
imeout is
again requ
ired in IE
, "wait" f
or id bein
g restored
|
|
|
429 |
|
$($a
[0].hash).
load(url,
function()
{
|
|
|
430 |
|
if (o.spin
ner) {
|
|
|
431 |
|
$span.
html(text)
;
|
|
|
432 |
|
}
|
|
|
433 |
|
$a.removeC
lass(o.loa
dingClass)
;
|
|
|
434 |
|
// This ca
llback is
required b
ecause the
switch ha
s to take
place afte
r loading
|
|
|
435 |
|
// has com
pleted.
|
|
|
436 |
|
if (callba
ck && call
back.const
ructor ==
Function)
{
|
|
|
437 |
|
callba
ck();
|
|
|
438 |
|
}
|
|
|
439 |
|
o.load(sel
f.$tabs[po
sition - 1
], self.$c
ontainers[
position -
1]); // c
allback
|
|
|
440 |
|
});
|
|
|
441 |
|
}, 0);
|
|
|
442 |
|
}
|
|
|
443 |
|
});
|
|
|
444 |
|
|
|
|
445 |
|
})(jQuery)
;
|