No regular expressions were active.
|
|
1 |
|
(function(
){
|
|
|
2 |
|
/*
|
|
|
3 |
|
* jQuery
1.2.3 - Ne
w Wave Jav
ascript
|
|
|
4 |
|
*
|
|
|
5 |
|
* Copyrig
ht (c) 200
8 John Res
ig (jquery
.com)
|
|
|
6 |
|
* Dual li
censed und
er the MIT
(MIT-LICE
NSE.txt)
|
|
|
7 |
|
* and GPL
(GPL-LICE
NSE.txt) l
icenses.
|
|
|
8 |
|
*
|
|
|
9 |
|
* $Date:
2008-02-06
00:21:25
-0500 (Wed
, 06 Feb 2
008) $
|
|
|
10 |
|
* $Rev: 4
663 $
|
|
|
11 |
|
*/
|
|
|
12 |
|
|
|
|
13 |
|
// Map ove
r jQuery i
n case of
overwrite
|
|
|
14 |
|
if ( windo
w.jQuery )
|
|
|
15 |
|
var _j
Query = wi
ndow.jQuer
y;
|
|
|
16 |
|
|
|
|
17 |
|
var jQuery
= window.
jQuery = f
unction( s
elector, c
ontext ) {
|
|
|
18 |
|
// The
jQuery ob
ject is ac
tually jus
t the init
construct
or 'enhanc
ed'
|
|
|
19 |
|
return
new jQuer
y.prototyp
e.init( se
lector, co
ntext );
|
|
|
20 |
|
};
|
|
|
21 |
|
|
|
|
22 |
|
// Map ove
r the $ in
case of o
verwrite
|
|
|
23 |
|
if ( windo
w.$ )
|
|
|
24 |
|
var _$
= window.
$;
|
|
|
25 |
|
|
|
|
26 |
|
// Map the
jQuery na
mespace to
the '$' o
ne
|
|
|
27 |
|
window.$ =
jQuery;
|
|
|
28 |
|
|
|
|
29 |
|
// A simpl
e way to c
heck for H
TML string
s or ID st
rings
|
|
|
30 |
|
// (both o
f which we
optimize
for)
|
|
|
31 |
|
var quickE
xpr = /^[^
<]*(<(.|\s
)+>)[^>]*$
|^#(\w+)$/
;
|
|
|
32 |
|
|
|
|
33 |
|
// Is it a
simple se
lector
|
|
|
34 |
|
var isSimp
le = /^.[^
:#\[\.]*$/
;
|
|
|
35 |
|
|
|
|
36 |
|
jQuery.fn
= jQuery.p
rototype =
{
|
|
|
37 |
|
init:
function(
selector,
context )
{
|
|
|
38 |
|
//
Make sure
that a se
lection wa
s provided
|
|
|
39 |
|
se
lector = s
elector ||
document;
|
|
|
40 |
|
|
|
|
41 |
|
//
Handle $(
DOMElement
)
|
|
|
42 |
|
if
( selecto
r.nodeType
) {
|
|
|
43 |
|
this[0]
= selector
;
|
|
|
44 |
|
this.len
gth = 1;
|
|
|
45 |
|
return t
his;
|
|
|
46 |
|
|
|
|
47 |
|
//
Handle HT
ML strings
|
|
|
48 |
|
}
else if (
typeof sel
ector == "
string" )
{
|
|
|
49 |
|
// Are w
e dealing
with HTML
string or
an ID?
|
|
|
50 |
|
var matc
h = quickE
xpr.exec(
selector )
;
|
|
|
51 |
|
|
|
|
52 |
|
// Verif
y a match,
and that
no context
was speci
fied for #
id
|
|
|
53 |
|
if ( mat
ch && (mat
ch[1] || !
context) )
{
|
|
|
54 |
|
|
|
|
55 |
|
// H
ANDLE: $(h
tml) -> $(
array)
|
|
|
56 |
|
if (
match[1]
)
|
|
|
57 |
|
selector =
jQuery.cl
ean( [ mat
ch[1] ], c
ontext );
|
|
|
58 |
|
|
|
|
59 |
|
// H
ANDLE: $("
#id")
|
|
|
60 |
|
else
{
|
|
|
61 |
|
var elem =
document.
getElement
ById( matc
h[3] );
|
|
|
62 |
|
|
|
|
63 |
|
// Make su
re an elem
ent was lo
cated
|
|
|
64 |
|
if ( elem
)
|
|
|
65 |
|
// Han
dle the ca
se where I
E and Oper
a return i
tems
|
|
|
66 |
|
// by
name inste
ad of ID
|
|
|
67 |
|
if ( e
lem.id !=
match[3] )
|
|
|
68 |
|
re
turn jQuer
y().find(
selector )
;
|
|
|
69 |
|
|
|
|
70 |
|
// Oth
erwise, we
inject th
e element
directly i
nto the jQ
uery objec
t
|
|
|
71 |
|
else {
|
|
|
72 |
|
th
is[0] = el
em;
|
|
|
73 |
|
th
is.length
= 1;
|
|
|
74 |
|
re
turn this;
|
|
|
75 |
|
}
|
|
|
76 |
|
|
|
|
77 |
|
else
|
|
|
78 |
|
select
or = [];
|
|
|
79 |
|
}
|
|
|
80 |
|
|
|
|
81 |
|
// HANDL
E: $(expr,
[context]
)
|
|
|
82 |
|
// (whic
h is just
equivalent
to: $(con
tent).find
(expr)
|
|
|
83 |
|
} else
|
|
|
84 |
|
retu
rn new jQu
ery( conte
xt ).find(
selector
);
|
|
|
85 |
|
|
|
|
86 |
|
//
HANDLE: $
(function)
|
|
|
87 |
|
//
Shortcut
for docume
nt ready
|
|
|
88 |
|
}
else if (
jQuery.isF
unction( s
elector )
)
|
|
|
89 |
|
return n
ew jQuery(
document
)[ jQuery.
fn.ready ?
"ready" :
"load" ](
selector
);
|
|
|
90 |
|
|
|
|
91 |
|
re
turn this.
setArray(
|
|
|
92 |
|
// HANDL
E: $(array
)
|
|
|
93 |
|
selector
.construct
or == Arra
y && selec
tor ||
|
|
|
94 |
|
|
|
|
95 |
|
// HANDL
E: $(array
like)
|
|
|
96 |
|
// Watch
for when
an array-l
ike object
, contains
DOM nodes
, is passe
d in as th
e selector
|
|
|
97 |
|
(selecto
r.jquery |
| selector
.length &&
selector
!= window
&& !select
or.nodeTyp
e && selec
tor[0] !=
undefined
&& selecto
r[0].nodeT
ype) && jQ
uery.makeA
rray( sele
ctor ) ||
|
|
|
98 |
|
|
|
|
99 |
|
// HANDL
E: $(*)
|
|
|
100 |
|
[ select
or ] );
|
|
|
101 |
|
},
|
|
|
102 |
|
|
|
|
103 |
|
// The
current v
ersion of
jQuery bei
ng used
|
|
|
104 |
|
jquery
: "1.2.3",
|
|
|
105 |
|
|
|
|
106 |
|
// The
number of
elements
contained
in the mat
ched eleme
nt set
|
|
|
107 |
|
size:
function()
{
|
|
|
108 |
|
re
turn this.
length;
|
|
|
109 |
|
},
|
|
|
110 |
|
|
|
|
111 |
|
// The
number of
elements
contained
in the mat
ched eleme
nt set
|
|
|
112 |
|
length
: 0,
|
|
|
113 |
|
|
|
|
114 |
|
// Get
the Nth e
lement in
the matche
d element
set OR
|
|
|
115 |
|
// Get
the whole
matched e
lement set
as a clea
n array
|
|
|
116 |
|
get: f
unction( n
um ) {
|
|
|
117 |
|
re
turn num =
= undefine
d ?
|
|
|
118 |
|
|
|
|
119 |
|
// Retur
n a 'clean
' array
|
|
|
120 |
|
jQuery.m
akeArray(
this ) :
|
|
|
121 |
|
|
|
|
122 |
|
// Retur
n just the
object
|
|
|
123 |
|
this[ nu
m ];
|
|
|
124 |
|
},
|
|
|
125 |
|
|
|
|
126 |
|
// Tak
e an array
of elemen
ts and pus
h it onto
the stack
|
|
|
127 |
|
// (re
turning th
e new matc
hed elemen
t set)
|
|
|
128 |
|
pushSt
ack: funct
ion( elems
) {
|
|
|
129 |
|
//
Build a n
ew jQuery
matched el
ement set
|
|
|
130 |
|
va
r ret = jQ
uery( elem
s );
|
|
|
131 |
|
|
|
|
132 |
|
//
Add the o
ld object
onto the s
tack (as a
reference
)
|
|
|
133 |
|
re
t.prevObje
ct = this;
|
|
|
134 |
|
|
|
|
135 |
|
//
Return th
e newly-fo
rmed eleme
nt set
|
|
|
136 |
|
re
turn ret;
|
|
|
137 |
|
},
|
|
|
138 |
|
|
|
|
139 |
|
// For
ce the cur
rent match
ed set of
elements t
o become
|
|
|
140 |
|
// the
specified
array of
elements (
destroying
the stack
in the pr
ocess)
|
|
|
141 |
|
// You
should us
e pushStac
k() in ord
er to do t
his, but m
aintain th
e stack
|
|
|
142 |
|
setArr
ay: functi
on( elems
) {
|
|
|
143 |
|
//
Resetting
the lengt
h to 0, th
en using t
he native
Array push
|
|
|
144 |
|
//
is a supe
r-fast way
to popula
te an obje
ct with ar
ray-like p
roperties
|
|
|
145 |
|
th
is.length
= 0;
|
|
|
146 |
|
Ar
ray.protot
ype.push.a
pply( this
, elems );
|
|
|
147 |
|
|
|
|
148 |
|
re
turn this;
|
|
|
149 |
|
},
|
|
|
150 |
|
|
|
|
151 |
|
// Exe
cute a cal
lback for
every elem
ent in the
matched s
et.
|
|
|
152 |
|
// (Yo
u can seed
the argum
ents with
an array o
f args, bu
t this is
|
|
|
153 |
|
// onl
y used int
ernally.)
|
|
|
154 |
|
each:
function(
callback,
args ) {
|
|
|
155 |
|
re
turn jQuer
y.each( th
is, callba
ck, args )
;
|
|
|
156 |
|
},
|
|
|
157 |
|
|
|
|
158 |
|
// Det
ermine the
position
of an elem
ent within
|
|
|
159 |
|
// the
matched s
et of elem
ents
|
|
|
160 |
|
index:
function(
elem ) {
|
|
|
161 |
|
va
r ret = -1
;
|
|
|
162 |
|
|
|
|
163 |
|
//
Locate th
e position
of the de
sired elem
ent
|
|
|
164 |
|
th
is.each(fu
nction(i){
|
|
|
165 |
|
if ( thi
s == elem
)
|
|
|
166 |
|
ret
= i;
|
|
|
167 |
|
})
;
|
|
|
168 |
|
|
|
|
169 |
|
re
turn ret;
|
|
|
170 |
|
},
|
|
|
171 |
|
|
|
|
172 |
|
attr:
function(
name, valu
e, type )
{
|
|
|
173 |
|
va
r options
= name;
|
|
|
174 |
|
|
|
|
175 |
|
//
Look for
the case w
here we're
accessing
a style v
alue
|
|
|
176 |
|
if
( name.co
nstructor
== String
)
|
|
|
177 |
|
if ( val
ue == unde
fined )
|
|
|
178 |
|
retu
rn this.le
ngth && jQ
uery[ type
|| "attr"
]( this[0
], name )
|| undefin
ed;
|
|
|
179 |
|
|
|
|
180 |
|
else {
|
|
|
181 |
|
opti
ons = {};
|
|
|
182 |
|
opti
ons[ name
] = value;
|
|
|
183 |
|
}
|
|
|
184 |
|
|
|
|
185 |
|
//
Check to
see if we'
re setting
style val
ues
|
|
|
186 |
|
re
turn this.
each(funct
ion(i){
|
|
|
187 |
|
// Set a
ll the sty
les
|
|
|
188 |
|
for ( na
me in opti
ons )
|
|
|
189 |
|
jQue
ry.attr(
|
|
|
190 |
|
type ?
|
|
|
191 |
|
this.s
tyle :
|
|
|
192 |
|
this,
|
|
|
193 |
|
name, jQue
ry.prop( t
his, optio
ns[ name ]
, type, i,
name )
|
|
|
194 |
|
);
|
|
|
195 |
|
})
;
|
|
|
196 |
|
},
|
|
|
197 |
|
|
|
|
198 |
|
css: f
unction( k
ey, value
) {
|
|
|
199 |
|
//
ignore ne
gative wid
th and hei
ght values
|
|
|
200 |
|
if
( (key ==
'width' |
| key == '
height') &
& parseFlo
at(value)
< 0 )
|
|
|
201 |
|
value =
undefined;
|
|
|
202 |
|
re
turn this.
attr( key,
value, "c
urCSS" );
|
|
|
203 |
|
},
|
|
|
204 |
|
|
|
|
205 |
|
text:
function(
text ) {
|
|
|
206 |
|
if
( typeof
text != "o
bject" &&
text != nu
ll )
|
|
|
207 |
|
return t
his.empty(
).append(
(this[0] &
& this[0].
ownerDocum
ent || doc
ument).cre
ateTextNod
e( text )
);
|
|
|
208 |
|
|
|
|
209 |
|
va
r ret = ""
;
|
|
|
210 |
|
|
|
|
211 |
|
jQ
uery.each(
text || t
his, funct
ion(){
|
|
|
212 |
|
jQuery.e
ach( this.
childNodes
, function
(){
|
|
|
213 |
|
if (
this.node
Type != 8
)
|
|
|
214 |
|
ret += thi
s.nodeType
!= 1 ?
|
|
|
215 |
|
this.n
odeValue :
|
|
|
216 |
|
jQuery
.fn.text(
[ this ] )
;
|
|
|
217 |
|
});
|
|
|
218 |
|
})
;
|
|
|
219 |
|
|
|
|
220 |
|
re
turn ret;
|
|
|
221 |
|
},
|
|
|
222 |
|
|
|
|
223 |
|
wrapAl
l: functio
n( html )
{
|
|
|
224 |
|
if
( this[0]
)
|
|
|
225 |
|
// The e
lements to
wrap the
target aro
und
|
|
|
226 |
|
jQuery(
html, this
[0].ownerD
ocument )
|
|
|
227 |
|
.clo
ne()
|
|
|
228 |
|
.ins
ertBefore(
this[0] )
|
|
|
229 |
|
.map
(function(
){
|
|
|
230 |
|
var elem =
this;
|
|
|
231 |
|
|
|
|
232 |
|
while ( el
em.firstCh
ild )
|
|
|
233 |
|
elem =
elem.firs
tChild;
|
|
|
234 |
|
|
|
|
235 |
|
return ele
m;
|
|
|
236 |
|
})
|
|
|
237 |
|
.app
end(this);
|
|
|
238 |
|
|
|
|
239 |
|
re
turn this;
|
|
|
240 |
|
},
|
|
|
241 |
|
|
|
|
242 |
|
wrapIn
ner: funct
ion( html
) {
|
|
|
243 |
|
re
turn this.
each(funct
ion(){
|
|
|
244 |
|
jQuery(
this ).con
tents().wr
apAll( htm
l );
|
|
|
245 |
|
})
;
|
|
|
246 |
|
},
|
|
|
247 |
|
|
|
|
248 |
|
wrap:
function(
html ) {
|
|
|
249 |
|
re
turn this.
each(funct
ion(){
|
|
|
250 |
|
jQuery(
this ).wra
pAll( html
);
|
|
|
251 |
|
})
;
|
|
|
252 |
|
},
|
|
|
253 |
|
|
|
|
254 |
|
append
: function
() {
|
|
|
255 |
|
re
turn this.
domManip(a
rguments,
true, fals
e, functio
n(elem){
|
|
|
256 |
|
if (this
.nodeType
== 1)
|
|
|
257 |
|
this
.appendChi
ld( elem )
;
|
|
|
258 |
|
})
;
|
|
|
259 |
|
},
|
|
|
260 |
|
|
|
|
261 |
|
prepen
d: functio
n() {
|
|
|
262 |
|
re
turn this.
domManip(a
rguments,
true, true
, function
(elem){
|
|
|
263 |
|
if (this
.nodeType
== 1)
|
|
|
264 |
|
this
.insertBef
ore( elem,
this.firs
tChild );
|
|
|
265 |
|
})
;
|
|
|
266 |
|
},
|
|
|
267 |
|
|
|
|
268 |
|
before
: function
() {
|
|
|
269 |
|
re
turn this.
domManip(a
rguments,
false, fal
se, functi
on(elem){
|
|
|
270 |
|
this.par
entNode.in
sertBefore
( elem, th
is );
|
|
|
271 |
|
})
;
|
|
|
272 |
|
},
|
|
|
273 |
|
|
|
|
274 |
|
after:
function(
) {
|
|
|
275 |
|
re
turn this.
domManip(a
rguments,
false, tru
e, functio
n(elem){
|
|
|
276 |
|
this.par
entNode.in
sertBefore
( elem, th
is.nextSib
ling );
|
|
|
277 |
|
})
;
|
|
|
278 |
|
},
|
|
|
279 |
|
|
|
|
280 |
|
end: f
unction()
{
|
|
|
281 |
|
re
turn this.
prevObject
|| jQuery
( [] );
|
|
|
282 |
|
},
|
|
|
283 |
|
|
|
|
284 |
|
find:
function(
selector )
{
|
|
|
285 |
|
va
r elems =
jQuery.map
(this, fun
ction(elem
){
|
|
|
286 |
|
return j
Query.find
( selector
, elem );
|
|
|
287 |
|
})
;
|
|
|
288 |
|
|
|
|
289 |
|
re
turn this.
pushStack(
/[^+>] [^
+>]/.test(
selector
) || selec
tor.indexO
f("..") >
-1 ?
|
|
|
290 |
|
jQuery.u
nique( ele
ms ) :
|
|
|
291 |
|
elems );
|
|
|
292 |
|
},
|
|
|
293 |
|
|
|
|
294 |
|
clone:
function(
events )
{
|
|
|
295 |
|
//
Do the cl
one
|
|
|
296 |
|
va
r ret = th
is.map(fun
ction(){
|
|
|
297 |
|
if ( jQu
ery.browse
r.msie &&
!jQuery.is
XMLDoc(thi
s) ) {
|
|
|
298 |
|
// I
E copies e
vents boun
d via atta
chEvent wh
en
|
|
|
299 |
|
// u
sing clone
Node. Call
ing detach
Event on t
he
|
|
|
300 |
|
// c
lone will
also remov
e the even
ts from th
e orignal
|
|
|
301 |
|
// I
n order to
get aroun
d this, we
use inner
HTML.
|
|
|
302 |
|
// U
nfortunate
ly, this m
eans some
modificati
ons to
|
|
|
303 |
|
// a
ttributes
in IE that
are actua
lly only s
tored
|
|
|
304 |
|
// a
s properti
es will no
t be copie
d (such as
the
|
|
|
305 |
|
// t
he name at
tribute on
an input)
.
|
|
|
306 |
|
var
clone = th
is.cloneNo
de(true),
|
|
|
307 |
|
container
= document
.createEle
ment("div"
);
|
|
|
308 |
|
cont
ainer.appe
ndChild(cl
one);
|
|
|
309 |
|
retu
rn jQuery.
clean([con
tainer.inn
erHTML])[0
];
|
|
|
310 |
|
} else
|
|
|
311 |
|
retu
rn this.cl
oneNode(tr
ue);
|
|
|
312 |
|
})
;
|
|
|
313 |
|
|
|
|
314 |
|
//
Need to s
et the exp
ando to nu
ll on the
cloned set
if it exi
sts
|
|
|
315 |
|
//
removeDat
a doesn't
work here,
IE remove
s it from
the origin
al as well
|
|
|
316 |
|
//
this is p
rimarily f
or IE but
the data e
xpando sho
uldn't be
copied ove
r in any b
rowser
|
|
|
317 |
|
va
r clone =
ret.find("
*").andSel
f().each(f
unction(){
|
|
|
318 |
|
if ( thi
s[ expando
] != unde
fined )
|
|
|
319 |
|
this
[ expando
] = null;
|
|
|
320 |
|
})
;
|
|
|
321 |
|
|
|
|
322 |
|
//
Copy the
events fro
m the orig
inal to th
e clone
|
|
|
323 |
|
if
( events
=== true )
|
|
|
324 |
|
this.fin
d("*").and
Self().eac
h(function
(i){
|
|
|
325 |
|
if (
this.nodeT
ype == 3)
|
|
|
326 |
|
return;
|
|
|
327 |
|
var
events = j
Query.data
( this, "e
vents" );
|
|
|
328 |
|
|
|
|
329 |
|
for
( var type
in events
)
|
|
|
330 |
|
for ( var
handler in
events[ t
ype ] )
|
|
|
331 |
|
jQuery
.event.add
( clone[ i
], type,
events[ ty
pe ][ hand
ler ], eve
nts[ type
][ handler
].data );
|
|
|
332 |
|
});
|
|
|
333 |
|
|
|
|
334 |
|
//
Return th
e cloned s
et
|
|
|
335 |
|
re
turn ret;
|
|
|
336 |
|
},
|
|
|
337 |
|
|
|
|
338 |
|
filter
: function
( selector
) {
|
|
|
339 |
|
re
turn this.
pushStack(
|
|
|
340 |
|
jQuery.i
sFunction(
selector
) &&
|
|
|
341 |
|
jQuery.g
rep(this,
function(e
lem, i){
|
|
|
342 |
|
retu
rn selecto
r.call( el
em, i );
|
|
|
343 |
|
}) ||
|
|
|
344 |
|
|
|
|
345 |
|
jQuery.m
ultiFilter
( selector
, this ) )
;
|
|
|
346 |
|
},
|
|
|
347 |
|
|
|
|
348 |
|
not: f
unction( s
elector )
{
|
|
|
349 |
|
if
( selecto
r.construc
tor == Str
ing )
|
|
|
350 |
|
// test
special ca
se where j
ust one se
lector is
passed in
|
|
|
351 |
|
if ( isS
imple.test
( selector
) )
|
|
|
352 |
|
retu
rn this.pu
shStack( j
Query.mult
iFilter( s
elector, t
his, true
) );
|
|
|
353 |
|
else
|
|
|
354 |
|
sele
ctor = jQu
ery.multiF
ilter( sel
ector, thi
s );
|
|
|
355 |
|
|
|
|
356 |
|
va
r isArrayL
ike = sele
ctor.lengt
h && selec
tor[select
or.length
- 1] !== u
ndefined &
& !selecto
r.nodeType
;
|
|
|
357 |
|
re
turn this.
filter(fun
ction() {
|
|
|
358 |
|
return i
sArrayLike
? jQuery.
inArray( t
his, selec
tor ) < 0
: this !=
selector;
|
|
|
359 |
|
})
;
|
|
|
360 |
|
},
|
|
|
361 |
|
|
|
|
362 |
|
add: f
unction( s
elector )
{
|
|
|
363 |
|
re
turn !sele
ctor ? thi
s : this.p
ushStack(
jQuery.mer
ge(
|
|
|
364 |
|
this.get
(),
|
|
|
365 |
|
selector
.construct
or == Stri
ng ?
|
|
|
366 |
|
jQue
ry( select
or ).get()
:
|
|
|
367 |
|
sele
ctor.lengt
h != undef
ined && (!
selector.n
odeName ||
jQuery.no
deName(sel
ector, "fo
rm")) ?
|
|
|
368 |
|
selector :
[selector
] ) );
|
|
|
369 |
|
},
|
|
|
370 |
|
|
|
|
371 |
|
is: fu
nction( se
lector ) {
|
|
|
372 |
|
re
turn selec
tor ?
|
|
|
373 |
|
jQuery.m
ultiFilter
( selector
, this ).l
ength > 0
:
|
|
|
374 |
|
false;
|
|
|
375 |
|
},
|
|
|
376 |
|
|
|
|
377 |
|
hasCla
ss: functi
on( select
or ) {
|
|
|
378 |
|
re
turn this.
is( "." +
selector )
;
|
|
|
379 |
|
},
|
|
|
380 |
|
|
|
|
381 |
|
val: f
unction( v
alue ) {
|
|
|
382 |
|
if
( value =
= undefine
d ) {
|
|
|
383 |
|
|
|
|
384 |
|
if ( thi
s.length )
{
|
|
|
385 |
|
var
elem = thi
s[0];
|
|
|
386 |
|
|
|
|
387 |
|
// W
e need to
handle sel
ect boxes
special
|
|
|
388 |
|
if (
jQuery.no
deName( el
em, "selec
t" ) ) {
|
|
|
389 |
|
var index
= elem.sel
ectedIndex
,
|
|
|
390 |
|
values
= [],
|
|
|
391 |
|
option
s = elem.o
ptions,
|
|
|
392 |
|
one =
elem.type
== "select
-one";
|
|
|
393 |
|
|
|
|
394 |
|
// Nothing
was selec
ted
|
|
|
395 |
|
if ( index
< 0 )
|
|
|
396 |
|
return
null;
|
|
|
397 |
|
|
|
|
398 |
|
// Loop th
rough all
the select
ed options
|
|
|
399 |
|
for ( var
i = one ?
index : 0,
max = one
? index +
1 : optio
ns.length;
i < max;
i++ ) {
|
|
|
400 |
|
var op
tion = opt
ions[ i ];
|
|
|
401 |
|
|
|
|
402 |
|
if ( o
ption.sele
cted ) {
|
|
|
403 |
|
//
Get the s
pecifc val
ue for the
option
|
|
|
404 |
|
va
lue = jQue
ry.browser
.msie && !
option.att
ributes.va
lue.specif
ied ? opti
on.text :
option.val
ue;
|
|
|
405 |
|
|
|
|
406 |
|
//
We don't
need an ar
ray for on
e selects
|
|
|
407 |
|
if
( one )
|
|
|
408 |
|
return v
alue;
|
|
|
409 |
|
|
|
|
410 |
|
//
Multi-Sel
ects retur
n an array
|
|
|
411 |
|
va
lues.push(
value );
|
|
|
412 |
|
}
|
|
|
413 |
|
}
|
|
|
414 |
|
|
|
|
415 |
|
return val
ues;
|
|
|
416 |
|
|
|
|
417 |
|
// E
verything
else, we j
ust grab t
he value
|
|
|
418 |
|
} el
se
|
|
|
419 |
|
return (th
is[0].valu
e || "").r
eplace(/\r
/g, "");
|
|
|
420 |
|
|
|
|
421 |
|
}
|
|
|
422 |
|
|
|
|
423 |
|
return u
ndefined;
|
|
|
424 |
|
}
|
|
|
425 |
|
|
|
|
426 |
|
re
turn this.
each(funct
ion(){
|
|
|
427 |
|
if ( thi
s.nodeType
!= 1 )
|
|
|
428 |
|
retu
rn;
|
|
|
429 |
|
|
|
|
430 |
|
if ( val
ue.constru
ctor == Ar
ray && /ra
dio|checkb
ox/.test(
this.type
) )
|
|
|
431 |
|
this
.checked =
(jQuery.i
nArray(thi
s.value, v
alue) >= 0
||
|
|
|
432 |
|
jQuery.inA
rray(this.
name, valu
e) >= 0);
|
|
|
433 |
|
|
|
|
434 |
|
else if
( jQuery.n
odeName( t
his, "sele
ct" ) ) {
|
|
|
435 |
|
var
values = v
alue.const
ructor ==
Array ?
|
|
|
436 |
|
value :
|
|
|
437 |
|
[ value ];
|
|
|
438 |
|
|
|
|
439 |
|
jQue
ry( "optio
n", this )
.each(func
tion(){
|
|
|
440 |
|
this.selec
ted = (jQu
ery.inArra
y( this.va
lue, value
s ) >= 0 |
|
|
|
|
441 |
|
jQuery
.inArray(
this.text,
values )
>= 0);
|
|
|
442 |
|
});
|
|
|
443 |
|
|
|
|
444 |
|
if (
!values.l
ength )
|
|
|
445 |
|
this.selec
tedIndex =
-1;
|
|
|
446 |
|
|
|
|
447 |
|
} else
|
|
|
448 |
|
this
.value = v
alue;
|
|
|
449 |
|
})
;
|
|
|
450 |
|
},
|
|
|
451 |
|
|
|
|
452 |
|
html:
function(
value ) {
|
|
|
453 |
|
re
turn value
== undefi
ned ?
|
|
|
454 |
|
(this.le
ngth ?
|
|
|
455 |
|
this
[0].innerH
TML :
|
|
|
456 |
|
null
) :
|
|
|
457 |
|
this.emp
ty().appen
d( value )
;
|
|
|
458 |
|
},
|
|
|
459 |
|
|
|
|
460 |
|
replac
eWith: fun
ction( val
ue ) {
|
|
|
461 |
|
re
turn this.
after( val
ue ).remov
e();
|
|
|
462 |
|
},
|
|
|
463 |
|
|
|
|
464 |
|
eq: fu
nction( i
) {
|
|
|
465 |
|
re
turn this.
slice( i,
i + 1 );
|
|
|
466 |
|
},
|
|
|
467 |
|
|
|
|
468 |
|
slice:
function(
) {
|
|
|
469 |
|
re
turn this.
pushStack(
Array.pro
totype.sli
ce.apply(
this, argu
ments ) );
|
|
|
470 |
|
},
|
|
|
471 |
|
|
|
|
472 |
|
map: f
unction( c
allback )
{
|
|
|
473 |
|
re
turn this.
pushStack(
jQuery.ma
p(this, fu
nction(ele
m, i){
|
|
|
474 |
|
return c
allback.ca
ll( elem,
i, elem );
|
|
|
475 |
|
})
);
|
|
|
476 |
|
},
|
|
|
477 |
|
|
|
|
478 |
|
andSel
f: functio
n() {
|
|
|
479 |
|
re
turn this.
add( this.
prevObject
);
|
|
|
480 |
|
},
|
|
|
481 |
|
|
|
|
482 |
|
data:
function(
key, value
){
|
|
|
483 |
|
va
r parts =
key.split(
".");
|
|
|
484 |
|
pa
rts[1] = p
arts[1] ?
"." + part
s[1] : "";
|
|
|
485 |
|
|
|
|
486 |
|
if
( value =
= null ) {
|
|
|
487 |
|
var data
= this.tr
iggerHandl
er("getDat
a" + parts
[1] + "!",
[parts[0]
]);
|
|
|
488 |
|
|
|
|
489 |
|
if ( dat
a == undef
ined && th
is.length
)
|
|
|
490 |
|
data
= jQuery.
data( this
[0], key )
;
|
|
|
491 |
|
|
|
|
492 |
|
return d
ata == nul
l && parts
[1] ?
|
|
|
493 |
|
this
.data( par
ts[0] ) :
|
|
|
494 |
|
data
;
|
|
|
495 |
|
}
else
|
|
|
496 |
|
return t
his.trigge
r("setData
" + parts[
1] + "!",
[parts[0],
value]).e
ach(functi
on(){
|
|
|
497 |
|
jQue
ry.data( t
his, key,
value );
|
|
|
498 |
|
});
|
|
|
499 |
|
},
|
|
|
500 |
|
|
|
|
501 |
|
remove
Data: func
tion( key
){
|
|
|
502 |
|
re
turn this.
each(funct
ion(){
|
|
|
503 |
|
jQuery.r
emoveData(
this, key
);
|
|
|
504 |
|
})
;
|
|
|
505 |
|
},
|
|
|
506 |
|
|
|
|
507 |
|
domMan
ip: functi
on( args,
table, rev
erse, call
back ) {
|
|
|
508 |
|
va
r clone =
this.lengt
h > 1, ele
ms;
|
|
|
509 |
|
|
|
|
510 |
|
re
turn this.
each(funct
ion(){
|
|
|
511 |
|
if ( !el
ems ) {
|
|
|
512 |
|
elem
s = jQuery
.clean( ar
gs, this.o
wnerDocume
nt );
|
|
|
513 |
|
|
|
|
514 |
|
if (
reverse )
|
|
|
515 |
|
elems.reve
rse();
|
|
|
516 |
|
}
|
|
|
517 |
|
|
|
|
518 |
|
var obj
= this;
|
|
|
519 |
|
|
|
|
520 |
|
if ( tab
le && jQue
ry.nodeNam
e( this, "
table" ) &
& jQuery.n
odeName( e
lems[0], "
tr" ) )
|
|
|
521 |
|
obj
= this.get
ElementsBy
TagName("t
body")[0]
|| this.ap
pendChild(
this.owne
rDocument.
createElem
ent("tbody
") );
|
|
|
522 |
|
|
|
|
523 |
|
var scri
pts = jQue
ry( [] );
|
|
|
524 |
|
|
|
|
525 |
|
jQuery.e
ach(elems,
function(
){
|
|
|
526 |
|
var
elem = clo
ne ?
|
|
|
527 |
|
jQuery( th
is ).clone
( true )[0
] :
|
|
|
528 |
|
this;
|
|
|
529 |
|
|
|
|
530 |
|
// e
xecute all
scripts a
fter the e
lements ha
ve been in
jected
|
|
|
531 |
|
if (
jQuery.no
deName( el
em, "scrip
t" ) ) {
|
|
|
532 |
|
scripts =
scripts.ad
d( elem );
|
|
|
533 |
|
} el
se {
|
|
|
534 |
|
// Remove
any inner
scripts fo
r later ev
aluation
|
|
|
535 |
|
if ( elem.
nodeType =
= 1 )
|
|
|
536 |
|
script
s = script
s.add( jQu
ery( "scri
pt", elem
).remove()
);
|
|
|
537 |
|
|
|
|
538 |
|
// Inject
the elemen
ts into th
e document
|
|
|
539 |
|
callback.c
all( obj,
elem );
|
|
|
540 |
|
}
|
|
|
541 |
|
});
|
|
|
542 |
|
|
|
|
543 |
|
scripts.
each( eval
Script );
|
|
|
544 |
|
})
;
|
|
|
545 |
|
}
|
|
|
546 |
|
};
|
|
|
547 |
|
|
|
|
548 |
|
// Give th
e init fun
ction the
jQuery pro
totype for
later ins
tantiation
|
|
|
549 |
|
jQuery.pro
totype.ini
t.prototyp
e = jQuery
.prototype
;
|
|
|
550 |
|
|
|
|
551 |
|
function e
valScript(
i, elem )
{
|
|
|
552 |
|
if ( e
lem.src )
|
|
|
553 |
|
jQ
uery.ajax(
{
|
|
|
554 |
|
url: ele
m.src,
|
|
|
555 |
|
async: f
alse,
|
|
|
556 |
|
dataType
: "script"
|
|
|
557 |
|
})
;
|
|
|
558 |
|
|
|
|
559 |
|
else
|
|
|
560 |
|
jQ
uery.globa
lEval( ele
m.text ||
elem.textC
ontent ||
elem.inner
HTML || ""
);
|
|
|
561 |
|
|
|
|
562 |
|
if ( e
lem.parent
Node )
|
|
|
563 |
|
el
em.parentN
ode.remove
Child( ele
m );
|
|
|
564 |
|
}
|
|
|
565 |
|
|
|
|
566 |
|
jQuery.ext
end = jQue
ry.fn.exte
nd = funct
ion() {
|
|
|
567 |
|
// cop
y referenc
e to targe
t object
|
|
|
568 |
|
var ta
rget = arg
uments[0]
|| {}, i =
1, length
= argumen
ts.length,
deep = fa
lse, optio
ns;
|
|
|
569 |
|
|
|
|
570 |
|
// Han
dle a deep
copy situ
ation
|
|
|
571 |
|
if ( t
arget.cons
tructor ==
Boolean )
{
|
|
|
572 |
|
de
ep = targe
t;
|
|
|
573 |
|
ta
rget = arg
uments[1]
|| {};
|
|
|
574 |
|
//
skip the
boolean an
d the targ
et
|
|
|
575 |
|
i
= 2;
|
|
|
576 |
|
}
|
|
|
577 |
|
|
|
|
578 |
|
// Han
dle case w
hen target
is a stri
ng or some
thing (pos
sible in d
eep copy)
|
|
|
579 |
|
if ( t
ypeof targ
et != "obj
ect" && ty
peof targe
t != "func
tion" )
|
|
|
580 |
|
ta
rget = {};
|
|
|
581 |
|
|
|
|
582 |
|
// ext
end jQuery
itself if
only one
argument i
s passed
|
|
|
583 |
|
if ( l
ength == 1
) {
|
|
|
584 |
|
ta
rget = thi
s;
|
|
|
585 |
|
i
= 0;
|
|
|
586 |
|
}
|
|
|
587 |
|
|
|
|
588 |
|
for (
; i < leng
th; i++ )
|
|
|
589 |
|
//
Only deal
with non-
null/undef
ined value
s
|
|
|
590 |
|
if
( (option
s = argume
nts[ i ])
!= null )
|
|
|
591 |
|
// Exten
d the base
object
|
|
|
592 |
|
for ( va
r name in
options )
{
|
|
|
593 |
|
// P
revent nev
er-ending
loop
|
|
|
594 |
|
if (
target ==
= options[
name ] )
|
|
|
595 |
|
continue;
|
|
|
596 |
|
|
|
|
597 |
|
// R
ecurse if
we're merg
ing object
values
|
|
|
598 |
|
if (
deep && o
ptions[ na
me ] && ty
peof optio
ns[ name ]
== "objec
t" && targ
et[ name ]
&& !optio
ns[ name ]
.nodeType
)
|
|
|
599 |
|
target[ na
me ] = jQu
ery.extend
( target[
name ], op
tions[ nam
e ] );
|
|
|
600 |
|
|
|
|
601 |
|
// D
on't bring
in undefi
ned values
|
|
|
602 |
|
else
if ( opti
ons[ name
] != undef
ined )
|
|
|
603 |
|
target[ na
me ] = opt
ions[ name
];
|
|
|
604 |
|
|
|
|
605 |
|
}
|
|
|
606 |
|
|
|
|
607 |
|
// Ret
urn the mo
dified obj
ect
|
|
|
608 |
|
return
target;
|
|
|
609 |
|
};
|
|
|
610 |
|
|
|
|
611 |
|
var expand
o = "jQuer
y" + (new
Date()).ge
tTime(), u
uid = 0, w
indowData
= {};
|
|
|
612 |
|
|
|
|
613 |
|
// exclude
the follo
wing css p
roperties
to add px
|
|
|
614 |
|
var exclud
e = /z-?in
dex|font-?
weight|opa
city|zoom|
line-?heig
ht/i;
|
|
|
615 |
|
|
|
|
616 |
|
jQuery.ext
end({
|
|
|
617 |
|
noConf
lict: func
tion( deep
) {
|
|
|
618 |
|
wi
ndow.$ = _
$;
|
|
|
619 |
|
|
|
|
620 |
|
if
( deep )
|
|
|
621 |
|
window.j
Query = _j
Query;
|
|
|
622 |
|
|
|
|
623 |
|
re
turn jQuer
y;
|
|
|
624 |
|
},
|
|
|
625 |
|
|
|
|
626 |
|
// See
test/unit
/core.js f
or details
concernin
g this fun
ction.
|
|
|
627 |
|
isFunc
tion: func
tion( fn )
{
|
|
|
628 |
|
re
turn !!fn
&& typeof
fn != "str
ing" && !f
n.nodeName
&&
|
|
|
629 |
|
fn.const
ructor !=
Array && /
function/i
.test( fn
+ "" );
|
|
|
630 |
|
},
|
|
|
631 |
|
|
|
|
632 |
|
// che
ck if an e
lement is
in a (or i
s an) XML
document
|
|
|
633 |
|
isXMLD
oc: functi
on( elem )
{
|
|
|
634 |
|
re
turn elem.
documentEl
ement && !
elem.body
||
|
|
|
635 |
|
elem.tag
Name && el
em.ownerDo
cument &&
!elem.owne
rDocument.
body;
|
|
|
636 |
|
},
|
|
|
637 |
|
|
|
|
638 |
|
// Eva
lulates a
script in
a global c
ontext
|
|
|
639 |
|
global
Eval: func
tion( data
) {
|
|
|
640 |
|
da
ta = jQuer
y.trim( da
ta );
|
|
|
641 |
|
|
|
|
642 |
|
if
( data )
{
|
|
|
643 |
|
// Inspi
red by cod
e by Andre
a Giammarc
hi
|
|
|
644 |
|
// http:
//webrefle
ction.blog
spot.com/2
007/08/glo
bal-scope-
evaluation
-and-dom.h
tml
|
|
|
645 |
|
var head
= documen
t.getEleme
ntsByTagNa
me("head")
[0] || doc
ument.docu
mentElemen
t,
|
|
|
646 |
|
scri
pt = docum
ent.create
Element("s
cript");
|
|
|
647 |
|
|
|
|
648 |
|
script.t
ype = "tex
t/javascri
pt";
|
|
|
649 |
|
if ( jQu
ery.browse
r.msie )
|
|
|
650 |
|
scri
pt.text =
data;
|
|
|
651 |
|
else
|
|
|
652 |
|
scri
pt.appendC
hild( docu
ment.creat
eTextNode(
data ) );
|
|
|
653 |
|
|
|
|
654 |
|
head.app
endChild(
script );
|
|
|
655 |
|
head.rem
oveChild(
script );
|
|
|
656 |
|
}
|
|
|
657 |
|
},
|
|
|
658 |
|
|
|
|
659 |
|
nodeNa
me: functi
on( elem,
name ) {
|
|
|
660 |
|
re
turn elem.
nodeName &
& elem.nod
eName.toUp
perCase()
== name.to
UpperCase(
);
|
|
|
661 |
|
},
|
|
|
662 |
|
|
|
|
663 |
|
cache:
{},
|
|
|
664 |
|
|
|
|
665 |
|
data:
function(
elem, name
, data ) {
|
|
|
666 |
|
el
em = elem
== window
?
|
|
|
667 |
|
windowDa
ta :
|
|
|
668 |
|
elem;
|
|
|
669 |
|
|
|
|
670 |
|
va
r id = ele
m[ expando
];
|
|
|
671 |
|
|
|
|
672 |
|
//
Compute a
unique ID
for the e
lement
|
|
|
673 |
|
if
( !id )
|
|
|
674 |
|
id = ele
m[ expando
] = ++uui
d;
|
|
|
675 |
|
|
|
|
676 |
|
//
Only gene
rate the d
ata cache
if we're
|
|
|
677 |
|
//
trying to
access or
manipulat
e it
|
|
|
678 |
|
if
( name &&
!jQuery.c
ache[ id ]
)
|
|
|
679 |
|
jQuery.c
ache[ id ]
= {};
|
|
|
680 |
|
|
|
|
681 |
|
//
Prevent o
verriding
the named
cache with
undefined
values
|
|
|
682 |
|
if
( data !=
undefined
)
|
|
|
683 |
|
jQuery.c
ache[ id ]
[ name ] =
data;
|
|
|
684 |
|
|
|
|
685 |
|
//
Return th
e named ca
che data,
or the ID
for the el
ement
|
|
|
686 |
|
re
turn name
?
|
|
|
687 |
|
jQuery.c
ache[ id ]
[ name ] :
|
|
|
688 |
|
id;
|
|
|
689 |
|
},
|
|
|
690 |
|
|
|
|
691 |
|
remove
Data: func
tion( elem
, name ) {
|
|
|
692 |
|
el
em = elem
== window
?
|
|
|
693 |
|
windowDa
ta :
|
|
|
694 |
|
elem;
|
|
|
695 |
|
|
|
|
696 |
|
va
r id = ele
m[ expando
];
|
|
|
697 |
|
|
|
|
698 |
|
//
If we wan
t to remov
e a specif
ic section
of the el
ement's da
ta
|
|
|
699 |
|
if
( name )
{
|
|
|
700 |
|
if ( jQu
ery.cache[
id ] ) {
|
|
|
701 |
|
// R
emove the
section of
cache dat
a
|
|
|
702 |
|
dele
te jQuery.
cache[ id
][ name ];
|
|
|
703 |
|
|
|
|
704 |
|
// I
f we've re
moved all
the data,
remove the
element's
cache
|
|
|
705 |
|
name
= "";
|
|
|
706 |
|
|
|
|
707 |
|
for
( name in
jQuery.cac
he[ id ] )
|
|
|
708 |
|
break;
|
|
|
709 |
|
|
|
|
710 |
|
if (
!name )
|
|
|
711 |
|
jQuery.rem
oveData( e
lem );
|
|
|
712 |
|
}
|
|
|
713 |
|
|
|
|
714 |
|
//
Otherwise
, we want
to remove
all of the
element's
data
|
|
|
715 |
|
}
else {
|
|
|
716 |
|
// Clean
up the el
ement expa
ndo
|
|
|
717 |
|
try {
|
|
|
718 |
|
dele
te elem[ e
xpando ];
|
|
|
719 |
|
} catch(
e){
|
|
|
720 |
|
// I
E has trou
ble direct
ly removin
g the expa
ndo
|
|
|
721 |
|
// b
ut it's ok
with usin
g removeAt
tribute
|
|
|
722 |
|
if (
elem.remo
veAttribut
e )
|
|
|
723 |
|
elem.remov
eAttribute
( expando
);
|
|
|
724 |
|
}
|
|
|
725 |
|
|
|
|
726 |
|
// Compl
etely remo
ve the dat
a cache
|
|
|
727 |
|
delete j
Query.cach
e[ id ];
|
|
|
728 |
|
}
|
|
|
729 |
|
},
|
|
|
730 |
|
|
|
|
731 |
|
// arg
s is for i
nternal us
age only
|
|
|
732 |
|
each:
function(
object, ca
llback, ar
gs ) {
|
|
|
733 |
|
if
( args )
{
|
|
|
734 |
|
if ( obj
ect.length
== undefi
ned ) {
|
|
|
735 |
|
for
( var name
in object
)
|
|
|
736 |
|
if ( callb
ack.apply(
object[ n
ame ], arg
s ) === fa
lse )
|
|
|
737 |
|
break;
|
|
|
738 |
|
} else
|
|
|
739 |
|
for
( var i =
0, length
= object.l
ength; i <
length; i
++ )
|
|
|
740 |
|
if ( callb
ack.apply(
object[ i
], args )
=== false
)
|
|
|
741 |
|
break;
|
|
|
742 |
|
|
|
|
743 |
|
//
A special
, fast, ca
se for the
most comm
on use of
each
|
|
|
744 |
|
}
else {
|
|
|
745 |
|
if ( obj
ect.length
== undefi
ned ) {
|
|
|
746 |
|
for
( var name
in object
)
|
|
|
747 |
|
if ( callb
ack.call(
object[ na
me ], name
, object[
name ] ) =
== false )
|
|
|
748 |
|
break;
|
|
|
749 |
|
} else
|
|
|
750 |
|
for
( var i =
0, length
= object.l
ength, val
ue = objec
t[0];
|
|
|
751 |
|
i < length
&& callba
ck.call( v
alue, i, v
alue ) !==
false; va
lue = obje
ct[++i] ){
}
|
|
|
752 |
|
}
|
|
|
753 |
|
|
|
|
754 |
|
re
turn objec
t;
|
|
|
755 |
|
},
|
|
|
756 |
|
|
|
|
757 |
|
prop:
function(
elem, valu
e, type, i
, name ) {
|
|
|
758 |
|
// Handl
e executab
le functio
ns
|
|
|
759 |
|
if ( jQu
ery.isFunc
tion( valu
e ) )
|
|
|
760 |
|
valu
e = value.
call( elem
, i );
|
|
|
761 |
|
|
|
|
762 |
|
// Handl
e passing
in a numbe
r to a CSS
property
|
|
|
763 |
|
return v
alue && va
lue.constr
uctor == N
umber && t
ype == "cu
rCSS" && !
exclude.te
st( name )
?
|
|
|
764 |
|
valu
e + "px" :
|
|
|
765 |
|
valu
e;
|
|
|
766 |
|
},
|
|
|
767 |
|
|
|
|
768 |
|
classN
ame: {
|
|
|
769 |
|
//
internal
only, use
addClass("
class")
|
|
|
770 |
|
ad
d: functio
n( elem, c
lassNames
) {
|
|
|
771 |
|
jQuery.e
ach((class
Names || "
").split(/
\s+/), fun
ction(i, c
lassName){
|
|
|
772 |
|
if (
elem.node
Type == 1
&& !jQuery
.className
.has( elem
.className
, classNam
e ) )
|
|
|
773 |
|
elem.class
Name += (e
lem.classN
ame ? " "
: "") + cl
assName;
|
|
|
774 |
|
});
|
|
|
775 |
|
},
|
|
|
776 |
|
|
|
|
777 |
|
//
internal
only, use
removeClas
s("class")
|
|
|
778 |
|
re
move: func
tion( elem
, classNam
es ) {
|
|
|
779 |
|
if (elem
.nodeType
== 1)
|
|
|
780 |
|
elem
.className
= classNa
mes != und
efined ?
|
|
|
781 |
|
jQuery.gre
p(elem.cla
ssName.spl
it(/\s+/),
function(
className)
{
|
|
|
782 |
|
return
!jQuery.c
lassName.h
as( classN
ames, clas
sName );
|
|
|
783 |
|
}).join("
") :
|
|
|
784 |
|
"";
|
|
|
785 |
|
},
|
|
|
786 |
|
|
|
|
787 |
|
//
internal
only, use
is(".class
")
|
|
|
788 |
|
ha
s: functio
n( elem, c
lassName )
{
|
|
|
789 |
|
return j
Query.inAr
ray( class
Name, (ele
m.classNam
e || elem)
.toString(
).split(/\
s+/) ) > -
1;
|
|
|
790 |
|
}
|
|
|
791 |
|
},
|
|
|
792 |
|
|
|
|
793 |
|
// A m
ethod for
quickly sw
apping in/
out CSS pr
operties t
o get corr
ect calcul
ations
|
|
|
794 |
|
swap:
function(
elem, opti
ons, callb
ack ) {
|
|
|
795 |
|
va
r old = {}
;
|
|
|
796 |
|
//
Remember
the old va
lues, and
insert the
new ones
|
|
|
797 |
|
fo
r ( var na
me in opti
ons ) {
|
|
|
798 |
|
old[ nam
e ] = elem
.style[ na
me ];
|
|
|
799 |
|
elem.sty
le[ name ]
= options
[ name ];
|
|
|
800 |
|
}
|
|
|
801 |
|
|
|
|
802 |
|
ca
llback.cal
l( elem );
|
|
|
803 |
|
|
|
|
804 |
|
//
Revert th
e old valu
es
|
|
|
805 |
|
fo
r ( var na
me in opti
ons )
|
|
|
806 |
|
elem.sty
le[ name ]
= old[ na
me ];
|
|
|
807 |
|
},
|
|
|
808 |
|
|
|
|
809 |
|
css: f
unction( e
lem, name,
force ) {
|
|
|
810 |
|
if
( name ==
"width" |
| name ==
"height" )
{
|
|
|
811 |
|
var val,
props = {
position:
"absolute
", visibil
ity: "hidd
en", displ
ay:"block"
}, which
= name ==
"width" ?
[ "Left",
"Right" ]
: [ "Top",
"Bottom"
];
|
|
|
812 |
|
|
|
|
813 |
|
function
getWH() {
|
|
|
814 |
|
val
= name ==
"width" ?
elem.offse
tWidth : e
lem.offset
Height;
|
|
|
815 |
|
var
padding =
0, border
= 0;
|
|
|
816 |
|
jQue
ry.each( w
hich, func
tion() {
|
|
|
817 |
|
padding +=
parseFloa
t(jQuery.c
urCSS( ele
m, "paddin
g" + this,
true)) ||
0;
|
|
|
818 |
|
border +=
parseFloat
(jQuery.cu
rCSS( elem
, "border"
+ this +
"Width", t
rue)) || 0
;
|
|
|
819 |
|
});
|
|
|
820 |
|
val
-= Math.ro
und(paddin
g + border
);
|
|
|
821 |
|
}
|
|
|
822 |
|
|
|
|
823 |
|
if ( jQu
ery(elem).
is(":visib
le") )
|
|
|
824 |
|
getW
H();
|
|
|
825 |
|
else
|
|
|
826 |
|
jQue
ry.swap( e
lem, props
, getWH );
|
|
|
827 |
|
|
|
|
828 |
|
return M
ath.max(0,
val);
|
|
|
829 |
|
}
|
|
|
830 |
|
|
|
|
831 |
|
re
turn jQuer
y.curCSS(
elem, name
, force );
|
|
|
832 |
|
},
|
|
|
833 |
|
|
|
|
834 |
|
curCSS
: function
( elem, na
me, force
) {
|
|
|
835 |
|
va
r ret;
|
|
|
836 |
|
|
|
|
837 |
|
//
A helper
method for
determini
ng if an e
lement's v
alues are
broken
|
|
|
838 |
|
fu
nction col
or( elem )
{
|
|
|
839 |
|
if ( !jQ
uery.brows
er.safari
)
|
|
|
840 |
|
retu
rn false;
|
|
|
841 |
|
|
|
|
842 |
|
var ret
= document
.defaultVi
ew.getComp
utedStyle(
elem, nul
l );
|
|
|
843 |
|
return !
ret || ret
.getProper
tyValue("c
olor") ==
"";
|
|
|
844 |
|
}
|
|
|
845 |
|
|
|
|
846 |
|
//
We need t
o handle o
pacity spe
cial in IE
|
|
|
847 |
|
if
( name ==
"opacity"
&& jQuery
.browser.m
sie ) {
|
|
|
848 |
|
ret = jQ
uery.attr(
elem.styl
e, "opacit
y" );
|
|
|
849 |
|
|
|
|
850 |
|
return r
et == "" ?
|
|
|
851 |
|
"1"
:
|
|
|
852 |
|
ret;
|
|
|
853 |
|
}
|
|
|
854 |
|
//
Opera som
etimes wil
l give the
wrong dis
play answe
r, this fi
xes it, se
e #2037
|
|
|
855 |
|
if
( jQuery.
browser.op
era && nam
e == "disp
lay" ) {
|
|
|
856 |
|
var save
= elem.st
yle.outlin
e;
|
|
|
857 |
|
elem.sty
le.outline
= "0 soli
d black";
|
|
|
858 |
|
elem.sty
le.outline
= save;
|
|
|
859 |
|
}
|
|
|
860 |
|
|
|
|
861 |
|
//
Make sure
we're usi
ng the rig
ht name fo
r getting
the float
value
|
|
|
862 |
|
if
( name.ma
tch( /floa
t/i ) )
|
|
|
863 |
|
name = s
tyleFloat;
|
|
|
864 |
|
|
|
|
865 |
|
if
( !force
&& elem.st
yle && ele
m.style[ n
ame ] )
|
|
|
866 |
|
ret = el
em.style[
name ];
|
|
|
867 |
|
|
|
|
868 |
|
el
se if ( do
cument.def
aultView &
& document
.defaultVi
ew.getComp
utedStyle
) {
|
|
|
869 |
|
|
|
|
870 |
|
// Only
"float" is
needed he
re
|
|
|
871 |
|
if ( nam
e.match( /
float/i )
)
|
|
|
872 |
|
name
= "float"
;
|
|
|
873 |
|
|
|
|
874 |
|
name = n
ame.replac
e( /([A-Z]
)/g, "-$1"
).toLower
Case();
|
|
|
875 |
|
|
|
|
876 |
|
var getC
omputedSty
le = docum
ent.defaul
tView.getC
omputedSty
le( elem,
null );
|
|
|
877 |
|
|
|
|
878 |
|
if ( get
ComputedSt
yle && !co
lor( elem
) )
|
|
|
879 |
|
ret
= getCompu
tedStyle.g
etProperty
Value( nam
e );
|
|
|
880 |
|
|
|
|
881 |
|
// If th
e element
isn't repo
rting its
values pro
perly in S
afari
|
|
|
882 |
|
// then
some displ
ay: none e
lements ar
e involved
|
|
|
883 |
|
else {
|
|
|
884 |
|
var
swap = [],
stack = [
];
|
|
|
885 |
|
|
|
|
886 |
|
// L
ocate all
of the par
ent displa
y: none el
ements
|
|
|
887 |
|
for
( var a =
elem; a &&
color(a);
a = a.par
entNode )
|
|
|
888 |
|
stack.unsh
ift(a);
|
|
|
889 |
|
|
|
|
890 |
|
// G
o through
and make t
hem visibl
e, but in
reverse
|
|
|
891 |
|
// (
It would b
e better i
f we knew
the exact
display ty
pe that th
ey had)
|
|
|
892 |
|
for
( var i =
0; i < sta
ck.length;
i++ )
|
|
|
893 |
|
if ( color
( stack[ i
] ) ) {
|
|
|
894 |
|
swap[
i ] = stac
k[ i ].sty
le.display
;
|
|
|
895 |
|
stack[
i ].style
.display =
"block";
|
|
|
896 |
|
}
|
|
|
897 |
|
|
|
|
898 |
|
// S
ince we fl
ip the dis
play style
, we have
to handle
that
|
|
|
899 |
|
// o
ne special
, otherwis
e get the
value
|
|
|
900 |
|
ret
= name ==
"display"
&& swap[ s
tack.lengt
h - 1 ] !=
null ?
|
|
|
901 |
|
"none" :
|
|
|
902 |
|
( getCompu
tedStyle &
& getCompu
tedStyle.g
etProperty
Value( nam
e ) ) || "
";
|
|
|
903 |
|
|
|
|
904 |
|
// F
inally, re
vert the d
isplay sty
les back
|
|
|
905 |
|
for
( var i =
0; i < swa
p.length;
i++ )
|
|
|
906 |
|
if ( swap[
i ] != nu
ll )
|
|
|
907 |
|
stack[
i ].style
.display =
swap[ i ]
;
|
|
|
908 |
|
}
|
|
|
909 |
|
|
|
|
910 |
|
// We sh
ould alway
s get a nu
mber back
from opaci
ty
|
|
|
911 |
|
if ( nam
e == "opac
ity" && re
t == "" )
|
|
|
912 |
|
ret
= "1";
|
|
|
913 |
|
|
|
|
914 |
|
}
else if (
elem.curre
ntStyle )
{
|
|
|
915 |
|
var came
lCase = na
me.replace
(/\-(\w)/g
, function
(all, lett
er){
|
|
|
916 |
|
retu
rn letter.
toUpperCas
e();
|
|
|
917 |
|
});
|
|
|
918 |
|
|
|
|
919 |
|
ret = el
em.current
Style[ nam
e ] || ele
m.currentS
tyle[ came
lCase ];
|
|
|
920 |
|
|
|
|
921 |
|
// From
the awesom
e hack by
Dean Edwar
ds
|
|
|
922 |
|
// http:
//erik.eae
.net/archi
ves/2007/0
7/27/18.54
.15/#comme
nt-102291
|
|
|
923 |
|
|
|
|
924 |
|
// If we
're not de
aling with
a regular
pixel num
ber
|
|
|
925 |
|
// but a
number th
at has a w
eird endin
g, we need
to conver
t it to pi
xels
|
|
|
926 |
|
if ( !/^
\d+(px)?$/
i.test( re
t ) && /^\
d/.test( r
et ) ) {
|
|
|
927 |
|
// R
emember th
e original
values
|
|
|
928 |
|
var
style = el
em.style.l
eft, runti
meStyle =
elem.runti
meStyle.le
ft;
|
|
|
929 |
|
|
|
|
930 |
|
// P
ut in the
new values
to get a
computed v
alue out
|
|
|
931 |
|
elem
.runtimeSt
yle.left =
elem.curr
entStyle.l
eft;
|
|
|
932 |
|
elem
.style.lef
t = ret ||
0;
|
|
|
933 |
|
ret
= elem.sty
le.pixelLe
ft + "px";
|
|
|
934 |
|
|
|
|
935 |
|
// R
evert the
changed va
lues
|
|
|
936 |
|
elem
.style.lef
t = style;
|
|
|
937 |
|
elem
.runtimeSt
yle.left =
runtimeSt
yle;
|
|
|
938 |
|
}
|
|
|
939 |
|
}
|
|
|
940 |
|
|
|
|
941 |
|
re
turn ret;
|
|
|
942 |
|
},
|
|
|
943 |
|
|
|
|
944 |
|
clean:
function(
elems, co
ntext ) {
|
|
|
945 |
|
va
r ret = []
;
|
|
|
946 |
|
co
ntext = co
ntext || d
ocument;
|
|
|
947 |
|
//
!context.
createElem
ent fails
in IE with
an error
but return
s typeof '
object'
|
|
|
948 |
|
if
(typeof c
ontext.cre
ateElement
== 'undef
ined')
|
|
|
949 |
|
context
= context.
ownerDocum
ent || con
text[0] &&
context[0
].ownerDoc
ument || d
ocument;
|
|
|
950 |
|
|
|
|
951 |
|
jQ
uery.each(
elems, fun
ction(i, e
lem){
|
|
|
952 |
|
if ( !el
em )
|
|
|
953 |
|
retu
rn;
|
|
|
954 |
|
|
|
|
955 |
|
if ( ele
m.construc
tor == Num
ber )
|
|
|
956 |
|
elem
= elem.to
String();
|
|
|
957 |
|
|
|
|
958 |
|
// Conve
rt html st
ring into
DOM nodes
|
|
|
959 |
|
if ( typ
eof elem =
= "string"
) {
|
|
|
960 |
|
// F
ix "XHTML"
-style tag
s in all b
rowsers
|
|
|
961 |
|
elem
= elem.re
place(/(<(
\w+)[^>]*?
)\/>/g, fu
nction(all
, front, t
ag){
|
|
|
962 |
|
return tag
.match(/^(
abbr|br|co
l|img|inpu
t|link|met
a|param|hr
|area|embe
d)$/i) ?
|
|
|
963 |
|
all :
|
|
|
964 |
|
front
+ "></" +
tag + ">";
|
|
|
965 |
|
});
|
|
|
966 |
|
|
|
|
967 |
|
// T
rim whites
pace, othe
rwise inde
xOf won't
work as ex
pected
|
|
|
968 |
|
var
tags = jQu
ery.trim(
elem ).toL
owerCase()
, div = co
ntext.crea
teElement(
"div");
|
|
|
969 |
|
|
|
|
970 |
|
var
wrap =
|
|
|
971 |
|
// option
or optgrou
p
|
|
|
972 |
|
!tags.inde
xOf("<opt"
) &&
|
|
|
973 |
|
[ 1, "<sel
ect multip
le='multip
le'>", "</
select>" ]
||
|
|
|
974 |
|
|
|
|
975 |
|
!tags.inde
xOf("<leg"
) &&
|
|
|
976 |
|
[ 1, "<fie
ldset>", "
</fieldset
>" ] ||
|
|
|
977 |
|
|
|
|
978 |
|
tags.match
(/^<(thead
|tbody|tfo
ot|colg|ca
p)/) &&
|
|
|
979 |
|
[ 1, "<tab
le>", "</t
able>" ] |
|
|
|
|
980 |
|
|
|
|
981 |
|
!tags.inde
xOf("<tr")
&&
|
|
|
982 |
|
[ 2, "<tab
le><tbody>
", "</tbod
y></table>
" ] ||
|
|
|
983 |
|
|
|
|
984 |
|
// <thead>
matched a
bove
|
|
|
985 |
|
(!tags.ind
exOf("<td"
) || !tags
.indexOf("
<th")) &&
|
|
|
986 |
|
[ 3, "<tab
le><tbody>
<tr>", "</
tr></tbody
></table>"
] ||
|
|
|
987 |
|
|
|
|
988 |
|
!tags.inde
xOf("<col"
) &&
|
|
|
989 |
|
[ 2, "<tab
le><tbody>
</tbody><c
olgroup>",
"</colgro
up></table
>" ] ||
|
|
|
990 |
|
|
|
|
991 |
|
// IE can'
t serializ
e <link> a
nd <script
> tags nor
mally
|
|
|
992 |
|
jQuery.bro
wser.msie
&&
|
|
|
993 |
|
[ 1, "div<
div>", "</
div>" ] ||
|
|
|
994 |
|
|
|
|
995 |
|
[ 0, "", "
" ];
|
|
|
996 |
|
|
|
|
997 |
|
// G
o to html
and back,
then peel
off extra
wrappers
|
|
|
998 |
|
div.
innerHTML
= wrap[1]
+ elem + w
rap[2];
|
|
|
999 |
|
|
|
|
1000 |
|
// M
ove to the
right dep
th
|
|
|
1001 |
|
whil
e ( wrap[0
]-- )
|
|
|
1002 |
|
div = div.
lastChild;
|
|
|
1003 |
|
|
|
|
1004 |
|
// R
emove IE's
autoinser
ted <tbody
> from tab
le fragmen
ts
|
|
|
1005 |
|
if (
jQuery.br
owser.msie
) {
|
|
|
1006 |
|
|
|
|
1007 |
|
// String
was a <tab
le>, *may*
have spur
ious <tbod
y>
|
|
|
1008 |
|
var tbody
= !tags.in
dexOf("<ta
ble") && t
ags.indexO
f("<tbody"
) < 0 ?
|
|
|
1009 |
|
div.fi
rstChild &
& div.firs
tChild.chi
ldNodes :
|
|
|
1010 |
|
|
|
|
1011 |
|
// Str
ing was a
bare <thea
d> or <tfo
ot>
|
|
|
1012 |
|
wrap[1
] == "<tab
le>" && ta
gs.indexOf
("<tbody")
< 0 ?
|
|
|
1013 |
|
di
v.childNod
es :
|
|
|
1014 |
|
[]
;
|
|
|
1015 |
|
|
|
|
1016 |
|
for ( var
j = tbody.
length - 1
; j >= 0 ;
--j )
|
|
|
1017 |
|
if ( j
Query.node
Name( tbod
y[ j ], "t
body" ) &&
!tbody[ j
].childNo
des.length
)
|
|
|
1018 |
|
tb
ody[ j ].p
arentNode.
removeChil
d( tbody[
j ] );
|
|
|
1019 |
|
|
|
|
1020 |
|
// IE comp
letely kil
ls leading
whitespac
e when inn
erHTML is
used
|
|
|
1021 |
|
if ( /^\s/
.test( ele
m ) )
|
|
|
1022 |
|
div.in
sertBefore
( context.
createText
Node( elem
.match(/^\
s*/)[0] ),
div.first
Child );
|
|
|
1023 |
|
|
|
|
1024 |
|
}
|
|
|
1025 |
|
|
|
|
1026 |
|
elem
= jQuery.
makeArray(
div.child
Nodes );
|
|
|
1027 |
|
}
|
|
|
1028 |
|
|
|
|
1029 |
|
if ( ele
m.length =
== 0 && (!
jQuery.nod
eName( ele
m, "form"
) && !jQue
ry.nodeNam
e( elem, "
select" ))
)
|
|
|
1030 |
|
retu
rn;
|
|
|
1031 |
|
|
|
|
1032 |
|
if ( ele
m[0] == un
defined ||
jQuery.no
deName( el
em, "form"
) || elem
.options )
|
|
|
1033 |
|
ret.
push( elem
);
|
|
|
1034 |
|
|
|
|
1035 |
|
else
|
|
|
1036 |
|
ret
= jQuery.m
erge( ret,
elem );
|
|
|
1037 |
|
|
|
|
1038 |
|
})
;
|
|
|
1039 |
|
|
|
|
1040 |
|
re
turn ret;
|
|
|
1041 |
|
},
|
|
|
1042 |
|
|
|
|
1043 |
|
attr:
function(
elem, name
, value )
{
|
|
|
1044 |
|
//
don't set
attribute
s on text
and commen
t nodes
|
|
|
1045 |
|
if
(!elem ||
elem.node
Type == 3
|| elem.no
deType ==
8)
|
|
|
1046 |
|
return u
ndefined;
|
|
|
1047 |
|
|
|
|
1048 |
|
va
r fix = jQ
uery.isXML
Doc( elem
) ?
|
|
|
1049 |
|
{} :
|
|
|
1050 |
|
jQuery.p
rops;
|
|
|
1051 |
|
|
|
|
1052 |
|
//
Safari mi
s-reports
the defaul
t selected
property
of a hidde
n option
|
|
|
1053 |
|
//
Accessing
the paren
t's select
edIndex pr
operty fix
es it
|
|
|
1054 |
|
if
( name ==
"selected
" && jQuer
y.browser.
safari )
|
|
|
1055 |
|
elem.par
entNode.se
lectedInde
x;
|
|
|
1056 |
|
|
|
|
1057 |
|
//
Certain a
ttributes
only work
when acces
sed via th
e old DOM
0 way
|
|
|
1058 |
|
if
( fix[ na
me ] ) {
|
|
|
1059 |
|
if ( val
ue != unde
fined )
|
|
|
1060 |
|
elem
[ fix[ nam
e ] ] = va
lue;
|
|
|
1061 |
|
|
|
|
1062 |
|
return e
lem[ fix[
name ] ];
|
|
|
1063 |
|
|
|
|
1064 |
|
}
else if (
jQuery.bro
wser.msie
&& name ==
"style" )
|
|
|
1065 |
|
return j
Query.attr
( elem.sty
le, "cssTe
xt", value
);
|
|
|
1066 |
|
|
|
|
1067 |
|
el
se if ( va
lue == und
efined &&
jQuery.bro
wser.msie
&& jQuery.
nodeName(
elem, "for
m" ) && (n
ame == "ac
tion" || n
ame == "me
thod") )
|
|
|
1068 |
|
return e
lem.getAtt
ributeNode
( name ).n
odeValue;
|
|
|
1069 |
|
|
|
|
1070 |
|
//
IE elem.g
etAttribut
e passes e
ven for st
yle
|
|
|
1071 |
|
el
se if ( el
em.tagName
) {
|
|
|
1072 |
|
|
|
|
1073 |
|
if ( val
ue != unde
fined ) {
|
|
|
1074 |
|
// W
e can't al
low the ty
pe propert
y to be ch
anged (sin
ce it caus
es problem
s in IE)
|
|
|
1075 |
|
if (
name == "
type" && j
Query.node
Name( elem
, "input"
) && elem.
parentNode
)
|
|
|
1076 |
|
throw "typ
e property
can't be
changed";
|
|
|
1077 |
|
|
|
|
1078 |
|
// c
onvert the
value to
a string (
all browse
rs do this
but IE) s
ee #1070
|
|
|
1079 |
|
elem
.setAttrib
ute( name,
"" + valu
e );
|
|
|
1080 |
|
}
|
|
|
1081 |
|
|
|
|
1082 |
|
if ( jQu
ery.browse
r.msie &&
/href|src/
.test( nam
e ) && !jQ
uery.isXML
Doc( elem
) )
|
|
|
1083 |
|
retu
rn elem.ge
tAttribute
( name, 2
);
|
|
|
1084 |
|
|
|
|
1085 |
|
return e
lem.getAtt
ribute( na
me );
|
|
|
1086 |
|
|
|
|
1087 |
|
//
elem is a
ctually el
em.style .
.. set the
style
|
|
|
1088 |
|
}
else {
|
|
|
1089 |
|
// IE ac
tually use
s filters
for opacit
y
|
|
|
1090 |
|
if ( nam
e == "opac
ity" && jQ
uery.brows
er.msie )
{
|
|
|
1091 |
|
if (
value !=
undefined
) {
|
|
|
1092 |
|
// IE has
trouble wi
th opacity
if it doe
s not have
layout
|
|
|
1093 |
|
// Force i
t by setti
ng the zoo
m level
|
|
|
1094 |
|
elem.zoom
= 1;
|
|
|
1095 |
|
|
|
|
1096 |
|
// Set the
alpha fil
ter to set
the opaci
ty
|
|
|
1097 |
|
elem.filte
r = (elem.
filter ||
"").replac
e( /alpha\
([^)]*\)/,
"" ) +
|
|
|
1098 |
|
(parse
Float( val
ue ).toStr
ing() == "
NaN" ? ""
: "alpha(o
pacity=" +
value * 1
00 + ")");
|
|
|
1099 |
|
}
|
|
|
1100 |
|
|
|
|
1101 |
|
retu
rn elem.fi
lter && el
em.filter.
indexOf("o
pacity=")
>= 0 ?
|
|
|
1102 |
|
(parseFloa
t( elem.fi
lter.match
(/opacity=
([^)]*)/)[
1] ) / 100
).toString
() :
|
|
|
1103 |
|
"";
|
|
|
1104 |
|
}
|
|
|
1105 |
|
|
|
|
1106 |
|
name = n
ame.replac
e(/-([a-z]
)/ig, func
tion(all,
letter){
|
|
|
1107 |
|
retu
rn letter.
toUpperCas
e();
|
|
|
1108 |
|
});
|
|
|
1109 |
|
|
|
|
1110 |
|
if ( val
ue != unde
fined )
|
|
|
1111 |
|
elem
[ name ] =
value;
|
|
|
1112 |
|
|
|
|
1113 |
|
return e
lem[ name
];
|
|
|
1114 |
|
}
|
|
|
1115 |
|
},
|
|
|
1116 |
|
|
|
|
1117 |
|
trim:
function(
text ) {
|
|
|
1118 |
|
re
turn (text
|| "").re
place( /^\
s+|\s+$/g,
"" );
|
|
|
1119 |
|
},
|
|
|
1120 |
|
|
|
|
1121 |
|
makeAr
ray: funct
ion( array
) {
|
|
|
1122 |
|
va
r ret = []
;
|
|
|
1123 |
|
|
|
|
1124 |
|
//
Need to u
se typeof
to fight S
afari chil
dNodes cra
shes
|
|
|
1125 |
|
if
( typeof
array != "
array" )
|
|
|
1126 |
|
for ( va
r i = 0, l
ength = ar
ray.length
; i < leng
th; i++ )
|
|
|
1127 |
|
ret.
push( arra
y[ i ] );
|
|
|
1128 |
|
el
se
|
|
|
1129 |
|
ret = ar
ray.slice(
0 );
|
|
|
1130 |
|
|
|
|
1131 |
|
re
turn ret;
|
|
|
1132 |
|
},
|
|
|
1133 |
|
|
|
|
1134 |
|
inArra
y: functio
n( elem, a
rray ) {
|
|
|
1135 |
|
fo
r ( var i
= 0, lengt
h = array.
length; i
< length;
i++ )
|
|
|
1136 |
|
if ( arr
ay[ i ] ==
elem )
|
|
|
1137 |
|
retu
rn i;
|
|
|
1138 |
|
|
|
|
1139 |
|
re
turn -1;
|
|
|
1140 |
|
},
|
|
|
1141 |
|
|
|
|
1142 |
|
merge:
function(
first, se
cond ) {
|
|
|
1143 |
|
//
We have t
o loop thi
s way beca
use IE & O
pera overw
rite the l
ength
|
|
|
1144 |
|
//
expando o
f getEleme
ntsByTagNa
me
|
|
|
1145 |
|
|
|
|
1146 |
|
//
Also, we
need to ma
ke sure th
at the cor
rect eleme
nts are be
ing return
ed
|
|
|
1147 |
|
//
(IE retur
ns comment
nodes in
a '*' quer
y)
|
|
|
1148 |
|
if
( jQuery.
browser.ms
ie ) {
|
|
|
1149 |
|
for ( va
r i = 0; s
econd[ i ]
; i++ )
|
|
|
1150 |
|
if (
second[ i
].nodeTyp
e != 8 )
|
|
|
1151 |
|
first.push
( second[
i ] );
|
|
|
1152 |
|
|
|
|
1153 |
|
}
else
|
|
|
1154 |
|
for ( va
r i = 0; s
econd[ i ]
; i++ )
|
|
|
1155 |
|
firs
t.push( se
cond[ i ]
);
|
|
|
1156 |
|
|
|
|
1157 |
|
re
turn first
;
|
|
|
1158 |
|
},
|
|
|
1159 |
|
|
|
|
1160 |
|
unique
: function
( array )
{
|
|
|
1161 |
|
va
r ret = []
, done = {
};
|
|
|
1162 |
|
|
|
|
1163 |
|
tr
y {
|
|
|
1164 |
|
|
|
|
1165 |
|
for ( va
r i = 0, l
ength = ar
ray.length
; i < leng
th; i++ )
{
|
|
|
1166 |
|
var
id = jQuer
y.data( ar
ray[ i ] )
;
|
|
|
1167 |
|
|
|
|
1168 |
|
if (
!done[ id
] ) {
|
|
|
1169 |
|
done[ id ]
= true;
|
|
|
1170 |
|
ret.push(
array[ i ]
);
|
|
|
1171 |
|
}
|
|
|
1172 |
|
}
|
|
|
1173 |
|
|
|
|
1174 |
|
}
catch( e )
{
|
|
|
1175 |
|
ret = ar
ray;
|
|
|
1176 |
|
}
|
|
|
1177 |
|
|
|
|
1178 |
|
re
turn ret;
|
|
|
1179 |
|
},
|
|
|
1180 |
|
|
|
|
1181 |
|
grep:
function(
elems, cal
lback, inv
) {
|
|
|
1182 |
|
va
r ret = []
;
|
|
|
1183 |
|
|
|
|
1184 |
|
//
Go throug
h the arra
y, only sa
ving the i
tems
|
|
|
1185 |
|
//
that pass
the valid
ator funct
ion
|
|
|
1186 |
|
fo
r ( var i
= 0, lengt
h = elems.
length; i
< length;
i++ )
|
|
|
1187 |
|
if ( !in
v && callb
ack( elems
[ i ], i )
|| inv &&
!callback
( elems[ i
], i ) )
|
|
|
1188 |
|
ret.
push( elem
s[ i ] );
|
|
|
1189 |
|
|
|
|
1190 |
|
re
turn ret;
|
|
|
1191 |
|
},
|
|
|
1192 |
|
|
|
|
1193 |
|
map: f
unction( e
lems, call
back ) {
|
|
|
1194 |
|
va
r ret = []
;
|
|
|
1195 |
|
|
|
|
1196 |
|
//
Go throug
h the arra
y, transla
ting each
of the ite
ms to thei
r
|
|
|
1197 |
|
//
new value
(or value
s).
|
|
|
1198 |
|
fo
r ( var i
= 0, lengt
h = elems.
length; i
< length;
i++ ) {
|
|
|
1199 |
|
var valu
e = callba
ck( elems[
i ], i );
|
|
|
1200 |
|
|
|
|
1201 |
|
if ( val
ue !== nul
l && value
!= undefi
ned ) {
|
|
|
1202 |
|
if (
value.con
structor !
= Array )
|
|
|
1203 |
|
value = [
value ];
|
|
|
1204 |
|
|
|
|
1205 |
|
ret
= ret.conc
at( value
);
|
|
|
1206 |
|
}
|
|
|
1207 |
|
}
|
|
|
1208 |
|
|
|
|
1209 |
|
re
turn ret;
|
|
|
1210 |
|
}
|
|
|
1211 |
|
});
|
|
|
1212 |
|
|
|
|
1213 |
|
var userAg
ent = navi
gator.user
Agent.toLo
werCase();
|
|
|
1214 |
|
|
|
|
1215 |
|
// Figure
out what b
rowser is
being used
|
|
|
1216 |
|
jQuery.bro
wser = {
|
|
|
1217 |
|
versio
n: (userAg
ent.match(
/.+(?:rv|
it|ra|ie)[
\/: ]([\d.
]+)/ ) ||
[])[1],
|
|
|
1218 |
|
safari
: /webkit/
.test( use
rAgent ),
|
|
|
1219 |
|
opera:
/opera/.t
est( userA
gent ),
|
|
|
1220 |
|
msie:
/msie/.tes
t( userAge
nt ) && !/
opera/.tes
t( userAge
nt ),
|
|
|
1221 |
|
mozill
a: /mozill
a/.test( u
serAgent )
&& !/(com
patible|we
bkit)/.tes
t( userAge
nt )
|
|
|
1222 |
|
};
|
|
|
1223 |
|
|
|
|
1224 |
|
var styleF
loat = jQu
ery.browse
r.msie ?
|
|
|
1225 |
|
"style
Float" :
|
|
|
1226 |
|
"cssFl
oat";
|
|
|
1227 |
|
|
|
|
1228 |
|
jQuery.ext
end({
|
|
|
1229 |
|
// Che
ck to see
if the W3C
box model
is being
used
|
|
|
1230 |
|
boxMod
el: !jQuer
y.browser.
msie || do
cument.com
patMode ==
"CSS1Comp
at",
|
|
|
1231 |
|
|
|
|
1232 |
|
props:
{
|
|
|
1233 |
|
"f
or": "html
For",
|
|
|
1234 |
|
"c
lass": "cl
assName",
|
|
|
1235 |
|
"f
loat": sty
leFloat,
|
|
|
1236 |
|
cs
sFloat: st
yleFloat,
|
|
|
1237 |
|
st
yleFloat:
styleFloat
,
|
|
|
1238 |
|
in
nerHTML: "
innerHTML"
,
|
|
|
1239 |
|
cl
assName: "
className"
,
|
|
|
1240 |
|
va
lue: "valu
e",
|
|
|
1241 |
|
di
sabled: "d
isabled",
|
|
|
1242 |
|
ch
ecked: "ch
ecked",
|
|
|
1243 |
|
re
adonly: "r
eadOnly",
|
|
|
1244 |
|
se
lected: "s
elected",
|
|
|
1245 |
|
ma
xlength: "
maxLength"
,
|
|
|
1246 |
|
se
lectedInde
x: "select
edIndex",
|
|
|
1247 |
|
de
faultValue
: "default
Value",
|
|
|
1248 |
|
ta
gName: "ta
gName",
|
|
|
1249 |
|
no
deName: "n
odeName"
|
|
|
1250 |
|
}
|
|
|
1251 |
|
});
|
|
|
1252 |
|
|
|
|
1253 |
|
jQuery.eac
h({
|
|
|
1254 |
|
parent
: function
(elem){ret
urn elem.p
arentNode;
},
|
|
|
1255 |
|
parent
s: functio
n(elem){re
turn jQuer
y.dir(elem
,"parentNo
de");},
|
|
|
1256 |
|
next:
function(e
lem){retur
n jQuery.n
th(elem,2,
"nextSibli
ng");},
|
|
|
1257 |
|
prev:
function(e
lem){retur
n jQuery.n
th(elem,2,
"previousS
ibling");}
,
|
|
|
1258 |
|
nextAl
l: functio
n(elem){re
turn jQuer
y.dir(elem
,"nextSibl
ing");},
|
|
|
1259 |
|
prevAl
l: functio
n(elem){re
turn jQuer
y.dir(elem
,"previous
Sibling");
},
|
|
|
1260 |
|
siblin
gs: functi
on(elem){r
eturn jQue
ry.sibling
(elem.pare
ntNode.fir
stChild,el
em);},
|
|
|
1261 |
|
childr
en: functi
on(elem){r
eturn jQue
ry.sibling
(elem.firs
tChild);},
|
|
|
1262 |
|
conten
ts: functi
on(elem){r
eturn jQue
ry.nodeNam
e(elem,"if
rame")?ele
m.contentD
ocument||e
lem.conten
tWindow.do
cument:jQu
ery.makeAr
ray(elem.c
hildNodes)
;}
|
|
|
1263 |
|
}, functio
n(name, fn
){
|
|
|
1264 |
|
jQuery
.fn[ name
] = functi
on( select
or ) {
|
|
|
1265 |
|
va
r ret = jQ
uery.map(
this, fn )
;
|
|
|
1266 |
|
|
|
|
1267 |
|
if
( selecto
r && typeo
f selector
== "strin
g" )
|
|
|
1268 |
|
ret = jQ
uery.multi
Filter( se
lector, re
t );
|
|
|
1269 |
|
|
|
|
1270 |
|
re
turn this.
pushStack(
jQuery.un
ique( ret
) );
|
|
|
1271 |
|
};
|
|
|
1272 |
|
});
|
|
|
1273 |
|
|
|
|
1274 |
|
jQuery.eac
h({
|
|
|
1275 |
|
append
To: "appen
d",
|
|
|
1276 |
|
prepen
dTo: "prep
end",
|
|
|
1277 |
|
insert
Before: "b
efore",
|
|
|
1278 |
|
insert
After: "af
ter",
|
|
|
1279 |
|
replac
eAll: "rep
laceWith"
|
|
|
1280 |
|
}, functio
n(name, or
iginal){
|
|
|
1281 |
|
jQuery
.fn[ name
] = functi
on() {
|
|
|
1282 |
|
va
r args = a
rguments;
|
|
|
1283 |
|
|
|
|
1284 |
|
re
turn this.
each(funct
ion(){
|
|
|
1285 |
|
for ( va
r i = 0, l
ength = ar
gs.length;
i < lengt
h; i++ )
|
|
|
1286 |
|
jQue
ry( args[
i ] )[ ori
ginal ]( t
his );
|
|
|
1287 |
|
})
;
|
|
|
1288 |
|
};
|
|
|
1289 |
|
});
|
|
|
1290 |
|
|
|
|
1291 |
|
jQuery.eac
h({
|
|
|
1292 |
|
remove
Attr: func
tion( name
) {
|
|
|
1293 |
|
jQ
uery.attr(
this, nam
e, "" );
|
|
|
1294 |
|
if
(this.nod
eType == 1
)
|
|
|
1295 |
|
this.rem
oveAttribu
te( name )
;
|
|
|
1296 |
|
},
|
|
|
1297 |
|
|
|
|
1298 |
|
addCla
ss: functi
on( classN
ames ) {
|
|
|
1299 |
|
jQ
uery.class
Name.add(
this, clas
sNames );
|
|
|
1300 |
|
},
|
|
|
1301 |
|
|
|
|
1302 |
|
remove
Class: fun
ction( cla
ssNames )
{
|
|
|
1303 |
|
jQ
uery.class
Name.remov
e( this, c
lassNames
);
|
|
|
1304 |
|
},
|
|
|
1305 |
|
|
|
|
1306 |
|
toggle
Class: fun
ction( cla
ssNames )
{
|
|
|
1307 |
|
jQ
uery.class
Name[ jQue
ry.classNa
me.has( th
is, classN
ames ) ? "
remove" :
"add" ]( t
his, class
Names );
|
|
|
1308 |
|
},
|
|
|
1309 |
|
|
|
|
1310 |
|
remove
: function
( selector
) {
|
|
|
1311 |
|
if
( !select
or || jQue
ry.filter(
selector,
[ this ]
).r.length
) {
|
|
|
1312 |
|
// Preve
nt memory
leaks
|
|
|
1313 |
|
jQuery(
"*", this
).add(this
).each(fun
ction(){
|
|
|
1314 |
|
jQue
ry.event.r
emove(this
);
|
|
|
1315 |
|
jQue
ry.removeD
ata(this);
|
|
|
1316 |
|
});
|
|
|
1317 |
|
if (this
.parentNod
e)
|
|
|
1318 |
|
this
.parentNod
e.removeCh
ild( this
);
|
|
|
1319 |
|
}
|
|
|
1320 |
|
},
|
|
|
1321 |
|
|
|
|
1322 |
|
empty:
function(
) {
|
|
|
1323 |
|
//
Remove el
ement node
s and prev
ent memory
leaks
|
|
|
1324 |
|
jQ
uery( ">*"
, this ).r
emove();
|
|
|
1325 |
|
|
|
|
1326 |
|
//
Remove an
y remainin
g nodes
|
|
|
1327 |
|
wh
ile ( this
.firstChil
d )
|
|
|
1328 |
|
this.rem
oveChild(
this.first
Child );
|
|
|
1329 |
|
}
|
|
|
1330 |
|
}, functio
n(name, fn
){
|
|
|
1331 |
|
jQuery
.fn[ name
] = functi
on(){
|
|
|
1332 |
|
re
turn this.
each( fn,
arguments
);
|
|
|
1333 |
|
};
|
|
|
1334 |
|
});
|
|
|
1335 |
|
|
|
|
1336 |
|
jQuery.eac
h([ "Heigh
t", "Width
" ], funct
ion(i, nam
e){
|
|
|
1337 |
|
var ty
pe = name.
toLowerCas
e();
|
|
|
1338 |
|
|
|
|
1339 |
|
jQuery
.fn[ type
] = functi
on( size )
{
|
|
|
1340 |
|
//
Get windo
w width or
height
|
|
|
1341 |
|
re
turn this[
0] == wind
ow ?
|
|
|
1342 |
|
// Opera
reports d
ocument.bo
dy.client[
Width/Heig
ht] proper
ly in both
quirks an
d standard
s
|
|
|
1343 |
|
jQuery.b
rowser.ope
ra && docu
ment.body[
"client"
+ name ] |
|
|
|
|
1344 |
|
|
|
|
1345 |
|
// Safar
i reports
inner[Widt
h/Height]
just fine
(Mozilla a
nd Opera i
nclude scr
oll bar wi
dths)
|
|
|
1346 |
|
jQuery.b
rowser.saf
ari && win
dow[ "inne
r" + name
] ||
|
|
|
1347 |
|
|
|
|
1348 |
|
// Every
one else u
se documen
t.document
Element or
document.
body depen
ding on Qu
irks vs St
andards mo
de
|
|
|
1349 |
|
document
.compatMod
e == "CSS1
Compat" &&
document.
documentEl
ement[ "cl
ient" + na
me ] || do
cument.bod
y[ "client
" + name ]
:
|
|
|
1350 |
|
|
|
|
1351 |
|
// Get d
ocument wi
dth or hei
ght
|
|
|
1352 |
|
this[0]
== documen
t ?
|
|
|
1353 |
|
// E
ither scro
ll[Width/H
eight] or
offset[Wid
th/Height]
, whicheve
r is great
er
|
|
|
1354 |
|
Math
.max(
|
|
|
1355 |
|
Math.max(d
ocument.bo
dy["scroll
" + name],
document.
documentEl
ement["scr
oll" + nam
e]),
|
|
|
1356 |
|
Math.max(d
ocument.bo
dy["offset
" + name],
document.
documentEl
ement["off
set" + nam
e])
|
|
|
1357 |
|
) :
|
|
|
1358 |
|
|
|
|
1359 |
|
// G
et or set
width or h
eight on t
he element
|
|
|
1360 |
|
size
== undefi
ned ?
|
|
|
1361 |
|
// Get wid
th or heig
ht on the
element
|
|
|
1362 |
|
(this.leng
th ? jQuer
y.css( thi
s[0], type
) : null)
:
|
|
|
1363 |
|
|
|
|
1364 |
|
// Set the
width or
height on
the elemen
t (default
to pixels
if value
is unitles
s)
|
|
|
1365 |
|
this.css(
type, size
.construct
or == Stri
ng ? size
: size + "
px" );
|
|
|
1366 |
|
};
|
|
|
1367 |
|
});
|
|
|
1368 |
|
|
|
|
1369 |
|
var chars
= jQuery.b
rowser.saf
ari && par
seInt(jQue
ry.browser
.version)
< 417 ?
|
|
|
1370 |
|
"(
?:[\\w*_-]
|\\\\.)" :
|
|
|
1371 |
|
"(
?:[\\w\u01
28-\uFFFF*
_-]|\\\\.)
",
|
|
|
1372 |
|
quickC
hild = new
RegExp("^
>\\s*(" +
chars + "+
)"),
|
|
|
1373 |
|
quickI
D = new Re
gExp("^("
+ chars +
"+)(#)(" +
chars + "
+)"),
|
|
|
1374 |
|
quickC
lass = new
RegExp("^
([#.]?)("
+ chars +
"*)");
|
|
|
1375 |
|
|
|
|
1376 |
|
jQuery.ext
end({
|
|
|
1377 |
|
expr:
{
|
|
|
1378 |
|
""
: function
(a,i,m){re
turn m[2]=
="*"||jQue
ry.nodeNam
e(a,m[2]);
},
|
|
|
1379 |
|
"#
": functio
n(a,i,m){r
eturn a.ge
tAttribute
("id")==m[
2];},
|
|
|
1380 |
|
":
": {
|
|
|
1381 |
|
// Posit
ion Checks
|
|
|
1382 |
|
lt: func
tion(a,i,m
){return i
<m[3]-0;},
|
|
|
1383 |
|
gt: func
tion(a,i,m
){return i
>m[3]-0;},
|
|
|
1384 |
|
nth: fun
ction(a,i,
m){return
m[3]-0==i;
},
|
|
|
1385 |
|
eq: func
tion(a,i,m
){return m
[3]-0==i;}
,
|
|
|
1386 |
|
first: f
unction(a,
i){return
i==0;},
|
|
|
1387 |
|
last: fu
nction(a,i
,m,r){retu
rn i==r.le
ngth-1;},
|
|
|
1388 |
|
even: fu
nction(a,i
){return i
%2==0;},
|
|
|
1389 |
|
odd: fun
ction(a,i)
{return i%
2;},
|
|
|
1390 |
|
|
|
|
1391 |
|
// Child
Checks
|
|
|
1392 |
|
"first-c
hild": fun
ction(a){r
eturn a.pa
rentNode.g
etElements
ByTagName(
"*")[0]==a
;},
|
|
|
1393 |
|
"last-ch
ild": func
tion(a){re
turn jQuer
y.nth(a.pa
rentNode.l
astChild,1
,"previous
Sibling")=
=a;},
|
|
|
1394 |
|
"only-ch
ild": func
tion(a){re
turn !jQue
ry.nth(a.p
arentNode.
lastChild,
2,"previou
sSibling")
;},
|
|
|
1395 |
|
|
|
|
1396 |
|
// Paren
t Checks
|
|
|
1397 |
|
parent:
function(a
){return a
.firstChil
d;},
|
|
|
1398 |
|
empty: f
unction(a)
{return !a
.firstChil
d;},
|
|
|
1399 |
|
|
|
|
1400 |
|
// Text
Check
|
|
|
1401 |
|
contains
: function
(a,i,m){re
turn (a.te
xtContent|
|a.innerTe
xt||jQuery
(a).text()
||"").inde
xOf(m[3])>
=0;},
|
|
|
1402 |
|
|
|
|
1403 |
|
// Visib
ility
|
|
|
1404 |
|
visible:
function(
a){return
"hidden"!=
a.type&&jQ
uery.css(a
,"display"
)!="none"&
&jQuery.cs
s(a,"visib
ility")!="
hidden";},
|
|
|
1405 |
|
hidden:
function(a
){return "
hidden"==a
.type||jQu
ery.css(a,
"display")
=="none"||
jQuery.css
(a,"visibi
lity")=="h
idden";},
|
|
|
1406 |
|
|
|
|
1407 |
|
// Form
attributes
|
|
|
1408 |
|
enabled:
function(
a){return
!a.disable
d;},
|
|
|
1409 |
|
disabled
: function
(a){return
a.disable
d;},
|
|
|
1410 |
|
checked:
function(
a){return
a.checked;
},
|
|
|
1411 |
|
selected
: function
(a){return
a.selecte
d||jQuery.
attr(a,"se
lected");}
,
|
|
|
1412 |
|
|
|
|
1413 |
|
// Form
elements
|
|
|
1414 |
|
text: fu
nction(a){
return "te
xt"==a.typ
e;},
|
|
|
1415 |
|
radio: f
unction(a)
{return "r
adio"==a.t
ype;},
|
|
|
1416 |
|
checkbox
: function
(a){return
"checkbox
"==a.type;
},
|
|
|
1417 |
|
file: fu
nction(a){
return "fi
le"==a.typ
e;},
|
|
|
1418 |
|
password
: function
(a){return
"password
"==a.type;
},
|
|
|
1419 |
|
submit:
function(a
){return "
submit"==a
.type;},
|
|
|
1420 |
|
image: f
unction(a)
{return "i
mage"==a.t
ype;},
|
|
|
1421 |
|
reset: f
unction(a)
{return "r
eset"==a.t
ype;},
|
|
|
1422 |
|
button:
function(a
){return "
button"==a
.type||jQu
ery.nodeNa
me(a,"butt
on");},
|
|
|
1423 |
|
input: f
unction(a)
{return /i
nput|selec
t|textarea
|button/i.
test(a.nod
eName);},
|
|
|
1424 |
|
|
|
|
1425 |
|
// :has(
)
|
|
|
1426 |
|
has: fun
ction(a,i,
m){return
jQuery.fin
d(m[3],a).
length;},
|
|
|
1427 |
|
|
|
|
1428 |
|
// :head
er
|
|
|
1429 |
|
header:
function(a
){return /
h\d/i.test
(a.nodeNam
e);},
|
|
|
1430 |
|
|
|
|
1431 |
|
// :anim
ated
|
|
|
1432 |
|
animated
: function
(a){return
jQuery.gr
ep(jQuery.
timers,fun
ction(fn){
return a==
fn.elem;})
.length;}
|
|
|
1433 |
|
}
|
|
|
1434 |
|
},
|
|
|
1435 |
|
|
|
|
1436 |
|
// The
regular e
xpressions
that powe
r the pars
ing engine
|
|
|
1437 |
|
parse:
[
|
|
|
1438 |
|
//
Match: [@
value='tes
t'], [@foo
]
|
|
|
1439 |
|
/^
(\[) *@?([
\w-]+) *([
!*$^~=]*)
*('?"?)(.*
?)\4 *\]/,
|
|
|
1440 |
|
|
|
|
1441 |
|
//
Match: :c
ontains('f
oo')
|
|
|
1442 |
|
/^
(:)([\w-]+
)\("?'?(.*
?(\(.*?\))
?[^(]*?)"?
'?\)/,
|
|
|
1443 |
|
|
|
|
1444 |
|
//
Match: :e
ven, :last
-chlid, #i
d, .class
|
|
|
1445 |
|
ne
w RegExp("
^([:.#]*)(
" + chars
+ "+)")
|
|
|
1446 |
|
],
|
|
|
1447 |
|
|
|
|
1448 |
|
multiF
ilter: fun
ction( exp
r, elems,
not ) {
|
|
|
1449 |
|
va
r old, cur
= [];
|
|
|
1450 |
|
|
|
|
1451 |
|
wh
ile ( expr
&& expr !
= old ) {
|
|
|
1452 |
|
old = ex
pr;
|
|
|
1453 |
|
var f =
jQuery.fil
ter( expr,
elems, no
t );
|
|
|
1454 |
|
expr = f
.t.replace
(/^\s*,\s*
/, "" );
|
|
|
1455 |
|
cur = no
t ? elems
= f.r : jQ
uery.merge
( cur, f.r
);
|
|
|
1456 |
|
}
|
|
|
1457 |
|
|
|
|
1458 |
|
re
turn cur;
|
|
|
1459 |
|
},
|
|
|
1460 |
|
|
|
|
1461 |
|
find:
function(
t, context
) {
|
|
|
1462 |
|
//
Quickly h
andle non-
string exp
ressions
|
|
|
1463 |
|
if
( typeof
t != "stri
ng" )
|
|
|
1464 |
|
return [
t ];
|
|
|
1465 |
|
|
|
|
1466 |
|
//
check to
make sure
context is
a DOM ele
ment or a
document
|
|
|
1467 |
|
if
( context
&& contex
t.nodeType
!= 1 && c
ontext.nod
eType != 9
)
|
|
|
1468 |
|
return [
];
|
|
|
1469 |
|
|
|
|
1470 |
|
//
Set the c
orrect con
text (if n
one is pro
vided)
|
|
|
1471 |
|
co
ntext = co
ntext || d
ocument;
|
|
|
1472 |
|
|
|
|
1473 |
|
//
Initializ
e the sear
ch
|
|
|
1474 |
|
va
r ret = [c
ontext], d
one = [],
last, node
Name;
|
|
|
1475 |
|
|
|
|
1476 |
|
//
Continue
while a se
lector exp
ression ex
ists, and
while
|
|
|
1477 |
|
//
we're no
longer loo
ping upon
ourselves
|
|
|
1478 |
|
wh
ile ( t &&
last != t
) {
|
|
|
1479 |
|
var r =
[];
|
|
|
1480 |
|
last = t
;
|
|
|
1481 |
|
|
|
|
1482 |
|
t = jQue
ry.trim(t)
;
|
|
|
1483 |
|
|
|
|
1484 |
|
var foun
dToken = f
alse;
|
|
|
1485 |
|
|
|
|
1486 |
|
// An at
tempt at s
peeding up
child sel
ectors tha
t
|
|
|
1487 |
|
// point
to a spec
ific eleme
nt tag
|
|
|
1488 |
|
var re =
quickChil
d;
|
|
|
1489 |
|
var m =
re.exec(t)
;
|
|
|
1490 |
|
|
|
|
1491 |
|
if ( m )
{
|
|
|
1492 |
|
node
Name = m[1
].toUpperC
ase();
|
|
|
1493 |
|
|
|
|
1494 |
|
// P
erform our
own itera
tion and f
ilter
|
|
|
1495 |
|
for
( var i =
0; ret[i];
i++ )
|
|
|
1496 |
|
for ( var
c = ret[i]
.firstChil
d; c; c =
c.nextSibl
ing )
|
|
|
1497 |
|
if ( c
.nodeType
== 1 && (n
odeName ==
"*" || c.
nodeName.t
oUpperCase
() == node
Name) )
|
|
|
1498 |
|
r.
push( c );
|
|
|
1499 |
|
|
|
|
1500 |
|
ret
= r;
|
|
|
1501 |
|
t =
t.replace(
re, "" );
|
|
|
1502 |
|
if (
t.indexOf
(" ") == 0
) continu
e;
|
|
|
1503 |
|
foun
dToken = t
rue;
|
|
|
1504 |
|
} else {
|
|
|
1505 |
|
re =
/^([>+~])
\s*(\w*)/i
;
|
|
|
1506 |
|
|
|
|
1507 |
|
if (
(m = re.e
xec(t)) !=
null ) {
|
|
|
1508 |
|
r = [];
|
|
|
1509 |
|
|
|
|
1510 |
|
var merge
= {};
|
|
|
1511 |
|
nodeName =
m[2].toUp
perCase();
|
|
|
1512 |
|
m = m[1];
|
|
|
1513 |
|
|
|
|
1514 |
|
for ( var
j = 0, rl
= ret.leng
th; j < rl
; j++ ) {
|
|
|
1515 |
|
var n
= m == "~"
|| m == "
+" ? ret[j
].nextSibl
ing : ret[
j].firstCh
ild;
|
|
|
1516 |
|
for (
; n; n = n
.nextSibli
ng )
|
|
|
1517 |
|
if
( n.nodeT
ype == 1 )
{
|
|
|
1518 |
|
var id =
jQuery.da
ta(n);
|
|
|
1519 |
|
|
|
|
1520 |
|
if ( m =
= "~" && m
erge[id] )
break;
|
|
|
1521 |
|
|
|
|
1522 |
|
if (!nod
eName || n
.nodeName.
toUpperCas
e() == nod
eName ) {
|
|
|
1523 |
|
if (
m == "~"
) merge[id
] = true;
|
|
|
1524 |
|
r.pu
sh( n );
|
|
|
1525 |
|
}
|
|
|
1526 |
|
|
|
|
1527 |
|
if ( m =
= "+" ) br
eak;
|
|
|
1528 |
|
}
|
|
|
1529 |
|
}
|
|
|
1530 |
|
|
|
|
1531 |
|
ret = r;
|
|
|
1532 |
|
|
|
|
1533 |
|
// And rem
ove the to
ken
|
|
|
1534 |
|
t = jQuery
.trim( t.r
eplace( re
, "" ) );
|
|
|
1535 |
|
foundToken
= true;
|
|
|
1536 |
|
}
|
|
|
1537 |
|
}
|
|
|
1538 |
|
|
|
|
1539 |
|
// See i
f there's
still an e
xpression,
and that
we haven't
already
|
|
|
1540 |
|
// match
ed a token
|
|
|
1541 |
|
if ( t &
& !foundTo
ken ) {
|
|
|
1542 |
|
// H
andle mult
iple expre
ssions
|
|
|
1543 |
|
if (
!t.indexO
f(",") ) {
|
|
|
1544 |
|
// Clean t
he result
set
|
|
|
1545 |
|
if ( conte
xt == ret[
0] ) ret.s
hift();
|
|
|
1546 |
|
|
|
|
1547 |
|
// Merge t
he result
sets
|
|
|
1548 |
|
done = jQu
ery.merge(
done, ret
);
|
|
|
1549 |
|
|
|
|
1550 |
|
// Reset t
he context
|
|
|
1551 |
|
r = ret =
[context];
|
|
|
1552 |
|
|
|
|
1553 |
|
// Touch u
p the sele
ctor strin
g
|
|
|
1554 |
|
t = " " +
t.substr(1
,t.length)
;
|
|
|
1555 |
|
|
|
|
1556 |
|
} el
se {
|
|
|
1557 |
|
// Optimiz
e for the
case nodeN
ame#idName
|
|
|
1558 |
|
var re2 =
quickID;
|
|
|
1559 |
|
var m = re
2.exec(t);
|
|
|
1560 |
|
|
|
|
1561 |
|
// Re-orga
nize the r
esults, so
that they
're consis
tent
|
|
|
1562 |
|
if ( m ) {
|
|
|
1563 |
|
m = [
0, m[2], m
[3], m[1]
];
|
|
|
1564 |
|
|
|
|
1565 |
|
} else {
|
|
|
1566 |
|
// Oth
erwise, do
a traditi
onal filte
r check fo
r
|
|
|
1567 |
|
// ID,
class, an
d element
selectors
|
|
|
1568 |
|
re2 =
quickClass
;
|
|
|
1569 |
|
m = re
2.exec(t);
|
|
|
1570 |
|
}
|
|
|
1571 |
|
|
|
|
1572 |
|
m[2] = m[2
].replace(
/\\/g, "")
;
|
|
|
1573 |
|
|
|
|
1574 |
|
var elem =
ret[ret.l
ength-1];
|
|
|
1575 |
|
|
|
|
1576 |
|
// Try to
do a globa
l search b
y ID, wher
e we can
|
|
|
1577 |
|
if ( m[1]
== "#" &&
elem && el
em.getElem
entById &&
!jQuery.i
sXMLDoc(el
em) ) {
|
|
|
1578 |
|
// Opt
imization
for HTML d
ocument ca
se
|
|
|
1579 |
|
var oi
d = elem.g
etElementB
yId(m[2]);
|
|
|
1580 |
|
|
|
|
1581 |
|
// Do
a quick ch
eck for th
e existenc
e of the a
ctual ID a
ttribute
|
|
|
1582 |
|
// to
avoid sele
cting by t
he name at
tribute in
IE
|
|
|
1583 |
|
// als
o check to
insure id
is a stri
ng to avoi
d selectin
g an eleme
nt with th
e name of
'id' insid
e a form
|
|
|
1584 |
|
if ( (
jQuery.bro
wser.msie|
|jQuery.br
owser.oper
a) && oid
&& typeof
oid.id ==
"string" &
& oid.id !
= m[2] )
|
|
|
1585 |
|
oi
d = jQuery
('[@id="'+
m[2]+'"]',
elem)[0];
|
|
|
1586 |
|
|
|
|
1587 |
|
// Do
a quick ch
eck for no
de name (w
here appli
cable) so
|
|
|
1588 |
|
// tha
t div#foo
searches w
ill be rea
lly fast
|
|
|
1589 |
|
ret =
r = oid &&
(!m[3] ||
jQuery.no
deName(oid
, m[3])) ?
[oid] : [
];
|
|
|
1590 |
|
} else {
|
|
|
1591 |
|
// We
need to fi
nd all des
cendant el
ements
|
|
|
1592 |
|
for (
var i = 0;
ret[i]; i
++ ) {
|
|
|
1593 |
|
//
Grab the
tag name b
eing searc
hed for
|
|
|
1594 |
|
va
r tag = m[
1] == "#"
&& m[3] ?
m[3] : m[1
] != "" ||
m[0] == "
" ? "*" :
m[2];
|
|
|
1595 |
|
|
|
|
1596 |
|
//
Handle IE
7 being re
ally dumb
about <obj
ect>s
|
|
|
1597 |
|
if
( tag ==
"*" && ret
[i].nodeNa
me.toLower
Case() ==
"object" )
|
|
|
1598 |
|
tag = "p
aram";
|
|
|
1599 |
|
|
|
|
1600 |
|
r
= jQuery.m
erge( r, r
et[i].getE
lementsByT
agName( ta
g ));
|
|
|
1601 |
|
}
|
|
|
1602 |
|
|
|
|
1603 |
|
// It'
s faster t
o filter b
y class an
d be done
with it
|
|
|
1604 |
|
if ( m
[1] == "."
)
|
|
|
1605 |
|
r
= jQuery.c
lassFilter
( r, m[2]
);
|
|
|
1606 |
|
|
|
|
1607 |
|
// Sam
e with ID
filtering
|
|
|
1608 |
|
if ( m
[1] == "#"
) {
|
|
|
1609 |
|
va
r tmp = []
;
|
|
|
1610 |
|
|
|
|
1611 |
|
//
Try to fi
nd the ele
ment with
the ID
|
|
|
1612 |
|
fo
r ( var i
= 0; r[i];
i++ )
|
|
|
1613 |
|
if ( r[i
].getAttri
bute("id")
== m[2] )
{
|
|
|
1614 |
|
tmp
= [ r[i] ]
;
|
|
|
1615 |
|
brea
k;
|
|
|
1616 |
|
}
|
|
|
1617 |
|
|
|
|
1618 |
|
r
= tmp;
|
|
|
1619 |
|
}
|
|
|
1620 |
|
|
|
|
1621 |
|
ret =
r;
|
|
|
1622 |
|
}
|
|
|
1623 |
|
|
|
|
1624 |
|
t = t.repl
ace( re2,
"" );
|
|
|
1625 |
|
}
|
|
|
1626 |
|
|
|
|
1627 |
|
}
|
|
|
1628 |
|
|
|
|
1629 |
|
// If a
selector s
tring stil
l exists
|
|
|
1630 |
|
if ( t )
{
|
|
|
1631 |
|
// A
ttempt to
filter it
|
|
|
1632 |
|
var
val = jQue
ry.filter(
t,r);
|
|
|
1633 |
|
ret
= r = val.
r;
|
|
|
1634 |
|
t =
jQuery.tri
m(val.t);
|
|
|
1635 |
|
}
|
|
|
1636 |
|
}
|
|
|
1637 |
|
|
|
|
1638 |
|
//
An error
occurred w
ith the se
lector;
|
|
|
1639 |
|
//
just retu
rn an empt
y set inst
ead
|
|
|
1640 |
|
if
( t )
|
|
|
1641 |
|
ret = []
;
|
|
|
1642 |
|
|
|
|
1643 |
|
//
Remove th
e root con
text
|
|
|
1644 |
|
if
( ret &&
context ==
ret[0] )
|
|
|
1645 |
|
ret.shif
t();
|
|
|
1646 |
|
|
|
|
1647 |
|
//
And combi
ne the res
ults
|
|
|
1648 |
|
do
ne = jQuer
y.merge( d
one, ret )
;
|
|
|
1649 |
|
|
|
|
1650 |
|
re
turn done;
|
|
|
1651 |
|
},
|
|
|
1652 |
|
|
|
|
1653 |
|
classF
ilter: fun
ction(r,m,
not){
|
|
|
1654 |
|
m
= " " + m
+ " ";
|
|
|
1655 |
|
va
r tmp = []
;
|
|
|
1656 |
|
fo
r ( var i
= 0; r[i];
i++ ) {
|
|
|
1657 |
|
var pass
= (" " +
r[i].class
Name + " "
).indexOf(
m ) >= 0;
|
|
|
1658 |
|
if ( !no
t && pass
|| not &&
!pass )
|
|
|
1659 |
|
tmp.
push( r[i]
);
|
|
|
1660 |
|
}
|
|
|
1661 |
|
re
turn tmp;
|
|
|
1662 |
|
},
|
|
|
1663 |
|
|
|
|
1664 |
|
filter
: function
(t,r,not)
{
|
|
|
1665 |
|
va
r last;
|
|
|
1666 |
|
|
|
|
1667 |
|
//
Look for
common fil
ter expres
sions
|
|
|
1668 |
|
wh
ile ( t &&
t != last
) {
|
|
|
1669 |
|
last = t
;
|
|
|
1670 |
|
|
|
|
1671 |
|
var p =
jQuery.par
se, m;
|
|
|
1672 |
|
|
|
|
1673 |
|
for ( va
r i = 0; p
[i]; i++ )
{
|
|
|
1674 |
|
m =
p[i].exec(
t );
|
|
|
1675 |
|
|
|
|
1676 |
|
if (
m ) {
|
|
|
1677 |
|
// Remove
what we ju
st matched
|
|
|
1678 |
|
t = t.subs
tring( m[0
].length )
;
|
|
|
1679 |
|
|
|
|
1680 |
|
m[2] = m[2
].replace(
/\\/g, "")
;
|
|
|
1681 |
|
break;
|
|
|
1682 |
|
}
|
|
|
1683 |
|
}
|
|
|
1684 |
|
|
|
|
1685 |
|
if ( !m
)
|
|
|
1686 |
|
brea
k;
|
|
|
1687 |
|
|
|
|
1688 |
|
// :not(
) is a spe
cial case
that can b
e optimize
d by
|
|
|
1689 |
|
// keepi
ng it out
of the exp
ression li
st
|
|
|
1690 |
|
if ( m[1
] == ":" &
& m[2] ==
"not" )
|
|
|
1691 |
|
// o
ptimize if
only one
selector f
ound (most
common ca
se)
|
|
|
1692 |
|
r =
isSimple.t
est( m[3]
) ?
|
|
|
1693 |
|
jQuery.fil
ter(m[3],
r, true).r
:
|
|
|
1694 |
|
jQuery( r
).not( m[3
] );
|
|
|
1695 |
|
|
|
|
1696 |
|
// We ca
n get a bi
g speed bo
ost by fil
tering by
class here
|
|
|
1697 |
|
else if
( m[1] ==
"." )
|
|
|
1698 |
|
r =
jQuery.cla
ssFilter(r
, m[2], no
t);
|
|
|
1699 |
|
|
|
|
1700 |
|
else if
( m[1] ==
"[" ) {
|
|
|
1701 |
|
var
tmp = [],
type = m[3
];
|
|
|
1702 |
|
|
|
|
1703 |
|
for
( var i =
0, rl = r.
length; i
< rl; i++
) {
|
|
|
1704 |
|
var a = r[
i], z = a[
jQuery.pr
ops[m[2]]
|| m[2] ];
|
|
|
1705 |
|
|
|
|
1706 |
|
if ( z ==
null || /h
ref|src|se
lected/.te
st(m[2]) )
|
|
|
1707 |
|
z = jQ
uery.attr(
a,m[2]) ||
'';
|
|
|
1708 |
|
|
|
|
1709 |
|
if ( (type
== "" &&
!!z ||
|
|
|
1710 |
|
type
== "=" &&
z == m[5]
||
|
|
|
1711 |
|
type
== "!=" &&
z != m[5]
||
|
|
|
1712 |
|
type
== "^=" &&
z && !z.i
ndexOf(m[5
]) ||
|
|
|
1713 |
|
type
== "$=" &&
z.substr(
z.length -
m[5].leng
th) == m[5
] ||
|
|
|
1714 |
|
(type
== "*=" |
| type ==
"~=") && z
.indexOf(m
[5]) >= 0)
^ not )
|
|
|
1715 |
|
tm
p.push( a
);
|
|
|
1716 |
|
}
|
|
|
1717 |
|
|
|
|
1718 |
|
r =
tmp;
|
|
|
1719 |
|
|
|
|
1720 |
|
// We ca
n get a sp
eed boost
by handlin
g nth-chil
d here
|
|
|
1721 |
|
} else i
f ( m[1] =
= ":" && m
[2] == "nt
h-child" )
{
|
|
|
1722 |
|
var
merge = {}
, tmp = []
,
|
|
|
1723 |
|
// parse e
quations l
ike 'even'
, 'odd', '
5', '2n',
'3n+2', '4
n-1', '-n+
6'
|
|
|
1724 |
|
test = /(-
?)(\d*)n((
?:\+|-)?\d
*)/.exec(
|
|
|
1725 |
|
m[3] =
= "even" &
& "2n" ||
m[3] == "o
dd" && "2n
+1" ||
|
|
|
1726 |
|
!/\D/.
test(m[3])
&& "0n+"
+ m[3] ||
m[3]),
|
|
|
1727 |
|
// calcula
te the num
bers (firs
t)n+(last)
including
if they a
re negativ
e
|
|
|
1728 |
|
first = (t
est[1] + (
test[2] ||
1)) - 0,
last = tes
t[3] - 0;
|
|
|
1729 |
|
|
|
|
1730 |
|
// l
oop throug
h all the
elements l
eft in the
jQuery ob
ject
|
|
|
1731 |
|
for
( var i =
0, rl = r.
length; i
< rl; i++
) {
|
|
|
1732 |
|
var node =
r[i], par
entNode =
node.paren
tNode, id
= jQuery.d
ata(parent
Node);
|
|
|
1733 |
|
|
|
|
1734 |
|
if ( !merg
e[id] ) {
|
|
|
1735 |
|
var c
= 1;
|
|
|
1736 |
|
|
|
|
1737 |
|
for (
var n = pa
rentNode.f
irstChild;
n; n = n.
nextSiblin
g )
|
|
|
1738 |
|
if
( n.nodeT
ype == 1 )
|
|
|
1739 |
|
n.nodeIn
dex = c++;
|
|
|
1740 |
|
|
|
|
1741 |
|
merge[
id] = true
;
|
|
|
1742 |
|
}
|
|
|
1743 |
|
|
|
|
1744 |
|
var add =
false;
|
|
|
1745 |
|
|
|
|
1746 |
|
if ( first
== 0 ) {
|
|
|
1747 |
|
if ( n
ode.nodeIn
dex == las
t )
|
|
|
1748 |
|
ad
d = true;
|
|
|
1749 |
|
} else if
( (node.no
deIndex -
last) % fi
rst == 0 &
& (node.no
deIndex -
last) / fi
rst >= 0 )
|
|
|
1750 |
|
add =
true;
|
|
|
1751 |
|
|
|
|
1752 |
|
if ( add ^
not )
|
|
|
1753 |
|
tmp.pu
sh( node )
;
|
|
|
1754 |
|
}
|
|
|
1755 |
|
|
|
|
1756 |
|
r =
tmp;
|
|
|
1757 |
|
|
|
|
1758 |
|
// Other
wise, find
the expre
ssion to e
xecute
|
|
|
1759 |
|
} else {
|
|
|
1760 |
|
var
fn = jQuer
y.expr[ m[
1] ];
|
|
|
1761 |
|
if (
typeof fn
== "objec
t" )
|
|
|
1762 |
|
fn = fn[ m
[2] ];
|
|
|
1763 |
|
|
|
|
1764 |
|
if (
typeof fn
== "strin
g" )
|
|
|
1765 |
|
fn = eval(
"false||fu
nction(a,i
){return "
+ fn + ";
}");
|
|
|
1766 |
|
|
|
|
1767 |
|
// E
xecute it
against th
e current
filter
|
|
|
1768 |
|
r =
jQuery.gre
p( r, func
tion(elem,
i){
|
|
|
1769 |
|
return fn(
elem, i, m
, r);
|
|
|
1770 |
|
}, n
ot );
|
|
|
1771 |
|
}
|
|
|
1772 |
|
}
|
|
|
1773 |
|
|
|
|
1774 |
|
//
Return an
array of
filtered e
lements (r
)
|
|
|
1775 |
|
//
and the m
odified ex
pression s
tring (t)
|
|
|
1776 |
|
re
turn { r:
r, t: t };
|
|
|
1777 |
|
},
|
|
|
1778 |
|
|
|
|
1779 |
|
dir: f
unction( e
lem, dir )
{
|
|
|
1780 |
|
va
r matched
= [];
|
|
|
1781 |
|
va
r cur = el
em[dir];
|
|
|
1782 |
|
wh
ile ( cur
&& cur !=
document )
{
|
|
|
1783 |
|
if ( cur
.nodeType
== 1 )
|
|
|
1784 |
|
matc
hed.push(
cur );
|
|
|
1785 |
|
cur = cu
r[dir];
|
|
|
1786 |
|
}
|
|
|
1787 |
|
re
turn match
ed;
|
|
|
1788 |
|
},
|
|
|
1789 |
|
|
|
|
1790 |
|
nth: f
unction(cu
r,result,d
ir,elem){
|
|
|
1791 |
|
re
sult = res
ult || 1;
|
|
|
1792 |
|
va
r num = 0;
|
|
|
1793 |
|
|
|
|
1794 |
|
fo
r ( ; cur;
cur = cur
[dir] )
|
|
|
1795 |
|
if ( cur
.nodeType
== 1 && ++
num == res
ult )
|
|
|
1796 |
|
brea
k;
|
|
|
1797 |
|
|
|
|
1798 |
|
re
turn cur;
|
|
|
1799 |
|
},
|
|
|
1800 |
|
|
|
|
1801 |
|
siblin
g: functio
n( n, elem
) {
|
|
|
1802 |
|
va
r r = [];
|
|
|
1803 |
|
|
|
|
1804 |
|
fo
r ( ; n; n
= n.nextS
ibling ) {
|
|
|
1805 |
|
if ( n.n
odeType ==
1 && (!el
em || n !=
elem) )
|
|
|
1806 |
|
r.pu
sh( n );
|
|
|
1807 |
|
}
|
|
|
1808 |
|
|
|
|
1809 |
|
re
turn r;
|
|
|
1810 |
|
}
|
|
|
1811 |
|
});
|
|
|
1812 |
|
|
|
|
1813 |
|
/*
|
|
|
1814 |
|
* A numbe
r of helpe
r function
s used for
managing
events.
|
|
|
1815 |
|
* Many of
the ideas
behind th
is code or
ignated fr
om
|
|
|
1816 |
|
* Dean Ed
wards' add
Event libr
ary.
|
|
|
1817 |
|
*/
|
|
|
1818 |
|
jQuery.eve
nt = {
|
|
|
1819 |
|
|
|
|
1820 |
|
// Bin
d an event
to an ele
ment
|
|
|
1821 |
|
// Ori
ginal by D
ean Edward
s
|
|
|
1822 |
|
add: f
unction(el
em, types,
handler,
data) {
|
|
|
1823 |
|
if
( elem.no
deType ==
3 || elem.
nodeType =
= 8 )
|
|
|
1824 |
|
return;
|
|
|
1825 |
|
|
|
|
1826 |
|
//
For whate
ver reason
, IE has t
rouble pas
sing the w
indow obje
ct
|
|
|
1827 |
|
//
around, c
ausing it
to be clon
ed in the
process
|
|
|
1828 |
|
if
( jQuery.
browser.ms
ie && elem
.setInterv
al != unde
fined )
|
|
|
1829 |
|
elem = w
indow;
|
|
|
1830 |
|
|
|
|
1831 |
|
//
Make sure
that the
function b
eing execu
ted has a
unique ID
|
|
|
1832 |
|
if
( !handle
r.guid )
|
|
|
1833 |
|
handler.
guid = thi
s.guid++;
|
|
|
1834 |
|
|
|
|
1835 |
|
//
if data i
s passed,
bind to ha
ndler
|
|
|
1836 |
|
if
( data !=
undefined
) {
|
|
|
1837 |
|
// Creat
e temporar
y function
pointer t
o original
handler
|
|
|
1838 |
|
var fn =
handler;
|
|
|
1839 |
|
|
|
|
1840 |
|
// Creat
e unique h
andler fun
ction, wra
pped aroun
d original
handler
|
|
|
1841 |
|
handler
= function
() {
|
|
|
1842 |
|
// P
ass argume
nts and co
ntext to o
riginal ha
ndler
|
|
|
1843 |
|
retu
rn fn.appl
y(this, ar
guments);
|
|
|
1844 |
|
};
|
|
|
1845 |
|
|
|
|
1846 |
|
// Store
data in u
nique hand
ler
|
|
|
1847 |
|
handler.
data = dat
a;
|
|
|
1848 |
|
|
|
|
1849 |
|
// Set t
he guid of
unique ha
ndler to t
he same of
original
handler, s
o it can b
e removed
|
|
|
1850 |
|
handler.
guid = fn.
guid;
|
|
|
1851 |
|
}
|
|
|
1852 |
|
|
|
|
1853 |
|
//
Init the
element's
event stru
cture
|
|
|
1854 |
|
va
r events =
jQuery.da
ta(elem, "
events") |
| jQuery.d
ata(elem,
"events",
{}),
|
|
|
1855 |
|
handle =
jQuery.da
ta(elem, "
handle") |
| jQuery.d
ata(elem,
"handle",
function()
{
|
|
|
1856 |
|
// r
eturned un
defined or
false
|
|
|
1857 |
|
var
val;
|
|
|
1858 |
|
|
|
|
1859 |
|
// H
andle the
second eve
nt of a tr
igger and
when
|
|
|
1860 |
|
// a
n event is
called af
ter a page
has unloa
ded
|
|
|
1861 |
|
if (
typeof jQ
uery == "u
ndefined"
|| jQuery.
event.trig
gered )
|
|
|
1862 |
|
return val
;
|
|
|
1863 |
|
|
|
|
1864 |
|
val
= jQuery.e
vent.handl
e.apply(ar
guments.ca
llee.elem,
arguments
);
|
|
|
1865 |
|
|
|
|
1866 |
|
retu
rn val;
|
|
|
1867 |
|
});
|
|
|
1868 |
|
//
Add elem
as a prope
rty of the
handle fu
nction
|
|
|
1869 |
|
//
This is t
o prevent
a memory l
eak with n
on-native
|
|
|
1870 |
|
//
event in
IE.
|
|
|
1871 |
|
ha
ndle.elem
= elem;
|
|
|
1872 |
|
|
|
|
1873 |
|
// Handl
e multiple
events se
perated by
a space
|
|
|
1874 |
|
// jQuer
y(...).bin
d("mouseov
er mouseou
t", fn);
|
|
|
1875 |
|
jQuery.e
ach(types.
split(/\s+
/), functi
on(index,
type) {
|
|
|
1876 |
|
// N
amespaced
event hand
lers
|
|
|
1877 |
|
var
parts = ty
pe.split("
.");
|
|
|
1878 |
|
type
= parts[0
];
|
|
|
1879 |
|
hand
ler.type =
parts[1];
|
|
|
1880 |
|
|
|
|
1881 |
|
// G
et the cur
rent list
of functio
ns bound t
o this eve
nt
|
|
|
1882 |
|
var
handlers =
events[ty
pe];
|
|
|
1883 |
|
|
|
|
1884 |
|
// I
nit the ev
ent handle
r queue
|
|
|
1885 |
|
if (
!handlers)
{
|
|
|
1886 |
|
handlers =
events[ty
pe] = {};
|
|
|
1887 |
|
|
|
|
1888 |
|
// Check f
or a speci
al event h
andler
|
|
|
1889 |
|
// Only us
e addEvent
Listener/a
ttachEvent
if the sp
ecial
|
|
|
1890 |
|
// events
handler re
turns fals
e
|
|
|
1891 |
|
if ( !jQue
ry.event.s
pecial[typ
e] || jQue
ry.event.s
pecial[typ
e].setup.c
all(elem)
=== false
) {
|
|
|
1892 |
|
// Bin
d the glob
al event h
andler to
the elemen
t
|
|
|
1893 |
|
if (el
em.addEven
tListener)
|
|
|
1894 |
|
el
em.addEven
tListener(
type, hand
le, false)
;
|
|
|
1895 |
|
else i
f (elem.at
tachEvent)
|
|
|
1896 |
|
el
em.attachE
vent("on"
+ type, ha
ndle);
|
|
|
1897 |
|
}
|
|
|
1898 |
|
}
|
|
|
1899 |
|
|
|
|
1900 |
|
// A
dd the fun
ction to t
he element
's handler
list
|
|
|
1901 |
|
hand
lers[handl
er.guid] =
handler;
|
|
|
1902 |
|
|
|
|
1903 |
|
// K
eep track
of which e
vents have
been used
, for glob
al trigger
ing
|
|
|
1904 |
|
jQue
ry.event.g
lobal[type
] = true;
|
|
|
1905 |
|
});
|
|
|
1906 |
|
|
|
|
1907 |
|
//
Nullify e
lem to pre
vent memor
y leaks in
IE
|
|
|
1908 |
|
el
em = null;
|
|
|
1909 |
|
},
|
|
|
1910 |
|
|
|
|
1911 |
|
guid:
1,
|
|
|
1912 |
|
global
: {},
|
|
|
1913 |
|
|
|
|
1914 |
|
// Det
ach an eve
nt or set
of events
from an el
ement
|
|
|
1915 |
|
remove
: function
(elem, typ
es, handle
r) {
|
|
|
1916 |
|
//
don't do
events on
text and c
omment nod
es
|
|
|
1917 |
|
if
( elem.no
deType ==
3 || elem.
nodeType =
= 8 )
|
|
|
1918 |
|
return;
|
|
|
1919 |
|
|
|
|
1920 |
|
va
r events =
jQuery.da
ta(elem, "
events"),
ret, index
;
|
|
|
1921 |
|
|
|
|
1922 |
|
if
( events
) {
|
|
|
1923 |
|
// Unbin
d all even
ts for the
element
|
|
|
1924 |
|
if ( typ
es == unde
fined || (
typeof typ
es == "str
ing" && ty
pes.charAt
(0) == "."
) )
|
|
|
1925 |
|
for
( var type
in events
)
|
|
|
1926 |
|
this.remov
e( elem, t
ype + (typ
es || "")
);
|
|
|
1927 |
|
else {
|
|
|
1928 |
|
// t
ypes is ac
tually an
event obje
ct here
|
|
|
1929 |
|
if (
types.typ
e ) {
|
|
|
1930 |
|
handler =
types.hand
ler;
|
|
|
1931 |
|
types = ty
pes.type;
|
|
|
1932 |
|
}
|
|
|
1933 |
|
|
|
|
1934 |
|
// H
andle mult
iple event
s seperate
d by a spa
ce
|
|
|
1935 |
|
// j
Query(...)
.unbind("m
ouseover m
ouseout",
fn);
|
|
|
1936 |
|
jQue
ry.each(ty
pes.split(
/\s+/), fu
nction(ind
ex, type){
|
|
|
1937 |
|
// Namespa
ced event
handlers
|
|
|
1938 |
|
var parts
= type.spl
it(".");
|
|
|
1939 |
|
type = par
ts[0];
|
|
|
1940 |
|
|
|
|
1941 |
|
if ( event
s[type] )
{
|
|
|
1942 |
|
// rem
ove the gi
ven handle
r for the
given type
|
|
|
1943 |
|
if ( h
andler )
|
|
|
1944 |
|
de
lete event
s[type][ha
ndler.guid
];
|
|
|
1945 |
|
|
|
|
1946 |
|
// rem
ove all ha
ndlers for
the given
type
|
|
|
1947 |
|
else
|
|
|
1948 |
|
fo
r ( handle
r in event
s[type] )
|
|
|
1949 |
|
// Handl
e the remo
val of nam
espaced ev
ents
|
|
|
1950 |
|
if ( !pa
rts[1] ||
events[typ
e][handler
].type ==
parts[1] )
|
|
|
1951 |
|
dele
te events[
type][hand
ler];
|
|
|
1952 |
|
|
|
|
1953 |
|
// rem
ove generi
c event ha
ndler if n
o more han
dlers exis
t
|
|
|
1954 |
|
for (
ret in eve
nts[type]
) break;
|
|
|
1955 |
|
if ( !
ret ) {
|
|
|
1956 |
|
if
( !jQuery
.event.spe
cial[type]
|| jQuery
.event.spe
cial[type]
.teardown.
call(elem)
=== false
) {
|
|
|
1957 |
|
if (elem
.removeEve
ntListener
)
|
|
|
1958 |
|
elem
.removeEve
ntListener
(type, jQu
ery.data(e
lem, "hand
le"), fals
e);
|
|
|
1959 |
|
else if
(elem.deta
chEvent)
|
|
|
1960 |
|
elem
.detachEve
nt("on" +
type, jQue
ry.data(el
em, "handl
e"));
|
|
|
1961 |
|
}
|
|
|
1962 |
|
re
t = null;
|
|
|
1963 |
|
de
lete event
s[type];
|
|
|
1964 |
|
}
|
|
|
1965 |
|
}
|
|
|
1966 |
|
});
|
|
|
1967 |
|
}
|
|
|
1968 |
|
|
|
|
1969 |
|
// Remov
e the expa
ndo if it'
s no longe
r used
|
|
|
1970 |
|
for ( re
t in event
s ) break;
|
|
|
1971 |
|
if ( !re
t ) {
|
|
|
1972 |
|
var
handle = j
Query.data
( elem, "h
andle" );
|
|
|
1973 |
|
if (
handle )
handle.ele
m = null;
|
|
|
1974 |
|
jQue
ry.removeD
ata( elem,
"events"
);
|
|
|
1975 |
|
jQue
ry.removeD
ata( elem,
"handle"
);
|
|
|
1976 |
|
}
|
|
|
1977 |
|
}
|
|
|
1978 |
|
},
|
|
|
1979 |
|
|
|
|
1980 |
|
trigge
r: functio
n(type, da
ta, elem,
donative,
extra) {
|
|
|
1981 |
|
//
Clone the
incoming
data, if a
ny
|
|
|
1982 |
|
da
ta = jQuer
y.makeArra
y(data ||
[]);
|
|
|
1983 |
|
|
|
|
1984 |
|
if
( type.in
dexOf("!")
>= 0 ) {
|
|
|
1985 |
|
type = t
ype.slice(
0, -1);
|
|
|
1986 |
|
var excl
usive = tr
ue;
|
|
|
1987 |
|
}
|
|
|
1988 |
|
|
|
|
1989 |
|
//
Handle a
global tri
gger
|
|
|
1990 |
|
if
( !elem )
{
|
|
|
1991 |
|
// Only
trigger if
we've eve
r bound an
event for
it
|
|
|
1992 |
|
if ( thi
s.global[t
ype] )
|
|
|
1993 |
|
jQue
ry("*").ad
d([window,
document]
).trigger(
type, data
);
|
|
|
1994 |
|
|
|
|
1995 |
|
//
Handle tr
iggering a
single el
ement
|
|
|
1996 |
|
}
else {
|
|
|
1997 |
|
// don't
do events
on text a
nd comment
nodes
|
|
|
1998 |
|
if ( ele
m.nodeType
== 3 || e
lem.nodeTy
pe == 8 )
|
|
|
1999 |
|
retu
rn undefin
ed;
|
|
|
2000 |
|
|
|
|
2001 |
|
var val,
ret, fn =
jQuery.is
Function(
elem[ type
] || null
),
|
|
|
2002 |
|
// C
heck to se
e if we ne
ed to prov
ide a fake
event, or
not
|
|
|
2003 |
|
even
t = !data[
0] || !dat
a[0].preve
ntDefault;
|
|
|
2004 |
|
|
|
|
2005 |
|
// Pass
along a fa
ke event
|
|
|
2006 |
|
if ( eve
nt )
|
|
|
2007 |
|
data
.unshift(
this.fix({
type: typ
e, target:
elem }) )
;
|
|
|
2008 |
|
|
|
|
2009 |
|
// Enfor
ce the rig
ht trigger
type
|
|
|
2010 |
|
data[0].
type = typ
e;
|
|
|
2011 |
|
if ( exc
lusive )
|
|
|
2012 |
|
data
[0].exclus
ive = true
;
|
|
|
2013 |
|
|
|
|
2014 |
|
// Trigg
er the eve
nt
|
|
|
2015 |
|
if ( jQu
ery.isFunc
tion( jQue
ry.data(el
em, "handl
e") ) )
|
|
|
2016 |
|
val
= jQuery.d
ata(elem,
"handle").
apply( ele
m, data );
|
|
|
2017 |
|
|
|
|
2018 |
|
// Handl
e triggeri
ng native
.onfoo han
dlers
|
|
|
2019 |
|
if ( !fn
&& elem["
on"+type]
&& elem["o
n"+type].a
pply( elem
, data ) =
== false )
|
|
|
2020 |
|
val
= false;
|
|
|
2021 |
|
|
|
|
2022 |
|
// Extra
functions
don't get
the custo
m event ob
ject
|
|
|
2023 |
|
if ( eve
nt )
|
|
|
2024 |
|
data
.shift();
|
|
|
2025 |
|
|
|
|
2026 |
|
// Handl
e triggeri
ng of extr
a function
|
|
|
2027 |
|
if ( ext
ra && jQue
ry.isFunct
ion( extra
) ) {
|
|
|
2028 |
|
// c
all the ex
tra functi
on and tac
k the curr
ent return
value on
the end fo
r possible
inspectio
n
|
|
|
2029 |
|
ret
= extra.ap
ply( elem,
val == nu
ll ? data
: data.con
cat( val )
);
|
|
|
2030 |
|
// i
f anything
is return
ed, give i
t preceden
ce and hav
e it overw
rite the p
revious va
lue
|
|
|
2031 |
|
if (
ret !== un
defined)
|
|
|
2032 |
|
val = ret;
|
|
|
2033 |
|
}
|
|
|
2034 |
|
|
|
|
2035 |
|
// Trigg
er the nat
ive events
(except f
or clicks
on links)
|
|
|
2036 |
|
if ( fn
&& donativ
e !== fals
e && val !
== false &
& !(jQuery
.nodeName(
elem, 'a')
&& type =
= "click")
) {
|
|
|
2037 |
|
this
.triggered
= true;
|
|
|
2038 |
|
try
{
|
|
|
2039 |
|
elem[ type
]();
|
|
|
2040 |
|
// p
revent IE
from throw
ing an err
or for som
e hidden e
lements
|
|
|
2041 |
|
} ca
tch (e) {}
|
|
|
2042 |
|
}
|
|
|
2043 |
|
|
|
|
2044 |
|
this.tri
ggered = f
alse;
|
|
|
2045 |
|
}
|
|
|
2046 |
|
|
|
|
2047 |
|
re
turn val;
|
|
|
2048 |
|
},
|
|
|
2049 |
|
|
|
|
2050 |
|
handle
: function
(event) {
|
|
|
2051 |
|
//
returned
undefined
or false
|
|
|
2052 |
|
va
r val;
|
|
|
2053 |
|
|
|
|
2054 |
|
//
Empty obj
ect is for
triggered
events wi
th no data
|
|
|
2055 |
|
ev
ent = jQue
ry.event.f
ix( event
|| window.
event || {
} );
|
|
|
2056 |
|
|
|
|
2057 |
|
//
Namespace
d event ha
ndlers
|
|
|
2058 |
|
va
r parts =
event.type
.split("."
);
|
|
|
2059 |
|
ev
ent.type =
parts[0];
|
|
|
2060 |
|
|
|
|
2061 |
|
va
r handlers
= jQuery.
data(this,
"events")
&& jQuery
.data(this
, "events"
)[event.ty
pe], args
= Array.pr
ototype.sl
ice.call(
arguments,
1 );
|
|
|
2062 |
|
ar
gs.unshift
( event );
|
|
|
2063 |
|
|
|
|
2064 |
|
fo
r ( var j
in handler
s ) {
|
|
|
2065 |
|
var hand
ler = hand
lers[j];
|
|
|
2066 |
|
// Pass
in a refer
ence to th
e handler
function i
tself
|
|
|
2067 |
|
// So th
at we can
later remo
ve it
|
|
|
2068 |
|
args[0].
handler =
handler;
|
|
|
2069 |
|
args[0].
data = han
dler.data;
|
|
|
2070 |
|
|
|
|
2071 |
|
// Filte
r the func
tions by c
lass
|
|
|
2072 |
|
if ( !pa
rts[1] &&
!event.exc
lusive ||
handler.ty
pe == part
s[1] ) {
|
|
|
2073 |
|
var
ret = hand
ler.apply(
this, arg
s );
|
|
|
2074 |
|
|
|
|
2075 |
|
if (
val !== f
alse )
|
|
|
2076 |
|
val = ret;
|
|
|
2077 |
|
|
|
|
2078 |
|
if (
ret === f
alse ) {
|
|
|
2079 |
|
event.prev
entDefault
();
|
|
|
2080 |
|
event.stop
Propagatio
n();
|
|
|
2081 |
|
}
|
|
|
2082 |
|
}
|
|
|
2083 |
|
}
|
|
|
2084 |
|
|
|
|
2085 |
|
//
Clean up
added prop
erties in
IE to prev
ent memory
leak
|
|
|
2086 |
|
if
(jQuery.b
rowser.msi
e)
|
|
|
2087 |
|
event.ta
rget = eve
nt.prevent
Default =
event.stop
Propagatio
n =
|
|
|
2088 |
|
even
t.handler
= event.da
ta = null;
|
|
|
2089 |
|
|
|
|
2090 |
|
re
turn val;
|
|
|
2091 |
|
},
|
|
|
2092 |
|
|
|
|
2093 |
|
fix: f
unction(ev
ent) {
|
|
|
2094 |
|
//
store a c
opy of the
original
event obje
ct
|
|
|
2095 |
|
//
and clone
to set re
ad-only pr
operties
|
|
|
2096 |
|
va
r original
Event = ev
ent;
|
|
|
2097 |
|
ev
ent = jQue
ry.extend(
{}, origin
alEvent);
|
|
|
2098 |
|
|
|
|
2099 |
|
//
add preve
ntDefault
and stopPr
opagation
since
|
|
|
2100 |
|
//
they will
not work
on the clo
ne
|
|
|
2101 |
|
ev
ent.preven
tDefault =
function(
) {
|
|
|
2102 |
|
// if pr
eventDefau
lt exists
run it on
the origin
al event
|
|
|
2103 |
|
if (orig
inalEvent.
preventDef
ault)
|
|
|
2104 |
|
orig
inalEvent.
preventDef
ault();
|
|
|
2105 |
|
// other
wise set t
he returnV
alue prope
rty of the
original
event to f
alse (IE)
|
|
|
2106 |
|
original
Event.retu
rnValue =
false;
|
|
|
2107 |
|
};
|
|
|
2108 |
|
ev
ent.stopPr
opagation
= function
() {
|
|
|
2109 |
|
// if st
opPropagat
ion exists
run it on
the origi
nal event
|
|
|
2110 |
|
if (orig
inalEvent.
stopPropag
ation)
|
|
|
2111 |
|
orig
inalEvent.
stopPropag
ation();
|
|
|
2112 |
|
// other
wise set t
he cancelB
ubble prop
erty of th
e original
event to
true (IE)
|
|
|
2113 |
|
original
Event.canc
elBubble =
true;
|
|
|
2114 |
|
};
|
|
|
2115 |
|
|
|
|
2116 |
|
//
Fix targe
t property
, if neces
sary
|
|
|
2117 |
|
if
( !event.
target )
|
|
|
2118 |
|
event.ta
rget = eve
nt.srcElem
ent || doc
ument; //
Fixes #192
5 where sr
cElement m
ight not b
e defined
either
|
|
|
2119 |
|
|
|
|
2120 |
|
//
check if
target is
a textnode
(safari)
|
|
|
2121 |
|
if
( event.t
arget.node
Type == 3
)
|
|
|
2122 |
|
event.ta
rget = ori
ginalEvent
.target.pa
rentNode;
|
|
|
2123 |
|
|
|
|
2124 |
|
//
Add relat
edTarget,
if necessa
ry
|
|
|
2125 |
|
if
( !event.
relatedTar
get && eve
nt.fromEle
ment )
|
|
|
2126 |
|
event.re
latedTarge
t = event.
fromElemen
t == event
.target ?
event.toEl
ement : ev
ent.fromEl
ement;
|
|
|
2127 |
|
|
|
|
2128 |
|
//
Calculate
pageX/Y i
f missing
and client
X/Y availa
ble
|
|
|
2129 |
|
if
( event.p
ageX == nu
ll && even
t.clientX
!= null )
{
|
|
|
2130 |
|
var doc
= document
.documentE
lement, bo
dy = docum
ent.body;
|
|
|
2131 |
|
event.pa
geX = even
t.clientX
+ (doc &&
doc.scroll
Left || bo
dy && body
.scrollLef
t || 0) -
(doc.clien
tLeft || 0
);
|
|
|
2132 |
|
event.pa
geY = even
t.clientY
+ (doc &&
doc.scroll
Top || bod
y && body.
scrollTop
|| 0) - (d
oc.clientT
op || 0);
|
|
|
2133 |
|
}
|
|
|
2134 |
|
|
|
|
2135 |
|
//
Add which
for key e
vents
|
|
|
2136 |
|
if
( !event.
which && (
(event.cha
rCode || e
vent.charC
ode === 0)
? event.c
harCode :
event.keyC
ode) )
|
|
|
2137 |
|
event.wh
ich = even
t.charCode
|| event.
keyCode;
|
|
|
2138 |
|
|
|
|
2139 |
|
//
Add metaK
ey to non-
Mac browse
rs (use ct
rl for PC'
s and Meta
for Macs)
|
|
|
2140 |
|
if
( !event.
metaKey &&
event.ctr
lKey )
|
|
|
2141 |
|
event.me
taKey = ev
ent.ctrlKe
y;
|
|
|
2142 |
|
|
|
|
2143 |
|
//
Add which
for click
: 1 == lef
t; 2 == mi
ddle; 3 ==
right
|
|
|
2144 |
|
//
Note: but
ton is not
normalize
d, so don'
t use it
|
|
|
2145 |
|
if
( !event.
which && e
vent.butto
n )
|
|
|
2146 |
|
event.wh
ich = (eve
nt.button
& 1 ? 1 :
( event.bu
tton & 2 ?
3 : ( eve
nt.button
& 4 ? 2 :
0 ) ));
|
|
|
2147 |
|
|
|
|
2148 |
|
re
turn event
;
|
|
|
2149 |
|
},
|
|
|
2150 |
|
|
|
|
2151 |
|
specia
l: {
|
|
|
2152 |
|
re
ady: {
|
|
|
2153 |
|
setup: f
unction()
{
|
|
|
2154 |
|
// M
ake sure t
he ready e
vent is se
tup
|
|
|
2155 |
|
bind
Ready();
|
|
|
2156 |
|
retu
rn;
|
|
|
2157 |
|
},
|
|
|
2158 |
|
|
|
|
2159 |
|
teardown
: function
() { retur
n; }
|
|
|
2160 |
|
},
|
|
|
2161 |
|
|
|
|
2162 |
|
mo
useenter:
{
|
|
|
2163 |
|
setup: f
unction()
{
|
|
|
2164 |
|
if (
jQuery.br
owser.msie
) return
false;
|
|
|
2165 |
|
jQue
ry(this).b
ind("mouse
over", jQu
ery.event.
special.mo
useenter.h
andler);
|
|
|
2166 |
|
retu
rn true;
|
|
|
2167 |
|
},
|
|
|
2168 |
|
|
|
|
2169 |
|
teardown
: function
() {
|
|
|
2170 |
|
if (
jQuery.br
owser.msie
) return
false;
|
|
|
2171 |
|
jQue
ry(this).u
nbind("mou
seover", j
Query.even
t.special.
mouseenter
.handler);
|
|
|
2172 |
|
retu
rn true;
|
|
|
2173 |
|
},
|
|
|
2174 |
|
|
|
|
2175 |
|
handler:
function(
event) {
|
|
|
2176 |
|
// I
f we actua
lly just m
oused on t
o a sub-el
ement, ign
ore it
|
|
|
2177 |
|
if (
withinEle
ment(event
, this) )
return tru
e;
|
|
|
2178 |
|
// E
xecute the
right han
dlers by s
etting the
event typ
e to mouse
enter
|
|
|
2179 |
|
argu
ments[0].t
ype = "mou
seenter";
|
|
|
2180 |
|
retu
rn jQuery.
event.hand
le.apply(t
his, argum
ents);
|
|
|
2181 |
|
}
|
|
|
2182 |
|
},
|
|
|
2183 |
|
|
|
|
2184 |
|
mo
useleave:
{
|
|
|
2185 |
|
setup: f
unction()
{
|
|
|
2186 |
|
if (
jQuery.br
owser.msie
) return
false;
|
|
|
2187 |
|
jQue
ry(this).b
ind("mouse
out", jQue
ry.event.s
pecial.mou
seleave.ha
ndler);
|
|
|
2188 |
|
retu
rn true;
|
|
|
2189 |
|
},
|
|
|
2190 |
|
|
|
|
2191 |
|
teardown
: function
() {
|
|
|
2192 |
|
if (
jQuery.br
owser.msie
) return
false;
|
|
|
2193 |
|
jQue
ry(this).u
nbind("mou
seout", jQ
uery.event
.special.m
ouseleave.
handler);
|
|
|
2194 |
|
retu
rn true;
|
|
|
2195 |
|
},
|
|
|
2196 |
|
|
|
|
2197 |
|
handler:
function(
event) {
|
|
|
2198 |
|
// I
f we actua
lly just m
oused on t
o a sub-el
ement, ign
ore it
|
|
|
2199 |
|
if (
withinEle
ment(event
, this) )
return tru
e;
|
|
|
2200 |
|
// E
xecute the
right han
dlers by s
etting the
event typ
e to mouse
leave
|
|
|
2201 |
|
argu
ments[0].t
ype = "mou
seleave";
|
|
|
2202 |
|
retu
rn jQuery.
event.hand
le.apply(t
his, argum
ents);
|
|
|
2203 |
|
}
|
|
|
2204 |
|
}
|
|
|
2205 |
|
}
|
|
|
2206 |
|
};
|
|
|
2207 |
|
|
|
|
2208 |
|
jQuery.fn.
extend({
|
|
|
2209 |
|
bind:
function(
type, data
, fn ) {
|
|
|
2210 |
|
re
turn type
== "unload
" ? this.o
ne(type, d
ata, fn) :
this.each
(function(
){
|
|
|
2211 |
|
jQuery.e
vent.add(
this, type
, fn || da
ta, fn &&
data );
|
|
|
2212 |
|
})
;
|
|
|
2213 |
|
},
|
|
|
2214 |
|
|
|
|
2215 |
|
one: f
unction( t
ype, data,
fn ) {
|
|
|
2216 |
|
re
turn this.
each(funct
ion(){
|
|
|
2217 |
|
jQuery.e
vent.add(
this, type
, function
(event) {
|
|
|
2218 |
|
jQue
ry(this).u
nbind(even
t);
|
|
|
2219 |
|
retu
rn (fn ||
data).appl
y( this, a
rguments);
|
|
|
2220 |
|
}, fn &&
data);
|
|
|
2221 |
|
})
;
|
|
|
2222 |
|
},
|
|
|
2223 |
|
|
|
|
2224 |
|
unbind
: function
( type, fn
) {
|
|
|
2225 |
|
re
turn this.
each(funct
ion(){
|
|
|
2226 |
|
jQuery.e
vent.remov
e( this, t
ype, fn );
|
|
|
2227 |
|
})
;
|
|
|
2228 |
|
},
|
|
|
2229 |
|
|
|
|
2230 |
|
trigge
r: functio
n( type, d
ata, fn )
{
|
|
|
2231 |
|
re
turn this.
each(funct
ion(){
|
|
|
2232 |
|
jQuery.e
vent.trigg
er( type,
data, this
, true, fn
);
|
|
|
2233 |
|
})
;
|
|
|
2234 |
|
},
|
|
|
2235 |
|
|
|
|
2236 |
|
trigge
rHandler:
function(
type, data
, fn ) {
|
|
|
2237 |
|
if
( this[0]
)
|
|
|
2238 |
|
return j
Query.even
t.trigger(
type, dat
a, this[0]
, false, f
n );
|
|
|
2239 |
|
re
turn undef
ined;
|
|
|
2240 |
|
},
|
|
|
2241 |
|
|
|
|
2242 |
|
toggle
: function
() {
|
|
|
2243 |
|
//
Save refe
rence to a
rguments f
or access
in closure
|
|
|
2244 |
|
va
r args = a
rguments;
|
|
|
2245 |
|
|
|
|
2246 |
|
re
turn this.
click(func
tion(event
) {
|
|
|
2247 |
|
// Figur
e out whic
h function
to execut
e
|
|
|
2248 |
|
this.las
tToggle =
0 == this.
lastToggle
? 1 : 0;
|
|
|
2249 |
|
|
|
|
2250 |
|
// Make
sure that
clicks sto
p
|
|
|
2251 |
|
event.pr
eventDefau
lt();
|
|
|
2252 |
|
|
|
|
2253 |
|
// and e
xecute the
function
|
|
|
2254 |
|
return a
rgs[this.l
astToggle]
.apply( th
is, argume
nts ) || f
alse;
|
|
|
2255 |
|
})
;
|
|
|
2256 |
|
},
|
|
|
2257 |
|
|
|
|
2258 |
|
hover:
function(
fnOver, fn
Out) {
|
|
|
2259 |
|
re
turn this.
bind('mous
eenter', f
nOver).bin
d('mousele
ave', fnOu
t);
|
|
|
2260 |
|
},
|
|
|
2261 |
|
|
|
|
2262 |
|
ready:
function(
fn) {
|
|
|
2263 |
|
//
Attach th
e listener
s
|
|
|
2264 |
|
bi
ndReady();
|
|
|
2265 |
|
|
|
|
2266 |
|
//
If the DO
M is alrea
dy ready
|
|
|
2267 |
|
if
( jQuery.
isReady )
|
|
|
2268 |
|
// Execu
te the fun
ction imme
diately
|
|
|
2269 |
|
fn.call(
document,
jQuery );
|
|
|
2270 |
|
|
|
|
2271 |
|
//
Otherwise
, remember
the funct
ion for la
ter
|
|
|
2272 |
|
el
se
|
|
|
2273 |
|
// Add t
he functio
n to the w
ait list
|
|
|
2274 |
|
jQuery.r
eadyList.p
ush( funct
ion() { re
turn fn.ca
ll(this, j
Query); }
);
|
|
|
2275 |
|
|
|
|
2276 |
|
re
turn this;
|
|
|
2277 |
|
}
|
|
|
2278 |
|
});
|
|
|
2279 |
|
|
|
|
2280 |
|
jQuery.ext
end({
|
|
|
2281 |
|
isRead
y: false,
|
|
|
2282 |
|
readyL
ist: [],
|
|
|
2283 |
|
// Han
dle when t
he DOM is
ready
|
|
|
2284 |
|
ready:
function(
) {
|
|
|
2285 |
|
//
Make sure
that the
DOM is not
already l
oaded
|
|
|
2286 |
|
if
( !jQuery
.isReady )
{
|
|
|
2287 |
|
// Remem
ber that t
he DOM is
ready
|
|
|
2288 |
|
jQuery.i
sReady = t
rue;
|
|
|
2289 |
|
|
|
|
2290 |
|
// If th
ere are fu
nctions bo
und, to ex
ecute
|
|
|
2291 |
|
if ( jQu
ery.readyL
ist ) {
|
|
|
2292 |
|
// E
xecute all
of them
|
|
|
2293 |
|
jQue
ry.each( j
Query.read
yList, fun
ction(){
|
|
|
2294 |
|
this.apply
( document
);
|
|
|
2295 |
|
});
|
|
|
2296 |
|
|
|
|
2297 |
|
// R
eset the l
ist of fun
ctions
|
|
|
2298 |
|
jQue
ry.readyLi
st = null;
|
|
|
2299 |
|
}
|
|
|
2300 |
|
|
|
|
2301 |
|
// Trigg
er any bou
nd ready e
vents
|
|
|
2302 |
|
jQuery(d
ocument).t
riggerHand
ler("ready
");
|
|
|
2303 |
|
}
|
|
|
2304 |
|
}
|
|
|
2305 |
|
});
|
|
|
2306 |
|
|
|
|
2307 |
|
var readyB
ound = fal
se;
|
|
|
2308 |
|
|
|
|
2309 |
|
function b
indReady()
{
|
|
|
2310 |
|
if ( r
eadyBound
) return;
|
|
|
2311 |
|
readyB
ound = tru
e;
|
|
|
2312 |
|
|
|
|
2313 |
|
// Moz
illa, Oper
a (see fur
ther below
for it) a
nd webkit
nightlies
currently
support th
is event
|
|
|
2314 |
|
if ( d
ocument.ad
dEventList
ener && !j
Query.brow
ser.opera)
|
|
|
2315 |
|
//
Use the h
andy event
callback
|
|
|
2316 |
|
do
cument.add
EventListe
ner( "DOMC
ontentLoad
ed", jQuer
y.ready, f
alse );
|
|
|
2317 |
|
|
|
|
2318 |
|
// If
IE is used
and is no
t in a fra
me
|
|
|
2319 |
|
// Con
tinually c
heck to se
e if the d
ocument is
ready
|
|
|
2320 |
|
if ( j
Query.brow
ser.msie &
& window =
= top ) (f
unction(){
|
|
|
2321 |
|
if
(jQuery.i
sReady) re
turn;
|
|
|
2322 |
|
tr
y {
|
|
|
2323 |
|
// If IE
is used,
use the tr
ick by Die
go Perini
|
|
|
2324 |
|
// http:
//javascri
pt.nwbox.c
om/IEConte
ntLoaded/
|
|
|
2325 |
|
document
.documentE
lement.doS
croll("lef
t");
|
|
|
2326 |
|
}
catch( err
or ) {
|
|
|
2327 |
|
setTimeo
ut( argume
nts.callee
, 0 );
|
|
|
2328 |
|
return;
|
|
|
2329 |
|
}
|
|
|
2330 |
|
//
and execu
te any wai
ting funct
ions
|
|
|
2331 |
|
jQ
uery.ready
();
|
|
|
2332 |
|
})();
|
|
|
2333 |
|
|
|
|
2334 |
|
if ( j
Query.brow
ser.opera
)
|
|
|
2335 |
|
do
cument.add
EventListe
ner( "DOMC
ontentLoad
ed", funct
ion () {
|
|
|
2336 |
|
if (jQue
ry.isReady
) return;
|
|
|
2337 |
|
for (var
i = 0; i
< document
.styleShee
ts.length;
i++)
|
|
|
2338 |
|
if (
document.s
tyleSheets
[i].disabl
ed) {
|
|
|
2339 |
|
setTimeout
( argument
s.callee,
0 );
|
|
|
2340 |
|
return;
|
|
|
2341 |
|
}
|
|
|
2342 |
|
// and e
xecute any
waiting f
unctions
|
|
|
2343 |
|
jQuery.r
eady();
|
|
|
2344 |
|
},
false);
|
|
|
2345 |
|
|
|
|
2346 |
|
if ( j
Query.brow
ser.safari
) {
|
|
|
2347 |
|
va
r numStyle
s;
|
|
|
2348 |
|
(f
unction(){
|
|
|
2349 |
|
if (jQue
ry.isReady
) return;
|
|
|
2350 |
|
if ( doc
ument.read
yState !=
"loaded" &
& document
.readyStat
e != "comp
lete" ) {
|
|
|
2351 |
|
setT
imeout( ar
guments.ca
llee, 0 );
|
|
|
2352 |
|
retu
rn;
|
|
|
2353 |
|
}
|
|
|
2354 |
|
if ( num
Styles ===
undefined
)
|
|
|
2355 |
|
numS
tyles = jQ
uery("styl
e, link[re
l=styleshe
et]").leng
th;
|
|
|
2356 |
|
if ( doc
ument.styl
eSheets.le
ngth != nu
mStyles )
{
|
|
|
2357 |
|
setT
imeout( ar
guments.ca
llee, 0 );
|
|
|
2358 |
|
retu
rn;
|
|
|
2359 |
|
}
|
|
|
2360 |
|
// and e
xecute any
waiting f
unctions
|
|
|
2361 |
|
jQuery.r
eady();
|
|
|
2362 |
|
})
();
|
|
|
2363 |
|
}
|
|
|
2364 |
|
|
|
|
2365 |
|
// A f
allback to
window.on
load, that
will alwa
ys work
|
|
|
2366 |
|
jQuery
.event.add
( window,
"load", jQ
uery.ready
);
|
|
|
2367 |
|
}
|
|
|
2368 |
|
|
|
|
2369 |
|
jQuery.eac
h( ("blur,
focus,load
,resize,sc
roll,unloa
d,click,db
lclick," +
|
|
|
2370 |
|
"mouse
down,mouse
up,mousemo
ve,mouseov
er,mouseou
t,change,s
elect," +
|
|
|
2371 |
|
"submi
t,keydown,
keypress,k
eyup,error
").split("
,"), funct
ion(i, nam
e){
|
|
|
2372 |
|
|
|
|
2373 |
|
// Han
dle event
binding
|
|
|
2374 |
|
jQuery
.fn[name]
= function
(fn){
|
|
|
2375 |
|
re
turn fn ?
this.bind(
name, fn)
: this.tri
gger(name)
;
|
|
|
2376 |
|
};
|
|
|
2377 |
|
});
|
|
|
2378 |
|
|
|
|
2379 |
|
// Checks
if an even
t happened
on an ele
ment withi
n another
element
|
|
|
2380 |
|
// Used in
jQuery.ev
ent.specia
l.mouseent
er and mou
seleave ha
ndlers
|
|
|
2381 |
|
var within
Element =
function(e
vent, elem
) {
|
|
|
2382 |
|
// Che
ck if mous
e(over|out
) are stil
l within t
he same pa
rent eleme
nt
|
|
|
2383 |
|
var pa
rent = eve
nt.related
Target;
|
|
|
2384 |
|
// Tra
verse up t
he tree
|
|
|
2385 |
|
while
( parent &
& parent !
= elem ) t
ry { paren
t = parent
.parentNod
e; } catch
(error) {
parent = e
lem; }
|
|
|
2386 |
|
// Ret
urn true i
f we actua
lly just m
oused on t
o a sub-el
ement
|
|
|
2387 |
|
return
parent ==
elem;
|
|
|
2388 |
|
};
|
|
|
2389 |
|
|
|
|
2390 |
|
// Prevent
memory le
aks in IE
|
|
|
2391 |
|
// And pre
vent error
s on refre
sh with ev
ents like
mouseover
in other b
rowsers
|
|
|
2392 |
|
// Window
isn't incl
uded so as
not to un
bind exist
ing unload
events
|
|
|
2393 |
|
jQuery(win
dow).bind(
"unload",
function()
{
|
|
|
2394 |
|
jQuery
("*").add(
document).
unbind();
|
|
|
2395 |
|
});
|
|
|
2396 |
|
jQuery.fn.
extend({
|
|
|
2397 |
|
load:
function(
url, param
s, callbac
k ) {
|
|
|
2398 |
|
if
( jQuery.
isFunction
( url ) )
|
|
|
2399 |
|
return t
his.bind("
load", url
);
|
|
|
2400 |
|
|
|
|
2401 |
|
va
r off = ur
l.indexOf(
" ");
|
|
|
2402 |
|
if
( off >=
0 ) {
|
|
|
2403 |
|
var sele
ctor = url
.slice(off
, url.leng
th);
|
|
|
2404 |
|
url = ur
l.slice(0,
off);
|
|
|
2405 |
|
}
|
|
|
2406 |
|
|
|
|
2407 |
|
ca
llback = c
allback ||
function(
){};
|
|
|
2408 |
|
|
|
|
2409 |
|
//
Default t
o a GET re
quest
|
|
|
2410 |
|
va
r type = "
GET";
|
|
|
2411 |
|
|
|
|
2412 |
|
//
If the se
cond param
eter was p
rovided
|
|
|
2413 |
|
if
( params
)
|
|
|
2414 |
|
// If it
's a funct
ion
|
|
|
2415 |
|
if ( jQu
ery.isFunc
tion( para
ms ) ) {
|
|
|
2416 |
|
// W
e assume t
hat it's t
he callbac
k
|
|
|
2417 |
|
call
back = par
ams;
|
|
|
2418 |
|
para
ms = null;
|
|
|
2419 |
|
|
|
|
2420 |
|
// Other
wise, buil
d a param
string
|
|
|
2421 |
|
} else {
|
|
|
2422 |
|
para
ms = jQuer
y.param( p
arams );
|
|
|
2423 |
|
type
= "POST";
|
|
|
2424 |
|
}
|
|
|
2425 |
|
|
|
|
2426 |
|
va
r self = t
his;
|
|
|
2427 |
|
|
|
|
2428 |
|
//
Request t
he remote
document
|
|
|
2429 |
|
jQ
uery.ajax(
{
|
|
|
2430 |
|
url: url
,
|
|
|
2431 |
|
type: ty
pe,
|
|
|
2432 |
|
dataType
: "html",
|
|
|
2433 |
|
data: pa
rams,
|
|
|
2434 |
|
complete
: function
(res, stat
us){
|
|
|
2435 |
|
// I
f successf
ul, inject
the HTML
into all t
he matched
elements
|
|
|
2436 |
|
if (
status ==
"success"
|| status
== "notmo
dified" )
|
|
|
2437 |
|
// See if
a selector
was speci
fied
|
|
|
2438 |
|
self.html(
selector
?
|
|
|
2439 |
|
// Cre
ate a dumm
y div to h
old the re
sults
|
|
|
2440 |
|
jQuery
("<div/>")
|
|
|
2441 |
|
//
inject th
e contents
of the do
cument in,
removing
the script
s
|
|
|
2442 |
|
//
to avoid
any 'Permi
ssion Deni
ed' errors
in IE
|
|
|
2443 |
|
.a
ppend(res.
responseTe
xt.replace
(/<script(
.|\s)*?\/s
cript>/g,
""))
|
|
|
2444 |
|
|
|
|
2445 |
|
//
Locate th
e specifie
d elements
|
|
|
2446 |
|
.f
ind(select
or) :
|
|
|
2447 |
|
|
|
|
2448 |
|
// If
not, just
inject the
full resu
lt
|
|
|
2449 |
|
res.re
sponseText
);
|
|
|
2450 |
|
|
|
|
2451 |
|
self
.each( cal
lback, [re
s.response
Text, stat
us, res] )
;
|
|
|
2452 |
|
}
|
|
|
2453 |
|
})
;
|
|
|
2454 |
|
re
turn this;
|
|
|
2455 |
|
},
|
|
|
2456 |
|
|
|
|
2457 |
|
serial
ize: funct
ion() {
|
|
|
2458 |
|
re
turn jQuer
y.param(th
is.seriali
zeArray())
;
|
|
|
2459 |
|
},
|
|
|
2460 |
|
serial
izeArray:
function()
{
|
|
|
2461 |
|
re
turn this.
map(functi
on(){
|
|
|
2462 |
|
return j
Query.node
Name(this,
"form") ?
|
|
|
2463 |
|
jQue
ry.makeArr
ay(this.el
ements) :
this;
|
|
|
2464 |
|
})
|
|
|
2465 |
|
.f
ilter(func
tion(){
|
|
|
2466 |
|
return t
his.name &
& !this.di
sabled &&
|
|
|
2467 |
|
(thi
s.checked
|| /select
|textarea/
i.test(thi
s.nodeName
) ||
|
|
|
2468 |
|
/text|hidd
en|passwor
d/i.test(t
his.type))
;
|
|
|
2469 |
|
})
|
|
|
2470 |
|
.m
ap(functio
n(i, elem)
{
|
|
|
2471 |
|
var val
= jQuery(t
his).val()
;
|
|
|
2472 |
|
return v
al == null
? null :
|
|
|
2473 |
|
val.
constructo
r == Array
?
|
|
|
2474 |
|
jQuery.map
( val, fun
ction(val,
i){
|
|
|
2475 |
|
return
{name: el
em.name, v
alue: val}
;
|
|
|
2476 |
|
}) :
|
|
|
2477 |
|
{name: ele
m.name, va
lue: val};
|
|
|
2478 |
|
})
.get();
|
|
|
2479 |
|
}
|
|
|
2480 |
|
});
|
|
|
2481 |
|
|
|
|
2482 |
|
// Attach
a bunch of
functions
for handl
ing common
AJAX even
ts
|
|
|
2483 |
|
jQuery.eac
h( "ajaxSt
art,ajaxSt
op,ajaxCom
plete,ajax
Error,ajax
Success,aj
axSend".sp
lit(","),
function(i
,o){
|
|
|
2484 |
|
jQuery
.fn[o] = f
unction(f)
{
|
|
|
2485 |
|
re
turn this.
bind(o, f)
;
|
|
|
2486 |
|
};
|
|
|
2487 |
|
});
|
|
|
2488 |
|
|
|
|
2489 |
|
var jsc =
(new Date)
.getTime()
;
|
|
|
2490 |
|
|
|
|
2491 |
|
jQuery.ext
end({
|
|
|
2492 |
|
get: f
unction( u
rl, data,
callback,
type ) {
|
|
|
2493 |
|
//
shift arg
uments if
data argum
ent was om
mited
|
|
|
2494 |
|
if
( jQuery.
isFunction
( data ) )
{
|
|
|
2495 |
|
callback
= data;
|
|
|
2496 |
|
data = n
ull;
|
|
|
2497 |
|
}
|
|
|
2498 |
|
|
|
|
2499 |
|
re
turn jQuer
y.ajax({
|
|
|
2500 |
|
type: "G
ET",
|
|
|
2501 |
|
url: url
,
|
|
|
2502 |
|
data: da
ta,
|
|
|
2503 |
|
success:
callback,
|
|
|
2504 |
|
dataType
: type
|
|
|
2505 |
|
})
;
|
|
|
2506 |
|
},
|
|
|
2507 |
|
|
|
|
2508 |
|
getScr
ipt: funct
ion( url,
callback )
{
|
|
|
2509 |
|
re
turn jQuer
y.get(url,
null, cal
lback, "sc
ript");
|
|
|
2510 |
|
},
|
|
|
2511 |
|
|
|
|
2512 |
|
getJSO
N: functio
n( url, da
ta, callba
ck ) {
|
|
|
2513 |
|
re
turn jQuer
y.get(url,
data, cal
lback, "js
on");
|
|
|
2514 |
|
},
|
|
|
2515 |
|
|
|
|
2516 |
|
post:
function(
url, data,
callback,
type ) {
|
|
|
2517 |
|
if
( jQuery.
isFunction
( data ) )
{
|
|
|
2518 |
|
callback
= data;
|
|
|
2519 |
|
data = {
};
|
|
|
2520 |
|
}
|
|
|
2521 |
|
|
|
|
2522 |
|
re
turn jQuer
y.ajax({
|
|
|
2523 |
|
type: "P
OST",
|
|
|
2524 |
|
url: url
,
|
|
|
2525 |
|
data: da
ta,
|
|
|
2526 |
|
success:
callback,
|
|
|
2527 |
|
dataType
: type
|
|
|
2528 |
|
})
;
|
|
|
2529 |
|
},
|
|
|
2530 |
|
|
|
|
2531 |
|
ajaxSe
tup: funct
ion( setti
ngs ) {
|
|
|
2532 |
|
jQ
uery.exten
d( jQuery.
ajaxSettin
gs, settin
gs );
|
|
|
2533 |
|
},
|
|
|
2534 |
|
|
|
|
2535 |
|
ajaxSe
ttings: {
|
|
|
2536 |
|
gl
obal: true
,
|
|
|
2537 |
|
ty
pe: "GET",
|
|
|
2538 |
|
ti
meout: 0,
|
|
|
2539 |
|
co
ntentType:
"applicat
ion/x-www-
form-urlen
coded",
|
|
|
2540 |
|
pr
ocessData:
true,
|
|
|
2541 |
|
as
ync: true,
|
|
|
2542 |
|
da
ta: null,
|
|
|
2543 |
|
us
ername: nu
ll,
|
|
|
2544 |
|
pa
ssword: nu
ll,
|
|
|
2545 |
|
ac
cepts: {
|
|
|
2546 |
|
xml: "ap
plication/
xml, text/
xml",
|
|
|
2547 |
|
html: "t
ext/html",
|
|
|
2548 |
|
script:
"text/java
script, ap
plication/
javascript
",
|
|
|
2549 |
|
json: "a
pplication
/json, tex
t/javascri
pt",
|
|
|
2550 |
|
text: "t
ext/plain"
,
|
|
|
2551 |
|
_default
: "*/*"
|
|
|
2552 |
|
}
|
|
|
2553 |
|
},
|
|
|
2554 |
|
|
|
|
2555 |
|
// Las
t-Modified
header ca
che for ne
xt request
|
|
|
2556 |
|
lastMo
dified: {}
,
|
|
|
2557 |
|
|
|
|
2558 |
|
ajax:
function(
s ) {
|
|
|
2559 |
|
va
r jsonp, j
sre = /=\?
(&|$)/g, s
tatus, dat
a;
|
|
|
2560 |
|
|
|
|
2561 |
|
//
Extend th
e settings
, but re-e
xtend 's'
so that it
can be
|
|
|
2562 |
|
//
checked a
gain later
(in the t
est suite,
specifica
lly)
|
|
|
2563 |
|
s
= jQuery.e
xtend(true
, s, jQuer
y.extend(t
rue, {}, j
Query.ajax
Settings,
s));
|
|
|
2564 |
|
|
|
|
2565 |
|
//
convert d
ata if not
already a
string
|
|
|
2566 |
|
if
( s.data
&& s.proce
ssData &&
typeof s.d
ata != "st
ring" )
|
|
|
2567 |
|
s.data =
jQuery.pa
ram(s.data
);
|
|
|
2568 |
|
|
|
|
2569 |
|
//
Handle JS
ONP Parame
ter Callba
cks
|
|
|
2570 |
|
if
( s.dataT
ype == "js
onp" ) {
|
|
|
2571 |
|
if ( s.t
ype.toLowe
rCase() ==
"get" ) {
|
|
|
2572 |
|
if (
!s.url.ma
tch(jsre)
)
|
|
|
2573 |
|
s.url += (
s.url.matc
h(/\?/) ?
"&" : "?")
+ (s.json
p || "call
back") + "
=?";
|
|
|
2574 |
|
} else i
f ( !s.dat
a || !s.da
ta.match(j
sre) )
|
|
|
2575 |
|
s.da
ta = (s.da
ta ? s.dat
a + "&" :
"") + (s.j
sonp || "c
allback")
+ "=?";
|
|
|
2576 |
|
s.dataTy
pe = "json
";
|
|
|
2577 |
|
}
|
|
|
2578 |
|
|
|
|
2579 |
|
//
Build tem
porary JSO
NP functio
n
|
|
|
2580 |
|
if
( s.dataT
ype == "js
on" && (s.
data && s.
data.match
(jsre) ||
s.url.matc
h(jsre)) )
{
|
|
|
2581 |
|
jsonp =
"jsonp" +
jsc++;
|
|
|
2582 |
|
|
|
|
2583 |
|
// Repla
ce the =?
sequence b
oth in the
query str
ing and th
e data
|
|
|
2584 |
|
if ( s.d
ata )
|
|
|
2585 |
|
s.da
ta = (s.da
ta + "").r
eplace(jsr
e, "=" + j
sonp + "$1
");
|
|
|
2586 |
|
s.url =
s.url.repl
ace(jsre,
"=" + json
p + "$1");
|
|
|
2587 |
|
|
|
|
2588 |
|
// We ne
ed to make
sure
|
|
|
2589 |
|
// that
a JSONP st
yle respon
se is exec
uted prope
rly
|
|
|
2590 |
|
s.dataTy
pe = "scri
pt";
|
|
|
2591 |
|
|
|
|
2592 |
|
// Handl
e JSONP-st
yle loadin
g
|
|
|
2593 |
|
window[
jsonp ] =
function(t
mp){
|
|
|
2594 |
|
data
= tmp;
|
|
|
2595 |
|
succ
ess();
|
|
|
2596 |
|
comp
lete();
|
|
|
2597 |
|
// G
arbage col
lect
|
|
|
2598 |
|
wind
ow[ jsonp
] = undefi
ned;
|
|
|
2599 |
|
try{
delete wi
ndow[ json
p ]; } cat
ch(e){}
|
|
|
2600 |
|
if (
head )
|
|
|
2601 |
|
head.remov
eChild( sc
ript );
|
|
|
2602 |
|
};
|
|
|
2603 |
|
}
|
|
|
2604 |
|
|
|
|
2605 |
|
if
( s.dataT
ype == "sc
ript" && s
.cache ==
null )
|
|
|
2606 |
|
s.cache
= false;
|
|
|
2607 |
|
|
|
|
2608 |
|
if
( s.cache
=== false
&& s.type
.toLowerCa
se() == "g
et" ) {
|
|
|
2609 |
|
var ts =
(new Date
()).getTim
e();
|
|
|
2610 |
|
// try r
eplacing _
= if it is
there
|
|
|
2611 |
|
var ret
= s.url.re
place(/(\?
|&)_=.*?(&
|$)/, "$1_
=" + ts +
"$2");
|
|
|
2612 |
|
// if no
thing was
replaced,
add timest
amp to the
end
|
|
|
2613 |
|
s.url =
ret + ((re
t == s.url
) ? (s.url
.match(/\?
/) ? "&" :
"?") + "_
=" + ts :
"");
|
|
|
2614 |
|
}
|
|
|
2615 |
|
|
|
|
2616 |
|
//
If data i
s availabl
e, append
data to ur
l for get
requests
|
|
|
2617 |
|
if
( s.data
&& s.type.
toLowerCas
e() == "ge
t" ) {
|
|
|
2618 |
|
s.url +=
(s.url.ma
tch(/\?/)
? "&" : "?
") + s.dat
a;
|
|
|
2619 |
|
|
|
|
2620 |
|
// IE li
kes to sen
d both get
and post
data, prev
ent this
|
|
|
2621 |
|
s.data =
null;
|
|
|
2622 |
|
}
|
|
|
2623 |
|
|
|
|
2624 |
|
//
Watch for
a new set
of reques
ts
|
|
|
2625 |
|
if
( s.globa
l && ! jQu
ery.active
++ )
|
|
|
2626 |
|
jQuery.e
vent.trigg
er( "ajaxS
tart" );
|
|
|
2627 |
|
|
|
|
2628 |
|
//
If we're
requesting
a remote
document
|
|
|
2629 |
|
//
and tryin
g to load
JSON or Sc
ript with
a GET
|
|
|
2630 |
|
if
( (!s.url
.indexOf("
http") ||
!s.url.ind
exOf("//")
) && s.dat
aType == "
script" &&
s.type.to
LowerCase(
) == "get"
) {
|
|
|
2631 |
|
var head
= documen
t.getEleme
ntsByTagNa
me("head")
[0];
|
|
|
2632 |
|
var scri
pt = docum
ent.create
Element("s
cript");
|
|
|
2633 |
|
script.s
rc = s.url
;
|
|
|
2634 |
|
if (s.sc
riptCharse
t)
|
|
|
2635 |
|
scri
pt.charset
= s.scrip
tCharset;
|
|
|
2636 |
|
|
|
|
2637 |
|
// Handl
e Script l
oading
|
|
|
2638 |
|
if ( !js
onp ) {
|
|
|
2639 |
|
var
done = fal
se;
|
|
|
2640 |
|
|
|
|
2641 |
|
// A
ttach hand
lers for a
ll browser
s
|
|
|
2642 |
|
scri
pt.onload
= script.o
nreadystat
echange =
function()
{
|
|
|
2643 |
|
if ( !done
&& (!this
.readyStat
e ||
|
|
|
2644 |
|
th
is.readySt
ate == "lo
aded" || t
his.readyS
tate == "c
omplete")
) {
|
|
|
2645 |
|
done =
true;
|
|
|
2646 |
|
succes
s();
|
|
|
2647 |
|
comple
te();
|
|
|
2648 |
|
head.r
emoveChild
( script )
;
|
|
|
2649 |
|
}
|
|
|
2650 |
|
};
|
|
|
2651 |
|
}
|
|
|
2652 |
|
|
|
|
2653 |
|
head.app
endChild(s
cript);
|
|
|
2654 |
|
|
|
|
2655 |
|
// We ha
ndle every
thing usin
g the scri
pt element
injection
|
|
|
2656 |
|
return u
ndefined;
|
|
|
2657 |
|
}
|
|
|
2658 |
|
|
|
|
2659 |
|
va
r requestD
one = fals
e;
|
|
|
2660 |
|
|
|
|
2661 |
|
//
Create th
e request
object; Mi
crosoft fa
iled to pr
operly
|
|
|
2662 |
|
//
implement
the XMLHt
tpRequest
in IE7, so
we use th
e ActiveXO
bject when
it is ava
ilable
|
|
|
2663 |
|
va
r xml = wi
ndow.Activ
eXObject ?
new Activ
eXObject("
Microsoft.
XMLHTTP")
: new XMLH
ttpRequest
();
|
|
|
2664 |
|
|
|
|
2665 |
|
//
Open the
socket
|
|
|
2666 |
|
xm
l.open(s.t
ype, s.url
, s.async,
s.usernam
e, s.passw
ord);
|
|
|
2667 |
|
|
|
|
2668 |
|
//
Need an e
xtra try/c
atch for c
ross domai
n requests
in Firefo
x 3
|
|
|
2669 |
|
tr
y {
|
|
|
2670 |
|
// Set t
he correct
header, i
f data is
being sent
|
|
|
2671 |
|
if ( s.d
ata )
|
|
|
2672 |
|
xml.
setRequest
Header("Co
ntent-Type
", s.conte
ntType);
|
|
|
2673 |
|
|
|
|
2674 |
|
// Set t
he If-Modi
fied-Since
header, i
f ifModifi
ed mode.
|
|
|
2675 |
|
if ( s.i
fModified
)
|
|
|
2676 |
|
xml.
setRequest
Header("If
-Modified-
Since",
|
|
|
2677 |
|
jQuery.las
tModified[
s.url] ||
"Thu, 01 J
an 1970 00
:00:00 GMT
" );
|
|
|
2678 |
|
|
|
|
2679 |
|
// Set h
eader so t
he called
script kno
ws that it
's an XMLH
ttpRequest
|
|
|
2680 |
|
xml.setR
equestHead
er("X-Requ
ested-With
", "XMLHtt
pRequest")
;
|
|
|
2681 |
|
|
|
|
2682 |
|
// Set t
he Accepts
header fo
r the serv
er, depend
ing on the
dataType
|
|
|
2683 |
|
xml.setR
equestHead
er("Accept
", s.dataT
ype && s.a
ccepts[ s.
dataType ]
?
|
|
|
2684 |
|
s.ac
cepts[ s.d
ataType ]
+ ", */*"
:
|
|
|
2685 |
|
s.ac
cepts._def
ault );
|
|
|
2686 |
|
}
catch(e){}
|
|
|
2687 |
|
|
|
|
2688 |
|
//
Allow cus
tom header
s/mimetype
s
|
|
|
2689 |
|
if
( s.befor
eSend )
|
|
|
2690 |
|
s.before
Send(xml);
|
|
|
2691 |
|
|
|
|
2692 |
|
if
( s.globa
l )
|
|
|
2693 |
|
jQuery.e
vent.trigg
er("ajaxSe
nd", [xml,
s]);
|
|
|
2694 |
|
|
|
|
2695 |
|
//
Wait for
a response
to come b
ack
|
|
|
2696 |
|
va
r onreadys
tatechange
= functio
n(isTimeou
t){
|
|
|
2697 |
|
// The t
ransfer is
complete
and the da
ta is avai
lable, or
the reques
t timed ou
t
|
|
|
2698 |
|
if ( !re
questDone
&& xml &&
(xml.ready
State == 4
|| isTime
out == "ti
meout") )
{
|
|
|
2699 |
|
requ
estDone =
true;
|
|
|
2700 |
|
|
|
|
2701 |
|
// c
lear poll
interval
|
|
|
2702 |
|
if (
ival) {
|
|
|
2703 |
|
clearInter
val(ival);
|
|
|
2704 |
|
ival = nul
l;
|
|
|
2705 |
|
}
|
|
|
2706 |
|
|
|
|
2707 |
|
stat
us = isTim
eout == "t
imeout" &&
"timeout"
||
|
|
|
2708 |
|
!jQuery.ht
tpSuccess(
xml ) &&
"error" ||
|
|
|
2709 |
|
s.ifModifi
ed && jQue
ry.httpNot
Modified(
xml, s.url
) && "not
modified"
||
|
|
|
2710 |
|
"success";
|
|
|
2711 |
|
|
|
|
2712 |
|
if (
status ==
"success"
) {
|
|
|
2713 |
|
// Watch f
or, and ca
tch, XML d
ocument pa
rse errors
|
|
|
2714 |
|
try {
|
|
|
2715 |
|
// pro
cess the d
ata (runs
the xml th
rough http
Data regar
dless of c
allback)
|
|
|
2716 |
|
data =
jQuery.ht
tpData( xm
l, s.dataT
ype );
|
|
|
2717 |
|
} catch(e)
{
|
|
|
2718 |
|
status
= "parser
error";
|
|
|
2719 |
|
}
|
|
|
2720 |
|
}
|
|
|
2721 |
|
|
|
|
2722 |
|
// M
ake sure t
hat the re
quest was
successful
or notmod
ified
|
|
|
2723 |
|
if (
status ==
"success"
) {
|
|
|
2724 |
|
// Cache L
ast-Modifi
ed header,
if ifModi
fied mode.
|
|
|
2725 |
|
var modRes
;
|
|
|
2726 |
|
try {
|
|
|
2727 |
|
modRes
= xml.get
ResponseHe
ader("Last
-Modified"
);
|
|
|
2728 |
|
} catch(e)
{} // swa
llow excep
tion throw
n by FF if
header is
not avail
able
|
|
|
2729 |
|
|
|
|
2730 |
|
if ( s.ifM
odified &&
modRes )
|
|
|
2731 |
|
jQuery
.lastModif
ied[s.url]
= modRes;
|
|
|
2732 |
|
|
|
|
2733 |
|
// JSONP h
andles its
own succe
ss callbac
k
|
|
|
2734 |
|
if ( !json
p )
|
|
|
2735 |
|
succes
s();
|
|
|
2736 |
|
} el
se
|
|
|
2737 |
|
jQuery.han
dleError(s
, xml, sta
tus);
|
|
|
2738 |
|
|
|
|
2739 |
|
// F
ire the co
mplete han
dlers
|
|
|
2740 |
|
comp
lete();
|
|
|
2741 |
|
|
|
|
2742 |
|
// S
top memory
leaks
|
|
|
2743 |
|
if (
s.async )
|
|
|
2744 |
|
xml = null
;
|
|
|
2745 |
|
}
|
|
|
2746 |
|
};
|
|
|
2747 |
|
|
|
|
2748 |
|
if
( s.async
) {
|
|
|
2749 |
|
// don't
attach th
e handler
to the req
uest, just
poll it i
nstead
|
|
|
2750 |
|
var ival
= setInte
rval(onrea
dystatecha
nge, 13);
|
|
|
2751 |
|
|
|
|
2752 |
|
// Timeo
ut checker
|
|
|
2753 |
|
if ( s.t
imeout > 0
)
|
|
|
2754 |
|
setT
imeout(fun
ction(){
|
|
|
2755 |
|
// Check t
o see if t
he request
is still
happening
|
|
|
2756 |
|
if ( xml )
{
|
|
|
2757 |
|
// Can
cel the re
quest
|
|
|
2758 |
|
xml.ab
ort();
|
|
|
2759 |
|
|
|
|
2760 |
|
if( !r
equestDone
)
|
|
|
2761 |
|
on
readystate
change( "t
imeout" );
|
|
|
2762 |
|
}
|
|
|
2763 |
|
}, s
.timeout);
|
|
|
2764 |
|
}
|
|
|
2765 |
|
|
|
|
2766 |
|
//
Send the
data
|
|
|
2767 |
|
tr
y {
|
|
|
2768 |
|
xml.send
(s.data);
|
|
|
2769 |
|
}
catch(e) {
|
|
|
2770 |
|
jQuery.h
andleError
(s, xml, n
ull, e);
|
|
|
2771 |
|
}
|
|
|
2772 |
|
|
|
|
2773 |
|
//
firefox 1
.5 doesn't
fire stat
echange fo
r sync req
uests
|
|
|
2774 |
|
if
( !s.asyn
c )
|
|
|
2775 |
|
onreadys
tatechange
();
|
|
|
2776 |
|
|
|
|
2777 |
|
fu
nction suc
cess(){
|
|
|
2778 |
|
// If a
local call
back was s
pecified,
fire it an
d pass it
the data
|
|
|
2779 |
|
if ( s.s
uccess )
|
|
|
2780 |
|
s.su
ccess( dat
a, status
);
|
|
|
2781 |
|
|
|
|
2782 |
|
// Fire
the global
callback
|
|
|
2783 |
|
if ( s.g
lobal )
|
|
|
2784 |
|
jQue
ry.event.t
rigger( "a
jaxSuccess
", [xml, s
] );
|
|
|
2785 |
|
}
|
|
|
2786 |
|
|
|
|
2787 |
|
fu
nction com
plete(){
|
|
|
2788 |
|
// Proce
ss result
|
|
|
2789 |
|
if ( s.c
omplete )
|
|
|
2790 |
|
s.co
mplete(xml
, status);
|
|
|
2791 |
|
|
|
|
2792 |
|
// The r
equest was
completed
|
|
|
2793 |
|
if ( s.g
lobal )
|
|
|
2794 |
|
jQue
ry.event.t
rigger( "a
jaxComplet
e", [xml,
s] );
|
|
|
2795 |
|
|
|
|
2796 |
|
// Handl
e the glob
al AJAX co
unter
|
|
|
2797 |
|
if ( s.g
lobal && !
--jQuery.
active )
|
|
|
2798 |
|
jQue
ry.event.t
rigger( "a
jaxStop" )
;
|
|
|
2799 |
|
}
|
|
|
2800 |
|
|
|
|
2801 |
|
//
return XM
LHttpReque
st to allo
w aborting
the reque
st etc.
|
|
|
2802 |
|
re
turn xml;
|
|
|
2803 |
|
},
|
|
|
2804 |
|
|
|
|
2805 |
|
handle
Error: fun
ction( s,
xml, statu
s, e ) {
|
|
|
2806 |
|
//
If a loca
l callback
was speci
fied, fire
it
|
|
|
2807 |
|
if
( s.error
) s.error
( xml, sta
tus, e );
|
|
|
2808 |
|
|
|
|
2809 |
|
//
Fire the
global cal
lback
|
|
|
2810 |
|
if
( s.globa
l )
|
|
|
2811 |
|
jQuery.e
vent.trigg
er( "ajaxE
rror", [xm
l, s, e] )
;
|
|
|
2812 |
|
},
|
|
|
2813 |
|
|
|
|
2814 |
|
// Cou
nter for h
olding the
number of
active qu
eries
|
|
|
2815 |
|
active
: 0,
|
|
|
2816 |
|
|
|
|
2817 |
|
// Det
ermines if
an XMLHtt
pRequest w
as success
ful or not
|
|
|
2818 |
|
httpSu
ccess: fun
ction( r )
{
|
|
|
2819 |
|
tr
y {
|
|
|
2820 |
|
// IE er
ror someti
mes return
s 1223 whe
n it shoul
d be 204 s
o treat it
as succes
s, see #14
50
|
|
|
2821 |
|
return !
r.status &
& location
.protocol
== "file:"
||
|
|
|
2822 |
|
( r.
status >=
200 && r.s
tatus < 30
0 ) || r.s
tatus == 3
04 || r.st
atus == 12
23 ||
|
|
|
2823 |
|
jQue
ry.browser
.safari &&
r.status
== undefin
ed;
|
|
|
2824 |
|
}
catch(e){}
|
|
|
2825 |
|
re
turn false
;
|
|
|
2826 |
|
},
|
|
|
2827 |
|
|
|
|
2828 |
|
// Det
ermines if
an XMLHtt
pRequest r
eturns Not
Modified
|
|
|
2829 |
|
httpNo
tModified:
function(
xml, url
) {
|
|
|
2830 |
|
tr
y {
|
|
|
2831 |
|
var xmlR
es = xml.g
etResponse
Header("La
st-Modifie
d");
|
|
|
2832 |
|
|
|
|
2833 |
|
// Firef
ox always
returns 20
0. check L
ast-Modifi
ed date
|
|
|
2834 |
|
return x
ml.status
== 304 ||
xmlRes ==
jQuery.las
tModified[
url] ||
|
|
|
2835 |
|
jQue
ry.browser
.safari &&
xml.statu
s == undef
ined;
|
|
|
2836 |
|
}
catch(e){}
|
|
|
2837 |
|
re
turn false
;
|
|
|
2838 |
|
},
|
|
|
2839 |
|
|
|
|
2840 |
|
httpDa
ta: functi
on( r, typ
e ) {
|
|
|
2841 |
|
va
r ct = r.g
etResponse
Header("co
ntent-type
");
|
|
|
2842 |
|
va
r xml = ty
pe == "xml
" || !type
&& ct &&
ct.indexOf
("xml") >=
0;
|
|
|
2843 |
|
va
r data = x
ml ? r.res
ponseXML :
r.respons
eText;
|
|
|
2844 |
|
|
|
|
2845 |
|
if
( xml &&
data.docum
entElement
.tagName =
= "parsere
rror" )
|
|
|
2846 |
|
throw "p
arsererror
";
|
|
|
2847 |
|
|
|
|
2848 |
|
//
If the ty
pe is "scr
ipt", eval
it in glo
bal contex
t
|
|
|
2849 |
|
if
( type ==
"script"
)
|
|
|
2850 |
|
jQuery.g
lobalEval(
data );
|
|
|
2851 |
|
|
|
|
2852 |
|
//
Get the J
avaScript
object, if
JSON is u
sed.
|
|
|
2853 |
|
if
( type ==
"json" )
|
|
|
2854 |
|
data = e
val("(" +
data + ")"
);
|
|
|
2855 |
|
|
|
|
2856 |
|
re
turn data;
|
|
|
2857 |
|
},
|
|
|
2858 |
|
|
|
|
2859 |
|
// Ser
ialize an
array of f
orm elemen
ts or a se
t of
|
|
|
2860 |
|
// key
/values in
to a query
string
|
|
|
2861 |
|
param:
function(
a ) {
|
|
|
2862 |
|
va
r s = [];
|
|
|
2863 |
|
|
|
|
2864 |
|
//
If an arr
ay was pas
sed in, as
sume that
it is an a
rray
|
|
|
2865 |
|
//
of form e
lements
|
|
|
2866 |
|
if
( a.const
ructor ==
Array || a
.jquery )
|
|
|
2867 |
|
// Seria
lize the f
orm elemen
ts
|
|
|
2868 |
|
jQuery.e
ach( a, fu
nction(){
|
|
|
2869 |
|
s.pu
sh( encode
URICompone
nt(this.na
me) + "="
+ encodeUR
IComponent
( this.val
ue ) );
|
|
|
2870 |
|
});
|
|
|
2871 |
|
|
|
|
2872 |
|
//
Otherwise
, assume t
hat it's a
n object o
f key/valu
e pairs
|
|
|
2873 |
|
el
se
|
|
|
2874 |
|
// Seria
lize the k
ey/values
|
|
|
2875 |
|
for ( va
r j in a )
|
|
|
2876 |
|
// I
f the valu
e is an ar
ray then t
he key nam
es need to
be repeat
ed
|
|
|
2877 |
|
if (
a[j] && a
[j].constr
uctor == A
rray )
|
|
|
2878 |
|
jQuery.eac
h( a[j], f
unction(){
|
|
|
2879 |
|
s.push
( encodeUR
IComponent
(j) + "="
+ encodeUR
IComponent
( this ) )
;
|
|
|
2880 |
|
});
|
|
|
2881 |
|
else
|
|
|
2882 |
|
s.push( en
codeURICom
ponent(j)
+ "=" + en
codeURICom
ponent( a[
j] ) );
|
|
|
2883 |
|
|
|
|
2884 |
|
//
Return th
e resultin
g serializ
ation
|
|
|
2885 |
|
re
turn s.joi
n("&").rep
lace(/%20/
g, "+");
|
|
|
2886 |
|
}
|
|
|
2887 |
|
|
|
|
2888 |
|
});
|
|
|
2889 |
|
jQuery.fn.
extend({
|
|
|
2890 |
|
show:
function(s
peed,callb
ack){
|
|
|
2891 |
|
re
turn speed
?
|
|
|
2892 |
|
this.ani
mate({
|
|
|
2893 |
|
heig
ht: "show"
, width: "
show", opa
city: "sho
w"
|
|
|
2894 |
|
}, speed
, callback
) :
|
|
|
2895 |
|
|
|
|
2896 |
|
this.fil
ter(":hidd
en").each(
function()
{
|
|
|
2897 |
|
this
.style.dis
play = thi
s.oldblock
|| "";
|
|
|
2898 |
|
if (
jQuery.cs
s(this,"di
splay") ==
"none" )
{
|
|
|
2899 |
|
var elem =
jQuery("<
" + this.t
agName + "
/>").appe
ndTo("body
");
|
|
|
2900 |
|
this.style
.display =
elem.css(
"display")
;
|
|
|
2901 |
|
// handle
an edge co
ndition wh
ere css is
- div { d
isplay:non
e; } or si
milar
|
|
|
2902 |
|
if (this.s
tyle.displ
ay == "non
e")
|
|
|
2903 |
|
this.s
tyle.displ
ay = "bloc
k";
|
|
|
2904 |
|
elem.remov
e();
|
|
|
2905 |
|
}
|
|
|
2906 |
|
}).end()
;
|
|
|
2907 |
|
},
|
|
|
2908 |
|
|
|
|
2909 |
|
hide:
function(s
peed,callb
ack){
|
|
|
2910 |
|
re
turn speed
?
|
|
|
2911 |
|
this.ani
mate({
|
|
|
2912 |
|
heig
ht: "hide"
, width: "
hide", opa
city: "hid
e"
|
|
|
2913 |
|
}, speed
, callback
) :
|
|
|
2914 |
|
|
|
|
2915 |
|
this.fil
ter(":visi
ble").each
(function(
){
|
|
|
2916 |
|
this
.oldblock
= this.old
block || j
Query.css(
this,"disp
lay");
|
|
|
2917 |
|
this
.style.dis
play = "no
ne";
|
|
|
2918 |
|
}).end()
;
|
|
|
2919 |
|
},
|
|
|
2920 |
|
|
|
|
2921 |
|
// Sav
e the old
toggle fun
ction
|
|
|
2922 |
|
_toggl
e: jQuery.
fn.toggle,
|
|
|
2923 |
|
|
|
|
2924 |
|
toggle
: function
( fn, fn2
){
|
|
|
2925 |
|
re
turn jQuer
y.isFuncti
on(fn) &&
jQuery.isF
unction(fn
2) ?
|
|
|
2926 |
|
this._to
ggle( fn,
fn2 ) :
|
|
|
2927 |
|
fn ?
|
|
|
2928 |
|
this
.animate({
|
|
|
2929 |
|
height: "t
oggle", wi
dth: "togg
le", opaci
ty: "toggl
e"
|
|
|
2930 |
|
}, f
n, fn2) :
|
|
|
2931 |
|
this
.each(func
tion(){
|
|
|
2932 |
|
jQuery(thi
s)[ jQuery
(this).is(
":hidden")
? "show"
: "hide" ]
();
|
|
|
2933 |
|
});
|
|
|
2934 |
|
},
|
|
|
2935 |
|
|
|
|
2936 |
|
slideD
own: funct
ion(speed,
callback){
|
|
|
2937 |
|
re
turn this.
animate({h
eight: "sh
ow"}, spee
d, callbac
k);
|
|
|
2938 |
|
},
|
|
|
2939 |
|
|
|
|
2940 |
|
slideU
p: functio
n(speed,ca
llback){
|
|
|
2941 |
|
re
turn this.
animate({h
eight: "hi
de"}, spee
d, callbac
k);
|
|
|
2942 |
|
},
|
|
|
2943 |
|
|
|
|
2944 |
|
slideT
oggle: fun
ction(spee
d, callbac
k){
|
|
|
2945 |
|
re
turn this.
animate({h
eight: "to
ggle"}, sp
eed, callb
ack);
|
|
|
2946 |
|
},
|
|
|
2947 |
|
|
|
|
2948 |
|
fadeIn
: function
(speed, ca
llback){
|
|
|
2949 |
|
re
turn this.
animate({o
pacity: "s
how"}, spe
ed, callba
ck);
|
|
|
2950 |
|
},
|
|
|
2951 |
|
|
|
|
2952 |
|
fadeOu
t: functio
n(speed, c
allback){
|
|
|
2953 |
|
re
turn this.
animate({o
pacity: "h
ide"}, spe
ed, callba
ck);
|
|
|
2954 |
|
},
|
|
|
2955 |
|
|
|
|
2956 |
|
fadeTo
: function
(speed,to,
callback){
|
|
|
2957 |
|
re
turn this.
animate({o
pacity: to
}, speed,
callback);
|
|
|
2958 |
|
},
|
|
|
2959 |
|
|
|
|
2960 |
|
animat
e: functio
n( prop, s
peed, easi
ng, callba
ck ) {
|
|
|
2961 |
|
va
r optall =
jQuery.sp
eed(speed,
easing, c
allback);
|
|
|
2962 |
|
|
|
|
2963 |
|
re
turn this[
optall.qu
eue === fa
lse ? "eac
h" : "queu
e" ](funct
ion(){
|
|
|
2964 |
|
if ( thi
s.nodeType
!= 1)
|
|
|
2965 |
|
retu
rn false;
|
|
|
2966 |
|
|
|
|
2967 |
|
var opt
= jQuery.e
xtend({},
optall);
|
|
|
2968 |
|
var hidd
en = jQuer
y(this).is
(":hidden"
), self =
this;
|
|
|
2969 |
|
|
|
|
2970 |
|
for ( va
r p in pro
p ) {
|
|
|
2971 |
|
if (
prop[p] =
= "hide" &
& hidden |
| prop[p]
== "show"
&& !hidden
)
|
|
|
2972 |
|
return jQu
ery.isFunc
tion(opt.c
omplete) &
& opt.comp
lete.apply
(this);
|
|
|
2973 |
|
|
|
|
2974 |
|
if (
p == "hei
ght" || p
== "width"
) {
|
|
|
2975 |
|
// Store d
isplay pro
perty
|
|
|
2976 |
|
opt.displa
y = jQuery
.css(this,
"display"
);
|
|
|
2977 |
|
|
|
|
2978 |
|
// Make su
re that no
thing snea
ks out
|
|
|
2979 |
|
opt.overfl
ow = this.
style.over
flow;
|
|
|
2980 |
|
}
|
|
|
2981 |
|
}
|
|
|
2982 |
|
|
|
|
2983 |
|
if ( opt
.overflow
!= null )
|
|
|
2984 |
|
this
.style.ove
rflow = "h
idden";
|
|
|
2985 |
|
|
|
|
2986 |
|
opt.curA
nim = jQue
ry.extend(
{}, prop);
|
|
|
2987 |
|
|
|
|
2988 |
|
jQuery.e
ach( prop,
function(
name, val)
{
|
|
|
2989 |
|
var
e = new jQ
uery.fx( s
elf, opt,
name );
|
|
|
2990 |
|
|
|
|
2991 |
|
if (
/toggle|s
how|hide/.
test(val)
)
|
|
|
2992 |
|
e[ val ==
"toggle" ?
hidden ?
"show" : "
hide" : va
l ]( prop
);
|
|
|
2993 |
|
else
{
|
|
|
2994 |
|
var parts
= val.toSt
ring().mat
ch(/^([+-]
=)?([\d+-.
]+)(.*)$/)
,
|
|
|
2995 |
|
start
= e.cur(tr
ue) || 0;
|
|
|
2996 |
|
|
|
|
2997 |
|
if ( parts
) {
|
|
|
2998 |
|
var en
d = parseF
loat(parts
[2]),
|
|
|
2999 |
|
un
it = parts
[3] || "px
";
|
|
|
3000 |
|
|
|
|
3001 |
|
// We
need to co
mpute star
ting value
|
|
|
3002 |
|
if ( u
nit != "px
" ) {
|
|
|
3003 |
|
se
lf.style[
name ] = (
end || 1)
+ unit;
|
|
|
3004 |
|
st
art = ((en
d || 1) /
e.cur(true
)) * start
;
|
|
|
3005 |
|
se
lf.style[
name ] = s
tart + uni
t;
|
|
|
3006 |
|
}
|
|
|
3007 |
|
|
|
|
3008 |
|
// If
a +=/-= to
ken was pr
ovided, we
're doing
a relative
animation
|
|
|
3009 |
|
if ( p
arts[1] )
|
|
|
3010 |
|
en
d = ((part
s[1] == "-
=" ? -1 :
1) * end)
+ start;
|
|
|
3011 |
|
|
|
|
3012 |
|
e.cust
om( start,
end, unit
);
|
|
|
3013 |
|
} else
|
|
|
3014 |
|
e.cust
om( start,
val, "" )
;
|
|
|
3015 |
|
}
|
|
|
3016 |
|
});
|
|
|
3017 |
|
|
|
|
3018 |
|
// For J
S strict c
ompliance
|
|
|
3019 |
|
return t
rue;
|
|
|
3020 |
|
})
;
|
|
|
3021 |
|
},
|
|
|
3022 |
|
|
|
|
3023 |
|
queue:
function(
type, fn){
|
|
|
3024 |
|
if
( jQuery.
isFunction
(type) ||
( type &&
type.const
ructor ==
Array )) {
|
|
|
3025 |
|
fn = typ
e;
|
|
|
3026 |
|
type = "
fx";
|
|
|
3027 |
|
}
|
|
|
3028 |
|
|
|
|
3029 |
|
if
( !type |
| (typeof
type == "s
tring" &&
!fn) )
|
|
|
3030 |
|
return q
ueue( this
[0], type
);
|
|
|
3031 |
|
|
|
|
3032 |
|
re
turn this.
each(funct
ion(){
|
|
|
3033 |
|
if ( fn.
constructo
r == Array
)
|
|
|
3034 |
|
queu
e(this, ty
pe, fn);
|
|
|
3035 |
|
else {
|
|
|
3036 |
|
queu
e(this, ty
pe).push(
fn );
|
|
|
3037 |
|
|
|
|
3038 |
|
if (
queue(thi
s, type).l
ength == 1
)
|
|
|
3039 |
|
fn.apply(t
his);
|
|
|
3040 |
|
}
|
|
|
3041 |
|
})
;
|
|
|
3042 |
|
},
|
|
|
3043 |
|
|
|
|
3044 |
|
stop:
function(c
learQueue,
gotoEnd){
|
|
|
3045 |
|
va
r timers =
jQuery.ti
mers;
|
|
|
3046 |
|
|
|
|
3047 |
|
if
(clearQue
ue)
|
|
|
3048 |
|
this.que
ue([]);
|
|
|
3049 |
|
|
|
|
3050 |
|
th
is.each(fu
nction(){
|
|
|
3051 |
|
// go in
reverse o
rder so an
ything add
ed to the
queue duri
ng the loo
p is ignor
ed
|
|
|
3052 |
|
for ( va
r i = time
rs.length
- 1; i >=
0; i-- )
|
|
|
3053 |
|
if (
timers[i]
.elem == t
his ) {
|
|
|
3054 |
|
if (gotoEn
d)
|
|
|
3055 |
|
// for
ce the nex
t step to
be the las
t
|
|
|
3056 |
|
timers
[i](true);
|
|
|
3057 |
|
timers.spl
ice(i, 1);
|
|
|
3058 |
|
}
|
|
|
3059 |
|
})
;
|
|
|
3060 |
|
|
|
|
3061 |
|
//
start the
next in t
he queue i
f the last
step wasn
't forced
|
|
|
3062 |
|
if
(!gotoEnd
)
|
|
|
3063 |
|
this.deq
ueue();
|
|
|
3064 |
|
|
|
|
3065 |
|
re
turn this;
|
|
|
3066 |
|
}
|
|
|
3067 |
|
|
|
|
3068 |
|
});
|
|
|
3069 |
|
|
|
|
3070 |
|
var queue
= function
( elem, ty
pe, array
) {
|
|
|
3071 |
|
if ( !
elem )
|
|
|
3072 |
|
re
turn undef
ined;
|
|
|
3073 |
|
|
|
|
3074 |
|
type =
type || "
fx";
|
|
|
3075 |
|
|
|
|
3076 |
|
var q
= jQuery.d
ata( elem,
type + "q
ueue" );
|
|
|
3077 |
|
|
|
|
3078 |
|
if ( !
q || array
)
|
|
|
3079 |
|
q
= jQuery.d
ata( elem,
type + "q
ueue",
|
|
|
3080 |
|
array ?
jQuery.mak
eArray(arr
ay) : [] )
;
|
|
|
3081 |
|
|
|
|
3082 |
|
return
q;
|
|
|
3083 |
|
};
|
|
|
3084 |
|
|
|
|
3085 |
|
jQuery.fn.
dequeue =
function(t
ype){
|
|
|
3086 |
|
type =
type || "
fx";
|
|
|
3087 |
|
|
|
|
3088 |
|
return
this.each
(function(
){
|
|
|
3089 |
|
va
r q = queu
e(this, ty
pe);
|
|
|
3090 |
|
|
|
|
3091 |
|
q.
shift();
|
|
|
3092 |
|
|
|
|
3093 |
|
if
( q.lengt
h )
|
|
|
3094 |
|
q[0].app
ly( this )
;
|
|
|
3095 |
|
});
|
|
|
3096 |
|
};
|
|
|
3097 |
|
|
|
|
3098 |
|
jQuery.ext
end({
|
|
|
3099 |
|
|
|
|
3100 |
|
speed:
function(
speed, eas
ing, fn) {
|
|
|
3101 |
|
va
r opt = sp
eed && spe
ed.constru
ctor == Ob
ject ? spe
ed : {
|
|
|
3102 |
|
complete
: fn || !f
n && easin
g ||
|
|
|
3103 |
|
jQue
ry.isFunct
ion( speed
) && spee
d,
|
|
|
3104 |
|
duration
: speed,
|
|
|
3105 |
|
easing:
fn && easi
ng || easi
ng && easi
ng.constru
ctor != Fu
nction &&
easing
|
|
|
3106 |
|
};
|
|
|
3107 |
|
|
|
|
3108 |
|
op
t.duration
= (opt.du
ration &&
opt.durati
on.constru
ctor == Nu
mber ?
|
|
|
3109 |
|
opt.dura
tion :
|
|
|
3110 |
|
{ slow:
600, fast:
200 }[opt
.duration]
) || 400;
|
|
|
3111 |
|
|
|
|
3112 |
|
//
Queueing
|
|
|
3113 |
|
op
t.old = op
t.complete
;
|
|
|
3114 |
|
op
t.complete
= functio
n(){
|
|
|
3115 |
|
if ( opt
.queue !==
false )
|
|
|
3116 |
|
jQue
ry(this).d
equeue();
|
|
|
3117 |
|
if ( jQu
ery.isFunc
tion( opt.
old ) )
|
|
|
3118 |
|
opt.
old.apply(
this );
|
|
|
3119 |
|
};
|
|
|
3120 |
|
|
|
|
3121 |
|
re
turn opt;
|
|
|
3122 |
|
},
|
|
|
3123 |
|
|
|
|
3124 |
|
easing
: {
|
|
|
3125 |
|
li
near: func
tion( p, n
, firstNum
, diff ) {
|
|
|
3126 |
|
return f
irstNum +
diff * p;
|
|
|
3127 |
|
},
|
|
|
3128 |
|
sw
ing: funct
ion( p, n,
firstNum,
diff ) {
|
|
|
3129 |
|
return (
(-Math.cos
(p*Math.PI
)/2) + 0.5
) * diff +
firstNum;
|
|
|
3130 |
|
}
|
|
|
3131 |
|
},
|
|
|
3132 |
|
|
|
|
3133 |
|
timers
: [],
|
|
|
3134 |
|
timerI
d: null,
|
|
|
3135 |
|
|
|
|
3136 |
|
fx: fu
nction( el
em, option
s, prop ){
|
|
|
3137 |
|
th
is.options
= options
;
|
|
|
3138 |
|
th
is.elem =
elem;
|
|
|
3139 |
|
th
is.prop =
prop;
|
|
|
3140 |
|
|
|
|
3141 |
|
if
( !option
s.orig )
|
|
|
3142 |
|
options.
orig = {};
|
|
|
3143 |
|
}
|
|
|
3144 |
|
|
|
|
3145 |
|
});
|
|
|
3146 |
|
|
|
|
3147 |
|
jQuery.fx.
prototype
= {
|
|
|
3148 |
|
|
|
|
3149 |
|
// Sim
ple functi
on for set
ting a sty
le value
|
|
|
3150 |
|
update
: function
(){
|
|
|
3151 |
|
if
( this.op
tions.step
)
|
|
|
3152 |
|
this.opt
ions.step.
apply( thi
s.elem, [
this.now,
this ] );
|
|
|
3153 |
|
|
|
|
3154 |
|
(j
Query.fx.s
tep[this.p
rop] || jQ
uery.fx.st
ep._defaul
t)( this )
;
|
|
|
3155 |
|
|
|
|
3156 |
|
//
Set displ
ay propert
y to block
for heigh
t/width an
imations
|
|
|
3157 |
|
if
( this.pr
op == "hei
ght" || th
is.prop ==
"width" )
|
|
|
3158 |
|
this.ele
m.style.di
splay = "b
lock";
|
|
|
3159 |
|
},
|
|
|
3160 |
|
|
|
|
3161 |
|
// Get
the curre
nt size
|
|
|
3162 |
|
cur: f
unction(fo
rce){
|
|
|
3163 |
|
if
( this.el
em[this.pr
op] != nul
l && this.
elem.style
[this.prop
] == null
)
|
|
|
3164 |
|
return t
his.elem[
this.prop
];
|
|
|
3165 |
|
|
|
|
3166 |
|
va
r r = pars
eFloat(jQu
ery.css(th
is.elem, t
his.prop,
force));
|
|
|
3167 |
|
re
turn r &&
r > -10000
? r : par
seFloat(jQ
uery.curCS
S(this.ele
m, this.pr
op)) || 0;
|
|
|
3168 |
|
},
|
|
|
3169 |
|
|
|
|
3170 |
|
// Sta
rt an anim
ation from
one numbe
r to anoth
er
|
|
|
3171 |
|
custom
: function
(from, to,
unit){
|
|
|
3172 |
|
th
is.startTi
me = (new
Date()).ge
tTime();
|
|
|
3173 |
|
th
is.start =
from;
|
|
|
3174 |
|
th
is.end = t
o;
|
|
|
3175 |
|
th
is.unit =
unit || th
is.unit ||
"px";
|
|
|
3176 |
|
th
is.now = t
his.start;
|
|
|
3177 |
|
th
is.pos = t
his.state
= 0;
|
|
|
3178 |
|
th
is.update(
);
|
|
|
3179 |
|
|
|
|
3180 |
|
va
r self = t
his;
|
|
|
3181 |
|
fu
nction t(g
otoEnd){
|
|
|
3182 |
|
return s
elf.step(g
otoEnd);
|
|
|
3183 |
|
}
|
|
|
3184 |
|
|
|
|
3185 |
|
t.
elem = thi
s.elem;
|
|
|
3186 |
|
|
|
|
3187 |
|
jQ
uery.timer
s.push(t);
|
|
|
3188 |
|
|
|
|
3189 |
|
if
( jQuery.
timerId ==
null ) {
|
|
|
3190 |
|
jQuery.t
imerId = s
etInterval
(function(
){
|
|
|
3191 |
|
var
timers = j
Query.time
rs;
|
|
|
3192 |
|
|
|
|
3193 |
|
for
( var i =
0; i < tim
ers.length
; i++ )
|
|
|
3194 |
|
if ( !time
rs[i]() )
|
|
|
3195 |
|
timers
.splice(i-
-, 1);
|
|
|
3196 |
|
|
|
|
3197 |
|
if (
!timers.l
ength ) {
|
|
|
3198 |
|
clearInter
val( jQuer
y.timerId
);
|
|
|
3199 |
|
jQuery.tim
erId = nul
l;
|
|
|
3200 |
|
}
|
|
|
3201 |
|
}, 13);
|
|
|
3202 |
|
}
|
|
|
3203 |
|
},
|
|
|
3204 |
|
|
|
|
3205 |
|
// Sim
ple 'show'
function
|
|
|
3206 |
|
show:
function()
{
|
|
|
3207 |
|
//
Remember
where we s
tarted, so
that we c
an go back
to it lat
er
|
|
|
3208 |
|
th
is.options
.orig[this
.prop] = j
Query.attr
( this.ele
m.style, t
his.prop )
;
|
|
|
3209 |
|
th
is.options
.show = tr
ue;
|
|
|
3210 |
|
|
|
|
3211 |
|
//
Begin the
animation
|
|
|
3212 |
|
th
is.custom(
0, this.cu
r());
|
|
|
3213 |
|
|
|
|
3214 |
|
//
Make sure
that we s
tart at a
small widt
h/height t
o avoid an
y
|
|
|
3215 |
|
//
flash of
content
|
|
|
3216 |
|
if
( this.pr
op == "wid
th" || thi
s.prop ==
"height" )
|
|
|
3217 |
|
this.ele
m.style[th
is.prop] =
"1px";
|
|
|
3218 |
|
|
|
|
3219 |
|
//
Start by
showing th
e element
|
|
|
3220 |
|
jQ
uery(this.
elem).show
();
|
|
|
3221 |
|
},
|
|
|
3222 |
|
|
|
|
3223 |
|
// Sim
ple 'hide'
function
|
|
|
3224 |
|
hide:
function()
{
|
|
|
3225 |
|
//
Remember
where we s
tarted, so
that we c
an go back
to it lat
er
|
|
|
3226 |
|
th
is.options
.orig[this
.prop] = j
Query.attr
( this.ele
m.style, t
his.prop )
;
|
|
|
3227 |
|
th
is.options
.hide = tr
ue;
|
|
|
3228 |
|
|
|
|
3229 |
|
//
Begin the
animation
|
|
|
3230 |
|
th
is.custom(
this.cur()
, 0);
|
|
|
3231 |
|
},
|
|
|
3232 |
|
|
|
|
3233 |
|
// Eac
h step of
an animati
on
|
|
|
3234 |
|
step:
function(g
otoEnd){
|
|
|
3235 |
|
va
r t = (new
Date()).g
etTime();
|
|
|
3236 |
|
|
|
|
3237 |
|
if
( gotoEnd
|| t > th
is.options
.duration
+ this.sta
rtTime ) {
|
|
|
3238 |
|
this.now
= this.en
d;
|
|
|
3239 |
|
this.pos
= this.st
ate = 1;
|
|
|
3240 |
|
this.upd
ate();
|
|
|
3241 |
|
|
|
|
3242 |
|
this.opt
ions.curAn
im[ this.p
rop ] = tr
ue;
|
|
|
3243 |
|
|
|
|
3244 |
|
var done
= true;
|
|
|
3245 |
|
for ( va
r i in thi
s.options.
curAnim )
|
|
|
3246 |
|
if (
this.opti
ons.curAni
m[i] !== t
rue )
|
|
|
3247 |
|
done = fal
se;
|
|
|
3248 |
|
|
|
|
3249 |
|
if ( don
e ) {
|
|
|
3250 |
|
if (
this.opti
ons.displa
y != null
) {
|
|
|
3251 |
|
// Reset t
he overflo
w
|
|
|
3252 |
|
this.elem.
style.over
flow = thi
s.options.
overflow;
|
|
|
3253 |
|
|
|
|
3254 |
|
// Reset t
he display
|
|
|
3255 |
|
this.elem.
style.disp
lay = this
.options.d
isplay;
|
|
|
3256 |
|
if ( jQuer
y.css(this
.elem, "di
splay") ==
"none" )
|
|
|
3257 |
|
this.e
lem.style.
display =
"block";
|
|
|
3258 |
|
}
|
|
|
3259 |
|
|
|
|
3260 |
|
// H
ide the el
ement if t
he "hide"
operation
was done
|
|
|
3261 |
|
if (
this.opti
ons.hide )
|
|
|
3262 |
|
this.elem.
style.disp
lay = "non
e";
|
|
|
3263 |
|
|
|
|
3264 |
|
// R
eset the p
roperties,
if the it
em has bee
n hidden o
r shown
|
|
|
3265 |
|
if (
this.opti
ons.hide |
| this.opt
ions.show
)
|
|
|
3266 |
|
for ( var
p in this.
options.cu
rAnim )
|
|
|
3267 |
|
jQuery
.attr(this
.elem.styl
e, p, this
.options.o
rig[p]);
|
|
|
3268 |
|
}
|
|
|
3269 |
|
|
|
|
3270 |
|
// If a
callback w
as provide
d, execute
it
|
|
|
3271 |
|
if ( don
e && jQuer
y.isFuncti
on( this.o
ptions.com
plete ) )
|
|
|
3272 |
|
// E
xecute the
complete
function
|
|
|
3273 |
|
this
.options.c
omplete.ap
ply( this.
elem );
|
|
|
3274 |
|
|
|
|
3275 |
|
return f
alse;
|
|
|
3276 |
|
}
else {
|
|
|
3277 |
|
var n =
t - this.s
tartTime;
|
|
|
3278 |
|
this.sta
te = n / t
his.option
s.duration
;
|
|
|
3279 |
|
|
|
|
3280 |
|
// Perfo
rm the eas
ing functi
on, defaul
ts to swin
g
|
|
|
3281 |
|
this.pos
= jQuery.
easing[thi
s.options.
easing ||
(jQuery.ea
sing.swing
? "swing"
: "linear
")](this.s
tate, n, 0
, 1, this.
options.du
ration);
|
|
|
3282 |
|
this.now
= this.st
art + ((th
is.end - t
his.start)
* this.po
s);
|
|
|
3283 |
|
|
|
|
3284 |
|
// Perfo
rm the nex
t step of
the animat
ion
|
|
|
3285 |
|
this.upd
ate();
|
|
|
3286 |
|
}
|
|
|
3287 |
|
|
|
|
3288 |
|
re
turn true;
|
|
|
3289 |
|
}
|
|
|
3290 |
|
|
|
|
3291 |
|
};
|
|
|
3292 |
|
|
|
|
3293 |
|
jQuery.fx.
step = {
|
|
|
3294 |
|
scroll
Left: func
tion(fx){
|
|
|
3295 |
|
fx
.elem.scro
llLeft = f
x.now;
|
|
|
3296 |
|
},
|
|
|
3297 |
|
|
|
|
3298 |
|
scroll
Top: funct
ion(fx){
|
|
|
3299 |
|
fx
.elem.scro
llTop = fx
.now;
|
|
|
3300 |
|
},
|
|
|
3301 |
|
|
|
|
3302 |
|
opacit
y: functio
n(fx){
|
|
|
3303 |
|
jQ
uery.attr(
fx.elem.st
yle, "opac
ity", fx.n
ow);
|
|
|
3304 |
|
},
|
|
|
3305 |
|
|
|
|
3306 |
|
_defau
lt: functi
on(fx){
|
|
|
3307 |
|
fx
.elem.styl
e[ fx.prop
] = fx.no
w + fx.uni
t;
|
|
|
3308 |
|
}
|
|
|
3309 |
|
};
|
|
|
3310 |
|
// The Off
set Method
|
|
|
3311 |
|
// Origina
lly By Bra
ndon Aaron
, part of
the Dimens
ion Plugin
|
|
|
3312 |
|
// http://
jquery.com
/plugins/p
roject/dim
ensions
|
|
|
3313 |
|
jQuery.fn.
offset = f
unction()
{
|
|
|
3314 |
|
var le
ft = 0, to
p = 0, ele
m = this[0
], results
;
|
|
|
3315 |
|
|
|
|
3316 |
|
if ( e
lem ) with
( jQuery.
browser )
{
|
|
|
3317 |
|
va
r parent
= ele
m.parentNo
de,
|
|
|
3318 |
|
offsetCh
ild = ele
m,
|
|
|
3319 |
|
offsetPa
rent = ele
m.offsetPa
rent,
|
|
|
3320 |
|
doc
= ele
m.ownerDoc
ument,
|
|
|
3321 |
|
safari2
= saf
ari && par
seInt(vers
ion) < 522
&& !/adob
eair/i.tes
t(userAgen
t),
|
|
|
3322 |
|
fixed
= jQu
ery.css(el
em, "posit
ion") == "
fixed";
|
|
|
3323 |
|
|
|
|
3324 |
|
//
Use getBo
undingClie
ntRect if
available
|
|
|
3325 |
|
if
( elem.ge
tBoundingC
lientRect
) {
|
|
|
3326 |
|
var box
= elem.get
BoundingCl
ientRect()
;
|
|
|
3327 |
|
|
|
|
3328 |
|
// Add t
he documen
t scroll o
ffsets
|
|
|
3329 |
|
add(box.
left + Mat
h.max(doc.
documentEl
ement.scro
llLeft, do
c.body.scr
ollLeft),
|
|
|
3330 |
|
box.
top + Mat
h.max(doc.
documentEl
ement.scro
llTop, do
c.body.scr
ollTop));
|
|
|
3331 |
|
|
|
|
3332 |
|
// IE ad
ds the HTM
L element'
s border,
by default
it is med
ium which
is 2px
|
|
|
3333 |
|
// IE 6
and 7 quir
ks mode th
e border w
idth is ov
erwritable
by the fo
llowing cs
s html { b
order: 0;
}
|
|
|
3334 |
|
// IE 7
standards
mode, the
border is
always 2px
|
|
|
3335 |
|
// This
border/off
set is typ
ically rep
resented b
y the clie
ntLeft and
clientTop
propertie
s
|
|
|
3336 |
|
// Howev
er, in IE6
and 7 qui
rks mode t
he clientL
eft and cl
ientTop pr
operties a
re not upd
ated when
overwritin
g it via C
SS
|
|
|
3337 |
|
// There
fore this
method wil
l be off b
y 2px in I
E while in
quirksmod
e
|
|
|
3338 |
|
add( -do
c.document
Element.cl
ientLeft,
-doc.docum
entElement
.clientTop
);
|
|
|
3339 |
|
|
|
|
3340 |
|
//
Otherwise
loop thro
ugh the of
fsetParent
s and pare
ntNodes
|
|
|
3341 |
|
}
else {
|
|
|
3342 |
|
|
|
|
3343 |
|
// Initi
al element
offsets
|
|
|
3344 |
|
add( ele
m.offsetLe
ft, elem.o
ffsetTop )
;
|
|
|
3345 |
|
|
|
|
3346 |
|
// Get p
arent offs
ets
|
|
|
3347 |
|
while (
offsetPare
nt ) {
|
|
|
3348 |
|
// A
dd offsetP
arent offs
ets
|
|
|
3349 |
|
add(
offsetPar
ent.offset
Left, offs
etParent.o
ffsetTop )
;
|
|
|
3350 |
|
|
|
|
3351 |
|
// M
ozilla and
Safari >
2 does not
include t
he border
on offset
parents
|
|
|
3352 |
|
// H
owever Moz
illa adds
the border
for table
or table
cells
|
|
|
3353 |
|
if (
mozilla &
& !/^t(abl
e|d|h)$/i.
test(offse
tParent.ta
gName) ||
safari &&
!safari2 )
|
|
|
3354 |
|
border( of
fsetParent
);
|
|
|
3355 |
|
|
|
|
3356 |
|
// A
dd the doc
ument scro
ll offsets
if positi
on is fixe
d on any o
ffsetParen
t
|
|
|
3357 |
|
if (
!fixed &&
jQuery.cs
s(offsetPa
rent, "pos
ition") ==
"fixed" )
|
|
|
3358 |
|
fixed = tr
ue;
|
|
|
3359 |
|
|
|
|
3360 |
|
// S
et offsetC
hild to pr
evious off
setParent
unless it
is the bod
y element
|
|
|
3361 |
|
offs
etChild =
/^body$/i
.test(offs
etParent.t
agName) ?
offsetChil
d : offset
Parent;
|
|
|
3362 |
|
// G
et next of
fsetParent
|
|
|
3363 |
|
offs
etParent =
offsetPar
ent.offset
Parent;
|
|
|
3364 |
|
}
|
|
|
3365 |
|
|
|
|
3366 |
|
// Get p
arent scro
ll offsets
|
|
|
3367 |
|
while (
parent &&
parent.tag
Name && !/
^body|html
$/i.test(p
arent.tagN
ame) ) {
|
|
|
3368 |
|
// R
emove pare
nt scroll
UNLESS tha
t parent i
s inline o
r a table
to work ar
ound Opera
inline/ta
ble scroll
Left/Top b
ug
|
|
|
3369 |
|
if (
!/^inline
|table.*$/
i.test(jQu
ery.css(pa
rent, "dis
play")) )
|
|
|
3370 |
|
// Subtrac
t parent s
croll offs
ets
|
|
|
3371 |
|
add( -pare
nt.scrollL
eft, -pare
nt.scrollT
op );
|
|
|
3372 |
|
|
|
|
3373 |
|
// M
ozilla doe
s not add
the border
for a par
ent that h
as overflo
w != visib
le
|
|
|
3374 |
|
if (
mozilla &
& jQuery.c
ss(parent,
"overflow
") != "vis
ible" )
|
|
|
3375 |
|
border( pa
rent );
|
|
|
3376 |
|
|
|
|
3377 |
|
// G
et next pa
rent
|
|
|
3378 |
|
pare
nt = paren
t.parentNo
de;
|
|
|
3379 |
|
}
|
|
|
3380 |
|
|
|
|
3381 |
|
// Safar
i <= 2 dou
bles body
offsets wi
th a fixed
position
element/of
fsetParent
or absolu
tely posit
ioned offs
etChild
|
|
|
3382 |
|
// Mozil
la doubles
body offs
ets with a
non-absol
utely posi
tioned off
setChild
|
|
|
3383 |
|
if ( (sa
fari2 && (
fixed || j
Query.css(
offsetChil
d, "positi
on") == "a
bsolute"))
||
|
|
|
3384 |
|
(moz
illa && jQ
uery.css(o
ffsetChild
, "positio
n") != "ab
solute") )
|
|
|
3385 |
|
add( -doc.
body.offse
tLeft, -do
c.body.off
setTop );
|
|
|
3386 |
|
|
|
|
3387 |
|
// Add t
he documen
t scroll o
ffsets if
position i
s fixed
|
|
|
3388 |
|
if ( fix
ed )
|
|
|
3389 |
|
add(
Math.max(d
oc.documen
tElement.s
crollLeft,
doc.body.
scrollLeft
),
|
|
|
3390 |
|
Math.max(d
oc.documen
tElement.s
crollTop,
doc.body.
scrollTop)
);
|
|
|
3391 |
|
}
|
|
|
3392 |
|
|
|
|
3393 |
|
//
Return an
object wi
th top and
left prop
erties
|
|
|
3394 |
|
re
sults = {
top: top,
left: left
};
|
|
|
3395 |
|
}
|
|
|
3396 |
|
|
|
|
3397 |
|
functi
on border(
elem) {
|
|
|
3398 |
|
ad
d( jQuery.
curCSS(ele
m, "border
LeftWidth"
, true), j
Query.curC
SS(elem, "
borderTopW
idth", tru
e) );
|
|
|
3399 |
|
}
|
|
|
3400 |
|
|
|
|
3401 |
|
functi
on add(l,
t) {
|
|
|
3402 |
|
le
ft += pars
eInt(l) ||
0;
|
|
|
3403 |
|
to
p += parse
Int(t) ||
0;
|
|
|
3404 |
|
}
|
|
|
3405 |
|
|
|
|
3406 |
|
return
results;
|
|
|
3407 |
|
};
|
|
|
3408 |
|
})();
|