Produced by Araxis Merge on 3/25/2019 8:58:10 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | C:\AraxisMergeCompare\Pri_un\IMAG_VIX\common\ZFViewerServices\ViewerRender-2.2.6968.19079\VIX.Viewer.Service\Viewer\js | jquery-1.11.1.js | Tue Jan 29 15:43:40 2019 UTC |
2 | C:\AraxisMergeCompare\Pri_re\IMAG_VIX\common\ZFViewerServices\ViewerRender-2.2.6968.19079\VIX.Viewer.Service\Viewer\js | jquery-1.11.1.js | Tue Mar 19 12:25:54 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 20612 |
Changed | 1 | 4 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | /*! | |
2 | * jQuery JavaScript Library v 1.11.1 | |
3 | * http:// jquery.com / | |
4 | * | |
5 | * Include s Sizzle.j s | |
6 | * http:// sizzlejs.c om/ | |
7 | * | |
8 | * Copyrig ht 2005, 2 014 jQuery Foundatio n, Inc. an d other co ntributors | |
9 | * Release d under th e MIT lice nse | |
10 | * http:// jquery.org /license | |
11 | * | |
12 | * Date: 2 014-05-01T 17:42Z | |
13 | */ | |
14 | ||
15 | (function( global, f actory ) { | |
16 | ||
17 | if ( t ypeof modu le === "ob ject" && t ypeof modu le.exports === "obje ct" ) { | |
18 | // For Commo nJS and Co mmonJS-lik e environm ents where a proper window is present, | |
19 | // execute t he factory and get j Query | |
20 | // For envir onments th at do not inherently posses a window wit h a docume nt | |
21 | // (such as Node.vendo r), expose a jQuery- making fac tory as mo dule.expor ts | |
22 | // This acce ntuates th e need for the creat ion of a r eal window | |
23 | // e.g. var jQuery = r equire("jq uery")(win dow); | |
24 | // See ticke t #14549 f or more in fo | |
25 | mo dule.expor ts = globa l.document ? | |
26 | factory( global, t rue ) : | |
27 | function ( w ) { | |
28 | if ( !w.docume nt ) { | |
29 | throw new Error( "jQ uery requi res a wind ow with a document" ); | |
30 | } | |
31 | retu rn factory ( w ); | |
32 | }; | |
33 | } else { | |
34 | fa ctory( glo bal ); | |
35 | } | |
36 | ||
37 | // Pass th is if wind ow is not defined ye t | |
38 | }(typeof w indow !== "undefined " ? window : this, f unction( w indow, noG lobal ) { | |
39 | ||
40 | // Can't d o this bec ause sever al apps in cluding AS P.NET trac e | |
41 | // the sta ck via arg uments.cal ler.callee and Firef ox dies if | |
42 | // you try to trace through "u se strict" call chai ns. (#1333 5) | |
43 | // Support : Firefox 18+ | |
44 | // | |
45 | ||
46 | var de letedIds = []; | |
47 | ||
48 | var sl ice = dele tedIds.sli ce; | |
49 | ||
50 | var co ncat = del etedIds.co ncat; | |
51 | ||
52 | var pu sh = delet edIds.push ; | |
53 | ||
54 | var in dexOf = de letedIds.i ndexOf; | |
55 | ||
56 | var cl ass2type = {}; | |
57 | ||
58 | var to String = c lass2type. toString; | |
59 | ||
60 | var ha sOwn = cla ss2type.ha sOwnProper ty; | |
61 | ||
62 | var su pport = {} ; | |
63 | ||
64 | ||
65 | ||
66 | var | |
67 | ve rsion = "1 .11.1", | |
68 | ||
69 | // Def ine a loca l copy of jQuery | |
70 | jQ uery = fun ction( sel ector, con text ) { | |
71 | // The j Query obje ct is actu ally just the init c onstructor 'enhanced ' | |
72 | // Need init if jQ uery is ca lled (just allow err or to be t hrown if n ot include d) | |
73 | return n ew jQuery. fn.init( s elector, c ontext ); | |
74 | }, | |
75 | ||
76 | // Sup port: Andr oid<4.1, I E<9 | |
77 | // Mak e sure we trim BOM a nd NBSP | |
78 | rt rim = /^[\ s\uFEFF\xA 0]+|[\s\uF EFF\xA0]+$ /g, | |
79 | ||
80 | // Mat ches dashe d string f or cameliz ing | |
81 | rm sPrefix = /^-ms-/, | |
82 | rd ashAlpha = /-([\da-z ])/gi, | |
83 | ||
84 | // Use d by jQuer y.camelCas e as callb ack to rep lace() | |
85 | fc amelCase = function( all, lett er ) { | |
86 | return l etter.toUp perCase(); | |
87 | }; | |
88 | ||
89 | jQuery .fn = jQue ry.prototy pe = { | |
90 | // The curre nt version of jQuery being use d | |
91 | jq uery: vers ion, | |
92 | ||
93 | co nstructor: jQuery, | |
94 | ||
95 | // Start wit h an empty selector | |
96 | se lector: "" , | |
97 | ||
98 | // The defau lt length of a jQuer y object i s 0 | |
99 | le ngth: 0, | |
100 | ||
101 | to Array: fun ction() { | |
102 | return s lice.call( this ); | |
103 | }, | |
104 | ||
105 | // Get the N th element in the ma tched elem ent set OR | |
106 | // Get the w hole match ed element set as a clean arra y | |
107 | ge t: functio n( num ) { | |
108 | return n um != null ? | |
109 | ||
110 | // R eturn just the one e lement fro m the set | |
111 | ( nu m < 0 ? th is[ num + this.lengt h ] : this [ num ] ) : | |
112 | ||
113 | // R eturn all the elemen ts in a cl ean array | |
114 | slic e.call( th is ); | |
115 | }, | |
116 | ||
117 | // Take an a rray of el ements and push it o nto the st ack | |
118 | // (returnin g the new matched el ement set) | |
119 | pu shStack: f unction( e lems ) { | |
120 | ||
121 | // Build a new jQu ery matche d element set | |
122 | var ret = jQuery.m erge( this .construct or(), elem s ); | |
123 | ||
124 | // Add t he old obj ect onto t he stack ( as a refer ence) | |
125 | ret.prev Object = t his; | |
126 | ret.cont ext = this .context; | |
127 | ||
128 | // Retur n the newl y-formed e lement set | |
129 | return r et; | |
130 | }, | |
131 | ||
132 | // Execute a callback for every element in the match ed set. | |
133 | // (You can seed the a rguments w ith an arr ay of args , but this is | |
134 | // only used internall y.) | |
135 | ea ch: functi on( callba ck, args ) { | |
136 | return j Query.each ( this, ca llback, ar gs ); | |
137 | }, | |
138 | ||
139 | ma p: functio n( callbac k ) { | |
140 | return t his.pushSt ack( jQuer y.map(this , function ( elem, i ) { | |
141 | retu rn callbac k.call( el em, i, ele m ); | |
142 | })); | |
143 | }, | |
144 | ||
145 | sl ice: funct ion() { | |
146 | return t his.pushSt ack( slice .apply( th is, argume nts ) ); | |
147 | }, | |
148 | ||
149 | fi rst: funct ion() { | |
150 | return t his.eq( 0 ); | |
151 | }, | |
152 | ||
153 | la st: functi on() { | |
154 | return t his.eq( -1 ); | |
155 | }, | |
156 | ||
157 | eq : function ( i ) { | |
158 | var len = this.len gth, | |
159 | j = +i + ( i < 0 ? len : 0 ); | |
160 | return t his.pushSt ack( j >= 0 && j < l en ? [ thi s[j] ] : [ ] ); | |
161 | }, | |
162 | ||
163 | en d: functio n() { | |
164 | return t his.prevOb ject || th is.constru ctor(null) ; | |
165 | }, | |
166 | ||
167 | // For inter nal use on ly. | |
168 | // Behaves l ike an Arr ay's metho d, not lik e a jQuery method. | |
169 | pu sh: push, | |
170 | so rt: delete dIds.sort, | |
171 | sp lice: dele tedIds.spl ice | |
172 | }; | |
173 | ||
174 | jQuery .extend = jQuery.fn. extend = f unction() { | |
175 | va r src, cop yIsArray, copy, name , options, clone, | |
176 | target = arguments [0] || {}, | |
177 | i = 1, | |
178 | length = arguments .length, | |
179 | deep = f alse; | |
180 | ||
181 | // Handle a deep copy situation | |
182 | if ( typeof target === "boolean" ) { | |
183 | deep = t arget; | |
184 | ||
185 | // skip the boolea n and the target | |
186 | target = arguments [ i ] || { }; | |
187 | i++; | |
188 | } | |
189 | ||
190 | // Handle ca se when ta rget is a string or something (possible in deep co py) | |
191 | if ( typeof target !== "object" && !jQuery .isFunctio n(target) ) { | |
192 | target = {}; | |
193 | } | |
194 | ||
195 | // extend jQ uery itsel f if only one argume nt is pass ed | |
196 | if ( i === l ength ) { | |
197 | target = this; | |
198 | i--; | |
199 | } | |
200 | ||
201 | fo r ( ; i < length; i+ + ) { | |
202 | // Only deal with non-null/u ndefined v alues | |
203 | if ( (op tions = ar guments[ i ]) != nul l ) { | |
204 | // E xtend the base objec t | |
205 | for ( name in options ) { | |
206 | src = targ et[ name ] ; | |
207 | copy = opt ions[ name ]; | |
208 | ||
209 | // Prevent never-end ing loop | |
210 | if ( targe t === copy ) { | |
211 | contin ue; | |
212 | } | |
213 | ||
214 | // Recurse if we're merging pl ain object s or array s | |
215 | if ( deep && copy && ( jQuery. isPlainObj ect(copy) || (copyIs Array = jQ uery.isArr ay(copy)) ) ) { | |
216 | if ( c opyIsArray ) { | |
217 | co pyIsArray = false; | |
218 | cl one = src && jQuery. isArray(sr c) ? src : []; | |
219 | ||
220 | } else { | |
221 | cl one = src && jQuery. isPlainObj ect(src) ? src : {}; | |
222 | } | |
223 | ||
224 | // Nev er move or iginal obj ects, clon e them | |
225 | target [ name ] = jQuery.ex tend( deep , clone, c opy ); | |
226 | ||
227 | // Don 't bring i n undefine d values | |
228 | } else if ( copy !== undefined ) { | |
229 | target [ name ] = copy; | |
230 | } | |
231 | } | |
232 | } | |
233 | } | |
234 | ||
235 | // Return th e modified object | |
236 | re turn targe t; | |
237 | }; | |
238 | ||
239 | jQuery .extend({ | |
240 | // Unique fo r each cop y of jQuer y on the p age | |
241 | ex pando: "jQ uery" + ( version + Math.rando m() ).repl ace( /\D/g , "" ), | |
242 | ||
243 | // Assume jQ uery is re ady withou t the read y module | |
244 | is Ready: tru e, | |
245 | ||
246 | er ror: funct ion( msg ) { | |
247 | throw ne w Error( m sg ); | |
248 | }, | |
249 | ||
250 | no op: functi on() {}, | |
251 | ||
252 | // See test/ unit/core. vendor for details c oncerning isFunction . | |
253 | // Since ver sion 1.3, DOM method s and func tions like alert | |
254 | // aren't su pported. T hey return false on IE (#2968) . | |
255 | is Function: function( obj ) { | |
256 | return j Query.type (obj) === "function" ; | |
257 | }, | |
258 | ||
259 | is Array: Arr ay.isArray || functi on( obj ) { | |
260 | return j Query.type (obj) === "array"; | |
261 | }, | |
262 | ||
263 | is Window: fu nction( ob j ) { | |
264 | /* jshin t eqeqeq: false */ | |
265 | return o bj != null && obj == obj.windo w; | |
266 | }, | |
267 | ||
268 | is Numeric: f unction( o bj ) { | |
269 | // parse Float NaNs numeric-c ast false positives (null|true |false|"") | |
270 | // ...bu t misinter prets lead ing-number strings, particular ly hex lit erals ("0x ...") | |
271 | // subtr action for ces infini ties to Na N | |
272 | return ! jQuery.isA rray( obj ) && obj - parseFloa t( obj ) > = 0; | |
273 | }, | |
274 | ||
275 | is EmptyObjec t: functio n( obj ) { | |
276 | var name ; | |
277 | for ( na me in obj ) { | |
278 | retu rn false; | |
279 | } | |
280 | return t rue; | |
281 | }, | |
282 | ||
283 | is PlainObjec t: functio n( obj ) { | |
284 | var key; | |
285 | ||
286 | // Must be an Obje ct. | |
287 | // Becau se of IE, we also ha ve to chec k the pres ence of th e construc tor proper ty. | |
288 | // Make sure that DOM nodes and window objects d on't pass through, a s well | |
289 | if ( !ob j || jQuer y.type(obj ) !== "obj ect" || ob j.nodeType || jQuery .isWindow( obj ) ) { | |
290 | retu rn false; | |
291 | } | |
292 | ||
293 | try { | |
294 | // N ot own con structor p roperty mu st be Obje ct | |
295 | if ( obj.const ructor && | |
296 | !hasOwn.ca ll(obj, "c onstructor ") && | |
297 | !hasOwn.ca ll(obj.con structor.p rototype, "isPrototy peOf") ) { | |
298 | return fal se; | |
299 | } | |
300 | } catch ( e ) { | |
301 | // I E8,9 Will throw exce ptions on certain ho st objects #9897 | |
302 | retu rn false; | |
303 | } | |
304 | ||
305 | // Suppo rt: IE<9 | |
306 | // Handl e iteratio n over inh erited pro perties be fore own p roperties. | |
307 | if ( sup port.ownLa st ) { | |
308 | for ( key in o bj ) { | |
309 | return has Own.call( obj, key ) ; | |
310 | } | |
311 | } | |
312 | ||
313 | // Own p roperties are enumer ated first ly, so to speed up, | |
314 | // if la st one is own, then all proper ties are o wn. | |
315 | for ( ke y in obj ) {} | |
316 | ||
317 | return k ey === und efined || hasOwn.cal l( obj, ke y ); | |
318 | }, | |
319 | ||
320 | ty pe: functi on( obj ) { | |
321 | if ( obj == null ) { | |
322 | retu rn obj + " "; | |
323 | } | |
324 | return t ypeof obj === "objec t" || type of obj === "function " ? | |
325 | clas s2type[ to String.cal l(obj) ] | | "object" : | |
326 | type of obj; | |
327 | }, | |
328 | ||
329 | // Evaluates a script in a globa l context | |
330 | // Workaroun ds based o n findings by Jim Dr iscoll | |
331 | // http://we blogs.java .net/blog/ driscoll/a rchive/200 9/09/08/ev al-javascr ipt-global -context | |
332 | gl obalEval: function( data ) { | |
333 | if ( dat a && jQuer y.trim( da ta ) ) { | |
334 | // W e use exec Script on Internet E xplorer | |
335 | // W e use an a nonymous f unction so that cont ext is win dow | |
336 | // r ather than jQuery in Firefox | |
337 | ( wi ndow.execS cript || f unction( d ata ) { | |
338 | window[ "e val" ].cal l( window, data ); | |
339 | } )( data ); | |
340 | } | |
341 | }, | |
342 | ||
343 | // Convert d ashed to c amelCase; used by th e css and data modul es | |
344 | // Microsoft forgot to hump thei r vendor p refix (#95 72) | |
345 | ca melCase: f unction( s tring ) { | |
346 | return s tring.repl ace( rmsPr efix, "ms- " ).replac e( rdashAl pha, fcame lCase ); | |
347 | }, | |
348 | ||
349 | no deName: fu nction( el em, name ) { | |
350 | return e lem.nodeNa me && elem .nodeName. toLowerCas e() === na me.toLower Case(); | |
351 | }, | |
352 | ||
353 | // args is f or interna l usage on ly | |
354 | ea ch: functi on( obj, c allback, a rgs ) { | |
355 | var valu e, | |
356 | i = 0, | |
357 | leng th = obj.l ength, | |
358 | isAr ray = isAr raylike( o bj ); | |
359 | ||
360 | if ( arg s ) { | |
361 | if ( isArray ) { | |
362 | for ( ; i < length; i++ ) { | |
363 | value = callback .apply( ob j[ i ], ar gs ); | |
364 | ||
365 | if ( v alue === f alse ) { | |
366 | br eak; | |
367 | } | |
368 | } | |
369 | } el se { | |
370 | for ( i in obj ) { | |
371 | value = callback .apply( ob j[ i ], ar gs ); | |
372 | ||
373 | if ( v alue === f alse ) { | |
374 | br eak; | |
375 | } | |
376 | } | |
377 | } | |
378 | ||
379 | // A special, fast, case for the m ost common use of ea ch | |
380 | } else { | |
381 | if ( isArray ) { | |
382 | for ( ; i < length; i++ ) { | |
383 | value = callback .call( obj [ i ], i, obj[ i ] ) ; | |
384 | ||
385 | if ( v alue === f alse ) { | |
386 | br eak; | |
387 | } | |
388 | } | |
389 | } el se { | |
390 | for ( i in obj ) { | |
391 | value = callback .call( obj [ i ], i, obj[ i ] ) ; | |
392 | ||
393 | if ( v alue === f alse ) { | |
394 | br eak; | |
395 | } | |
396 | } | |
397 | } | |
398 | } | |
399 | ||
400 | return o bj; | |
401 | }, | |
402 | ||
403 | // Support: Android<4. 1, IE<9 | |
404 | tr im: functi on( text ) { | |
405 | return t ext == nul l ? | |
406 | "" : | |
407 | ( te xt + "" ). replace( r trim, "" ) ; | |
408 | }, | |
409 | ||
410 | // results i s for inte rnal usage only | |
411 | ma keArray: f unction( a rr, result s ) { | |
412 | var ret = results || []; | |
413 | ||
414 | if ( arr != null ) { | |
415 | if ( isArrayli ke( Object (arr) ) ) { | |
416 | jQuery.mer ge( ret, | |
417 | ty peof arr = == "string " ? | |
418 | [ arr ] : ar r | |
419 | ); | |
420 | } el se { | |
421 | push.call( ret, arr ); | |
422 | } | |
423 | } | |
424 | ||
425 | return r et; | |
426 | }, | |
427 | ||
428 | in Array: fun ction( ele m, arr, i ) { | |
429 | var len; | |
430 | ||
431 | if ( arr ) { | |
432 | if ( indexOf ) { | |
433 | return ind exOf.call( arr, elem , i ); | |
434 | } | |
435 | ||
436 | len = arr.leng th; | |
437 | i = i ? i < 0 ? Math.max ( 0, len + i ) : i : 0; | |
438 | ||
439 | for ( ; i < le n; i++ ) { | |
440 | // Skip ac cessing in sparse ar rays | |
441 | if ( i in arr && arr [ i ] === elem ) { | |
442 | return i; | |
443 | } | |
444 | } | |
445 | } | |
446 | ||
447 | return - 1; | |
448 | }, | |
449 | ||
450 | me rge: funct ion( first , second ) { | |
451 | var len = +second. length, | |
452 | j = 0, | |
453 | i = first.leng th; | |
454 | ||
455 | while ( j < len ) { | |
456 | firs t[ i++ ] = second[ j ++ ]; | |
457 | } | |
458 | ||
459 | // Suppo rt: IE<9 | |
460 | // Worka round cast ing of .le ngth to Na N on other wise array like objec ts (e.g., NodeLists) | |
461 | if ( len !== len ) { | |
462 | whil e ( second [j] !== un defined ) { | |
463 | first[ i++ ] = secon d[ j++ ]; | |
464 | } | |
465 | } | |
466 | ||
467 | first.le ngth = i; | |
468 | ||
469 | return f irst; | |
470 | }, | |
471 | ||
472 | gr ep: functi on( elems, callback, invert ) { | |
473 | var call backInvers e, | |
474 | matc hes = [], | |
475 | i = 0, | |
476 | leng th = elems .length, | |
477 | call backExpect = !invert ; | |
478 | ||
479 | // Go th rough the array, onl y saving t he items | |
480 | // that pass the v alidator f unction | |
481 | for ( ; i < length ; i++ ) { | |
482 | call backInvers e = !callb ack( elems [ i ], i ) ; | |
483 | if ( callbackI nverse !== callbackE xpect ) { | |
484 | matches.pu sh( elems[ i ] ); | |
485 | } | |
486 | } | |
487 | ||
488 | return m atches; | |
489 | }, | |
490 | ||
491 | // arg is fo r internal usage onl y | |
492 | ma p: functio n( elems, callback, arg ) { | |
493 | var valu e, | |
494 | i = 0, | |
495 | leng th = elems .length, | |
496 | isAr ray = isAr raylike( e lems ), | |
497 | ret = []; | |
498 | ||
499 | // Go th rough the array, tra nslating e ach of the items to their new values | |
500 | if ( isA rray ) { | |
501 | for ( ; i < le ngth; i++ ) { | |
502 | value = ca llback( el ems[ i ], i, arg ); | |
503 | ||
504 | if ( value != null ) { | |
505 | ret.pu sh( value ); | |
506 | } | |
507 | } | |
508 | ||
509 | // G o through every key on the obj ect, | |
510 | } else { | |
511 | for ( i in ele ms ) { | |
512 | value = ca llback( el ems[ i ], i, arg ); | |
513 | ||
514 | if ( value != null ) { | |
515 | ret.pu sh( value ); | |
516 | } | |
517 | } | |
518 | } | |
519 | ||
520 | // Flatt en any nes ted arrays | |
521 | return c oncat.appl y( [], ret ); | |
522 | }, | |
523 | ||
524 | // A global GUID count er for obj ects | |
525 | gu id: 1, | |
526 | ||
527 | // Bind a fu nction to a context, optionall y partiall y applying any | |
528 | // arguments . | |
529 | pr oxy: funct ion( fn, c ontext ) { | |
530 | var args , proxy, t mp; | |
531 | ||
532 | if ( typ eof contex t === "str ing" ) { | |
533 | tmp = fn[ cont ext ]; | |
534 | cont ext = fn; | |
535 | fn = tmp; | |
536 | } | |
537 | ||
538 | // Quick check to determine if target is callabl e, in the spec | |
539 | // this throws a T ypeError, but we wil l just ret urn undefi ned. | |
540 | if ( !jQ uery.isFun ction( fn ) ) { | |
541 | retu rn undefin ed; | |
542 | } | |
543 | ||
544 | // Simul ated bind | |
545 | args = s lice.call( arguments , 2 ); | |
546 | proxy = function() { | |
547 | retu rn fn.appl y( context || this, args.conca t( slice.c all( argum ents ) ) ) ; | |
548 | }; | |
549 | ||
550 | // Set t he guid of unique ha ndler to t he same of original handler, s o it can b e removed | |
551 | proxy.gu id = fn.gu id = fn.gu id || jQue ry.guid++; | |
552 | ||
553 | return p roxy; | |
554 | }, | |
555 | ||
556 | no w: functio n() { | |
557 | return + ( new Date () ); | |
558 | }, | |
559 | ||
560 | // jQuery.su pport is n ot used in Core but other proj ects attac h their | |
561 | // propertie s to it so it needs to exist. | |
562 | su pport: sup port | |
563 | }); | |
564 | ||
565 | // Populat e the clas s2type map | |
566 | jQuery .each("Boo lean Numbe r String F unction Ar ray Date R egExp Obje ct Error". split(" ") , function (i, name) { | |
567 | cl ass2type[ "[object " + name + "]" ] = na me.toLower Case(); | |
568 | }); | |
569 | ||
570 | functi on isArray like( obj ) { | |
571 | va r length = obj.lengt h, | |
572 | type = j Query.type ( obj ); | |
573 | ||
574 | if ( type == = "functio n" || jQue ry.isWindo w( obj ) ) { | |
575 | return f alse; | |
576 | } | |
577 | ||
578 | if ( obj.nod eType === 1 && lengt h ) { | |
579 | return t rue; | |
580 | } | |
581 | ||
582 | re turn type === "array " || lengt h === 0 || | |
583 | typeof l ength === "number" & & length > 0 && ( le ngth - 1 ) in obj; | |
584 | } | |
585 | var Si zzle = | |
586 | /* ! | |
587 | * Sizzle CS S Selector Engine v1 .10.19 | |
588 | * http://si zzlejs.com / | |
589 | * | |
590 | * Copyright 2013 jQue ry Foundat ion, Inc. and other contributo rs | |
591 | * Released under the MIT licens e | |
592 | * http://jq uery.org/l icense | |
593 | * | |
594 | * Date: 201 4-04-18 | |
595 | * / | |
596 | (f unction( w indow ) { | |
597 | ||
598 | var i, | |
599 | supp ort, | |
600 | Expr , | |
601 | getT ext, | |
602 | isXM L, | |
603 | toke nize, | |
604 | comp ile, | |
605 | sele ct, | |
606 | oute rmostConte xt, | |
607 | sort Input, | |
608 | hasD uplicate, | |
609 | ||
610 | // Local document vars | |
611 | setD ocument, | |
612 | docu ment, | |
613 | docE lem, | |
614 | docu mentIsHTML , | |
615 | rbug gyQSA, | |
616 | rbug gyMatches, | |
617 | matc hes, | |
618 | cont ains, | |
619 | ||
620 | // Insta nce-specif ic data | |
621 | expa ndo = "siz zle" + -(n ew Date()) , | |
622 | pref erredDoc = window.do cument, | |
623 | dirr uns = 0, | |
624 | done = 0, | |
625 | clas sCache = c reateCache (), | |
626 | toke nCache = c reateCache (), | |
627 | comp ilerCache = createCa che(), | |
628 | sort Order = fu nction( a, b ) { | |
629 | if ( a === b ) { | |
630 | hasDup licate = t rue; | |
631 | } | |
632 | return 0; | |
633 | }, | |
634 | ||
635 | // Gener al-purpose constants | |
636 | stru ndefined = typeof un defined, | |
637 | MAX_ NEGATIVE = 1 << 31, | |
638 | ||
639 | // Insta nce method s | |
640 | hasO wn = ({}). hasOwnProp erty, | |
641 | arr = [], | |
642 | pop = arr.pop, | |
643 | push _native = arr.push, | |
644 | push = arr.pus h, | |
645 | slic e = arr.sl ice, | |
646 | // Use a stripped- down index Of if we c an't use a native on e | |
647 | inde xOf = arr. indexOf || function( elem ) { | |
648 | var i = 0, | |
649 | len = this.lengt h; | |
650 | for ( ; i < len; i++ ) { | |
651 | if ( t his[i] === elem ) { | |
652 | re turn i; | |
653 | } | |
654 | } | |
655 | return -1; | |
656 | }, | |
657 | ||
658 | bool eans = "ch ecked|sele cted|async |autofocus |autoplay| controls|d efer|disab led|hidden |ismap|loo p|multiple |open|read only|requi red|scoped ", | |
659 | ||
660 | // Regul ar express ions | |
661 | ||
662 | // White space char acters htt p://www.w3 .org/TR/cs s3-selecto rs/#whites pace | |
663 | whit espace = " [\\x20\\t\ \r\\n\\f]" , | |
664 | // http: //www.w3.o rg/TR/css3 -syntax/#c haracters | |
665 | char acterEncod ing = "(?: \\\\.|[\\w -]|[^\\x00 -\\xa0])+" , | |
666 | ||
667 | // Loose ly modeled on CSS id entifier c haracters | |
668 | // An un quoted val ue should be a CSS i dentifier http://www .w3.org/TR /css3-sele ctors/#att ribute-sel ectors | |
669 | // Prope r syntax: http://www .w3.org/TR /CSS21/syn data.html# value-def- identifier | |
670 | iden tifier = c haracterEn coding.rep lace( "w", "w#" ), | |
671 | ||
672 | // Attri bute selec tors: http ://www.w3. org/TR/sel ectors/#at tribute-se lectors | |
673 | attr ibutes = " \\[" + whi tespace + "*(" + cha racterEnco ding + ")( ?:" + whit espace + | |
674 | // Operato r (capture 2) | |
675 | "*([*^$|!~ ]?=)" + wh itespace + | |
676 | // "Attrib ute values must be C SS identif iers [capt ure 5] or strings [c apture 3 o r capture 4]" | |
677 | "*(?:'((?: \\\\.|[^\\ \\'])*)'|\ "((?:\\\\. |[^\\\\\"] )*)\"|(" + identifie r + "))|)" + whitesp ace + | |
678 | "*\\]", | |
679 | ||
680 | pseu dos = ":(" + charact erEncoding + ")(?:\\ ((" + | |
681 | // To redu ce the num ber of sel ectors nee ding token ize in the preFilter , prefer a rguments: | |
682 | // 1. quot ed (captur e 3; captu re 4 or ca pture 5) | |
683 | "('((?:\\\ \.|[^\\\\' ])*)'|\"(( ?:\\\\.|[^ \\\\\"])*) \")|" + | |
684 | // 2. simp le (captur e 6) | |
685 | "((?:\\\\. |[^\\\\()[ \\]]|" + a ttributes + ")*)|" + | |
686 | // 3. anyt hing else (capture 2 ) | |
687 | ".*" + | |
688 | ")\\)|)", | |
689 | ||
690 | // Leadi ng and non -escaped t railing wh itespace, capturing some non-w hitespace characters preceding the latte r | |
691 | rtri m = new Re gExp( "^" + whitespa ce + "+|(( ?:^|[^\\\\ ])(?:\\\\. )*)" + whi tespace + "+$", "g" ), | |
692 | ||
693 | rcom ma = new R egExp( "^" + whitesp ace + "*," + whitesp ace + "*" ), | |
694 | rcom binators = new RegEx p( "^" + w hitespace + "*([>+~] |" + white space + ") " + whites pace + "*" ), | |
695 | ||
696 | ratt ributeQuot es = new R egExp( "=" + whitesp ace + "*([ ^\\]'\"]*? )" + white space + "* \\]", "g" ), | |
697 | ||
698 | rpse udo = new RegExp( ps eudos ), | |
699 | ride ntifier = new RegExp ( "^" + id entifier + "$" ), | |
700 | ||
701 | matc hExpr = { | |
702 | "ID": new RegExp( "^ #(" + char acterEncod ing + ")" ), | |
703 | "CLASS": n ew RegExp( "^\\.(" + character Encoding + ")" ), | |
704 | "TAG": new RegExp( " ^(" + char acterEncod ing.replac e( "w", "w *" ) + ")" ), | |
705 | "ATTR": ne w RegExp( "^" + attr ibutes ), | |
706 | "PSEUDO": new RegExp ( "^" + ps eudos ), | |
707 | "CHILD": n ew RegExp( "^:(only| first|last |nth|nth-l ast)-(chil d|of-type) (?:\\(" + whitespace + | |
708 | "*(eve n|odd|(([+ -]|)(\\d*) n|)" + whi tespace + "*(?:([+-] |)" + whit espace + | |
709 | "*(\\d +)|))" + w hitespace + "*\\)|)" , "i" ), | |
710 | "bool": ne w RegExp( "^(?:" + b ooleans + ")$", "i" ), | |
711 | // For use in librar ies implem enting .is () | |
712 | // We use this for P OS matchin g in `sele ct` | |
713 | "needsCont ext": new RegExp( "^ " + whites pace + "*[ >+~]|:(eve n|odd|eq|g t|lt|nth|f irst|last) (?:\\(" + | |
714 | whites pace + "*( (?:-\\d)?\ \d*)" + wh itespace + "*\\)|)(? =[^-]|$)", "i" ) | |
715 | }, | |
716 | ||
717 | rinp uts = /^(? :input|sel ect|textar ea|button) $/i, | |
718 | rhea der = /^h\ d$/i, | |
719 | ||
720 | rnat ive = /^[^ {]+\{\s*\[ native \w/ , | |
721 | ||
722 | // Easil y-parseabl e/retrieva ble ID or TAG or CLA SS selecto rs | |
723 | rqui ckExpr = / ^(?:#([\w- ]+)|(\w+)| \.([\w-]+) )$/, | |
724 | ||
725 | rsib ling = /[+ ~]/, | |
726 | resc ape = /'|\ \/g, | |
727 | ||
728 | // CSS e scapes htt p://www.w3 .org/TR/CS S21/syndat a.html#esc aped-chara cters | |
729 | rune scape = ne w RegExp( "\\\\([\\d a-f]{1,6}" + whitesp ace + "?|( " + whites pace + ")| .)", "ig" ), | |
730 | fune scape = fu nction( _, escaped, escapedWhi tespace ) { | |
731 | var high = "0x" + es caped - 0x 10000; | |
732 | // NaN mea ns non-cod epoint | |
733 | // Support : Firefox< 24 | |
734 | // Workaro und errone ous numeri c interpre tation of +"0x" | |
735 | return hig h !== high || escape dWhitespac e ? | |
736 | escape d : | |
737 | hi gh < 0 ? | |
738 | // BMP codepoint | |
739 | String .fromCharC ode( high + 0x10000 ) : | |
740 | // Sup plemental Plane code point (sur rogate pai r) | |
741 | String .fromCharC ode( high >> 10 | 0x D800, high & 0x3FF | 0xDC00 ); | |
742 | }; | |
743 | ||
744 | // Optimiz e for push .apply( _, NodeList ) | |
745 | try { | |
746 | push .apply( | |
747 | (arr = sli ce.call( p referredDo c.childNod es )), | |
748 | preferredD oc.childNo des | |
749 | ); | |
750 | // S upport: An droid<4.0 | |
751 | // D etect sile ntly faili ng push.ap ply | |
752 | arr[ preferred Doc.childN odes.lengt h ].nodeTy pe; | |
753 | } catch ( e ) { | |
754 | push = { apply : arr.leng th ? | |
755 | ||
756 | // Leverag e slice if possible | |
757 | function( target, el s ) { | |
758 | push_n ative.appl y( target, slice.cal l(els) ); | |
759 | } : | |
760 | ||
761 | // Support : IE<9 | |
762 | // Otherwi se append directly | |
763 | function( target, el s ) { | |
764 | var j = target.l ength, | |
765 | i = 0; | |
766 | // Can 't trust N odeList.le ngth | |
767 | while ( (target[ j++] = els [i++]) ) { } | |
768 | target .length = j - 1; | |
769 | } | |
770 | }; | |
771 | } | |
772 | ||
773 | function Sizzle( s elector, c ontext, re sults, see d ) { | |
774 | var match, ele m, m, node Type, | |
775 | // Q SA vars | |
776 | i, groups, old, nid, newContex t, newSele ctor; | |
777 | ||
778 | if ( ( context ? context .ownerDocu ment || co ntext : pr eferredDoc ) !== doc ument ) { | |
779 | setDocumen t( context ); | |
780 | } | |
781 | ||
782 | cont ext = cont ext || doc ument; | |
783 | resu lts = resu lts || []; | |
784 | ||
785 | if ( !selector || typeof selector !== "strin g" ) { | |
786 | return res ults; | |
787 | } | |
788 | ||
789 | if ( (nodeType = context .nodeType) !== 1 && nodeType ! == 9 ) { | |
790 | return []; | |
791 | } | |
792 | ||
793 | if ( documentI sHTML && ! seed ) { | |
794 | ||
795 | // Shortcu ts | |
796 | if ( (matc h = rquick Expr.exec( selector )) ) { | |
797 | // Spe ed-up: Siz zle("#ID") | |
798 | if ( ( m = match[ 1]) ) { | |
799 | if ( nodeTyp e === 9 ) { | |
800 | elem = c ontext.get ElementByI d( m ); | |
801 | // Check parentNod e to catch when Blac kberry 4.6 returns | |
802 | // nodes that are no longer in the doc ument (jQu ery #6963) | |
803 | if ( ele m && elem. parentNode ) { | |
804 | // H andle the case where IE, Opera , and Webk it return items | |
805 | // b y name ins tead of ID | |
806 | if ( elem.id = == m ) { | |
807 | results.pu sh( elem ) ; | |
808 | return res ults; | |
809 | } | |
810 | } else { | |
811 | retu rn results ; | |
812 | } | |
813 | } else { | |
814 | // Conte xt is not a document | |
815 | if ( con text.owner Document & & (elem = context.ow nerDocumen t.getEleme ntById( m )) && | |
816 | cont ains( cont ext, elem ) && elem. id === m ) { | |
817 | resu lts.push( elem ); | |
818 | retu rn results ; | |
819 | } | |
820 | } | |
821 | ||
822 | // Speed-up: Sizzle("T AG") | |
823 | } else if ( matc h[2] ) { | |
824 | pu sh.apply( results, c ontext.get ElementsBy TagName( s elector ) ); | |
825 | re turn resul ts; | |
826 | ||
827 | // Speed-up: Sizzle(". CLASS") | |
828 | } else if ( (m = match[3]) && suppor t.getEleme ntsByClass Name && co ntext.getE lementsByC lassName ) { | |
829 | pu sh.apply( results, c ontext.get ElementsBy ClassName( m ) ); | |
830 | re turn resul ts; | |
831 | } | |
832 | } | |
833 | ||
834 | // QSA pat h | |
835 | if ( suppo rt.qsa && (!rbuggyQS A || !rbug gyQSA.test ( selector )) ) { | |
836 | nid = old = expa ndo; | |
837 | newCon text = con text; | |
838 | newSel ector = no deType === 9 && sele ctor; | |
839 | ||
840 | // qSA works str angely on Element-ro oted queri es | |
841 | // We can work a round this by specif ying an ex tra ID on the root | |
842 | // and working u p from the re (Thanks to Andrew Dupont fo r the tech nique) | |
843 | // IE 8 doesn't work on ob ject eleme nts | |
844 | if ( n odeType == = 1 && con text.nodeN ame.toLowe rCase() != = "object" ) { | |
845 | gr oups = tok enize( sel ector ); | |
846 | ||
847 | if ( (old = context.ge tAttribute ("id")) ) { | |
848 | nid = ol d.replace( rescape, "\\$&" ); | |
849 | } else { | |
850 | context. setAttribu te( "id", nid ); | |
851 | } | |
852 | ni d = "[id=' " + nid + "'] "; | |
853 | ||
854 | i = groups.l ength; | |
855 | wh ile ( i-- ) { | |
856 | groups[i ] = nid + toSelector ( groups[i ] ); | |
857 | } | |
858 | ne wContext = rsibling. test( sele ctor ) && testContex t( context .parentNod e ) || con text; | |
859 | ne wSelector = groups.j oin(","); | |
860 | } | |
861 | ||
862 | if ( n ewSelector ) { | |
863 | tr y { | |
864 | push.app ly( result s, | |
865 | newC ontext.que rySelector All( newSe lector ) | |
866 | ); | |
867 | return r esults; | |
868 | } catch(qsaE rror) { | |
869 | } finally { | |
870 | if ( !ol d ) { | |
871 | cont ext.remove Attribute( "id"); | |
872 | } | |
873 | } | |
874 | } | |
875 | } | |
876 | } | |
877 | ||
878 | // A ll others | |
879 | retu rn select( selector. replace( r trim, "$1" ), contex t, results , seed ); | |
880 | } | |
881 | ||
882 | /** | |
883 | * Creat e key-valu e caches o f limited size | |
884 | * @retu rns {Funct ion(string , Object)} Returns t he Object data after storing i t on itsel f with | |
885 | * prop erty name the (space -suffixed) string an d (if the cache is l arger than Expr.cach eLength) | |
886 | * dele ting the o ldest entr y | |
887 | */ | |
888 | function createCac he() { | |
889 | var keys = []; | |
890 | ||
891 | func tion cache ( key, val ue ) { | |
892 | // Use (ke y + " ") t o avoid co llision wi th native prototype properties (see Issu e #157) | |
893 | if ( keys. push( key + " " ) > Expr.cache Length ) { | |
894 | // Onl y keep the most rece nt entries | |
895 | delete cache[ ke ys.shift() ]; | |
896 | } | |
897 | return (ca che[ key + " " ] = v alue); | |
898 | } | |
899 | retu rn cache; | |
900 | } | |
901 | ||
902 | /** | |
903 | * Mark a function for speci al use by Sizzle | |
904 | * @para m {Functio n} fn The function t o mark | |
905 | */ | |
906 | function markFunct ion( fn ) { | |
907 | fn[ expando ] = true; | |
908 | retu rn fn; | |
909 | } | |
910 | ||
911 | /** | |
912 | * Suppo rt testing using an element | |
913 | * @para m {Functio n} fn Pass ed the cre ated div a nd expects a boolean result | |
914 | */ | |
915 | function assert( f n ) { | |
916 | var div = docu ment.creat eElement(" div"); | |
917 | ||
918 | try { | |
919 | return !!f n( div ); | |
920 | } ca tch (e) { | |
921 | return fal se; | |
922 | } fi nally { | |
923 | // Remove from its p arent by d efault | |
924 | if ( div.p arentNode ) { | |
925 | div.pa rentNode.r emoveChild ( div ); | |
926 | } | |
927 | // release memory in IE | |
928 | div = null ; | |
929 | } | |
930 | } | |
931 | ||
932 | /** | |
933 | * Adds the same h andler for all of th e specifie d attrs | |
934 | * @para m {String} attrs Pip e-separate d list of attributes | |
935 | * @para m {Functio n} handler The metho d that wil l be appli ed | |
936 | */ | |
937 | function addHandle ( attrs, h andler ) { | |
938 | var arr = attr s.split("| "), | |
939 | i = attrs. length; | |
940 | ||
941 | whil e ( i-- ) { | |
942 | Expr.attrH andle[ arr [i] ] = ha ndler; | |
943 | } | |
944 | } | |
945 | ||
946 | /** | |
947 | * Check s document order of two siblin gs | |
948 | * @para m {Element } a | |
949 | * @para m {Element } b | |
950 | * @retu rns {Numbe r} Returns less than 0 if a pr ecedes b, greater th an 0 if a follows b | |
951 | */ | |
952 | function siblingCh eck( a, b ) { | |
953 | var cur = b && a, | |
954 | diff = cur && a.node Type === 1 && b.node Type === 1 && | |
955 | ( ~b.s ourceIndex || MAX_NE GATIVE ) - | |
956 | ( ~a.s ourceIndex || MAX_NE GATIVE ); | |
957 | ||
958 | // U se IE sour ceIndex if available on both n odes | |
959 | if ( diff ) { | |
960 | return dif f; | |
961 | } | |
962 | ||
963 | // C heck if b follows a | |
964 | if ( cur ) { | |
965 | while ( (c ur = cur.n extSibling ) ) { | |
966 | if ( c ur === b ) { | |
967 | re turn -1; | |
968 | } | |
969 | } | |
970 | } | |
971 | ||
972 | retu rn a ? 1 : -1; | |
973 | } | |
974 | ||
975 | /** | |
976 | * Retur ns a funct ion to use in pseudo s for inpu t types | |
977 | * @para m {String} type | |
978 | */ | |
979 | function createInp utPseudo( type ) { | |
980 | retu rn functio n( elem ) { | |
981 | var name = elem.node Name.toLow erCase(); | |
982 | return nam e === "inp ut" && ele m.type === type; | |
983 | }; | |
984 | } | |
985 | ||
986 | /** | |
987 | * Retur ns a funct ion to use in pseudo s for butt ons | |
988 | * @para m {String} type | |
989 | */ | |
990 | function createBut tonPseudo( type ) { | |
991 | retu rn functio n( elem ) { | |
992 | var name = elem.node Name.toLow erCase(); | |
993 | return (na me === "in put" || na me === "bu tton") && elem.type === type; | |
994 | }; | |
995 | } | |
996 | ||
997 | /** | |
998 | * Retur ns a funct ion to use in pseudo s for posi tionals | |
999 | * @para m {Functio n} fn | |
1000 | */ | |
1001 | function createPos itionalPse udo( fn ) { | |
1002 | retu rn markFun ction(func tion( argu ment ) { | |
1003 | argument = +argument ; | |
1004 | return mar kFunction( function( seed, matc hes ) { | |
1005 | var j, | |
1006 | ma tchIndexes = fn( [], seed.leng th, argume nt ), | |
1007 | i = matchInd exes.lengt h; | |
1008 | ||
1009 | // Mat ch element s found at the speci fied index es | |
1010 | while ( i-- ) { | |
1011 | if ( seed[ ( j = matchI ndexes[i]) ] ) { | |
1012 | seed[j] = !(matche s[j] = see d[j]); | |
1013 | } | |
1014 | } | |
1015 | }); | |
1016 | }); | |
1017 | } | |
1018 | ||
1019 | /** | |
1020 | * Check s a node f or validit y as a Siz zle contex t | |
1021 | * @para m {Element |Object=} context | |
1022 | * @retu rns {Eleme nt|Object| Boolean} T he input n ode if acc eptable, o therwise a falsy val ue | |
1023 | */ | |
1024 | function testConte xt( contex t ) { | |
1025 | retu rn context && typeof context.g etElements ByTagName !== strund efined && context; | |
1026 | } | |
1027 | ||
1028 | // Expose support va rs for con venience | |
1029 | support = Sizzle.s upport = { }; | |
1030 | ||
1031 | /** | |
1032 | * Detec ts XML nod es | |
1033 | * @para m {Element |Object} e lem An ele ment or a document | |
1034 | * @retu rns {Boole an} True i ff elem is a non-HTM L XML node | |
1035 | */ | |
1036 | isXML = Sizzle.isX ML = funct ion( elem ) { | |
1037 | // d ocumentEle ment is ve rified for cases whe re it does n't yet ex ist | |
1038 | // ( such as lo ading ifra mes in IE - #4833) | |
1039 | var documentEl ement = el em && (ele m.ownerDoc ument || e lem).docum entElement ; | |
1040 | retu rn documen tElement ? documentE lement.nod eName !== "HTML" : f alse; | |
1041 | }; | |
1042 | ||
1043 | /** | |
1044 | * Sets document-r elated var iables onc e based on the curre nt documen t | |
1045 | * @para m {Element |Object} [ doc] An el ement or d ocument ob ject to us e to set t he documen t | |
1046 | * @retu rns {Objec t} Returns the curre nt documen t | |
1047 | */ | |
1048 | setDocum ent = Sizz le.setDocu ment = fun ction( nod e ) { | |
1049 | var hasCompare , | |
1050 | doc = node ? node.ow nerDocumen t || node : preferre dDoc, | |
1051 | parent = d oc.default View; | |
1052 | ||
1053 | // I f no docum ent and do cumentElem ent is ava ilable, re turn | |
1054 | if ( doc === d ocument || doc.nodeT ype !== 9 || !doc.do cumentElem ent ) { | |
1055 | return doc ument; | |
1056 | } | |
1057 | ||
1058 | // S et our doc ument | |
1059 | docu ment = doc ; | |
1060 | docE lem = doc. documentEl ement; | |
1061 | ||
1062 | // S upport tes ts | |
1063 | docu mentIsHTML = !isXML( doc ); | |
1064 | ||
1065 | // S upport: IE >8 | |
1066 | // I f iframe d ocument is assigned to "docume nt" variab le and if iframe has been relo aded, | |
1067 | // I E will thr ow "permis sion denie d" error w hen access ing "docum ent" varia ble, see j Query #139 36 | |
1068 | // I E6-8 do no t support the defaul tView prop erty so pa rent will be undefin ed | |
1069 | if ( parent && parent != = parent.t op ) { | |
1070 | // IE11 do es not hav e attachEv ent, so al l must suf fer | |
1071 | if ( paren t.addEvent Listener ) { | |
1072 | parent .addEventL istener( " unload", f unction() { | |
1073 | se tDocument( ); | |
1074 | }, fal se ); | |
1075 | } else if ( parent.a ttachEvent ) { | |
1076 | parent .attachEve nt( "onunl oad", func tion() { | |
1077 | se tDocument( ); | |
1078 | }); | |
1079 | } | |
1080 | } | |
1081 | ||
1082 | /* A ttributes | |
1083 | --- ---------- ---------- ---------- ---------- ---------- ---------- ------- */ | |
1084 | ||
1085 | // S upport: IE <8 | |
1086 | // V erify that getAttrib ute really returns a ttributes and not pr operties ( excepting IE8 boolea ns) | |
1087 | supp ort.attrib utes = ass ert(functi on( div ) { | |
1088 | div.classN ame = "i"; | |
1089 | return !di v.getAttri bute("clas sName"); | |
1090 | }); | |
1091 | ||
1092 | /* g etElement( s)By* | |
1093 | --- ---------- ---------- ---------- ---------- ---------- ---------- ------- */ | |
1094 | ||
1095 | // C heck if ge tElementsB yTagName(" *") return s only ele ments | |
1096 | supp ort.getEle mentsByTag Name = ass ert(functi on( div ) { | |
1097 | div.append Child( doc .createCom ment("") ) ; | |
1098 | return !di v.getEleme ntsByTagNa me("*").le ngth; | |
1099 | }); | |
1100 | ||
1101 | // C heck if ge tElementsB yClassName can be tr usted | |
1102 | supp ort.getEle mentsByCla ssName = r native.tes t( doc.get ElementsBy ClassName ) && asser t(function ( div ) { | |
1103 | div.innerH TML = "<di v class='a '></div><d iv class=' a i'></div >"; | |
1104 | ||
1105 | // Support : Safari<4 | |
1106 | // Catch c lass over- caching | |
1107 | div.firstC hild.class Name = "i" ; | |
1108 | // Support : Opera<10 | |
1109 | // Catch g EBCN failu re to find non-leadi ng classes | |
1110 | return div .getElemen tsByClassN ame("i").l ength === 2; | |
1111 | }); | |
1112 | ||
1113 | // S upport: IE <10 | |
1114 | // C heck if ge tElementBy Id returns elements by name | |
1115 | // T he broken getElement ById metho ds don't p ick up pro gramatical ly-set nam es, | |
1116 | // s o use a ro undabout g etElements ByName tes t | |
1117 | supp ort.getByI d = assert (function( div ) { | |
1118 | docElem.ap pendChild( div ).id = expando; | |
1119 | return !do c.getEleme ntsByName || !doc.ge tElementsB yName( exp ando ).len gth; | |
1120 | }); | |
1121 | ||
1122 | // I D find and filter | |
1123 | if ( support.g etById ) { | |
1124 | Expr.find[ "ID"] = fu nction( id , context ) { | |
1125 | if ( t ypeof cont ext.getEle mentById ! == strunde fined && d ocumentIsH TML ) { | |
1126 | va r m = cont ext.getEle mentById( id ); | |
1127 | // Check par entNode to catch whe n Blackber ry 4.6 ret urns | |
1128 | // nodes tha t are no l onger in t he documen t #6963 | |
1129 | re turn m && m.parentNo de ? [ m ] : []; | |
1130 | } | |
1131 | }; | |
1132 | Expr.filte r["ID"] = function( id ) { | |
1133 | var at trId = id. replace( r unescape, funescape ); | |
1134 | return function( elem ) { | |
1135 | re turn elem. getAttribu te("id") = == attrId; | |
1136 | }; | |
1137 | }; | |
1138 | } el se { | |
1139 | // Support : IE6/7 | |
1140 | // getElem entById is not relia ble as a f ind shortc ut | |
1141 | delete Exp r.find["ID "]; | |
1142 | ||
1143 | Expr.filte r["ID"] = function( id ) { | |
1144 | var at trId = id. replace( r unescape, funescape ); | |
1145 | return function( elem ) { | |
1146 | va r node = t ypeof elem .getAttrib uteNode != = strundef ined && el em.getAttr ibuteNode( "id"); | |
1147 | re turn node && node.va lue === at trId; | |
1148 | }; | |
1149 | }; | |
1150 | } | |
1151 | ||
1152 | // T ag | |
1153 | Expr .find["TAG "] = suppo rt.getElem entsByTagN ame ? | |
1154 | function( tag, conte xt ) { | |
1155 | if ( t ypeof cont ext.getEle mentsByTag Name !== s trundefine d ) { | |
1156 | re turn conte xt.getElem entsByTagN ame( tag ) ; | |
1157 | } | |
1158 | } : | |
1159 | function( tag, conte xt ) { | |
1160 | var el em, | |
1161 | tm p = [], | |
1162 | i = 0, | |
1163 | re sults = co ntext.getE lementsByT agName( ta g ); | |
1164 | ||
1165 | // Fil ter out po ssible com ments | |
1166 | if ( t ag === "*" ) { | |
1167 | wh ile ( (ele m = result s[i++]) ) { | |
1168 | if ( ele m.nodeType === 1 ) { | |
1169 | tmp. push( elem ); | |
1170 | } | |
1171 | } | |
1172 | ||
1173 | re turn tmp; | |
1174 | } | |
1175 | return results; | |
1176 | }; | |
1177 | ||
1178 | // C lass | |
1179 | Expr .find["CLA SS"] = sup port.getEl ementsByCl assName && function( className , context ) { | |
1180 | if ( typeo f context. getElement sByClassNa me !== str undefined && documen tIsHTML ) { | |
1181 | return context.g etElements ByClassNam e( classNa me ); | |
1182 | } | |
1183 | }; | |
1184 | ||
1185 | /* Q SA/matches Selector | |
1186 | --- ---------- ---------- ---------- ---------- ---------- ---------- ------- */ | |
1187 | ||
1188 | // Q SA and mat chesSelect or support | |
1189 | ||
1190 | // m atchesSele ctor(:acti ve) report s false wh en true (I E9/Opera 1 1.5) | |
1191 | rbug gyMatches = []; | |
1192 | ||
1193 | // q Sa(:focus) reports f alse when true (Chro me 21) | |
1194 | // W e allow th is because of a bug in IE8/9 t hat throws an error | |
1195 | // w henever `d ocument.ac tiveElemen t` is acce ssed on an iframe | |
1196 | // S o, we allo w :focus t o pass thr ough QSA a ll the tim e to avoid the IE er ror | |
1197 | // S ee http:// bugs.jquer y.com/tick et/13378 | |
1198 | rbug gyQSA = [] ; | |
1199 | ||
1200 | if ( (support. qsa = rnat ive.test( doc.queryS electorAll )) ) { | |
1201 | // Build Q SA regex | |
1202 | // Regex s trategy ad opted from Diego Per ini | |
1203 | assert(fun ction( div ) { | |
1204 | // Sel ect is set to empty string on purpose | |
1205 | // Thi s is to te st IE's tr eatment of not expli citly | |
1206 | // set ting a boo lean resou rces attri bute, | |
1207 | // sin ce its pre sence shou ld be enou gh | |
1208 | // htt p://bugs.j query.com/ ticket/123 59 | |
1209 | div.in nerHTML = "<select m sallowclip =''><optio n selected =''></opti on></selec t>"; | |
1210 | ||
1211 | // Sup port: IE8, Opera 11- 12.16 | |
1212 | // Not hing shoul d be selec ted when e mpty strin gs follow ^= or $= o r *= | |
1213 | // The test attr ibute must be unknow n in Opera but "safe " for WinR T | |
1214 | // htt p://msdn.m icrosoft.c om/en-us/l ibrary/ie/ hh465388.a spx#attrib ute_sectio n | |
1215 | if ( d iv.querySe lectorAll( "[msallowc lip^='']") .length ) { | |
1216 | rb uggyQSA.pu sh( "[*^$] =" + white space + "* (?:''|\"\" )" ); | |
1217 | } | |
1218 | ||
1219 | // Sup port: IE8 | |
1220 | // Boo lean attri butes and "value" ar e not trea ted correc tly | |
1221 | if ( ! div.queryS electorAll ("[selecte d]").lengt h ) { | |
1222 | rb uggyQSA.pu sh( "\\[" + whitespa ce + "*(?: value|" + booleans + ")" ); | |
1223 | } | |
1224 | ||
1225 | // Web kit/Opera - :checked should re turn selec ted option elements | |
1226 | // htt p://www.w3 .org/TR/20 11/REC-css 3-selector s-20110929 /#checked | |
1227 | // IE8 throws er ror here a nd will no t see late r tests | |
1228 | if ( ! div.queryS electorAll (":checked ").length ) { | |
1229 | rb uggyQSA.pu sh(":check ed"); | |
1230 | } | |
1231 | }); | |
1232 | ||
1233 | assert(fun ction( div ) { | |
1234 | // Sup port: Wind ows 8 Nati ve Apps | |
1235 | // The type and name attri butes are restricted during .i nnerHTML a ssignment | |
1236 | var in put = doc. createElem ent("input "); | |
1237 | input. setAttribu te( "type" , "hidden" ); | |
1238 | div.ap pendChild( input ).s etAttribut e( "name", "D" ); | |
1239 | ||
1240 | // Sup port: IE8 | |
1241 | // Enf orce case- sensitivit y of name attribute | |
1242 | if ( d iv.querySe lectorAll( "[name=d]" ).length ) { | |
1243 | rb uggyQSA.pu sh( "name" + whitesp ace + "*[* ^$|!~]?=" ); | |
1244 | } | |
1245 | ||
1246 | // FF 3.5 - :ena bled/:disa bled and h idden elem ents (hidd en element s are stil l enabled) | |
1247 | // IE8 throws er ror here a nd will no t see late r tests | |
1248 | if ( ! div.queryS electorAll (":enabled ").length ) { | |
1249 | rb uggyQSA.pu sh( ":enab led", ":di sabled" ); | |
1250 | } | |
1251 | ||
1252 | // Ope ra 10-11 d oes not th row on pos t-comma in valid pseu dos | |
1253 | div.qu erySelecto rAll("*,:x "); | |
1254 | rbuggy QSA.push(" ,.*:"); | |
1255 | }); | |
1256 | } | |
1257 | ||
1258 | if ( (support. matchesSel ector = rn ative.test ( (matches = docElem .matches | | | |
1259 | docElem.we bkitMatche sSelector || | |
1260 | docElem.mo zMatchesSe lector || | |
1261 | docElem.oM atchesSele ctor || | |
1262 | docElem.ms MatchesSel ector) )) ) { | |
1263 | ||
1264 | assert(fun ction( div ) { | |
1265 | // Che ck to see if it's po ssible to do matches Selector | |
1266 | // on a disconne cted node (IE 9) | |
1267 | suppor t.disconne ctedMatch = matches. call( div, "div" ); | |
1268 | ||
1269 | // Thi s should f ail with a n exceptio n | |
1270 | // Gec ko does no t error, r eturns fal se instead | |
1271 | matche s.call( di v, "[s!='' ]:x" ); | |
1272 | rbuggy Matches.pu sh( "!=", pseudos ); | |
1273 | }); | |
1274 | } | |
1275 | ||
1276 | rbug gyQSA = rb uggyQSA.le ngth && ne w RegExp( rbuggyQSA. join("|") ); | |
1277 | rbug gyMatches = rbuggyMa tches.leng th && new RegExp( rb uggyMatche s.join("|" ) ); | |
1278 | ||
1279 | /* C ontains | |
1280 | --- ---------- ---------- ---------- ---------- ---------- ---------- ------- */ | |
1281 | hasC ompare = r native.tes t( docElem .compareDo cumentPosi tion ); | |
1282 | ||
1283 | // E lement con tains anot her | |
1284 | // P urposefull y does not implement inclusive descenden t | |
1285 | // A s in, an e lement doe s not cont ain itself | |
1286 | cont ains = has Compare || rnative.t est( docEl em.contain s ) ? | |
1287 | function( a, b ) { | |
1288 | var ad own = a.no deType === 9 ? a.doc umentEleme nt : a, | |
1289 | bu p = b && b .parentNod e; | |
1290 | return a === bup || !!( bu p && bup.n odeType == = 1 && ( | |
1291 | ad own.contai ns ? | |
1292 | adown.co ntains( bu p ) : | |
1293 | a.compar eDocumentP osition && a.compare DocumentPo sition( bu p ) & 16 | |
1294 | )) ; | |
1295 | } : | |
1296 | function( a, b ) { | |
1297 | if ( b ) { | |
1298 | wh ile ( (b = b.parentN ode) ) { | |
1299 | if ( b = == a ) { | |
1300 | retu rn true; | |
1301 | } | |
1302 | } | |
1303 | } | |
1304 | return false; | |
1305 | }; | |
1306 | ||
1307 | /* S orting | |
1308 | --- ---------- ---------- ---------- ---------- ---------- ---------- ------- */ | |
1309 | ||
1310 | // D ocument or der sortin g | |
1311 | sort Order = ha sCompare ? | |
1312 | function( a, b ) { | |
1313 | ||
1314 | // Fla g for dupl icate remo val | |
1315 | if ( a === b ) { | |
1316 | ha sDuplicate = true; | |
1317 | re turn 0; | |
1318 | } | |
1319 | ||
1320 | // Sor t on metho d existenc e if only one input has compar eDocumentP osition | |
1321 | var co mpare = !a .compareDo cumentPosi tion - !b. compareDoc umentPosit ion; | |
1322 | if ( c ompare ) { | |
1323 | re turn compa re; | |
1324 | } | |
1325 | ||
1326 | // Cal culate pos ition if b oth inputs belong to the same document | |
1327 | compar e = ( a.ow nerDocumen t || a ) = == ( b.own erDocument || b ) ? | |
1328 | a. compareDoc umentPosit ion( b ) : | |
1329 | ||
1330 | // Otherwise we know t hey are di sconnected | |
1331 | 1; | |
1332 | ||
1333 | // Dis connected nodes | |
1334 | if ( c ompare & 1 || | |
1335 | (! support.so rtDetached && b.comp areDocumen tPosition( a ) === c ompare) ) { | |
1336 | ||
1337 | // Choose th e first el ement that is relate d to our p referred d ocument | |
1338 | if ( a === d oc || a.ow nerDocumen t === pref erredDoc & & contains (preferred Doc, a) ) { | |
1339 | return - 1; | |
1340 | } | |
1341 | if ( b === d oc || b.ow nerDocumen t === pref erredDoc & & contains (preferred Doc, b) ) { | |
1342 | return 1 ; | |
1343 | } | |
1344 | ||
1345 | // Maintain original o rder | |
1346 | re turn sortI nput ? | |
1347 | ( indexO f.call( so rtInput, a ) - index Of.call( s ortInput, b ) ) : | |
1348 | 0; | |
1349 | } | |
1350 | ||
1351 | return compare & 4 ? -1 : 1; | |
1352 | } : | |
1353 | function( a, b ) { | |
1354 | // Exi t early if the nodes are ident ical | |
1355 | if ( a === b ) { | |
1356 | ha sDuplicate = true; | |
1357 | re turn 0; | |
1358 | } | |
1359 | ||
1360 | var cu r, | |
1361 | i = 0, | |
1362 | au p = a.pare ntNode, | |
1363 | bu p = b.pare ntNode, | |
1364 | ap = [ a ], | |
1365 | bp = [ b ]; | |
1366 | ||
1367 | // Par entless no des are ei ther docum ents or di sconnected | |
1368 | if ( ! aup || !bu p ) { | |
1369 | re turn a === doc ? -1 : | |
1370 | b == = doc ? 1 : | |
1371 | aup ? -1 : | |
1372 | bup ? 1 : | |
1373 | sortInput ? | |
1374 | ( inde xOf.call( sortInput, a ) - ind exOf.call( sortInput , b ) ) : | |
1375 | 0; | |
1376 | ||
1377 | // If the no des are si blings, we can do a quick chec k | |
1378 | } else if ( aup === bup ) { | |
1379 | re turn sibli ngCheck( a , b ); | |
1380 | } | |
1381 | ||
1382 | // Oth erwise we need full lists of t heir ances tors for c omparison | |
1383 | cur = a; | |
1384 | while ( (cur = c ur.parentN ode) ) { | |
1385 | ap .unshift( cur ); | |
1386 | } | |
1387 | cur = b; | |
1388 | while ( (cur = c ur.parentN ode) ) { | |
1389 | bp .unshift( cur ); | |
1390 | } | |
1391 | ||
1392 | // Wal k down the tree look ing for a discrepanc y | |
1393 | while ( ap[i] == = bp[i] ) { | |
1394 | i+ +; | |
1395 | } | |
1396 | ||
1397 | return i ? | |
1398 | // Do a sibl ing check if the nod es have a common anc estor | |
1399 | si blingCheck ( ap[i], b p[i] ) : | |
1400 | ||
1401 | // Otherwise nodes in our docume nt sort fi rst | |
1402 | ap[i] == = preferre dDoc ? -1 : | |
1403 | bp[i] == = preferre dDoc ? 1 : | |
1404 | 0; | |
1405 | }; | |
1406 | ||
1407 | retu rn doc; | |
1408 | }; | |
1409 | ||
1410 | Sizzle.m atches = f unction( e xpr, eleme nts ) { | |
1411 | retu rn Sizzle( expr, nul l, null, e lements ); | |
1412 | }; | |
1413 | ||
1414 | Sizzle.m atchesSele ctor = fun ction( ele m, expr ) { | |
1415 | // S et documen t vars if needed | |
1416 | if ( ( elem.ow nerDocumen t || elem ) !== docu ment ) { | |
1417 | setDocumen t( elem ); | |
1418 | } | |
1419 | ||
1420 | // M ake sure t hat attrib ute select ors are qu oted | |
1421 | expr = expr.re place( rat tributeQuo tes, "='$1 ']" ); | |
1422 | ||
1423 | if ( support.m atchesSele ctor && do cumentIsHT ML && | |
1424 | ( !rbuggyM atches || !rbuggyMat ches.test( expr ) ) && | |
1425 | ( !rbuggyQ SA || !rbuggyQSA .test( exp r ) ) ) { | |
1426 | ||
1427 | try { | |
1428 | var re t = matche s.call( el em, expr ) ; | |
1429 | ||
1430 | // IE 9's matche sSelector returns fa lse on dis connected nodes | |
1431 | if ( r et || supp ort.discon nectedMatc h || | |
1432 | // As well, disconnect ed nodes a re said to be in a d ocument | |
1433 | // fragment in IE 9 | |
1434 | el em.documen t && elem. document.n odeType != = 11 ) { | |
1435 | re turn ret; | |
1436 | } | |
1437 | } catch(e) {} | |
1438 | } | |
1439 | ||
1440 | retu rn Sizzle( expr, doc ument, nul l, [ elem ] ).length > 0; | |
1441 | }; | |
1442 | ||
1443 | Sizzle.c ontains = function( context, e lem ) { | |
1444 | // S et documen t vars if needed | |
1445 | if ( ( context .ownerDocu ment || co ntext ) != = document ) { | |
1446 | setDocumen t( context ); | |
1447 | } | |
1448 | retu rn contain s( context , elem ); | |
1449 | }; | |
1450 | ||
1451 | Sizzle.a ttr = func tion( elem , name ) { | |
1452 | // S et documen t vars if needed | |
1453 | if ( ( elem.ow nerDocumen t || elem ) !== docu ment ) { | |
1454 | setDocumen t( elem ); | |
1455 | } | |
1456 | ||
1457 | var fn = Expr. attrHandle [ name.toL owerCase() ], | |
1458 | // D on't get f ooled by O bject.prot otype prop erties (jQ uery #1380 7) | |
1459 | val = fn & & hasOwn.c all( Expr. attrHandle , name.toL owerCase() ) ? | |
1460 | fn( el em, name, !documentI sHTML ) : | |
1461 | undefi ned; | |
1462 | ||
1463 | retu rn val !== undefined ? | |
1464 | val : | |
1465 | suppor t.attribut es || !doc umentIsHTM L ? | |
1466 | elem.getAt tribute( n ame ) : | |
1467 | (val = elem.getA ttributeNo de(name)) && val.spe cified ? | |
1468 | val.value : | |
1469 | null; | |
1470 | }; | |
1471 | ||
1472 | Sizzle.e rror = fun ction( msg ) { | |
1473 | thro w new Erro r( "Syntax error, un recognized expressio n: " + msg ); | |
1474 | }; | |
1475 | ||
1476 | /** | |
1477 | * Docum ent sortin g and remo ving dupli cates | |
1478 | * @para m {ArrayLi ke} result s | |
1479 | */ | |
1480 | Sizzle.u niqueSort = function ( results ) { | |
1481 | var elem, | |
1482 | duplicates = [], | |
1483 | j = 0, | |
1484 | i = 0; | |
1485 | ||
1486 | // U nless we * know* we c an detect duplicates , assume t heir prese nce | |
1487 | hasD uplicate = !support. detectDupl icates; | |
1488 | sort Input = !s upport.sor tStable && results.s lice( 0 ); | |
1489 | resu lts.sort( sortOrder ); | |
1490 | ||
1491 | if ( hasDuplic ate ) { | |
1492 | while ( (e lem = resu lts[i++]) ) { | |
1493 | if ( e lem === re sults[ i ] ) { | |
1494 | j = duplicat es.push( i ); | |
1495 | } | |
1496 | } | |
1497 | while ( j- - ) { | |
1498 | result s.splice( duplicates [ j ], 1 ) ; | |
1499 | } | |
1500 | } | |
1501 | ||
1502 | // C lear input after sor ting to re lease obje cts | |
1503 | // S ee https:/ /github.co m/jquery/s izzle/pull /225 | |
1504 | sort Input = nu ll; | |
1505 | ||
1506 | retu rn results ; | |
1507 | }; | |
1508 | ||
1509 | /** | |
1510 | * Utili ty functio n for retr ieving the text valu e of an ar ray of DOM nodes | |
1511 | * @para m {Array|E lement} el em | |
1512 | */ | |
1513 | getText = Sizzle.g etText = f unction( e lem ) { | |
1514 | var node, | |
1515 | ret = "", | |
1516 | i = 0, | |
1517 | nodeType = elem.node Type; | |
1518 | ||
1519 | if ( !nodeType ) { | |
1520 | // If no n odeType, t his is exp ected to b e an array | |
1521 | while ( (n ode = elem [i++]) ) { | |
1522 | // Do not traver se comment nodes | |
1523 | ret += getText( node ); | |
1524 | } | |
1525 | } el se if ( no deType === 1 || node Type === 9 || nodeTy pe === 11 ) { | |
1526 | // Use tex tContent f or element s | |
1527 | // innerTe xt usage r emoved for consisten cy of new lines (jQu ery #11153 ) | |
1528 | if ( typeo f elem.tex tContent = == "string " ) { | |
1529 | return elem.text Content; | |
1530 | } else { | |
1531 | // Tra verse its children | |
1532 | for ( elem = ele m.firstChi ld; elem; elem = ele m.nextSibl ing ) { | |
1533 | re t += getTe xt( elem ) ; | |
1534 | } | |
1535 | } | |
1536 | } el se if ( no deType === 3 || node Type === 4 ) { | |
1537 | return ele m.nodeValu e; | |
1538 | } | |
1539 | // D o not incl ude commen t or proce ssing inst ruction no des | |
1540 | ||
1541 | retu rn ret; | |
1542 | }; | |
1543 | ||
1544 | Expr = S izzle.sele ctors = { | |
1545 | ||
1546 | // C an be adju sted by th e user | |
1547 | cach eLength: 5 0, | |
1548 | ||
1549 | crea tePseudo: markFuncti on, | |
1550 | ||
1551 | matc h: matchEx pr, | |
1552 | ||
1553 | attr Handle: {} , | |
1554 | ||
1555 | find : {}, | |
1556 | ||
1557 | rela tive: { | |
1558 | ">": { dir : "parentN ode", firs t: true }, | |
1559 | " ": { dir : "parentN ode" }, | |
1560 | "+": { dir : "previou sSibling", first: tr ue }, | |
1561 | "~": { dir : "previou sSibling" } | |
1562 | }, | |
1563 | ||
1564 | preF ilter: { | |
1565 | "ATTR": fu nction( ma tch ) { | |
1566 | match[ 1] = match [1].replac e( runesca pe, funesc ape ); | |
1567 | ||
1568 | // Mov e the give n value to match[3] whether qu oted or un quoted | |
1569 | match[ 3] = ( mat ch[3] || m atch[4] || match[5] || "" ).re place( run escape, fu nescape ); | |
1570 | ||
1571 | if ( m atch[2] == = "~=" ) { | |
1572 | ma tch[3] = " " + match [3] + " "; | |
1573 | } | |
1574 | ||
1575 | return match.sli ce( 0, 4 ) ; | |
1576 | }, | |
1577 | ||
1578 | "CHILD": f unction( m atch ) { | |
1579 | /* mat ches from matchExpr[ "CHILD"] | |
1580 | 1 typ e (only|nt h|...) | |
1581 | 2 wha t (child|o f-type) | |
1582 | 3 arg ument (eve n|odd|\d*| \d*n([+-]\ d+)?|...) | |
1583 | 4 xn- component of xn+y ar gument ([+ -]?\d*n|) | |
1584 | 5 sig n of xn-co mponent | |
1585 | 6 x o f xn-compo nent | |
1586 | 7 sig n of y-com ponent | |
1587 | 8 y o f y-compon ent | |
1588 | */ | |
1589 | match[ 1] = match [1].toLowe rCase(); | |
1590 | ||
1591 | if ( m atch[1].sl ice( 0, 3 ) === "nth " ) { | |
1592 | // nth-* req uires argu ment | |
1593 | if ( !match[ 3] ) { | |
1594 | Sizzle.e rror( matc h[0] ); | |
1595 | } | |
1596 | ||
1597 | // numeric x and y par ameters fo r Expr.fil ter.CHILD | |
1598 | // remember that false /true cast respectiv ely to 0/1 | |
1599 | ma tch[4] = + ( match[4] ? match[5 ] + (match [6] || 1) : 2 * ( ma tch[3] === "even" || match[3] === "odd" ) ); | |
1600 | ma tch[5] = + ( ( match[ 7] + match [8] ) || m atch[3] == = "odd" ); | |
1601 | ||
1602 | // other typ es prohibi t argument s | |
1603 | } else if ( matc h[3] ) { | |
1604 | Si zzle.error ( match[0] ); | |
1605 | } | |
1606 | ||
1607 | return match; | |
1608 | }, | |
1609 | ||
1610 | "PSEUDO": function( match ) { | |
1611 | var ex cess, | |
1612 | un quoted = ! match[6] & & match[2] ; | |
1613 | ||
1614 | if ( m atchExpr[" CHILD"].te st( match[ 0] ) ) { | |
1615 | re turn null; | |
1616 | } | |
1617 | ||
1618 | // Acc ept quoted arguments as-is | |
1619 | if ( m atch[3] ) { | |
1620 | ma tch[2] = m atch[4] || match[5] || ""; | |
1621 | ||
1622 | // Strip exc ess charac ters from unquoted a rguments | |
1623 | } else if ( unqu oted && rp seudo.test ( unquoted ) && | |
1624 | // Get exces s from tok enize (rec ursively) | |
1625 | (e xcess = to kenize( un quoted, tr ue )) && | |
1626 | // advance t o the next closing p arenthesis | |
1627 | (e xcess = un quoted.ind exOf( ")", unquoted. length - e xcess ) - unquoted.l ength) ) { | |
1628 | ||
1629 | // excess is a negativ e index | |
1630 | ma tch[0] = m atch[0].sl ice( 0, ex cess ); | |
1631 | ma tch[2] = u nquoted.sl ice( 0, ex cess ); | |
1632 | } | |
1633 | ||
1634 | // Ret urn only c aptures ne eded by th e pseudo f ilter meth od (type a nd argumen t) | |
1635 | return match.sli ce( 0, 3 ) ; | |
1636 | } | |
1637 | }, | |
1638 | ||
1639 | filt er: { | |
1640 | ||
1641 | "TAG": fun ction( nod eNameSelec tor ) { | |
1642 | var no deName = n odeNameSel ector.repl ace( runes cape, fune scape ).to LowerCase( ); | |
1643 | return nodeNameS elector == = "*" ? | |
1644 | fu nction() { return tr ue; } : | |
1645 | fu nction( el em ) { | |
1646 | return e lem.nodeNa me && elem .nodeName. toLowerCas e() === no deName; | |
1647 | }; | |
1648 | }, | |
1649 | ||
1650 | "CLASS": f unction( c lassName ) { | |
1651 | var pa ttern = cl assCache[ className + " " ]; | |
1652 | ||
1653 | return pattern | | | |
1654 | (p attern = n ew RegExp( "(^|" + w hitespace + ")" + cl assName + "(" + whit espace + " |$)" )) && | |
1655 | cl assCache( className, function( elem ) { | |
1656 | return p attern.tes t( typeof elem.class Name === " string" && elem.clas sName || t ypeof elem .getAttrib ute !== st rundefined && elem.g etAttribut e("class") || "" ); | |
1657 | }) ; | |
1658 | }, | |
1659 | ||
1660 | "ATTR": fu nction( na me, operat or, check ) { | |
1661 | return function( elem ) { | |
1662 | va r result = Sizzle.at tr( elem, name ); | |
1663 | ||
1664 | if ( result == null ) { | |
1665 | return o perator == = "!="; | |
1666 | } | |
1667 | if ( !operat or ) { | |
1668 | return t rue; | |
1669 | } | |
1670 | ||
1671 | re sult += "" ; | |
1672 | ||
1673 | re turn opera tor === "= " ? result === check : | |
1674 | oper ator === " !=" ? resu lt !== che ck : | |
1675 | oper ator === " ^=" ? chec k && resul t.indexOf( check ) = == 0 : | |
1676 | oper ator === " *=" ? chec k && resul t.indexOf( check ) > -1 : | |
1677 | oper ator === " $=" ? chec k && resul t.slice( - check.leng th ) === c heck : | |
1678 | oper ator === " ~=" ? ( " " + result + " " ).i ndexOf( ch eck ) > -1 : | |
1679 | oper ator === " |=" ? resu lt === che ck || resu lt.slice( 0, check.l ength + 1 ) === chec k + "-" : | |
1680 | false; | |
1681 | }; | |
1682 | }, | |
1683 | ||
1684 | "CHILD": f unction( t ype, what, argument, first, la st ) { | |
1685 | var si mple = typ e.slice( 0 , 3 ) !== "nth", | |
1686 | fo rward = ty pe.slice( -4 ) !== " last", | |
1687 | of Type = wha t === "of- type"; | |
1688 | ||
1689 | return first === 1 && last === 0 ? | |
1690 | ||
1691 | // Shortcut for :nth-* (n) | |
1692 | fu nction( el em ) { | |
1693 | return ! !elem.pare ntNode; | |
1694 | } : | |
1695 | ||
1696 | fu nction( el em, contex t, xml ) { | |
1697 | var cach e, outerCa che, node, diff, nod eIndex, st art, | |
1698 | dir = simple ! == forward ? "nextSi bling" : " previousSi bling", | |
1699 | pare nt = elem. parentNode , | |
1700 | name = ofType && elem.no deName.toL owerCase() , | |
1701 | useC ache = !xm l && !ofTy pe; | |
1702 | ||
1703 | if ( par ent ) { | |
1704 | ||
1705 | // : (first|las t|only)-(c hild|of-ty pe) | |
1706 | if ( simple ) { | |
1707 | while ( di r ) { | |
1708 | node = elem; | |
1709 | while ( (node = node[ dir ]) ) { | |
1710 | if ( ofType ? node.nod eName.toLo werCase() === name : node.node Type === 1 ) { | |
1711 | return f alse; | |
1712 | } | |
1713 | } | |
1714 | // Rev erse direc tion for : only-* (if we haven' t yet done so) | |
1715 | start = dir = ty pe === "on ly" && !st art && "ne xtSibling" ; | |
1716 | } | |
1717 | return tru e; | |
1718 | } | |
1719 | ||
1720 | star t = [ forw ard ? pare nt.firstCh ild : pare nt.lastChi ld ]; | |
1721 | ||
1722 | // n on-xml :nt h-child(.. .) stores cache data on `paren t` | |
1723 | if ( forward & & useCache ) { | |
1724 | // Seek `e lem` from a previous ly-cached index | |
1725 | outerCache = parent[ expando ] || (paren t[ expando ] = {}); | |
1726 | cache = ou terCache[ type ] || []; | |
1727 | nodeIndex = cache[0] === dirru ns && cach e[1]; | |
1728 | diff = cac he[0] === dirruns && cache[2]; | |
1729 | node = nod eIndex && parent.chi ldNodes[ n odeIndex ] ; | |
1730 | ||
1731 | while ( (n ode = ++no deIndex && node && n ode[ dir ] || | |
1732 | ||
1733 | // Fal lback to s eeking `el em` from t he start | |
1734 | (diff = nodeInde x = 0) || start.pop( )) ) { | |
1735 | ||
1736 | // Whe n found, c ache index es on `par ent` and b reak | |
1737 | if ( n ode.nodeTy pe === 1 & & ++diff & & node === elem ) { | |
1738 | ou terCache[ type ] = [ dirruns, nodeIndex, diff ]; | |
1739 | br eak; | |
1740 | } | |
1741 | } | |
1742 | ||
1743 | // Use pre viously-ca ched eleme nt index i f availabl e | |
1744 | } el se if ( us eCache && (cache = ( elem[ expa ndo ] || ( elem[ expa ndo ] = {} ))[ type ] ) && cache [0] === di rruns ) { | |
1745 | diff = cac he[1]; | |
1746 | ||
1747 | // xml :nt h-child(.. .) or :nth -last-chil d(...) or :nth(-last )?-of-type (...) | |
1748 | } el se { | |
1749 | // Use the same loop as above to seek `e lem` from the start | |
1750 | while ( (n ode = ++no deIndex && node && n ode[ dir ] || | |
1751 | (diff = nodeInde x = 0) || start.pop( )) ) { | |
1752 | ||
1753 | if ( ( ofType ? node.nodeN ame.toLowe rCase() == = name : n ode.nodeTy pe === 1 ) && ++diff ) { | |
1754 | // Cache the index of each encou ntered ele ment | |
1755 | if ( useCach e ) { | |
1756 | (node[ e xpando ] | | (node[ e xpando ] = {}))[ typ e ] = [ di rruns, dif f ]; | |
1757 | } | |
1758 | ||
1759 | if ( node == = elem ) { | |
1760 | break; | |
1761 | } | |
1762 | } | |
1763 | } | |
1764 | } | |
1765 | ||
1766 | // I ncorporate the offse t, then ch eck agains t cycle si ze | |
1767 | diff -= last; | |
1768 | retu rn diff == = first || ( diff % first === 0 && diff / first >= 0 ); | |
1769 | } | |
1770 | }; | |
1771 | }, | |
1772 | ||
1773 | "PSEUDO": function( pseudo, ar gument ) { | |
1774 | // pse udo-class names are case-insen sitive | |
1775 | // htt p://www.w3 .org/TR/se lectors/#p seudo-clas ses | |
1776 | // Pri oritize by case sens itivity in case cust om pseudos are added with uppe rcase lett ers | |
1777 | // Rem ember that setFilter s inherits from pseu dos | |
1778 | var ar gs, | |
1779 | fn = Expr.ps eudos[ pse udo ] || E xpr.setFil ters[ pseu do.toLower Case() ] | | | |
1780 | Sizzle.e rror( "uns upported p seudo: " + pseudo ); | |
1781 | ||
1782 | // The user may use create Pseudo to indicate t hat | |
1783 | // arg uments are needed to create th e filter f unction | |
1784 | // jus t as Sizzl e does | |
1785 | if ( f n[ expando ] ) { | |
1786 | re turn fn( a rgument ); | |
1787 | } | |
1788 | ||
1789 | // But maintain support fo r old sign atures | |
1790 | if ( f n.length > 1 ) { | |
1791 | ar gs = [ pse udo, pseud o, "", arg ument ]; | |
1792 | re turn Expr. setFilters .hasOwnPro perty( pse udo.toLowe rCase() ) ? | |
1793 | markFunc tion(funct ion( seed, matches ) { | |
1794 | var idx, | |
1795 | matched = fn( seed, argument ) , | |
1796 | i = matche d.length; | |
1797 | whil e ( i-- ) { | |
1798 | idx = inde xOf.call( seed, matc hed[i] ); | |
1799 | seed[ idx ] = !( mat ches[ idx ] = matche d[i] ); | |
1800 | } | |
1801 | }) : | |
1802 | function ( elem ) { | |
1803 | retu rn fn( ele m, 0, args ); | |
1804 | }; | |
1805 | } | |
1806 | ||
1807 | return fn; | |
1808 | } | |
1809 | }, | |
1810 | ||
1811 | pseu dos: { | |
1812 | // Potenti ally compl ex pseudos | |
1813 | "not": mar kFunction( function( selector ) { | |
1814 | // Tri m the sele ctor passe d to compi le | |
1815 | // to avoid trea ting leadi ng and tra iling | |
1816 | // spa ces as com binators | |
1817 | var in put = [], | |
1818 | re sults = [] , | |
1819 | ma tcher = co mpile( sel ector.repl ace( rtrim , "$1" ) ) ; | |
1820 | ||
1821 | return matcher[ expando ] ? | |
1822 | ma rkFunction (function( seed, mat ches, cont ext, xml ) { | |
1823 | var elem , | |
1824 | unma tched = ma tcher( see d, null, x ml, [] ), | |
1825 | i = seed.lengt h; | |
1826 | ||
1827 | // Match elements unmatched by `matche r` | |
1828 | while ( i-- ) { | |
1829 | if ( (elem = u nmatched[i ]) ) { | |
1830 | seed[i] = !(matches[ i] = elem) ; | |
1831 | } | |
1832 | } | |
1833 | }) : | |
1834 | fu nction( el em, contex t, xml ) { | |
1835 | input[0] = elem; | |
1836 | matcher( input, nu ll, xml, r esults ); | |
1837 | return ! results.po p(); | |
1838 | }; | |
1839 | }), | |
1840 | ||
1841 | "has": mar kFunction( function( selector ) { | |
1842 | return function( elem ) { | |
1843 | re turn Sizzl e( selecto r, elem ). length > 0 ; | |
1844 | }; | |
1845 | }), | |
1846 | ||
1847 | "contains" : markFunc tion(funct ion( text ) { | |
1848 | return function( elem ) { | |
1849 | re turn ( ele m.textCont ent || ele m.innerTex t || getTe xt( elem ) ).indexOf ( text ) > -1; | |
1850 | }; | |
1851 | }), | |
1852 | ||
1853 | // "Whethe r an eleme nt is repr esented by a :lang() selector | |
1854 | // is base d solely o n the elem ent's lang uage value | |
1855 | // being e qual to th e identifi er C, | |
1856 | // or begi nning with the ident ifier C im mediately followed b y "-". | |
1857 | // The mat ching of C against t he element 's languag e value is performed case-inse nsitively. | |
1858 | // The ide ntifier C does not h ave to be a valid la nguage nam e." | |
1859 | // http:// www.w3.org /TR/select ors/#lang- pseudo | |
1860 | "lang": ma rkFunction ( function ( lang ) { | |
1861 | // lan g value mu st be a va lid identi fier | |
1862 | if ( ! ridentifie r.test(lan g || "") ) { | |
1863 | Si zzle.error ( "unsuppo rted lang: " + lang ); | |
1864 | } | |
1865 | lang = lang.repl ace( runes cape, fune scape ).to LowerCase( ); | |
1866 | return function( elem ) { | |
1867 | va r elemLang ; | |
1868 | do { | |
1869 | if ( (el emLang = d ocumentIsH TML ? | |
1870 | elem .lang : | |
1871 | elem .getAttrib ute("xml:l ang") || e lem.getAtt ribute("la ng")) ) { | |
1872 | ||
1873 | elem Lang = ele mLang.toLo werCase(); | |
1874 | retu rn elemLan g === lang || elemLa ng.indexOf ( lang + " -" ) === 0 ; | |
1875 | } | |
1876 | } while ( (e lem = elem .parentNod e) && elem .nodeType === 1 ); | |
1877 | re turn false ; | |
1878 | }; | |
1879 | }), | |
1880 | ||
1881 | // Miscell aneous | |
1882 | "target": function( elem ) { | |
1883 | var ha sh = windo w.location && window .location. hash; | |
1884 | return hash && h ash.slice( 1 ) === e lem.id; | |
1885 | }, | |
1886 | ||
1887 | "root": fu nction( el em ) { | |
1888 | return elem === docElem; | |
1889 | }, | |
1890 | ||
1891 | "focus": f unction( e lem ) { | |
1892 | return elem === document.a ctiveEleme nt && (!do cument.has Focus || d ocument.ha sFocus()) && !!(elem .type || e lem.href | | ~elem.ta bIndex); | |
1893 | }, | |
1894 | ||
1895 | // Boolean propertie s | |
1896 | "enabled": function( elem ) { | |
1897 | return elem.disa bled === f alse; | |
1898 | }, | |
1899 | ||
1900 | "disabled" : function ( elem ) { | |
1901 | return elem.disa bled === t rue; | |
1902 | }, | |
1903 | ||
1904 | "checked": function( elem ) { | |
1905 | // In CSS3, :che cked shoul d return b oth checke d and sele cted eleme nts | |
1906 | // htt p://www.w3 .org/TR/20 11/REC-css 3-selector s-20110929 /#checked | |
1907 | var no deName = e lem.nodeNa me.toLower Case(); | |
1908 | return (nodeName === "inpu t" && !!el em.checked ) || (node Name === " option" && !!elem.se lected); | |
1909 | }, | |
1910 | ||
1911 | "selected" : function ( elem ) { | |
1912 | // Acc essing thi s property makes sel ected-by-d efault | |
1913 | // opt ions in Sa fari work properly | |
1914 | if ( e lem.parent Node ) { | |
1915 | el em.parentN ode.select edIndex; | |
1916 | } | |
1917 | ||
1918 | return elem.sele cted === t rue; | |
1919 | }, | |
1920 | ||
1921 | // Content s | |
1922 | "empty": f unction( e lem ) { | |
1923 | // htt p://www.w3 .org/TR/se lectors/#e mpty-pseud o | |
1924 | // :em pty is neg ated by el ement (1) or resourc es nodes ( text: 3; c data: 4; e ntity ref: 5), | |
1925 | // b ut not by others (co mment: 8; processing instructi on: 7; etc .) | |
1926 | // nod eType < 6 works beca use attrib utes (2) d o not appe ar as chil dren | |
1927 | for ( elem = ele m.firstChi ld; elem; elem = ele m.nextSibl ing ) { | |
1928 | if ( elem.no deType < 6 ) { | |
1929 | return f alse; | |
1930 | } | |
1931 | } | |
1932 | return true; | |
1933 | }, | |
1934 | ||
1935 | "parent": function( elem ) { | |
1936 | return !Expr.pse udos["empt y"]( elem ); | |
1937 | }, | |
1938 | ||
1939 | // Element /input typ es | |
1940 | "header": function( elem ) { | |
1941 | return rheader.t est( elem. nodeName ) ; | |
1942 | }, | |
1943 | ||
1944 | "input": f unction( e lem ) { | |
1945 | return rinputs.t est( elem. nodeName ) ; | |
1946 | }, | |
1947 | ||
1948 | "button": function( elem ) { | |
1949 | var na me = elem. nodeName.t oLowerCase (); | |
1950 | return name === "input" && elem.type === "butt on" || nam e === "but ton"; | |
1951 | }, | |
1952 | ||
1953 | "text": fu nction( el em ) { | |
1954 | var at tr; | |
1955 | return elem.node Name.toLow erCase() = == "input" && | |
1956 | el em.type == = "text" & & | |
1957 | ||
1958 | // Support: IE<8 | |
1959 | // New HTML5 attribute values (e .g., "sear ch") appea r with ele m.type === "text" | |
1960 | ( (attr = el em.getAttr ibute("typ e")) == nu ll || attr .toLowerCa se() === " text" ); | |
1961 | }, | |
1962 | ||
1963 | // Positio n-in-colle ction | |
1964 | "first": c reatePosit ionalPseud o(function () { | |
1965 | return [ 0 ]; | |
1966 | }), | |
1967 | ||
1968 | "last": cr eatePositi onalPseudo (function( matchInde xes, lengt h ) { | |
1969 | return [ length - 1 ]; | |
1970 | }), | |
1971 | ||
1972 | "eq": crea tePosition alPseudo(f unction( m atchIndexe s, length, argument ) { | |
1973 | return [ argumen t < 0 ? ar gument + l ength : ar gument ]; | |
1974 | }), | |
1975 | ||
1976 | "even": cr eatePositi onalPseudo (function( matchInde xes, lengt h ) { | |
1977 | var i = 0; | |
1978 | for ( ; i < leng th; i += 2 ) { | |
1979 | ma tchIndexes .push( i ) ; | |
1980 | } | |
1981 | return matchInde xes; | |
1982 | }), | |
1983 | ||
1984 | "odd": cre atePositio nalPseudo( function( matchIndex es, length ) { | |
1985 | var i = 1; | |
1986 | for ( ; i < leng th; i += 2 ) { | |
1987 | ma tchIndexes .push( i ) ; | |
1988 | } | |
1989 | return matchInde xes; | |
1990 | }), | |
1991 | ||
1992 | "lt": crea tePosition alPseudo(f unction( m atchIndexe s, length, argument ) { | |
1993 | var i = argument < 0 ? arg ument + le ngth : arg ument; | |
1994 | for ( ; --i >= 0 ; ) { | |
1995 | ma tchIndexes .push( i ) ; | |
1996 | } | |
1997 | return matchInde xes; | |
1998 | }), | |
1999 | ||
2000 | "gt": crea tePosition alPseudo(f unction( m atchIndexe s, length, argument ) { | |
2001 | var i = argument < 0 ? arg ument + le ngth : arg ument; | |
2002 | for ( ; ++i < le ngth; ) { | |
2003 | ma tchIndexes .push( i ) ; | |
2004 | } | |
2005 | return matchInde xes; | |
2006 | }) | |
2007 | } | |
2008 | }; | |
2009 | ||
2010 | Expr.pse udos["nth" ] = Expr.p seudos["eq "]; | |
2011 | ||
2012 | // Add but ton/input type pseud os | |
2013 | for ( i in { radio : true, ch eckbox: tr ue, file: true, pass word: true , image: t rue } ) { | |
2014 | Expr .pseudos[ i ] = crea teInputPse udo( i ); | |
2015 | } | |
2016 | for ( i in { submi t: true, r eset: true } ) { | |
2017 | Expr .pseudos[ i ] = crea teButtonPs eudo( i ); | |
2018 | } | |
2019 | ||
2020 | // Easy AP I for crea ting new s etFilters | |
2021 | function setFilter s() {} | |
2022 | setFilte rs.prototy pe = Expr. filters = Expr.pseud os; | |
2023 | Expr.set Filters = new setFil ters(); | |
2024 | ||
2025 | tokenize = Sizzle. tokenize = function( selector, parseOnly ) { | |
2026 | var matched, m atch, toke ns, type, | |
2027 | soFar, gro ups, preFi lters, | |
2028 | cached = t okenCache[ selector + " " ]; | |
2029 | ||
2030 | if ( cached ) { | |
2031 | return par seOnly ? 0 : cached. slice( 0 ) ; | |
2032 | } | |
2033 | ||
2034 | soFa r = select or; | |
2035 | grou ps = []; | |
2036 | preF ilters = E xpr.preFil ter; | |
2037 | ||
2038 | whil e ( soFar ) { | |
2039 | ||
2040 | // Comma a nd first r un | |
2041 | if ( !matc hed || (ma tch = rcom ma.exec( s oFar )) ) { | |
2042 | if ( m atch ) { | |
2043 | // Don't con sume trail ing commas as valid | |
2044 | so Far = soFa r.slice( m atch[0].le ngth ) || soFar; | |
2045 | } | |
2046 | groups .push( (to kens = []) ); | |
2047 | } | |
2048 | ||
2049 | matched = false; | |
2050 | ||
2051 | // Combina tors | |
2052 | if ( (matc h = rcombi nators.exe c( soFar ) ) ) { | |
2053 | matche d = match. shift(); | |
2054 | tokens .push({ | |
2055 | va lue: match ed, | |
2056 | // Cast desc endant com binators t o space | |
2057 | ty pe: match[ 0].replace ( rtrim, " " ) | |
2058 | }); | |
2059 | soFar = soFar.sl ice( match ed.length ); | |
2060 | } | |
2061 | ||
2062 | // Filters | |
2063 | for ( type in Expr.f ilter ) { | |
2064 | if ( ( match = ma tchExpr[ t ype ].exec ( soFar )) && (!preF ilters[ ty pe ] || | |
2065 | (m atch = pre Filters[ t ype ]( mat ch ))) ) { | |
2066 | ma tched = ma tch.shift( ); | |
2067 | to kens.push( { | |
2068 | value: m atched, | |
2069 | type: ty pe, | |
2070 | matches: match | |
2071 | }) ; | |
2072 | so Far = soFa r.slice( m atched.len gth ); | |
2073 | } | |
2074 | } | |
2075 | ||
2076 | if ( !matc hed ) { | |
2077 | break; | |
2078 | } | |
2079 | } | |
2080 | ||
2081 | // R eturn the length of the invali d excess | |
2082 | // i f we're ju st parsing | |
2083 | // O therwise, throw an e rror or re turn token s | |
2084 | retu rn parseOn ly ? | |
2085 | soFar.leng th : | |
2086 | soFar ? | |
2087 | Sizzle .error( se lector ) : | |
2088 | // Cac he the tok ens | |
2089 | tokenC ache( sele ctor, grou ps ).slice ( 0 ); | |
2090 | }; | |
2091 | ||
2092 | function toSelecto r( tokens ) { | |
2093 | var i = 0, | |
2094 | len = toke ns.length, | |
2095 | selector = ""; | |
2096 | for ( ; i < le n; i++ ) { | |
2097 | selector + = tokens[i ].value; | |
2098 | } | |
2099 | retu rn selecto r; | |
2100 | } | |
2101 | ||
2102 | function addCombin ator( matc her, combi nator, bas e ) { | |
2103 | var dir = comb inator.dir , | |
2104 | checkNonEl ements = b ase && dir === "pare ntNode", | |
2105 | doneName = done++; | |
2106 | ||
2107 | retu rn combina tor.first ? | |
2108 | // Check a gainst clo sest ances tor/preced ing elemen t | |
2109 | function( elem, cont ext, xml ) { | |
2110 | while ( (elem = elem[ dir ]) ) { | |
2111 | if ( elem.no deType === 1 || chec kNonElemen ts ) { | |
2112 | return m atcher( el em, contex t, xml ); | |
2113 | } | |
2114 | } | |
2115 | } : | |
2116 | ||
2117 | // Check a gainst all ancestor/ preceding elements | |
2118 | function( elem, cont ext, xml ) { | |
2119 | var ol dCache, ou terCache, | |
2120 | ne wCache = [ dirruns, doneName ] ; | |
2121 | ||
2122 | // We can't set arbitrary data on XM L nodes, s o they don 't benefit from dir caching | |
2123 | if ( x ml ) { | |
2124 | wh ile ( (ele m = elem[ dir ]) ) { | |
2125 | if ( ele m.nodeType === 1 || checkNonEl ements ) { | |
2126 | if ( matcher( elem, cont ext, xml ) ) { | |
2127 | return tru e; | |
2128 | } | |
2129 | } | |
2130 | } | |
2131 | } else { | |
2132 | wh ile ( (ele m = elem[ dir ]) ) { | |
2133 | if ( ele m.nodeType === 1 || checkNonEl ements ) { | |
2134 | oute rCache = e lem[ expan do ] || (e lem[ expan do ] = {}) ; | |
2135 | if ( (oldCache = outerCa che[ dir ] ) && | |
2136 | oldCache[ 0 ] === di rruns && o ldCache[ 1 ] === don eName ) { | |
2137 | ||
2138 | // Assign to newCach e so resul ts back-pr opagate to previous elements | |
2139 | return (ne wCache[ 2 ] = oldCac he[ 2 ]); | |
2140 | } el se { | |
2141 | // Reuse n ewcache so results b ack-propag ate to pre vious elem ents | |
2142 | outerCache [ dir ] = newCache; | |
2143 | ||
2144 | // A match means we' re done; a fail mean s we have to keep ch ecking | |
2145 | if ( (newC ache[ 2 ] = matcher( elem, con text, xml )) ) { | |
2146 | return true; | |
2147 | } | |
2148 | } | |
2149 | } | |
2150 | } | |
2151 | } | |
2152 | }; | |
2153 | } | |
2154 | ||
2155 | function elementMa tcher( mat chers ) { | |
2156 | retu rn matcher s.length > 1 ? | |
2157 | function( elem, cont ext, xml ) { | |
2158 | var i = matchers .length; | |
2159 | while ( i-- ) { | |
2160 | if ( !matche rs[i]( ele m, context , xml ) ) { | |
2161 | return f alse; | |
2162 | } | |
2163 | } | |
2164 | return true; | |
2165 | } : | |
2166 | matchers[0 ]; | |
2167 | } | |
2168 | ||
2169 | function multipleC ontexts( s elector, c ontexts, r esults ) { | |
2170 | var i = 0, | |
2171 | len = cont exts.lengt h; | |
2172 | for ( ; i < le n; i++ ) { | |
2173 | Sizzle( se lector, co ntexts[i], results ) ; | |
2174 | } | |
2175 | retu rn results ; | |
2176 | } | |
2177 | ||
2178 | function condense( unmatched , map, fil ter, conte xt, xml ) { | |
2179 | var elem, | |
2180 | newUnmatch ed = [], | |
2181 | i = 0, | |
2182 | len = unma tched.leng th, | |
2183 | mapped = m ap != null ; | |
2184 | ||
2185 | for ( ; i < le n; i++ ) { | |
2186 | if ( (elem = unmatch ed[i]) ) { | |
2187 | if ( ! filter || filter( el em, contex t, xml ) ) { | |
2188 | ne wUnmatched .push( ele m ); | |
2189 | if ( mapped ) { | |
2190 | map.push ( i ); | |
2191 | } | |
2192 | } | |
2193 | } | |
2194 | } | |
2195 | ||
2196 | retu rn newUnma tched; | |
2197 | } | |
2198 | ||
2199 | function setMatche r( preFilt er, select or, matche r, postFil ter, postF inder, pos tSelector ) { | |
2200 | if ( postFilte r && !post Filter[ ex pando ] ) { | |
2201 | postFilter = setMatc her( postF ilter ); | |
2202 | } | |
2203 | if ( postFinde r && !post Finder[ ex pando ] ) { | |
2204 | postFinder = setMatc her( postF inder, pos tSelector ); | |
2205 | } | |
2206 | retu rn markFun ction(func tion( seed , results, context, xml ) { | |
2207 | var temp, i, elem, | |
2208 | preMap = [], | |
2209 | postMa p = [], | |
2210 | preexi sting = re sults.leng th, | |
2211 | ||
2212 | // Get ini tial eleme nts from s eed or con text | |
2213 | elems = seed || multipleCo ntexts( se lector || "*", conte xt.nodeTyp e ? [ cont ext ] : co ntext, [] ), | |
2214 | ||
2215 | // Prefilt er to get matcher in put, prese rving a ma p for seed -results s ynchroniza tion | |
2216 | matche rIn = preF ilter && ( seed || ! selector ) ? | |
2217 | co ndense( el ems, preMa p, preFilt er, contex t, xml ) : | |
2218 | el ems, | |
2219 | ||
2220 | matche rOut = mat cher ? | |
2221 | // If we hav e a postFi nder, or f iltered se ed, or non -seed post Filter or preexistin g results, | |
2222 | postFind er || ( se ed ? preFi lter : pre existing | | postFilt er ) ? | |
2223 | ||
2224 | // ...interm ediate pro cessing is necessary | |
2225 | [] : | |
2226 | ||
2227 | // ...otherw ise use re sults dire ctly | |
2228 | re sults : | |
2229 | ma tcherIn; | |
2230 | ||
2231 | // Find pr imary matc hes | |
2232 | if ( match er ) { | |
2233 | matche r( matcher In, matche rOut, cont ext, xml ) ; | |
2234 | } | |
2235 | ||
2236 | // Apply p ostFilter | |
2237 | if ( postF ilter ) { | |
2238 | temp = condense( matcherOu t, postMap ); | |
2239 | postFi lter( temp , [], cont ext, xml ) ; | |
2240 | ||
2241 | // Un- match fail ing elemen ts by movi ng them ba ck to matc herIn | |
2242 | i = te mp.length; | |
2243 | while ( i-- ) { | |
2244 | if ( (elem = temp[i]) ) { | |
2245 | matcherO ut[ postMa p[i] ] = ! (matcherIn [ postMap[ i] ] = ele m); | |
2246 | } | |
2247 | } | |
2248 | } | |
2249 | ||
2250 | if ( seed ) { | |
2251 | if ( p ostFinder || preFilt er ) { | |
2252 | if ( postFin der ) { | |
2253 | // Get t he final m atcherOut by condens ing this i ntermediat e into pos tFinder co ntexts | |
2254 | temp = [ ]; | |
2255 | i = matc herOut.len gth; | |
2256 | while ( i-- ) { | |
2257 | if ( (elem = m atcherOut[ i]) ) { | |
2258 | // Restore matcherIn since ele m is not y et a final match | |
2259 | temp.push( (matcherI n[i] = ele m) ); | |
2260 | } | |
2261 | } | |
2262 | postFind er( null, (matcherOu t = []), t emp, xml ) ; | |
2263 | } | |
2264 | ||
2265 | // Move matc hed elemen ts from se ed to resu lts to kee p them syn chronized | |
2266 | i = matcherO ut.length; | |
2267 | wh ile ( i-- ) { | |
2268 | if ( (el em = match erOut[i]) && | |
2269 | (tem p = postFi nder ? ind exOf.call( seed, ele m ) : preM ap[i]) > - 1 ) { | |
2270 | ||
2271 | seed [temp] = ! (results[t emp] = ele m); | |
2272 | } | |
2273 | } | |
2274 | } | |
2275 | ||
2276 | // Add elements to results , through postFinder if define d | |
2277 | } else { | |
2278 | matche rOut = con dense( | |
2279 | matcherO ut === res ults ? | |
2280 | matcherO ut.splice( preexisti ng, matche rOut.lengt h ) : | |
2281 | matcherO ut | |
2282 | ); | |
2283 | if ( p ostFinder ) { | |
2284 | po stFinder( null, resu lts, match erOut, xml ); | |
2285 | } else { | |
2286 | pu sh.apply( results, m atcherOut ); | |
2287 | } | |
2288 | } | |
2289 | }); | |
2290 | } | |
2291 | ||
2292 | function matcherFr omTokens( tokens ) { | |
2293 | var checkConte xt, matche r, j, | |
2294 | len = toke ns.length, | |
2295 | leadingRel ative = Ex pr.relativ e[ tokens[ 0].type ], | |
2296 | implicitRe lative = l eadingRela tive || Ex pr.relativ e[" "], | |
2297 | i = leadin gRelative ? 1 : 0, | |
2298 | ||
2299 | // T he foundat ional matc her ensure s that ele ments are reachable from top-l evel conte xt(s) | |
2300 | matchConte xt = addCo mbinator( function( elem ) { | |
2301 | return elem === checkConte xt; | |
2302 | }, implici tRelative, true ), | |
2303 | matchAnyCo ntext = ad dCombinato r( functio n( elem ) { | |
2304 | return indexOf.c all( check Context, e lem ) > -1 ; | |
2305 | }, implici tRelative, true ), | |
2306 | matchers = [ functio n( elem, c ontext, xm l ) { | |
2307 | return ( !leadin gRelative && ( xml | | context !== outerm ostContext ) ) || ( | |
2308 | (c heckContex t = contex t).nodeTyp e ? | |
2309 | matchCon text( elem , context, xml ) : | |
2310 | matchAny Context( e lem, conte xt, xml ) ); | |
2311 | } ]; | |
2312 | ||
2313 | for ( ; i < le n; i++ ) { | |
2314 | if ( (matc her = Expr .relative[ tokens[i] .type ]) ) { | |
2315 | matche rs = [ add Combinator (elementMa tcher( mat chers ), m atcher) ]; | |
2316 | } else { | |
2317 | matche r = Expr.f ilter[ tok ens[i].typ e ].apply( null, tok ens[i].mat ches ); | |
2318 | ||
2319 | // Ret urn specia l upon see ing a posi tional mat cher | |
2320 | if ( m atcher[ ex pando ] ) { | |
2321 | // Find the next relat ive operat or (if any ) for prop er handlin g | |
2322 | j = ++i; | |
2323 | fo r ( ; j < len; j++ ) { | |
2324 | if ( Exp r.relative [ tokens[j ].type ] ) { | |
2325 | brea k; | |
2326 | } | |
2327 | } | |
2328 | re turn setMa tcher( | |
2329 | i > 1 && eleme ntMatcher( matchers ), | |
2330 | i > 1 && toSel ector( | |
2331 | // I f the prec eding toke n was a de scendant c ombinator, insert an implicit any-elemen t `*` | |
2332 | toke ns.slice( 0, i - 1 ) .concat({ value: tok ens[ i - 2 ].type == = " " ? "* " : "" }) | |
2333 | ).replac e( rtrim, "$1" ), | |
2334 | matcher, | |
2335 | i < j && match erFromToke ns( tokens .slice( i, j ) ), | |
2336 | j < len && mat cherFromTo kens( (tok ens = toke ns.slice( j )) ), | |
2337 | j < len && toS elector( t okens ) | |
2338 | ); | |
2339 | } | |
2340 | matche rs.push( m atcher ); | |
2341 | } | |
2342 | } | |
2343 | ||
2344 | retu rn element Matcher( m atchers ); | |
2345 | } | |
2346 | ||
2347 | function matcherFr omGroupMat chers( ele mentMatche rs, setMat chers ) { | |
2348 | var bySet = se tMatchers. length > 0 , | |
2349 | byElement = elementM atchers.le ngth > 0, | |
2350 | superMatch er = funct ion( seed, context, xml, resul ts, outerm ost ) { | |
2351 | var el em, j, mat cher, | |
2352 | ma tchedCount = 0, | |
2353 | i = "0", | |
2354 | un matched = seed && [] , | |
2355 | se tMatched = [], | |
2356 | co ntextBacku p = outerm ostContext , | |
2357 | // We must alway s have eit her seed e lements or outermost context | |
2358 | el ems = seed || byElem ent && Exp r.find["TA G"]( "*", outermost ), | |
2359 | // Use integer d irruns iff this is t he outermo st matcher | |
2360 | di rrunsUniqu e = (dirru ns += cont extBackup == null ? 1 : Math.r andom() || 0.1), | |
2361 | le n = elems. length; | |
2362 | ||
2363 | if ( o utermost ) { | |
2364 | ou termostCon text = con text !== d ocument && context; | |
2365 | } | |
2366 | ||
2367 | // Add elements passing el ementMatch ers direct ly to resu lts | |
2368 | // Kee p `i` a st ring if th ere are no elements so `matche dCount` wi ll be "00" below | |
2369 | // Sup port: IE<9 , Safari | |
2370 | // Tol erate Node List prope rties (IE: "length"; Safari: < number>) m atching el ements by id | |
2371 | for ( ; i !== le n && (elem = elems[i ]) != null ; i++ ) { | |
2372 | if ( byEleme nt && elem ) { | |
2373 | j = 0; | |
2374 | while ( (matcher = elementMa tchers[j++ ]) ) { | |
2375 | if ( matcher( elem, cont ext, xml ) ) { | |
2376 | results.pu sh( elem ) ; | |
2377 | break; | |
2378 | } | |
2379 | } | |
2380 | if ( out ermost ) { | |
2381 | dirr uns = dirr unsUnique; | |
2382 | } | |
2383 | } | |
2384 | ||
2385 | // Track unm atched ele ments for set filter s | |
2386 | if ( bySet ) { | |
2387 | // They will have gone throu gh all pos sible matc hers | |
2388 | if ( (el em = !matc her && ele m) ) { | |
2389 | matc hedCount-- ; | |
2390 | } | |
2391 | ||
2392 | // Lengt hen the ar ray for ev ery elemen t, matched or not | |
2393 | if ( see d ) { | |
2394 | unma tched.push ( elem ); | |
2395 | } | |
2396 | } | |
2397 | } | |
2398 | ||
2399 | // App ly set fil ters to un matched el ements | |
2400 | matche dCount += i; | |
2401 | if ( b ySet && i !== matche dCount ) { | |
2402 | j = 0; | |
2403 | wh ile ( (mat cher = set Matchers[j ++]) ) { | |
2404 | matcher( unmatched , setMatch ed, contex t, xml ); | |
2405 | } | |
2406 | ||
2407 | if ( seed ) { | |
2408 | // Reint egrate ele ment match es to elim inate the need for s orting | |
2409 | if ( mat chedCount > 0 ) { | |
2410 | whil e ( i-- ) { | |
2411 | if ( !(unm atched[i] || setMatc hed[i]) ) { | |
2412 | setMat ched[i] = pop.call( results ); | |
2413 | } | |
2414 | } | |
2415 | } | |
2416 | ||
2417 | // Disca rd index p laceholder values to get only actual mat ches | |
2418 | setMatch ed = conde nse( setMa tched ); | |
2419 | } | |
2420 | ||
2421 | // Add match es to resu lts | |
2422 | pu sh.apply( results, s etMatched ); | |
2423 | ||
2424 | // Seedless set matche s succeedi ng multipl e successf ul matcher s stipulat e sorting | |
2425 | if ( outermo st && !see d && setMa tched.leng th > 0 && | |
2426 | ( matche dCount + s etMatchers .length ) > 1 ) { | |
2427 | ||
2428 | Sizzle.u niqueSort( results ) ; | |
2429 | } | |
2430 | } | |
2431 | ||
2432 | // Ove rride mani pulation o f globals by nested matchers | |
2433 | if ( o utermost ) { | |
2434 | di rruns = di rrunsUniqu e; | |
2435 | ou termostCon text = con textBackup ; | |
2436 | } | |
2437 | ||
2438 | return unmatched ; | |
2439 | }; | |
2440 | ||
2441 | retu rn bySet ? | |
2442 | markFuncti on( superM atcher ) : | |
2443 | superMatch er; | |
2444 | } | |
2445 | ||
2446 | compile = Sizzle.c ompile = f unction( s elector, m atch /* In ternal Use Only */ ) { | |
2447 | var i, | |
2448 | setMatcher s = [], | |
2449 | elementMat chers = [] , | |
2450 | cached = c ompilerCac he[ select or + " " ] ; | |
2451 | ||
2452 | if ( !cached ) { | |
2453 | // Generat e a functi on of recu rsive func tions that can be us ed to chec k each ele ment | |
2454 | if ( !matc h ) { | |
2455 | match = tokenize ( selector ); | |
2456 | } | |
2457 | i = match. length; | |
2458 | while ( i- - ) { | |
2459 | cached = matcher FromTokens ( match[i] ); | |
2460 | if ( c ached[ exp ando ] ) { | |
2461 | se tMatchers. push( cach ed ); | |
2462 | } else { | |
2463 | el ementMatch ers.push( cached ); | |
2464 | } | |
2465 | } | |
2466 | ||
2467 | // Cache t he compile d function | |
2468 | cached = c ompilerCac he( select or, matche rFromGroup Matchers( elementMat chers, set Matchers ) ); | |
2469 | ||
2470 | // Save se lector and tokenizat ion | |
2471 | cached.sel ector = se lector; | |
2472 | } | |
2473 | retu rn cached; | |
2474 | }; | |
2475 | ||
2476 | /** | |
2477 | * A low -level sel ection fun ction that works wit h Sizzle's compiled | |
2478 | * sele ctor funct ions | |
2479 | * @para m {String| Function} selector A selector or a pre-c ompiled | |
2480 | * sele ctor funct ion built with Sizzl e.compile | |
2481 | * @para m {Element } context | |
2482 | * @para m {Array} [results] | |
2483 | * @para m {Array} [seed] A s et of elem ents to ma tch agains t | |
2484 | */ | |
2485 | select = Sizzle.se lect = fun ction( sel ector, con text, resu lts, seed ) { | |
2486 | var i, tokens, token, ty pe, find, | |
2487 | compiled = typeof se lector === "function " && selec tor, | |
2488 | match = !s eed && tok enize( (se lector = c ompiled.se lector || selector) ); | |
2489 | ||
2490 | resu lts = resu lts || []; | |
2491 | ||
2492 | // T ry to mini mize opera tions if t here is no seed and only one g roup | |
2493 | if ( match.len gth === 1 ) { | |
2494 | ||
2495 | // Take a shortcut a nd set the context i f the root selector is an ID | |
2496 | tokens = m atch[0] = match[0].s lice( 0 ); | |
2497 | if ( token s.length > 2 && (tok en = token s[0]).type === "ID" && | |
2498 | suppor t.getById && context .nodeType === 9 && d ocumentIsH TML && | |
2499 | Expr.r elative[ t okens[1].t ype ] ) { | |
2500 | ||
2501 | contex t = ( Expr .find["ID" ]( token.m atches[0]. replace(ru nescape, f unescape), context ) || [] )[0 ]; | |
2502 | if ( ! context ) { | |
2503 | re turn resul ts; | |
2504 | ||
2505 | // Precompil ed matcher s will sti ll verify ancestry, so step up a level | |
2506 | } else if ( comp iled ) { | |
2507 | co ntext = co ntext.pare ntNode; | |
2508 | } | |
2509 | ||
2510 | select or = selec tor.slice( tokens.sh ift().valu e.length ) ; | |
2511 | } | |
2512 | ||
2513 | // Fetch a seed set for right- to-left ma tching | |
2514 | i = matchE xpr["needs Context"]. test( sele ctor ) ? 0 : tokens. length; | |
2515 | while ( i- - ) { | |
2516 | token = tokens[i ]; | |
2517 | ||
2518 | // Abo rt if we h it a combi nator | |
2519 | if ( E xpr.relati ve[ (type = token.ty pe) ] ) { | |
2520 | br eak; | |
2521 | } | |
2522 | if ( ( find = Exp r.find[ ty pe ]) ) { | |
2523 | // Search, e xpanding c ontext for leading s ibling com binators | |
2524 | if ( (seed = find( | |
2525 | token.ma tches[0].r eplace( ru nescape, f unescape ) , | |
2526 | rsib ling.test( tokens[0] .type ) && testConte xt( contex t.parentNo de ) || co ntext | |
2527 | )) ) { | |
2528 | ||
2529 | // If se ed is empt y or no to kens remai n, we can return ear ly | |
2530 | tokens.s plice( i, 1 ); | |
2531 | selector = seed.le ngth && to Selector( tokens ); | |
2532 | if ( !se lector ) { | |
2533 | push .apply( re sults, see d ); | |
2534 | retu rn results ; | |
2535 | } | |
2536 | ||
2537 | break; | |
2538 | } | |
2539 | } | |
2540 | } | |
2541 | } | |
2542 | ||
2543 | // C ompile and execute a filtering function if one is not provid ed | |
2544 | // P rovide `ma tch` to av oid retoke nization i f we modif ied the se lector abo ve | |
2545 | ( co mpiled || compile( s elector, m atch ) )( | |
2546 | seed, | |
2547 | context, | |
2548 | !documentI sHTML, | |
2549 | results, | |
2550 | rsibli ng.test( s elector ) && testCon text( cont ext.parent Node ) || context | |
2551 | ); | |
2552 | retu rn results ; | |
2553 | }; | |
2554 | ||
2555 | // One-tim e assignme nts | |
2556 | ||
2557 | // Sort st ability | |
2558 | support. sortStable = expando .split("") .sort( sor tOrder ).j oin("") == = expando; | |
2559 | ||
2560 | // Support : Chrome<1 4 | |
2561 | // Always assume dup licates if they aren 't passed to the com parison fu nction | |
2562 | support. detectDupl icates = ! !hasDuplic ate; | |
2563 | ||
2564 | // Initial ize agains t the defa ult docume nt | |
2565 | setDocum ent(); | |
2566 | ||
2567 | // Support : Webkit<5 37.32 - Sa fari 6.0.3 /Chrome 25 (fixed in Chrome 27 ) | |
2568 | // Detache d nodes co nfoundingl y follow * each other * | |
2569 | support. sortDetach ed = asser t(function ( div1 ) { | |
2570 | // S hould retu rn 1, but returns 4 (following ) | |
2571 | retu rn div1.co mpareDocum entPositio n( documen t.createEl ement("div ") ) & 1; | |
2572 | }); | |
2573 | ||
2574 | // Support : IE<8 | |
2575 | // Prevent attribute /property "interpola tion" | |
2576 | // http:// msdn.micro soft.com/e n-us/libra ry/ms53642 9%28VS.85% 29.aspx | |
2577 | if ( !as sert(funct ion( div ) { | |
2578 | div. innerHTML = "<a href ='#'></a>" ; | |
2579 | retu rn div.fir stChild.ge tAttribute ("href") = == "#" ; | |
2580 | }) ) { | |
2581 | addH andle( "ty pe|href|he ight|width ", functio n( elem, n ame, isXML ) { | |
2582 | if ( !isXM L ) { | |
2583 | return elem.getA ttribute( name, name .toLowerCa se() === " type" ? 1 : 2 ); | |
2584 | } | |
2585 | }); | |
2586 | } | |
2587 | ||
2588 | // Support : IE<9 | |
2589 | // Use def aultValue in place o f getAttri bute("valu e") | |
2590 | if ( !su pport.attr ibutes || !assert(fu nction( di v ) { | |
2591 | div. innerHTML = "<input/ >"; | |
2592 | div. firstChild .setAttrib ute( "valu e", "" ); | |
2593 | retu rn div.fir stChild.ge tAttribute ( "value" ) === ""; | |
2594 | }) ) { | |
2595 | addH andle( "va lue", func tion( elem , name, is XML ) { | |
2596 | if ( !isXM L && elem. nodeName.t oLowerCase () === "in put" ) { | |
2597 | return elem.defa ultValue; | |
2598 | } | |
2599 | }); | |
2600 | } | |
2601 | ||
2602 | // Support : IE<9 | |
2603 | // Use get AttributeN ode to fet ch boolean s when get Attribute lies | |
2604 | if ( !as sert(funct ion( div ) { | |
2605 | retu rn div.get Attribute( "disabled" ) == null; | |
2606 | }) ) { | |
2607 | addH andle( boo leans, fun ction( ele m, name, i sXML ) { | |
2608 | var val; | |
2609 | if ( !isXM L ) { | |
2610 | return elem[ nam e ] === tr ue ? name. toLowerCas e() : | |
2611 | (val = e lem.getAtt ributeNode ( name )) && val.spe cified ? | |
2612 | va l.value : | |
2613 | nu ll; | |
2614 | } | |
2615 | }); | |
2616 | } | |
2617 | ||
2618 | return S izzle; | |
2619 | ||
2620 | }) ( window ) ; | |
2621 | ||
2622 | ||
2623 | ||
2624 | jQuery .find = Si zzle; | |
2625 | jQuery .expr = Si zzle.selec tors; | |
2626 | jQuery .expr[":"] = jQuery. expr.pseud os; | |
2627 | jQuery .unique = Sizzle.uni queSort; | |
2628 | jQuery .text = Si zzle.getTe xt; | |
2629 | jQuery .isXMLDoc = Sizzle.i sXML; | |
2630 | jQuery .contains = Sizzle.c ontains; | |
2631 | ||
2632 | ||
2633 | ||
2634 | var rn eedsContex t = jQuery .expr.matc h.needsCon text; | |
2635 | ||
2636 | var rs ingleTag = (/^<(\w+) \s*\/?>(?: <\/\1>|)$/ ); | |
2637 | ||
2638 | ||
2639 | ||
2640 | var ri sSimple = /^.[^:#\[\ .,]*$/; | |
2641 | ||
2642 | // Impleme nt the ide ntical fun ctionality for filte r and not | |
2643 | functi on winnow( elements, qualifier , not ) { | |
2644 | if ( jQuery. isFunction ( qualifie r ) ) { | |
2645 | return j Query.grep ( elements , function ( elem, i ) { | |
2646 | /* j shint -W01 8 */ | |
2647 | retu rn !!quali fier.call( elem, i, elem ) !== not; | |
2648 | }); | |
2649 | ||
2650 | } | |
2651 | ||
2652 | if ( qualifi er.nodeTyp e ) { | |
2653 | return j Query.grep ( elements , function ( elem ) { | |
2654 | retu rn ( elem === qualif ier ) !== not; | |
2655 | }); | |
2656 | ||
2657 | } | |
2658 | ||
2659 | if ( typeof qualifier === "strin g" ) { | |
2660 | if ( ris Simple.tes t( qualifi er ) ) { | |
2661 | retu rn jQuery. filter( qu alifier, e lements, n ot ); | |
2662 | } | |
2663 | ||
2664 | qualifie r = jQuery .filter( q ualifier, elements ) ; | |
2665 | } | |
2666 | ||
2667 | re turn jQuer y.grep( el ements, fu nction( el em ) { | |
2668 | return ( jQuery.in Array( ele m, qualifi er ) >= 0 ) !== not; | |
2669 | }) ; | |
2670 | } | |
2671 | ||
2672 | jQuery .filter = function( expr, elem s, not ) { | |
2673 | va r elem = e lems[ 0 ]; | |
2674 | ||
2675 | if ( not ) { | |
2676 | expr = " :not(" + e xpr + ")"; | |
2677 | } | |
2678 | ||
2679 | re turn elems .length == = 1 && ele m.nodeType === 1 ? | |
2680 | jQuery.f ind.matche sSelector( elem, exp r ) ? [ el em ] : [] : | |
2681 | jQuery.f ind.matche s( expr, j Query.grep ( elems, f unction( e lem ) { | |
2682 | retu rn elem.no deType === 1; | |
2683 | })); | |
2684 | }; | |
2685 | ||
2686 | jQuery .fn.extend ({ | |
2687 | fi nd: functi on( select or ) { | |
2688 | var i, | |
2689 | ret = [], | |
2690 | self = this, | |
2691 | len = self.len gth; | |
2692 | ||
2693 | if ( typ eof select or !== "st ring" ) { | |
2694 | retu rn this.pu shStack( j Query( sel ector ).fi lter(funct ion() { | |
2695 | for ( i = 0; i < len ; i++ ) { | |
2696 | if ( j Query.cont ains( self [ i ], thi s ) ) { | |
2697 | re turn true; | |
2698 | } | |
2699 | } | |
2700 | }) ) ; | |
2701 | } | |
2702 | ||
2703 | for ( i = 0; i < l en; i++ ) { | |
2704 | jQue ry.find( s elector, s elf[ i ], ret ); | |
2705 | } | |
2706 | ||
2707 | // Neede d because $( selecto r, context ) becomes $( contex t ).find( selector ) | |
2708 | ret = th is.pushSta ck( len > 1 ? jQuery .unique( r et ) : ret ); | |
2709 | ret.sele ctor = thi s.selector ? this.se lector + " " + selec tor : sele ctor; | |
2710 | return r et; | |
2711 | }, | |
2712 | fi lter: func tion( sele ctor ) { | |
2713 | return t his.pushSt ack( winno w(this, se lector || [], false) ); | |
2714 | }, | |
2715 | no t: functio n( selecto r ) { | |
2716 | return t his.pushSt ack( winno w(this, se lector || [], true) ); | |
2717 | }, | |
2718 | is : function ( selector ) { | |
2719 | return ! !winnow( | |
2720 | this , | |
2721 | ||
2722 | // I f this is a position al/relativ e selector , check me mbership i n the retu rned set | |
2723 | // s o $("p:fir st").is("p :last") wo n't return true for a doc with two "p". | |
2724 | typeof sel ector === "string" & & rneedsCo ntext.test ( selector ) ? | |
2725 | jQuery( se lector ) : | |
2726 | selector | | [], | |
2727 | fals e | |
2728 | ).length ; | |
2729 | } | |
2730 | }); | |
2731 | ||
2732 | ||
2733 | // Initial ize a jQue ry object | |
2734 | ||
2735 | ||
2736 | // A centr al referen ce to the root jQuer y(document ) | |
2737 | var ro otjQuery, | |
2738 | ||
2739 | // Use the corre ct documen t accordin gly with w indow argu ment (sand box) | |
2740 | do cument = w indow.docu ment, | |
2741 | ||
2742 | // A s imple way to check f or HTML st rings | |
2743 | // Pri oritize #i d over <ta g> to avoi d XSS via location.h ash (#9521 ) | |
2744 | // Str ict HTML r ecognition (#11290: must start with <) | |
2745 | rq uickExpr = /^(?:\s*( <[\w\W]+>) [^>]*|#([\ w-]*))$/, | |
2746 | ||
2747 | in it = jQuer y.fn.init = function ( selector , context ) { | |
2748 | var matc h, elem; | |
2749 | ||
2750 | // HANDL E: $(""), $(null), $ (undefined ), $(false ) | |
2751 | if ( !se lector ) { | |
2752 | retu rn this; | |
2753 | } | |
2754 | ||
2755 | // Handl e HTML str ings | |
2756 | if ( typ eof select or === "st ring" ) { | |
2757 | if ( selector. charAt(0) === "<" && selector. charAt( se lector.len gth - 1 ) === ">" && selector. length >= 3 ) { | |
2758 | // Assume that strin gs that st art and en d with <> are HTML a nd skip th e regex ch eck | |
2759 | match = [ null, sele ctor, null ]; | |
2760 | ||
2761 | } el se { | |
2762 | match = rq uickExpr.e xec( selec tor ); | |
2763 | } | |
2764 | ||
2765 | // M atch html or make su re no cont ext is spe cified for #id | |
2766 | if ( match && (match[1] || !contex t) ) { | |
2767 | ||
2768 | // HANDLE: $(html) - > $(array) | |
2769 | if ( match [1] ) { | |
2770 | contex t = contex t instance of jQuery ? context[ 0] : conte xt; | |
2771 | ||
2772 | // ven dor is tru e for back -compat | |
2773 | // Int entionally let the e rror be th rown if pa rseHTML is not prese nt | |
2774 | jQuery .merge( th is, jQuery .parseHTML ( | |
2775 | ma tch[1], | |
2776 | context && context .nodeType ? context. ownerDocum ent || con text : doc ument, | |
2777 | tr ue | |
2778 | ) ); | |
2779 | ||
2780 | // HAN DLE: $(htm l, props) | |
2781 | if ( r singleTag. test( matc h[1] ) && jQuery.isP lainObject ( context ) ) { | |
2782 | fo r ( match in context ) { | |
2783 | // Prope rties of c ontext are called as methods i f possible | |
2784 | if ( jQu ery.isFunc tion( this [ match ] ) ) { | |
2785 | this [ match ]( context[ match ] ); | |
2786 | ||
2787 | // . ..and othe rwise set as attribu tes | |
2788 | } else { | |
2789 | this .attr( mat ch, contex t[ match ] ); | |
2790 | } | |
2791 | } | |
2792 | } | |
2793 | ||
2794 | return this; | |
2795 | ||
2796 | // HAN DLE: $(#id ) | |
2797 | } else { | |
2798 | elem = document. getElement ById( matc h[2] ); | |
2799 | ||
2800 | // Che ck parentN ode to cat ch when Bl ackberry 4 .6 returns | |
2801 | // nod es that ar e no longe r in the d ocument #6 963 | |
2802 | if ( e lem && ele m.parentNo de ) { | |
2803 | // Handle th e case whe re IE and Opera retu rn items | |
2804 | // by name i nstead of ID | |
2805 | if ( elem.id !== match [2] ) { | |
2806 | return r ootjQuery. find( sele ctor ); | |
2807 | } | |
2808 | ||
2809 | // Otherwise , we injec t the elem ent direct ly into th e jQuery o bject | |
2810 | th is.length = 1; | |
2811 | th is[0] = el em; | |
2812 | } | |
2813 | ||
2814 | this.c ontext = d ocument; | |
2815 | this.s elector = selector; | |
2816 | return this; | |
2817 | } | |
2818 | ||
2819 | // HANDLE: $(expr, $ (...)) | |
2820 | } el se if ( !c ontext || context.jq uery ) { | |
2821 | return ( c ontext || rootjQuery ).find( s elector ); | |
2822 | ||
2823 | // HANDLE: $(expr, c ontext) | |
2824 | // (which is just eq uivalent t o: $(conte xt).find(e xpr) | |
2825 | } el se { | |
2826 | return thi s.construc tor( conte xt ).find( selector ); | |
2827 | } | |
2828 | ||
2829 | // H ANDLE: $(D OMElement) | |
2830 | } else i f ( select or.nodeTyp e ) { | |
2831 | this .context = this[0] = selector; | |
2832 | this .length = 1; | |
2833 | retu rn this; | |
2834 | ||
2835 | // H ANDLE: $(f unction) | |
2836 | // S hortcut fo r document ready | |
2837 | } else i f ( jQuery .isFunctio n( selecto r ) ) { | |
2838 | retu rn typeof rootjQuery .ready !== "undefine d" ? | |
2839 | rootjQuery .ready( se lector ) : | |
2840 | // Execute immediate ly if read y is not p resent | |
2841 | selector( jQuery ); | |
2842 | } | |
2843 | ||
2844 | if ( sel ector.sele ctor !== u ndefined ) { | |
2845 | this .selector = selector .selector; | |
2846 | this .context = selector. context; | |
2847 | } | |
2848 | ||
2849 | return j Query.make Array( sel ector, thi s ); | |
2850 | }; | |
2851 | ||
2852 | // Give th e init fun ction the jQuery pro totype for later ins tantiation | |
2853 | init.p rototype = jQuery.fn ; | |
2854 | ||
2855 | // Initial ize centra l referenc e | |
2856 | rootjQ uery = jQu ery( docum ent ); | |
2857 | ||
2858 | ||
2859 | var rp arentsprev = /^(?:pa rents|prev (?:Until|A ll))/, | |
2860 | // met hods guara nteed to p roduce a u nique set when start ing from a unique se t | |
2861 | gu aranteedUn ique = { | |
2862 | children : true, | |
2863 | contents : true, | |
2864 | next: tr ue, | |
2865 | prev: tr ue | |
2866 | }; | |
2867 | ||
2868 | jQuery .extend({ | |
2869 | di r: functio n( elem, d ir, until ) { | |
2870 | var matc hed = [], | |
2871 | cur = elem[ di r ]; | |
2872 | ||
2873 | while ( cur && cur .nodeType !== 9 && ( until === undefined || cur.nod eType !== 1 || !jQue ry( cur ). is( until )) ) { | |
2874 | if ( cur.nodeT ype === 1 ) { | |
2875 | matched.pu sh( cur ); | |
2876 | } | |
2877 | cur = cur[dir] ; | |
2878 | } | |
2879 | return m atched; | |
2880 | }, | |
2881 | ||
2882 | si bling: fun ction( n, elem ) { | |
2883 | var r = []; | |
2884 | ||
2885 | for ( ; n; n = n.n extSibling ) { | |
2886 | if ( n.nodeTyp e === 1 && n !== ele m ) { | |
2887 | r.push( n ); | |
2888 | } | |
2889 | } | |
2890 | ||
2891 | return r ; | |
2892 | } | |
2893 | }); | |
2894 | ||
2895 | jQuery .fn.extend ({ | |
2896 | ha s: functio n( target ) { | |
2897 | var i, | |
2898 | targ ets = jQue ry( target , this ), | |
2899 | len = targets. length; | |
2900 | ||
2901 | return t his.filter (function( ) { | |
2902 | for ( i = 0; i < len; i+ + ) { | |
2903 | if ( jQuer y.contains ( this, ta rgets[i] ) ) { | |
2904 | return true; | |
2905 | } | |
2906 | } | |
2907 | }); | |
2908 | }, | |
2909 | ||
2910 | cl osest: fun ction( sel ectors, co ntext ) { | |
2911 | var cur, | |
2912 | i = 0, | |
2913 | l = this.lengt h, | |
2914 | matc hed = [], | |
2915 | pos = rneedsCo ntext.test ( selector s ) || typ eof select ors !== "s tring" ? | |
2916 | jQuery( se lectors, c ontext || this.conte xt ) : | |
2917 | 0; | |
2918 | ||
2919 | for ( ; i < l; i++ ) { | |
2920 | for ( cur = th is[i]; cur && cur != = context; cur = cur .parentNod e ) { | |
2921 | // Always skip docum ent fragme nts | |
2922 | if ( cur.n odeType < 11 && (pos ? | |
2923 | pos.in dex(cur) > -1 : | |
2924 | ||
2925 | // Don 't pass no n-elements to Sizzle | |
2926 | cur.no deType === 1 && | |
2927 | jQuery .find.matc hesSelecto r(cur, sel ectors)) ) { | |
2928 | ||
2929 | matche d.push( cu r ); | |
2930 | break; | |
2931 | } | |
2932 | } | |
2933 | } | |
2934 | ||
2935 | return t his.pushSt ack( match ed.length > 1 ? jQue ry.unique( matched ) : matched ); | |
2936 | }, | |
2937 | ||
2938 | // Determine the posit ion of an element wi thin | |
2939 | // the match ed set of elements | |
2940 | in dex: funct ion( elem ) { | |
2941 | ||
2942 | // No ar gument, re turn index in parent | |
2943 | if ( !el em ) { | |
2944 | retu rn ( this[ 0] && this [0].parent Node ) ? t his.first( ).prevAll( ).length : -1; | |
2945 | } | |
2946 | ||
2947 | // index in select or | |
2948 | if ( typ eof elem = == "string " ) { | |
2949 | retu rn jQuery. inArray( t his[0], jQ uery( elem ) ); | |
2950 | } | |
2951 | ||
2952 | // Locat e the posi tion of th e desired element | |
2953 | return j Query.inAr ray( | |
2954 | // I f it recei ves a jQue ry object, the first element i s used | |
2955 | elem .jquery ? elem[0] : elem, this ); | |
2956 | }, | |
2957 | ||
2958 | ad d: functio n( selecto r, context ) { | |
2959 | return t his.pushSt ack( | |
2960 | jQue ry.unique( | |
2961 | jQuery.mer ge( this.g et(), jQue ry( select or, contex t ) ) | |
2962 | ) | |
2963 | ); | |
2964 | }, | |
2965 | ||
2966 | ad dBack: fun ction( sel ector ) { | |
2967 | return t his.add( s elector == null ? | |
2968 | this.prevO bject : th is.prevObj ect.filter (selector) | |
2969 | ); | |
2970 | } | |
2971 | }); | |
2972 | ||
2973 | functi on sibling ( cur, dir ) { | |
2974 | do { | |
2975 | cur = cu r[ dir ]; | |
2976 | } while ( cu r && cur.n odeType != = 1 ); | |
2977 | ||
2978 | re turn cur; | |
2979 | } | |
2980 | ||
2981 | jQuery .each({ | |
2982 | pa rent: func tion( elem ) { | |
2983 | var pare nt = elem. parentNode ; | |
2984 | return p arent && p arent.node Type !== 1 1 ? parent : null; | |
2985 | }, | |
2986 | pa rents: fun ction( ele m ) { | |
2987 | return j Query.dir( elem, "pa rentNode" ); | |
2988 | }, | |
2989 | pa rentsUntil : function ( elem, i, until ) { | |
2990 | return j Query.dir( elem, "pa rentNode", until ); | |
2991 | }, | |
2992 | ne xt: functi on( elem ) { | |
2993 | return s ibling( el em, "nextS ibling" ); | |
2994 | }, | |
2995 | pr ev: functi on( elem ) { | |
2996 | return s ibling( el em, "previ ousSibling " ); | |
2997 | }, | |
2998 | ne xtAll: fun ction( ele m ) { | |
2999 | return j Query.dir( elem, "ne xtSibling" ); | |
3000 | }, | |
3001 | pr evAll: fun ction( ele m ) { | |
3002 | return j Query.dir( elem, "pr eviousSibl ing" ); | |
3003 | }, | |
3004 | ne xtUntil: f unction( e lem, i, un til ) { | |
3005 | return j Query.dir( elem, "ne xtSibling" , until ); | |
3006 | }, | |
3007 | pr evUntil: f unction( e lem, i, un til ) { | |
3008 | return j Query.dir( elem, "pr eviousSibl ing", unti l ); | |
3009 | }, | |
3010 | si blings: fu nction( el em ) { | |
3011 | return j Query.sibl ing( ( ele m.parentNo de || {} ) .firstChil d, elem ); | |
3012 | }, | |
3013 | ch ildren: fu nction( el em ) { | |
3014 | return j Query.sibl ing( elem. firstChild ); | |
3015 | }, | |
3016 | co ntents: fu nction( el em ) { | |
3017 | return j Query.node Name( elem , "iframe" ) ? | |
3018 | elem .contentDo cument || elem.conte ntWindow.d ocument : | |
3019 | jQue ry.merge( [], elem.c hildNodes ); | |
3020 | } | |
3021 | }, fun ction( nam e, fn ) { | |
3022 | jQ uery.fn[ n ame ] = fu nction( un til, selec tor ) { | |
3023 | var ret = jQuery.m ap( this, fn, until ); | |
3024 | ||
3025 | if ( nam e.slice( - 5 ) !== "U ntil" ) { | |
3026 | sele ctor = unt il; | |
3027 | } | |
3028 | ||
3029 | if ( sel ector && t ypeof sele ctor === " string" ) { | |
3030 | ret = jQuery.f ilter( sel ector, ret ); | |
3031 | } | |
3032 | ||
3033 | if ( thi s.length > 1 ) { | |
3034 | // R emove dupl icates | |
3035 | if ( !guarante edUnique[ name ] ) { | |
3036 | ret = jQue ry.unique( ret ); | |
3037 | } | |
3038 | ||
3039 | // R everse ord er for par ents* and prev-deriv atives | |
3040 | if ( rparentsp rev.test( name ) ) { | |
3041 | ret = ret. reverse(); | |
3042 | } | |
3043 | } | |
3044 | ||
3045 | return t his.pushSt ack( ret ) ; | |
3046 | }; | |
3047 | }); | |
3048 | var rn otwhite = (/\S+/g); | |
3049 | ||
3050 | ||
3051 | ||
3052 | // String to Object options fo rmat cache | |
3053 | var op tionsCache = {}; | |
3054 | ||
3055 | // Convert String-fo rmatted op tions into Object-fo rmatted on es and sto re in cach e | |
3056 | functi on createO ptions( op tions ) { | |
3057 | va r object = optionsCa che[ optio ns ] = {}; | |
3058 | jQ uery.each( options.m atch( rnot white ) || [], funct ion( _, fl ag ) { | |
3059 | object[ flag ] = t rue; | |
3060 | }) ; | |
3061 | re turn objec t; | |
3062 | } | |
3063 | ||
3064 | /* | |
3065 | * Cre ate a call back list using the following parameters : | |
3066 | * | |
3067 | * op tions: an optional l ist of spa ce-separat ed options that will change ho w | |
3068 | * the ca llback lis t behaves or a more traditiona l option o bject | |
3069 | * | |
3070 | * By default a callback l ist will a ct like an event cal lback list and can b e | |
3071 | * "fi red" multi ple times. | |
3072 | * | |
3073 | * Pos sible opti ons: | |
3074 | * | |
3075 | * on ce: will ens ure the ca llback lis t can only be fired once (like a Deferre d) | |
3076 | * | |
3077 | * me mory: will kee p track of previous values and will call any callb ack added | |
3078 | * after the list has b een fired right away with the latest "me morized" | |
3079 | * values (li ke a Defer red) | |
3080 | * | |
3081 | * un ique: will ens ure a call back can o nly be add ed once (n o duplicat e in the l ist) | |
3082 | * | |
3083 | * st opOnFalse: interr upt callin gs when a callback r eturns fal se | |
3084 | * | |
3085 | */ | |
3086 | jQuery .Callbacks = functio n( options ) { | |
3087 | ||
3088 | // Convert o ptions fro m String-f ormatted t o Object-f ormatted i f needed | |
3089 | // (we check in cache first) | |
3090 | op tions = ty peof optio ns === "st ring" ? | |
3091 | ( option sCache[ op tions ] || createOpt ions( opti ons ) ) : | |
3092 | jQuery.e xtend( {}, options ) ; | |
3093 | ||
3094 | va r // Flag to know if list is c urrently f iring | |
3095 | firing, | |
3096 | // Last fire value (fo r non-forg ettable li sts) | |
3097 | memory, | |
3098 | // Flag to k now if lis t was alre ady fired | |
3099 | fired, | |
3100 | // End of th e loop whe n firing | |
3101 | firingLe ngth, | |
3102 | // Index of currently firing cal lback (mod ified by r emove if n eeded) | |
3103 | firingIn dex, | |
3104 | // First cal lback to f ire (used internally by add an d fireWith ) | |
3105 | firingSt art, | |
3106 | // Actual ca llback lis t | |
3107 | list = [ ], | |
3108 | // Stack of fire calls for repea table list s | |
3109 | stack = !options.o nce && [], | |
3110 | // Fire call backs | |
3111 | fire = f unction( d ata ) { | |
3112 | memo ry = optio ns.memory && data; | |
3113 | fire d = true; | |
3114 | firi ngIndex = firingStar t || 0; | |
3115 | firi ngStart = 0; | |
3116 | firi ngLength = list.leng th; | |
3117 | firi ng = true; | |
3118 | for ( ; list & & firingIn dex < firi ngLength; firingInde x++ ) { | |
3119 | if ( list[ firingInd ex ].apply ( data[ 0 ], data[ 1 ] ) === f alse && op tions.stop OnFalse ) { | |
3120 | memory = false; // To prev ent furthe r calls us ing add | |
3121 | break; | |
3122 | } | |
3123 | } | |
3124 | firi ng = false ; | |
3125 | if ( list ) { | |
3126 | if ( stack ) { | |
3127 | if ( s tack.lengt h ) { | |
3128 | fi re( stack. shift() ); | |
3129 | } | |
3130 | } else if ( memory ) { | |
3131 | list = []; | |
3132 | } else { | |
3133 | self.d isable(); | |
3134 | } | |
3135 | } | |
3136 | }, | |
3137 | // Actual Ca llbacks ob ject | |
3138 | self = { | |
3139 | // A dd a callb ack or a c ollection of callbac ks to the list | |
3140 | add: function( ) { | |
3141 | if ( list ) { | |
3142 | // Fir st, we sav e the curr ent length | |
3143 | var st art = list .length; | |
3144 | (funct ion add( a rgs ) { | |
3145 | jQ uery.each( args, fun ction( _, arg ) { | |
3146 | var type = jQuery. type( arg ); | |
3147 | if ( typ e === "fun ction" ) { | |
3148 | if ( !options. unique || !self.has( arg ) ) { | |
3149 | list.push( arg ); | |
3150 | } | |
3151 | } else i f ( arg && arg.lengt h && type !== "strin g" ) { | |
3152 | // I nspect rec ursively | |
3153 | add( arg ); | |
3154 | } | |
3155 | }) ; | |
3156 | })( ar guments ); | |
3157 | // Do we need to add the c allbacks t o the | |
3158 | // cur rent firin g batch? | |
3159 | if ( f iring ) { | |
3160 | fi ringLength = list.le ngth; | |
3161 | // With memo ry, if we' re not fir ing then | |
3162 | // we should call righ t away | |
3163 | } else if ( memo ry ) { | |
3164 | fi ringStart = start; | |
3165 | fi re( memory ); | |
3166 | } | |
3167 | } | |
3168 | return thi s; | |
3169 | }, | |
3170 | // R emove a ca llback fro m the list | |
3171 | remo ve: functi on() { | |
3172 | if ( list ) { | |
3173 | jQuery .each( arg uments, fu nction( _, arg ) { | |
3174 | va r index; | |
3175 | wh ile ( ( in dex = jQue ry.inArray ( arg, lis t, index ) ) > -1 ) { | |
3176 | list.spl ice( index , 1 ); | |
3177 | // Handl e firing i ndexes | |
3178 | if ( fir ing ) { | |
3179 | if ( index <= firingLeng th ) { | |
3180 | firingLeng th--; | |
3181 | } | |
3182 | if ( index <= firingInde x ) { | |
3183 | firingInde x--; | |
3184 | } | |
3185 | } | |
3186 | } | |
3187 | }); | |
3188 | } | |
3189 | return thi s; | |
3190 | }, | |
3191 | // C heck if a given call back is in the list. | |
3192 | // I f no argum ent is giv en, return whether o r not list has callb acks attac hed. | |
3193 | has: function( fn ) { | |
3194 | return fn ? jQuery.i nArray( fn , list ) > -1 : !!( list && li st.length ); | |
3195 | }, | |
3196 | // R emove all callbacks from the l ist | |
3197 | empt y: functio n() { | |
3198 | list = []; | |
3199 | firingLeng th = 0; | |
3200 | return thi s; | |
3201 | }, | |
3202 | // H ave the li st do noth ing anymor e | |
3203 | disa ble: funct ion() { | |
3204 | list = sta ck = memor y = undefi ned; | |
3205 | return thi s; | |
3206 | }, | |
3207 | // I s it disab led? | |
3208 | disa bled: func tion() { | |
3209 | return !li st; | |
3210 | }, | |
3211 | // L ock the li st in its current st ate | |
3212 | lock : function () { | |
3213 | stack = un defined; | |
3214 | if ( !memo ry ) { | |
3215 | self.d isable(); | |
3216 | } | |
3217 | return thi s; | |
3218 | }, | |
3219 | // I s it locke d? | |
3220 | lock ed: functi on() { | |
3221 | return !st ack; | |
3222 | }, | |
3223 | // C all all ca llbacks wi th the giv en context and argum ents | |
3224 | fire With: func tion( cont ext, args ) { | |
3225 | if ( list && ( !fire d || stack ) ) { | |
3226 | args = args || [ ]; | |
3227 | args = [ context , args.sli ce ? args. slice() : args ]; | |
3228 | if ( f iring ) { | |
3229 | st ack.push( args ); | |
3230 | } else { | |
3231 | fi re( args ) ; | |
3232 | } | |
3233 | } | |
3234 | return thi s; | |
3235 | }, | |
3236 | // C all all th e callback s with the given arg uments | |
3237 | fire : function () { | |
3238 | self.fireW ith( this, arguments ); | |
3239 | return thi s; | |
3240 | }, | |
3241 | // T o know if the callba cks have a lready bee n called a t least on ce | |
3242 | fire d: functio n() { | |
3243 | return !!f ired; | |
3244 | } | |
3245 | }; | |
3246 | ||
3247 | re turn self; | |
3248 | }; | |
3249 | ||
3250 | ||
3251 | jQuery .extend({ | |
3252 | ||
3253 | De ferred: fu nction( fu nc ) { | |
3254 | var tupl es = [ | |
3255 | // action, add liste ner, liste ner list, final stat e | |
3256 | [ "resolve ", "done", jQuery.Ca llbacks("o nce memory "), "resol ved" ], | |
3257 | [ "reject" , "fail", jQuery.Cal lbacks("on ce memory" ), "reject ed" ], | |
3258 | [ "notify" , "progres s", jQuery .Callbacks ("memory") ] | |
3259 | ], | |
3260 | stat e = "pendi ng", | |
3261 | prom ise = { | |
3262 | state: fun ction() { | |
3263 | return state; | |
3264 | }, | |
3265 | always: fu nction() { | |
3266 | deferr ed.done( a rguments ) .fail( arg uments ); | |
3267 | return this; | |
3268 | }, | |
3269 | then: func tion( /* f nDone, fnF ail, fnPro gress */ ) { | |
3270 | var fn s = argume nts; | |
3271 | return jQuery.De ferred(fun ction( new Defer ) { | |
3272 | jQ uery.each( tuples, f unction( i , tuple ) { | |
3273 | var fn = jQuery.is Function( fns[ i ] ) && fns[ i ]; | |
3274 | // defer red[ done | fail | p rogress ] for forwar ding actio ns to newD efer | |
3275 | deferred [ tuple[1] ](functio n() { | |
3276 | var returned = fn && fn. apply( thi s, argumen ts ); | |
3277 | if ( returned && jQuery. isFunction ( returned .promise ) ) { | |
3278 | returned.p romise() | |
3279 | .done( newDefer. resolve ) | |
3280 | .fail( newDefer. reject ) | |
3281 | .progr ess( newDe fer.notify ); | |
3282 | } el se { | |
3283 | newDefer[ tuple[ 0 ] + "With" ]( this == = promise ? newDefer .promise() : this, f n ? [ retu rned ] : a rguments ) ; | |
3284 | } | |
3285 | }); | |
3286 | }) ; | |
3287 | fn s = null; | |
3288 | }).pro mise(); | |
3289 | }, | |
3290 | // Get a p romise for this defe rred | |
3291 | // If obj is provide d, the pro mise aspec t is added to the ob ject | |
3292 | promise: f unction( o bj ) { | |
3293 | return obj != nu ll ? jQuer y.extend( obj, promi se ) : pro mise; | |
3294 | } | |
3295 | }, | |
3296 | defe rred = {}; | |
3297 | ||
3298 | // Keep pipe for b ack-compat | |
3299 | promise. pipe = pro mise.then; | |
3300 | ||
3301 | // Add l ist-specif ic methods | |
3302 | jQuery.e ach( tuple s, functio n( i, tupl e ) { | |
3303 | var list = tup le[ 2 ], | |
3304 | stateStrin g = tuple[ 3 ]; | |
3305 | ||
3306 | // p romise[ do ne | fail | progress ] = list. add | |
3307 | prom ise[ tuple [1] ] = li st.add; | |
3308 | ||
3309 | // H andle stat e | |
3310 | if ( stateStri ng ) { | |
3311 | list.add(f unction() { | |
3312 | // sta te = [ res olved | re jected ] | |
3313 | state = stateStr ing; | |
3314 | ||
3315 | // [ r eject_list | resolve _list ].di sable; pro gress_list .lock | |
3316 | }, tuples[ i ^ 1 ][ 2 ].disabl e, tuples[ 2 ][ 2 ]. lock ); | |
3317 | } | |
3318 | ||
3319 | // d eferred[ r esolve | r eject | no tify ] | |
3320 | defe rred[ tupl e[0] ] = f unction() { | |
3321 | deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arg uments ); | |
3322 | return thi s; | |
3323 | }; | |
3324 | defe rred[ tupl e[0] + "Wi th" ] = li st.fireWit h; | |
3325 | }); | |
3326 | ||
3327 | // Make the deferr ed a promi se | |
3328 | promise. promise( d eferred ); | |
3329 | ||
3330 | // Call given func if any | |
3331 | if ( fun c ) { | |
3332 | func .call( def erred, def erred ); | |
3333 | } | |
3334 | ||
3335 | // All d one! | |
3336 | return d eferred; | |
3337 | }, | |
3338 | ||
3339 | // Deferred helper | |
3340 | wh en: functi on( subord inate /* , ..., subo rdinateN * / ) { | |
3341 | var i = 0, | |
3342 | reso lveValues = slice.ca ll( argume nts ), | |
3343 | leng th = resol veValues.l ength, | |
3344 | ||
3345 | // the c ount of un completed subordinat es | |
3346 | rema ining = le ngth !== 1 || ( subo rdinate && jQuery.is Function( subordinat e.promise ) ) ? leng th : 0, | |
3347 | ||
3348 | // the m aster Defe rred. If r esolveValu es consist of only a single De ferred, ju st use tha t. | |
3349 | defe rred = rem aining === 1 ? subor dinate : j Query.Defe rred(), | |
3350 | ||
3351 | // Updat e function for both resolve an d progress values | |
3352 | upda teFunc = f unction( i , contexts , values ) { | |
3353 | return fun ction( val ue ) { | |
3354 | contex ts[ i ] = this; | |
3355 | values [ i ] = ar guments.le ngth > 1 ? slice.cal l( argumen ts ) : val ue; | |
3356 | if ( v alues === progressVa lues ) { | |
3357 | de ferred.not ifyWith( c ontexts, v alues ); | |
3358 | ||
3359 | } else if ( !(-- remaining) ) { | |
3360 | de ferred.res olveWith( contexts, values ); | |
3361 | } | |
3362 | }; | |
3363 | }, | |
3364 | ||
3365 | prog ressValues , progress Contexts, resolveCon texts; | |
3366 | ||
3367 | // add l isteners t o Deferred subordina tes; treat others as resolved | |
3368 | if ( len gth > 1 ) { | |
3369 | prog ressValues = new Arr ay( length ); | |
3370 | prog ressContex ts = new A rray( leng th ); | |
3371 | reso lveContext s = new Ar ray( lengt h ); | |
3372 | for ( ; i < le ngth; i++ ) { | |
3373 | if ( resol veValues[ i ] && jQu ery.isFunc tion( reso lveValues[ i ].promi se ) ) { | |
3374 | resolv eValues[ i ].promise () | |
3375 | .d one( updat eFunc( i, resolveCon texts, res olveValues ) ) | |
3376 | .f ail( defer red.reject ) | |
3377 | .p rogress( u pdateFunc( i, progre ssContexts , progress Values ) ) ; | |
3378 | } else { | |
3379 | --rema ining; | |
3380 | } | |
3381 | } | |
3382 | } | |
3383 | ||
3384 | // if we 're not wa iting on a nything, r esolve the master | |
3385 | if ( !re maining ) { | |
3386 | defe rred.resol veWith( re solveConte xts, resol veValues ) ; | |
3387 | } | |
3388 | ||
3389 | return d eferred.pr omise(); | |
3390 | } | |
3391 | }); | |
3392 | ||
3393 | ||
3394 | // The def erred used on DOM re ady | |
3395 | var re adyList; | |
3396 | ||
3397 | jQuery .fn.ready = function ( fn ) { | |
3398 | // Add the c allback | |
3399 | jQ uery.ready .promise() .done( fn ); | |
3400 | ||
3401 | re turn this; | |
3402 | }; | |
3403 | ||
3404 | jQuery .extend({ | |
3405 | // Is the DO M ready to be used? Set to tru e once it occurs. | |
3406 | is Ready: fal se, | |
3407 | ||
3408 | // A counter to track how many i tems to wa it for bef ore | |
3409 | // the ready event fir es. See #6 781 | |
3410 | re adyWait: 1 , | |
3411 | ||
3412 | // Hold (or release) t he ready e vent | |
3413 | ho ldReady: f unction( h old ) { | |
3414 | if ( hol d ) { | |
3415 | jQue ry.readyWa it++; | |
3416 | } else { | |
3417 | jQue ry.ready( true ); | |
3418 | } | |
3419 | }, | |
3420 | ||
3421 | // Handle wh en the DOM is ready | |
3422 | re ady: funct ion( wait ) { | |
3423 | ||
3424 | // Abort if there are pendin g holds or we're alr eady ready | |
3425 | if ( wai t === true ? --jQuer y.readyWai t : jQuery .isReady ) { | |
3426 | retu rn; | |
3427 | } | |
3428 | ||
3429 | // Make sure body exists, at least, in case IE g ets a litt le overzea lous (tick et #5443). | |
3430 | if ( !do cument.bod y ) { | |
3431 | retu rn setTime out( jQuer y.ready ); | |
3432 | } | |
3433 | ||
3434 | // Remem ber that t he DOM is ready | |
3435 | jQuery.i sReady = t rue; | |
3436 | ||
3437 | // If a normal DOM Ready eve nt fired, decrement, and wait if need be | |
3438 | if ( wai t !== true && --jQue ry.readyWa it > 0 ) { | |
3439 | retu rn; | |
3440 | } | |
3441 | ||
3442 | // If th ere are fu nctions bo und, to ex ecute | |
3443 | readyLis t.resolveW ith( docum ent, [ jQu ery ] ); | |
3444 | ||
3445 | // Trigg er any bou nd ready e vents | |
3446 | if ( jQu ery.fn.tri ggerHandle r ) { | |
3447 | jQue ry( docume nt ).trigg erHandler( "ready" ) ; | |
3448 | jQue ry( docume nt ).off( "ready" ); | |
3449 | } | |
3450 | } | |
3451 | }); | |
3452 | ||
3453 | /** | |
3454 | * Cle an-up meth od for dom ready eve nts | |
3455 | */ | |
3456 | functi on detach( ) { | |
3457 | if ( documen t.addEvent Listener ) { | |
3458 | document .removeEve ntListener ( "DOMCont entLoaded" , complete d, false ) ; | |
3459 | window.r emoveEvent Listener( "load", co mpleted, f alse ); | |
3460 | ||
3461 | } else { | |
3462 | document .detachEve nt( "onrea dystatecha nge", comp leted ); | |
3463 | window.d etachEvent ( "onload" , complete d ); | |
3464 | } | |
3465 | } | |
3466 | ||
3467 | /** | |
3468 | * The ready eve nt handler and self cleanup me thod | |
3469 | */ | |
3470 | functi on complet ed() { | |
3471 | // readyStat e === "com plete" is good enoug h for us t o call the dom ready in oldIE | |
3472 | if ( documen t.addEvent Listener | | event.ty pe === "lo ad" || doc ument.read yState === "complete " ) { | |
3473 | detach() ; | |
3474 | jQuery.r eady(); | |
3475 | } | |
3476 | } | |
3477 | ||
3478 | jQuery .ready.pro mise = fun ction( obj ) { | |
3479 | if ( !readyL ist ) { | |
3480 | ||
3481 | readyLis t = jQuery .Deferred( ); | |
3482 | ||
3483 | // Catch cases whe re $(docum ent).ready () is call ed after t he browser event has already o ccurred. | |
3484 | // we on ce tried t o use read yState "in teractive" here, but it caused issues li ke the one | |
3485 | // disco vered by C hrisS here : http://b ugs.jquery .com/ticke t/12282#co mment:15 | |
3486 | if ( doc ument.read yState === "complete " ) { | |
3487 | // H andle it a synchronou sly to all ow vendor the opport unity to d elay ready | |
3488 | setT imeout( jQ uery.ready ); | |
3489 | ||
3490 | // S tandards-b ased brows ers suppor t DOMConte ntLoaded | |
3491 | } else i f ( docume nt.addEven tListener ) { | |
3492 | // U se the han dy event c allback | |
3493 | docu ment.addEv entListene r( "DOMCon tentLoaded ", complet ed, false ); | |
3494 | ||
3495 | // A fallback to window. onload, th at will al ways work | |
3496 | wind ow.addEven tListener( "load", c ompleted, false ); | |
3497 | ||
3498 | // I f IE event model is used | |
3499 | } else { | |
3500 | // E nsure firi ng before onload, ma ybe late b ut safe al so for ifr ames | |
3501 | docu ment.attac hEvent( "o nreadystat echange", completed ); | |
3502 | ||
3503 | // A fallback to window. onload, th at will al ways work | |
3504 | wind ow.attachE vent( "onl oad", comp leted ); | |
3505 | ||
3506 | // I f IE and n ot a frame | |
3507 | // c ontinually check to see if the document is ready | |
3508 | var top = fals e; | |
3509 | ||
3510 | try { | |
3511 | top = wind ow.frameEl ement == n ull && doc ument.docu mentElemen t; | |
3512 | } ca tch(e) {} | |
3513 | ||
3514 | if ( top && to p.doScroll ) { | |
3515 | (function doScrollCh eck() { | |
3516 | if ( ! jQuery.isR eady ) { | |
3517 | ||
3518 | tr y { | |
3519 | // Use t he trick b y Diego Pe rini | |
3520 | // http: //javascri pt.nwbox.c om/IEConte ntLoaded/ | |
3521 | top.doSc roll("left "); | |
3522 | } catch(e) { | |
3523 | return s etTimeout( doScrollC heck, 50 ) ; | |
3524 | } | |
3525 | ||
3526 | // detach al l dom read y events | |
3527 | de tach(); | |
3528 | ||
3529 | // and execu te any wai ting funct ions | |
3530 | jQ uery.ready (); | |
3531 | } | |
3532 | })(); | |
3533 | } | |
3534 | } | |
3535 | } | |
3536 | re turn ready List.promi se( obj ); | |
3537 | }; | |
3538 | ||
3539 | ||
3540 | var st rundefined = typeof undefined; | |
3541 | ||
3542 | ||
3543 | ||
3544 | // Support : IE<9 | |
3545 | // Iterati on over ob ject's inh erited pro perties be fore its o wn | |
3546 | var i; | |
3547 | for ( i in jQuer y( support ) ) { | |
3548 | br eak; | |
3549 | } | |
3550 | suppor t.ownLast = i !== "0 "; | |
3551 | ||
3552 | // Note: m ost suppor t tests ar e defined in their r espective modules. | |
3553 | // false u ntil the t est is run | |
3554 | suppor t.inlineBl ockNeedsLa yout = fal se; | |
3555 | ||
3556 | // Execute ASAP in c ase we nee d to set b ody.style. zoom | |
3557 | jQuery (function( ) { | |
3558 | // Minified: var a,b,c ,d | |
3559 | va r val, div , body, co ntainer; | |
3560 | ||
3561 | bo dy = docum ent.getEle mentsByTag Name( "bod y" )[ 0 ]; | |
3562 | if ( !body | | !body.st yle ) { | |
3563 | // Retur n for fram eset docs that don't have a bo dy | |
3564 | return; | |
3565 | } | |
3566 | ||
3567 | // Setup | |
3568 | di v = docume nt.createE lement( "d iv" ); | |
3569 | co ntainer = document.c reateEleme nt( "div" ); | |
3570 | co ntainer.st yle.cssTex t = "posit ion:absolu te;border: 0;width:0; height:0;t op:0;left: -9999px"; | |
3571 | bo dy.appendC hild( cont ainer ).ap pendChild( div ); | |
3572 | ||
3573 | if ( typeof div.style. zoom !== s trundefine d ) { | |
3574 | // Suppo rt: IE<8 | |
3575 | // Check if native ly block-l evel eleme nts act li ke inline- block | |
3576 | // eleme nts when s etting the ir display to 'inlin e' and giv ing | |
3577 | // them layout | |
3578 | div.styl e.cssText = "display :inline;ma rgin:0;bor der:0;padd ing:1px;wi dth:1px;zo om:1"; | |
3579 | ||
3580 | support. inlineBloc kNeedsLayo ut = val = div.offse tWidth === 3; | |
3581 | if ( val ) { | |
3582 | // P revent IE 6 from aff ecting lay out for po sitioned e lements #1 1048 | |
3583 | // P revent IE from shrin king the b ody in IE 7 mode #12 869 | |
3584 | // S upport: IE <8 | |
3585 | body .style.zoo m = 1; | |
3586 | } | |
3587 | } | |
3588 | ||
3589 | bo dy.removeC hild( cont ainer ); | |
3590 | }); | |
3591 | ||
3592 | ||
3593 | ||
3594 | ||
3595 | (funct ion() { | |
3596 | va r div = do cument.cre ateElement ( "div" ); | |
3597 | ||
3598 | // Execute t he test on ly if not already ex ecuted in another mo dule. | |
3599 | if (support. deleteExpa ndo == nul l) { | |
3600 | // Suppo rt: IE<9 | |
3601 | support. deleteExpa ndo = true ; | |
3602 | try { | |
3603 | dele te div.tes t; | |
3604 | } catch( e ) { | |
3605 | supp ort.delete Expando = false; | |
3606 | } | |
3607 | } | |
3608 | ||
3609 | // Null elem ents to av oid leaks in IE. | |
3610 | di v = null; | |
3611 | })(); | |
3612 | ||
3613 | ||
3614 | /** | |
3615 | * Det ermines wh ether an o bject can have data | |
3616 | */ | |
3617 | jQuery .acceptDat a = functi on( elem ) { | |
3618 | va r noData = jQuery.no Data[ (ele m.nodeName + " ").to LowerCase( ) ], | |
3619 | nodeType = +elem.n odeType || 1; | |
3620 | ||
3621 | // Do not se t data on non-elemen t DOM node s because it will no t be clear ed (#8335) . | |
3622 | re turn nodeT ype !== 1 && nodeTyp e !== 9 ? | |
3623 | false : | |
3624 | ||
3625 | // Nodes accept da ta unless otherwise specified; rejection can be co nditional | |
3626 | !noData || noData !== true & & elem.get Attribute( "classid") === noDat a; | |
3627 | }; | |
3628 | ||
3629 | ||
3630 | var rb race = /^( ?:\{[\w\W] *\}|\[[\w\ W]*\])$/, | |
3631 | rm ultiDash = /([A-Z])/ g; | |
3632 | ||
3633 | functi on dataAtt r( elem, k ey, data ) { | |
3634 | // If nothin g was foun d internal ly, try to fetch any | |
3635 | // data from the HTML5 data-* at tribute | |
3636 | if ( data == = undefine d && elem. nodeType = == 1 ) { | |
3637 | ||
3638 | var name = "data-" + key.rep lace( rmul tiDash, "- $1" ).toLo werCase(); | |
3639 | ||
3640 | data = e lem.getAtt ribute( na me ); | |
3641 | ||
3642 | if ( typ eof data = == "string " ) { | |
3643 | try { | |
3644 | data = dat a === "tru e" ? true : | |
3645 | da ta === "fa lse" ? fal se : | |
3646 | da ta === "nu ll" ? null : | |
3647 | // Onl y convert to a numbe r if it do esn't chan ge the str ing | |
3648 | +d ata + "" = == data ? +data : | |
3649 | rbrace .test( dat a ) ? jQue ry.parseJS ON( data ) : | |
3650 | da ta; | |
3651 | } ca tch( e ) { } | |
3652 | ||
3653 | // M ake sure w e set the data so it isn't cha nged later | |
3654 | jQue ry.data( e lem, key, data ); | |
3655 | ||
3656 | } else { | |
3657 | data = undefin ed; | |
3658 | } | |
3659 | } | |
3660 | ||
3661 | re turn data; | |
3662 | } | |
3663 | ||
3664 | // checks a cache ob ject for e mptiness | |
3665 | functi on isEmpty DataObject ( obj ) { | |
3666 | va r name; | |
3667 | fo r ( name i n obj ) { | |
3668 | ||
3669 | // if th e public d ata object is empty, the priva te is stil l empty | |
3670 | if ( nam e === "dat a" && jQue ry.isEmpty Object( ob j[name] ) ) { | |
3671 | cont inue; | |
3672 | } | |
3673 | if ( nam e !== "toJ SON" ) { | |
3674 | retu rn false; | |
3675 | } | |
3676 | } | |
3677 | ||
3678 | re turn true; | |
3679 | } | |
3680 | ||
3681 | functi on interna lData( ele m, name, d ata, pvt / * Internal Use Only */ ) { | |
3682 | if ( !jQuery .acceptDat a( elem ) ) { | |
3683 | return; | |
3684 | } | |
3685 | ||
3686 | va r ret, thi sCache, | |
3687 | internal Key = jQue ry.expando , | |
3688 | ||
3689 | // We have t o handle D OM nodes a nd JS obje cts differ ently beca use IE6-7 | |
3690 | // can't GC object ref erences pr operly acr oss the DO M-JS bound ary | |
3691 | isNode = elem.node Type, | |
3692 | ||
3693 | // Only DOM nodes need the globa l jQuery c ache; JS o bject data is | |
3694 | // attached directly t o the obje ct so GC c an occur a utomatical ly | |
3695 | cache = isNode ? j Query.cach e : elem, | |
3696 | ||
3697 | // Only defi ning an ID for JS ob jects if i ts cache a lready exi sts allows | |
3698 | // the code to shortcu t on the s ame path a s a DOM no de with no cache | |
3699 | id = isN ode ? elem [ internal Key ] : el em[ intern alKey ] && internalK ey; | |
3700 | ||
3701 | // Avoid doi ng any mor e work tha n we need to when tr ying to ge t data on an | |
3702 | // object th at has no data at al l | |
3703 | if ( (!id || !cache[id ] || (!pvt && !cache [id].data) ) && data === undefi ned && typ eof name = == "string " ) { | |
3704 | return; | |
3705 | } | |
3706 | ||
3707 | if ( !id ) { | |
3708 | // Only DOM nodes need a new unique ID for each element si nce their data | |
3709 | // ends up in the global cac he | |
3710 | if ( isN ode ) { | |
3711 | id = elem[ int ernalKey ] = deleted Ids.pop() || jQuery. guid++; | |
3712 | } else { | |
3713 | id = internalK ey; | |
3714 | } | |
3715 | } | |
3716 | ||
3717 | if ( !cache[ id ] ) { | |
3718 | // Avoid exposing jQuery met adata on p lain JS ob jects when the objec t | |
3719 | // is se rialized u sing JSON. stringify | |
3720 | cache[ i d ] = isNo de ? {} : { toJSON: jQuery.noo p }; | |
3721 | } | |
3722 | ||
3723 | // An object can be pa ssed to jQ uery.data instead of a key/val ue pair; t his gets | |
3724 | // shallow c opied over onto the existing c ache | |
3725 | if ( typeof name === " object" || typeof na me === "fu nction" ) { | |
3726 | if ( pvt ) { | |
3727 | cach e[ id ] = jQuery.ext end( cache [ id ], na me ); | |
3728 | } else { | |
3729 | cach e[ id ].da ta = jQuer y.extend( cache[ id ].data, na me ); | |
3730 | } | |
3731 | } | |
3732 | ||
3733 | th isCache = cache[ id ]; | |
3734 | ||
3735 | // jQuery da ta() is st ored in a separate o bject insi de the obj ect's inte rnal data | |
3736 | // cache in order to a void key c ollisions between in ternal dat a and user -defined | |
3737 | // data. | |
3738 | if ( !pvt ) { | |
3739 | if ( !th isCache.da ta ) { | |
3740 | this Cache.data = {}; | |
3741 | } | |
3742 | ||
3743 | thisCach e = thisCa che.data; | |
3744 | } | |
3745 | ||
3746 | if ( data != = undefine d ) { | |
3747 | thisCach e[ jQuery. camelCase( name ) ] = data; | |
3748 | } | |
3749 | ||
3750 | // Check for both conv erted-to-c amel and n on-convert ed data pr operty nam es | |
3751 | // If a data property was specif ied | |
3752 | if ( typeof name === " string" ) { | |
3753 | ||
3754 | // First Try to fi nd as-is p roperty da ta | |
3755 | ret = th isCache[ n ame ]; | |
3756 | ||
3757 | // Test for null|u ndefined p roperty da ta | |
3758 | if ( ret == null ) { | |
3759 | ||
3760 | // T ry to find the camel Cased prop erty | |
3761 | ret = thisCach e[ jQuery. camelCase( name ) ]; | |
3762 | } | |
3763 | } else { | |
3764 | ret = th isCache; | |
3765 | } | |
3766 | ||
3767 | re turn ret; | |
3768 | } | |
3769 | ||
3770 | functi on interna lRemoveDat a( elem, n ame, pvt ) { | |
3771 | if ( !jQuery .acceptDat a( elem ) ) { | |
3772 | return; | |
3773 | } | |
3774 | ||
3775 | va r thisCach e, i, | |
3776 | isNode = elem.node Type, | |
3777 | ||
3778 | // See jQuer y.data for more info rmation | |
3779 | cache = isNode ? j Query.cach e : elem, | |
3780 | id = isN ode ? elem [ jQuery.e xpando ] : jQuery.ex pando; | |
3781 | ||
3782 | // If there is already no cache entry for this objec t, there i s no | |
3783 | // purpose i n continui ng | |
3784 | if ( !cache[ id ] ) { | |
3785 | return; | |
3786 | } | |
3787 | ||
3788 | if ( name ) { | |
3789 | ||
3790 | thisCach e = pvt ? cache[ id ] : cache[ id ].data ; | |
3791 | ||
3792 | if ( thi sCache ) { | |
3793 | ||
3794 | // S upport arr ay or spac e separate d string n ames for d ata keys | |
3795 | if ( !jQuery.i sArray( na me ) ) { | |
3796 | ||
3797 | // try the string as a key bef ore any ma nipulation | |
3798 | if ( name in thisCac he ) { | |
3799 | name = [ name ]; | |
3800 | } else { | |
3801 | ||
3802 | // spl it the cam el cased v ersion by spaces unl ess a key with the s paces exis ts | |
3803 | name = jQuery.ca melCase( n ame ); | |
3804 | if ( n ame in thi sCache ) { | |
3805 | na me = [ nam e ]; | |
3806 | } else { | |
3807 | na me = name. split(" ") ; | |
3808 | } | |
3809 | } | |
3810 | } el se { | |
3811 | // If "nam e" is an a rray of ke ys... | |
3812 | // When da ta is init ially crea ted, via ( "key", "va l") signat ure, | |
3813 | // keys wi ll be conv erted to c amelCase. | |
3814 | // Since t here is no way to te ll _how_ a key was a dded, remo ve | |
3815 | // both pl ain key an d camelCas e key. #12 786 | |
3816 | // This wi ll only pe nalize the array arg ument path . | |
3817 | name = nam e.concat( jQuery.map ( name, jQ uery.camel Case ) ); | |
3818 | } | |
3819 | ||
3820 | i = name.lengt h; | |
3821 | whil e ( i-- ) { | |
3822 | delete thi sCache[ na me[i] ]; | |
3823 | } | |
3824 | ||
3825 | // I f there is no data l eft in the cache, we want to c ontinue | |
3826 | // a nd let the cache obj ect itself get destr oyed | |
3827 | if ( pvt ? !is EmptyDataO bject(this Cache) : ! jQuery.isE mptyObject (thisCache ) ) { | |
3828 | return; | |
3829 | } | |
3830 | } | |
3831 | } | |
3832 | ||
3833 | // See jQuer y.data for more info rmation | |
3834 | if ( !pvt ) { | |
3835 | delete c ache[ id ] .data; | |
3836 | ||
3837 | // Don't destroy t he parent cache unle ss the int ernal data object | |
3838 | // had b een the on ly thing l eft in it | |
3839 | if ( !is EmptyDataO bject( cac he[ id ] ) ) { | |
3840 | retu rn; | |
3841 | } | |
3842 | } | |
3843 | ||
3844 | // Destroy t he cache | |
3845 | if ( isNode ) { | |
3846 | jQuery.c leanData( [ elem ], true ); | |
3847 | ||
3848 | // Use d elete when supported for expan dos or `ca che` is no t a window per isWin dow (#1008 0) | |
3849 | /* jshin t eqeqeq: false */ | |
3850 | } else if ( support.de leteExpand o || cache != cache. window ) { | |
3851 | /* jshin t eqeqeq: true */ | |
3852 | delete c ache[ id ] ; | |
3853 | ||
3854 | // When all else f ails, null | |
3855 | } else { | |
3856 | cache[ i d ] = null ; | |
3857 | } | |
3858 | } | |
3859 | ||
3860 | jQuery .extend({ | |
3861 | ca che: {}, | |
3862 | ||
3863 | // The follo wing eleme nts (space -suffixed to avoid O bject.prot otype coll isions) | |
3864 | // throw unc atchable e xceptions if you att empt to se t expando properties | |
3865 | no Data: { | |
3866 | "applet ": true, | |
3867 | "embed " : true, | |
3868 | // ...bu t Flash ob jects (whi ch have th is classid ) *can* ha ndle expan dos | |
3869 | "object ": "clsid: D27CDB6E-A E6D-11cf-9 6B8-444553 540000" | |
3870 | }, | |
3871 | ||
3872 | ha sData: fun ction( ele m ) { | |
3873 | elem = e lem.nodeTy pe ? jQuer y.cache[ e lem[jQuery .expando] ] : elem[ jQuery.exp ando ]; | |
3874 | return ! !elem && ! isEmptyDat aObject( e lem ); | |
3875 | }, | |
3876 | ||
3877 | da ta: functi on( elem, name, data ) { | |
3878 | return i nternalDat a( elem, n ame, data ); | |
3879 | }, | |
3880 | ||
3881 | re moveData: function( elem, name ) { | |
3882 | return i nternalRem oveData( e lem, name ); | |
3883 | }, | |
3884 | ||
3885 | // For inter nal use on ly. | |
3886 | _d ata: funct ion( elem, name, dat a ) { | |
3887 | return i nternalDat a( elem, n ame, data, true ); | |
3888 | }, | |
3889 | ||
3890 | _r emoveData: function( elem, nam e ) { | |
3891 | return i nternalRem oveData( e lem, name, true ); | |
3892 | } | |
3893 | }); | |
3894 | ||
3895 | jQuery .fn.extend ({ | |
3896 | da ta: functi on( key, v alue ) { | |
3897 | var i, n ame, data, | |
3898 | elem = this[0] , | |
3899 | attr s = elem & & elem.att ributes; | |
3900 | ||
3901 | // Speci al expecti ons of .da ta basical ly thwart jQuery.acc ess, | |
3902 | // so im plement th e relevant behavior ourselves | |
3903 | ||
3904 | // Gets all values | |
3905 | if ( key === undef ined ) { | |
3906 | if ( this.leng th ) { | |
3907 | data = jQu ery.data( elem ); | |
3908 | ||
3909 | if ( elem. nodeType = == 1 && !j Query._dat a( elem, " parsedAttr s" ) ) { | |
3910 | i = at trs.length ; | |
3911 | while ( i-- ) { | |
3912 | ||
3913 | // Support: IE11+ | |
3914 | // The attrs elements can be nul l (#14894) | |
3915 | if ( attrs[ i ] ) { | |
3916 | name = a ttrs[ i ]. name; | |
3917 | if ( nam e.indexOf( "data-" ) === 0 ) { | |
3918 | name = jQuery. camelCase( name.slic e(5) ); | |
3919 | data Attr( elem , name, da ta[ name ] ); | |
3920 | } | |
3921 | } | |
3922 | } | |
3923 | jQuery ._data( el em, "parse dAttrs", t rue ); | |
3924 | } | |
3925 | } | |
3926 | ||
3927 | retu rn data; | |
3928 | } | |
3929 | ||
3930 | // Sets multiple v alues | |
3931 | if ( typ eof key == = "object" ) { | |
3932 | retu rn this.ea ch(functio n() { | |
3933 | jQuery.dat a( this, k ey ); | |
3934 | }); | |
3935 | } | |
3936 | ||
3937 | return a rguments.l ength > 1 ? | |
3938 | ||
3939 | // S ets one va lue | |
3940 | this .each(func tion() { | |
3941 | jQuery.dat a( this, k ey, value ); | |
3942 | }) : | |
3943 | ||
3944 | // G ets one va lue | |
3945 | // T ry to fetc h any inte rnally sto red data f irst | |
3946 | elem ? dataAtt r( elem, k ey, jQuery .data( ele m, key ) ) : undefin ed; | |
3947 | }, | |
3948 | ||
3949 | re moveData: function( key ) { | |
3950 | return t his.each(f unction() { | |
3951 | jQue ry.removeD ata( this, key ); | |
3952 | }); | |
3953 | } | |
3954 | }); | |
3955 | ||
3956 | ||
3957 | jQuery .extend({ | |
3958 | qu eue: funct ion( elem, type, dat a ) { | |
3959 | var queu e; | |
3960 | ||
3961 | if ( ele m ) { | |
3962 | type = ( type || "fx" ) + "queue"; | |
3963 | queu e = jQuery ._data( el em, type ) ; | |
3964 | ||
3965 | // S peed up de queue by g etting out quickly i f this is just a loo kup | |
3966 | if ( data ) { | |
3967 | if ( !queu e || jQuer y.isArray( data) ) { | |
3968 | queue = jQuery._ data( elem , type, jQ uery.makeA rray(data) ); | |
3969 | } else { | |
3970 | queue. push( data ); | |
3971 | } | |
3972 | } | |
3973 | retu rn queue | | []; | |
3974 | } | |
3975 | }, | |
3976 | ||
3977 | de queue: fun ction( ele m, type ) { | |
3978 | type = t ype || "fx "; | |
3979 | ||
3980 | var queu e = jQuery .queue( el em, type ) , | |
3981 | star tLength = queue.leng th, | |
3982 | fn = queue.shi ft(), | |
3983 | hook s = jQuery ._queueHoo ks( elem, type ), | |
3984 | next = functio n() { | |
3985 | jQuery.deq ueue( elem , type ); | |
3986 | }; | |
3987 | ||
3988 | // If th e fx queue is dequeu ed, always remove th e progress sentinel | |
3989 | if ( fn === "inpro gress" ) { | |
3990 | fn = queue.shi ft(); | |
3991 | star tLength--; | |
3992 | } | |
3993 | ||
3994 | if ( fn ) { | |
3995 | ||
3996 | // A dd a progr ess sentin el to prev ent the fx queue fro m being | |
3997 | // a utomatical ly dequeue d | |
3998 | if ( type === "fx" ) { | |
3999 | queue.unsh ift( "inpr ogress" ); | |
4000 | } | |
4001 | ||
4002 | // c lear up th e last que ue stop fu nction | |
4003 | dele te hooks.s top; | |
4004 | fn.c all( elem, next, hoo ks ); | |
4005 | } | |
4006 | ||
4007 | if ( !st artLength && hooks ) { | |
4008 | hook s.empty.fi re(); | |
4009 | } | |
4010 | }, | |
4011 | ||
4012 | // not inten ded for pu blic consu mption - g enerates a queueHook s object, or returns the curre nt one | |
4013 | _q ueueHooks: function( elem, typ e ) { | |
4014 | var key = type + " queueHooks "; | |
4015 | return j Query._dat a( elem, k ey ) || jQ uery._data ( elem, ke y, { | |
4016 | empt y: jQuery. Callbacks( "once memo ry").add(f unction() { | |
4017 | jQuery._re moveData( elem, type + "queue" ); | |
4018 | jQuery._re moveData( elem, key ); | |
4019 | }) | |
4020 | }); | |
4021 | } | |
4022 | }); | |
4023 | ||
4024 | jQuery .fn.extend ({ | |
4025 | qu eue: funct ion( type, data ) { | |
4026 | var sett er = 2; | |
4027 | ||
4028 | if ( typ eof type ! == "string " ) { | |
4029 | data = type; | |
4030 | type = "fx"; | |
4031 | sett er--; | |
4032 | } | |
4033 | ||
4034 | if ( arg uments.len gth < sett er ) { | |
4035 | retu rn jQuery. queue( thi s[0], type ); | |
4036 | } | |
4037 | ||
4038 | return d ata === un defined ? | |
4039 | this : | |
4040 | this .each(func tion() { | |
4041 | var queue = jQuery.q ueue( this , type, da ta ); | |
4042 | ||
4043 | // ensure a hooks fo r this que ue | |
4044 | jQuery._qu eueHooks( this, type ); | |
4045 | ||
4046 | if ( type === "fx" & & queue[0] !== "inpr ogress" ) { | |
4047 | jQuery .dequeue( this, type ); | |
4048 | } | |
4049 | }); | |
4050 | }, | |
4051 | de queue: fun ction( typ e ) { | |
4052 | return t his.each(f unction() { | |
4053 | jQue ry.dequeue ( this, ty pe ); | |
4054 | }); | |
4055 | }, | |
4056 | cl earQueue: function( type ) { | |
4057 | return t his.queue( type || " fx", [] ); | |
4058 | }, | |
4059 | // Get a pro mise resol ved when q ueues of a certain t ype | |
4060 | // are empti ed (fx is the type b y default) | |
4061 | pr omise: fun ction( typ e, obj ) { | |
4062 | var tmp, | |
4063 | coun t = 1, | |
4064 | defe r = jQuery .Deferred( ), | |
4065 | elem ents = thi s, | |
4066 | i = this.lengt h, | |
4067 | reso lve = func tion() { | |
4068 | if ( !( -- count ) ) { | |
4069 | defer. resolveWit h( element s, [ eleme nts ] ); | |
4070 | } | |
4071 | }; | |
4072 | ||
4073 | if ( typ eof type ! == "string " ) { | |
4074 | obj = type; | |
4075 | type = undefin ed; | |
4076 | } | |
4077 | type = t ype || "fx "; | |
4078 | ||
4079 | while ( i-- ) { | |
4080 | tmp = jQuery._ data( elem ents[ i ], type + "q ueueHooks" ); | |
4081 | if ( tmp && tm p.empty ) { | |
4082 | count++; | |
4083 | tmp.empty. add( resol ve ); | |
4084 | } | |
4085 | } | |
4086 | resolve( ); | |
4087 | return d efer.promi se( obj ); | |
4088 | } | |
4089 | }); | |
4090 | var pn um = (/[+- ]?(?:\d*\. |)\d+(?:[e E][+-]?\d+ |)/).sourc e; | |
4091 | ||
4092 | var cs sExpand = [ "Top", " Right", "B ottom", "L eft" ]; | |
4093 | ||
4094 | var is Hidden = f unction( e lem, el ) { | |
4095 | // isHidden might be c alled from jQuery#fi lter funct ion; | |
4096 | // in that c ase, eleme nt will be second ar gument | |
4097 | el em = el || elem; | |
4098 | re turn jQuer y.css( ele m, "displa y" ) === " none" || ! jQuery.con tains( ele m.ownerDoc ument, ele m ); | |
4099 | }; | |
4100 | ||
4101 | ||
4102 | ||
4103 | // Multifu nctional m ethod to g et and set values of a collect ion | |
4104 | // The val ue/s can o ptionally be execute d if it's a function | |
4105 | var ac cess = jQu ery.access = functio n( elems, fn, key, v alue, chai nable, emp tyGet, raw ) { | |
4106 | va r i = 0, | |
4107 | length = elems.len gth, | |
4108 | bulk = k ey == null ; | |
4109 | ||
4110 | // Sets many values | |
4111 | if ( jQuery. type( key ) === "obj ect" ) { | |
4112 | chainabl e = true; | |
4113 | for ( i in key ) { | |
4114 | jQue ry.access( elems, fn , i, key[i ], true, e mptyGet, r aw ); | |
4115 | } | |
4116 | ||
4117 | // Sets one value | |
4118 | } else if ( value !== undefined ) { | |
4119 | chainabl e = true; | |
4120 | ||
4121 | if ( !jQ uery.isFun ction( val ue ) ) { | |
4122 | raw = true; | |
4123 | } | |
4124 | ||
4125 | if ( bul k ) { | |
4126 | // B ulk operat ions run a gainst the entire se t | |
4127 | if ( raw ) { | |
4128 | fn.call( e lems, valu e ); | |
4129 | fn = null; | |
4130 | ||
4131 | // ...exce pt when ex ecuting fu nction val ues | |
4132 | } el se { | |
4133 | bulk = fn; | |
4134 | fn = funct ion( elem, key, valu e ) { | |
4135 | return bulk.call ( jQuery( elem ), va lue ); | |
4136 | }; | |
4137 | } | |
4138 | } | |
4139 | ||
4140 | if ( fn ) { | |
4141 | for ( ; i < le ngth; i++ ) { | |
4142 | fn( elems[ i], key, r aw ? value : value.c all( elems [i], i, fn ( elems[i] , key ) ) ); | |
4143 | } | |
4144 | } | |
4145 | } | |
4146 | ||
4147 | re turn chain able ? | |
4148 | elems : | |
4149 | ||
4150 | // Gets | |
4151 | bulk ? | |
4152 | fn.c all( elems ) : | |
4153 | leng th ? fn( e lems[0], k ey ) : emp tyGet; | |
4154 | }; | |
4155 | var rc heckableTy pe = (/^(? :checkbox| radio)$/i) ; | |
4156 | ||
4157 | ||
4158 | ||
4159 | (funct ion() { | |
4160 | // Minified: var a,b,c | |
4161 | va r input = document.c reateEleme nt( "input " ), | |
4162 | div = do cument.cre ateElement ( "div" ), | |
4163 | fragment = documen t.createDo cumentFrag ment(); | |
4164 | ||
4165 | // Setup | |
4166 | di v.innerHTM L = " <li nk/><table ></table>< a href='/a '>a</a><in put type=' checkbox'/ >"; | |
4167 | ||
4168 | // IE strips leading w hitespace when .inne rHTML is u sed | |
4169 | su pport.lead ingWhitesp ace = div. firstChild .nodeType === 3; | |
4170 | ||
4171 | // Make sure that tbod y elements aren't au tomaticall y inserted | |
4172 | // IE will i nsert them into empt y tables | |
4173 | su pport.tbod y = !div.g etElements ByTagName( "tbody" ) .length; | |
4174 | ||
4175 | // Make sure that link elements get serial ized corre ctly by in nerHTML | |
4176 | // This requ ires a wra pper eleme nt in IE | |
4177 | su pport.html Serialize = !!div.ge tElementsB yTagName( "link" ).l ength; | |
4178 | ||
4179 | // Makes sur e cloning an html5 e lement doe s not caus e problems | |
4180 | // Where out erHTML is undefined, this stil l works | |
4181 | su pport.html 5Clone = | |
4182 | document .createEle ment( "nav " ).cloneN ode( true ).outerHTM L !== "<:n av></:nav> "; | |
4183 | ||
4184 | // Check if a disconne cted check box will r etain its checked | |
4185 | // value of true after appended to the DOM (IE6/7) | |
4186 | in put.type = "checkbox "; | |
4187 | in put.checke d = true; | |
4188 | fr agment.app endChild( input ); | |
4189 | su pport.appe ndChecked = input.ch ecked; | |
4190 | ||
4191 | // Make sure textarea (and check box) defau ltValue is properly cloned | |
4192 | // Support: IE6-IE11+ | |
4193 | di v.innerHTM L = "<text area>x</te xtarea>"; | |
4194 | su pport.noCl oneChecked = !!div.c loneNode( true ).las tChild.def aultValue; | |
4195 | ||
4196 | // #11217 - WebKit los es check w hen the na me is afte r the chec ked attrib ute | |
4197 | fr agment.app endChild( div ); | |
4198 | di v.innerHTM L = "<inpu t type='ra dio' check ed='checke d' name='t '/>"; | |
4199 | ||
4200 | // Support: Safari 5.1 , iOS 5.1, Android 4 .x, Androi d 2.3 | |
4201 | // old WebKi t doesn't clone chec ked state correctly in fragmen ts | |
4202 | su pport.chec kClone = d iv.cloneNo de( true ) .cloneNode ( true ).l astChild.c hecked; | |
4203 | ||
4204 | // Support: IE<9 | |
4205 | // Opera doe s not clon e events ( and typeof div.attac hEvent === undefined ). | |
4206 | // IE9-10 cl ones event s bound vi a attachEv ent, but t hey don't trigger wi th .click( ) | |
4207 | su pport.noCl oneEvent = true; | |
4208 | if ( div.att achEvent ) { | |
4209 | div.atta chEvent( " onclick", function() { | |
4210 | supp ort.noClon eEvent = f alse; | |
4211 | }); | |
4212 | ||
4213 | div.clon eNode( tru e ).click( ); | |
4214 | } | |
4215 | ||
4216 | // Execute t he test on ly if not already ex ecuted in another mo dule. | |
4217 | if (support. deleteExpa ndo == nul l) { | |
4218 | // Suppo rt: IE<9 | |
4219 | support. deleteExpa ndo = true ; | |
4220 | try { | |
4221 | dele te div.tes t; | |
4222 | } catch( e ) { | |
4223 | supp ort.delete Expando = false; | |
4224 | } | |
4225 | } | |
4226 | })(); | |
4227 | ||
4228 | ||
4229 | (funct ion() { | |
4230 | va r i, event Name, | |
4231 | div = do cument.cre ateElement ( "div" ); | |
4232 | ||
4233 | // Support: IE<9 (lack submit/ch ange bubbl e), Firefo x 23+ (lac k focusin event) | |
4234 | fo r ( i in { submit: t rue, chang e: true, f ocusin: tr ue }) { | |
4235 | eventNam e = "on" + i; | |
4236 | ||
4237 | if ( !(s upport[ i + "Bubbles " ] = even tName in w indow) ) { | |
4238 | // B eware of C SP restric tions (htt ps://devel oper.mozil la.org/en/ Security/C SP) | |
4239 | div. setAttribu te( eventN ame, "t" ) ; | |
4240 | supp ort[ i + " Bubbles" ] = div.att ributes[ e ventName ] .expando = == false; | |
4241 | } | |
4242 | } | |
4243 | ||
4244 | // Null elem ents to av oid leaks in IE. | |
4245 | di v = null; | |
4246 | })(); | |
4247 | ||
4248 | ||
4249 | var rf ormElems = /^(?:inpu t|select|t extarea)$/ i, | |
4250 | rk eyEvent = /^key/, | |
4251 | rm ouseEvent = /^(?:mou se|pointer |contextme nu)|click/ , | |
4252 | rf ocusMorph = /^(?:foc usinfocus| focusoutbl ur)$/, | |
4253 | rt ypenamespa ce = /^([^ .]*)(?:\.( .+)|)$/; | |
4254 | ||
4255 | functi on returnT rue() { | |
4256 | re turn true; | |
4257 | } | |
4258 | ||
4259 | functi on returnF alse() { | |
4260 | re turn false ; | |
4261 | } | |
4262 | ||
4263 | functi on safeAct iveElement () { | |
4264 | tr y { | |
4265 | return d ocument.ac tiveElemen t; | |
4266 | } catch ( er r ) { } | |
4267 | } | |
4268 | ||
4269 | /* | |
4270 | * Hel per functi ons for ma naging eve nts -- not part of t he public interface. | |
4271 | * Pro ps to Dean Edwards' addEvent l ibrary for many of t he ideas. | |
4272 | */ | |
4273 | jQuery .event = { | |
4274 | ||
4275 | gl obal: {}, | |
4276 | ||
4277 | ad d: functio n( elem, t ypes, hand ler, data, selector ) { | |
4278 | var tmp, events, t , handleOb jIn, | |
4279 | spec ial, event Handle, ha ndleObj, | |
4280 | hand lers, type , namespac es, origTy pe, | |
4281 | elem Data = jQu ery._data( elem ); | |
4282 | ||
4283 | // Don't attach ev ents to no Data or te xt/comment nodes (bu t allow pl ain object s) | |
4284 | if ( !el emData ) { | |
4285 | retu rn; | |
4286 | } | |
4287 | ||
4288 | // Calle r can pass in an obj ect of cus tom data i n lieu of the handle r | |
4289 | if ( han dler.handl er ) { | |
4290 | hand leObjIn = handler; | |
4291 | hand ler = hand leObjIn.ha ndler; | |
4292 | sele ctor = han dleObjIn.s elector; | |
4293 | } | |
4294 | ||
4295 | // Make sure that the handle r has a un ique ID, u sed to fin d/remove i t later | |
4296 | if ( !ha ndler.guid ) { | |
4297 | hand ler.guid = jQuery.gu id++; | |
4298 | } | |
4299 | ||
4300 | // Init the elemen t's event structure and main h andler, if this is t he first | |
4301 | if ( !(e vents = el emData.eve nts) ) { | |
4302 | even ts = elemD ata.events = {}; | |
4303 | } | |
4304 | if ( !(e ventHandle = elemDat a.handle) ) { | |
4305 | even tHandle = elemData.h andle = fu nction( e ) { | |
4306 | // Discard the secon d event of a jQuery. event.trig ger() and | |
4307 | // when an event is called aft er a page has unload ed | |
4308 | return typ eof jQuery !== strun defined && (!e || jQ uery.event .triggered !== e.typ e) ? | |
4309 | jQuery .event.dis patch.appl y( eventHa ndle.elem, arguments ) : | |
4310 | undefi ned; | |
4311 | }; | |
4312 | // A dd elem as a propert y of the h andle fn t o prevent a memory l eak with I E non-nati ve events | |
4313 | even tHandle.el em = elem; | |
4314 | } | |
4315 | ||
4316 | // Handl e multiple events se parated by a space | |
4317 | types = ( types || "" ).matc h( rnotwhi te ) || [ "" ]; | |
4318 | t = type s.length; | |
4319 | while ( t-- ) { | |
4320 | tmp = rtypenam espace.exe c( types[t ] ) || []; | |
4321 | type = origTyp e = tmp[1] ; | |
4322 | name spaces = ( tmp[2] || "" ).spli t( "." ).s ort(); | |
4323 | ||
4324 | // T here *must * be a typ e, no atta ching name space-only handlers | |
4325 | if ( !type ) { | |
4326 | continue; | |
4327 | } | |
4328 | ||
4329 | // I f event ch anges its type, use the specia l event ha ndlers for the chang ed type | |
4330 | spec ial = jQue ry.event.s pecial[ ty pe ] || {} ; | |
4331 | ||
4332 | // I f selector defined, determine special ev ent api ty pe, otherw ise given type | |
4333 | type = ( selec tor ? spec ial.delega teType : s pecial.bin dType ) || type; | |
4334 | ||
4335 | // U pdate spec ial based on newly r eset type | |
4336 | spec ial = jQue ry.event.s pecial[ ty pe ] || {} ; | |
4337 | ||
4338 | // h andleObj i s passed t o all even t handlers | |
4339 | hand leObj = jQ uery.exten d({ | |
4340 | type: type , | |
4341 | origType: origType, | |
4342 | data: data , | |
4343 | handler: h andler, | |
4344 | guid: hand ler.guid, | |
4345 | selector: selector, | |
4346 | needsConte xt: select or && jQue ry.expr.ma tch.needsC ontext.tes t( selecto r ), | |
4347 | namespace: namespace s.join("." ) | |
4348 | }, h andleObjIn ); | |
4349 | ||
4350 | // I nit the ev ent handle r queue if we're the first | |
4351 | if ( !(handler s = events [ type ]) ) { | |
4352 | handlers = events[ t ype ] = [] ; | |
4353 | handlers.d elegateCou nt = 0; | |
4354 | ||
4355 | // Only us e addEvent Listener/a ttachEvent if the sp ecial even ts handler returns f alse | |
4356 | if ( !spec ial.setup || special .setup.cal l( elem, d ata, names paces, eve ntHandle ) === false ) { | |
4357 | // Bin d the glob al event h andler to the elemen t | |
4358 | if ( e lem.addEve ntListener ) { | |
4359 | el em.addEven tListener( type, eve ntHandle, false ); | |
4360 | ||
4361 | } else if ( elem .attachEve nt ) { | |
4362 | el em.attachE vent( "on" + type, e ventHandle ); | |
4363 | } | |
4364 | } | |
4365 | } | |
4366 | ||
4367 | if ( special.a dd ) { | |
4368 | special.ad d.call( el em, handle Obj ); | |
4369 | ||
4370 | if ( !hand leObj.hand ler.guid ) { | |
4371 | handle Obj.handle r.guid = h andler.gui d; | |
4372 | } | |
4373 | } | |
4374 | ||
4375 | // A dd to the element's handler li st, delega tes in fro nt | |
4376 | if ( selector ) { | |
4377 | handlers.s plice( han dlers.dele gateCount+ +, 0, hand leObj ); | |
4378 | } el se { | |
4379 | handlers.p ush( handl eObj ); | |
4380 | } | |
4381 | ||
4382 | // K eep track of which e vents have ever been used, for event opt imization | |
4383 | jQue ry.event.g lobal[ typ e ] = true ; | |
4384 | } | |
4385 | ||
4386 | // Nulli fy elem to prevent m emory leak s in IE | |
4387 | elem = n ull; | |
4388 | }, | |
4389 | ||
4390 | // Detach an event or set of eve nts from a n element | |
4391 | re move: func tion( elem , types, h andler, se lector, ma ppedTypes ) { | |
4392 | var j, h andleObj, tmp, | |
4393 | orig Count, t, events, | |
4394 | spec ial, handl ers, type, | |
4395 | name spaces, or igType, | |
4396 | elem Data = jQu ery.hasDat a( elem ) && jQuery. _data( ele m ); | |
4397 | ||
4398 | if ( !el emData || !(events = elemData. events) ) { | |
4399 | retu rn; | |
4400 | } | |
4401 | ||
4402 | // Once for each t ype.namesp ace in typ es; type m ay be omit ted | |
4403 | types = ( types || "" ).matc h( rnotwhi te ) || [ "" ]; | |
4404 | t = type s.length; | |
4405 | while ( t-- ) { | |
4406 | tmp = rtypenam espace.exe c( types[t ] ) || []; | |
4407 | type = origTyp e = tmp[1] ; | |
4408 | name spaces = ( tmp[2] || "" ).spli t( "." ).s ort(); | |
4409 | ||
4410 | // U nbind all events (on this name space, if provided) for the el ement | |
4411 | if ( !type ) { | |
4412 | for ( type in events ) { | |
4413 | jQuery .event.rem ove( elem, type + ty pes[ t ], handler, s elector, t rue ); | |
4414 | } | |
4415 | continue; | |
4416 | } | |
4417 | ||
4418 | spec ial = jQue ry.event.s pecial[ ty pe ] || {} ; | |
4419 | type = ( selec tor ? spec ial.delega teType : s pecial.bin dType ) || type; | |
4420 | hand lers = eve nts[ type ] || []; | |
4421 | tmp = tmp[2] & & new RegE xp( "(^|\\ .)" + name spaces.joi n("\\.(?:. *\\.|)") + "(\\.|$)" ); | |
4422 | ||
4423 | // R emove matc hing event s | |
4424 | orig Count = j = handlers .length; | |
4425 | whil e ( j-- ) { | |
4426 | handleObj = handlers [ j ]; | |
4427 | ||
4428 | if ( ( map pedTypes | | origType === handl eObj.origT ype ) && | |
4429 | ( !han dler || ha ndler.guid === handl eObj.guid ) && | |
4430 | ( !tmp || tmp.te st( handle Obj.namesp ace ) ) && | |
4431 | ( !sel ector || s elector == = handleOb j.selector || select or === "** " && handl eObj.selec tor ) ) { | |
4432 | handle rs.splice( j, 1 ); | |
4433 | ||
4434 | if ( h andleObj.s elector ) { | |
4435 | ha ndlers.del egateCount --; | |
4436 | } | |
4437 | if ( s pecial.rem ove ) { | |
4438 | sp ecial.remo ve.call( e lem, handl eObj ); | |
4439 | } | |
4440 | } | |
4441 | } | |
4442 | ||
4443 | // R emove gene ric event handler if we remove d somethin g and no m ore handle rs exist | |
4444 | // ( avoids pot ential for endless r ecursion d uring remo val of spe cial event handlers) | |
4445 | if ( origCount && !handl ers.length ) { | |
4446 | if ( !spec ial.teardo wn || spec ial.teardo wn.call( e lem, names paces, ele mData.hand le ) === f alse ) { | |
4447 | jQuery .removeEve nt( elem, type, elem Data.handl e ); | |
4448 | } | |
4449 | ||
4450 | delete eve nts[ type ]; | |
4451 | } | |
4452 | } | |
4453 | ||
4454 | // Remov e the expa ndo if it' s no longe r used | |
4455 | if ( jQu ery.isEmpt yObject( e vents ) ) { | |
4456 | dele te elemDat a.handle; | |
4457 | ||
4458 | // r emoveData also check s for empt iness and clears the expando i f empty | |
4459 | // s o use it i nstead of delete | |
4460 | jQue ry._remove Data( elem , "events" ); | |
4461 | } | |
4462 | }, | |
4463 | ||
4464 | tr igger: fun ction( eve nt, data, elem, only Handlers ) { | |
4465 | var hand le, ontype , cur, | |
4466 | bubb leType, sp ecial, tmp , i, | |
4467 | even tPath = [ elem || do cument ], | |
4468 | type = hasOwn. call( even t, "type" ) ? event. type : eve nt, | |
4469 | name spaces = h asOwn.call ( event, " namespace" ) ? event .namespace .split("." ) : []; | |
4470 | ||
4471 | cur = tm p = elem = elem || d ocument; | |
4472 | ||
4473 | // Don't do events on text a nd comment nodes | |
4474 | if ( ele m.nodeType === 3 || elem.nodeT ype === 8 ) { | |
4475 | retu rn; | |
4476 | } | |
4477 | ||
4478 | // focus /blur morp hs to focu sin/out; e nsure we'r e not firi ng them ri ght now | |
4479 | if ( rfo cusMorph.t est( type + jQuery.e vent.trigg ered ) ) { | |
4480 | retu rn; | |
4481 | } | |
4482 | ||
4483 | if ( typ e.indexOf( ".") >= 0 ) { | |
4484 | // N amespaced trigger; c reate a re gexp to ma tch event type in ha ndle() | |
4485 | name spaces = t ype.split( "."); | |
4486 | type = namespa ces.shift( ); | |
4487 | name spaces.sor t(); | |
4488 | } | |
4489 | ontype = type.inde xOf(":") < 0 && "on" + type; | |
4490 | ||
4491 | // Calle r can pass in a jQue ry.Event o bject, Obj ect, or ju st an even t type str ing | |
4492 | event = event[ jQu ery.expand o ] ? | |
4493 | even t : | |
4494 | new jQuery.Eve nt( type, typeof eve nt === "ob ject" && e vent ); | |
4495 | ||
4496 | // Trigg er bitmask : & 1 for native han dlers; & 2 for jQuer y (always true) | |
4497 | event.is Trigger = onlyHandle rs ? 2 : 3 ; | |
4498 | event.na mespace = namespaces .join(".") ; | |
4499 | event.na mespace_re = event.n amespace ? | |
4500 | new RegExp( "( ^|\\.)" + namespaces .join("\\. (?:.*\\.|) ") + "(\\. |$)" ) : | |
4501 | null ; | |
4502 | ||
4503 | // Clean up the ev ent in cas e it is be ing reused | |
4504 | event.re sult = und efined; | |
4505 | if ( !ev ent.target ) { | |
4506 | even t.target = elem; | |
4507 | } | |
4508 | ||
4509 | // Clone any incom ing data a nd prepend the event , creating the handl er arg lis t | |
4510 | data = d ata == nul l ? | |
4511 | [ ev ent ] : | |
4512 | jQue ry.makeArr ay( data, [ event ] ); | |
4513 | ||
4514 | // Allow special e vents to d raw outsid e the line s | |
4515 | special = jQuery.e vent.speci al[ type ] || {}; | |
4516 | if ( !on lyHandlers && specia l.trigger && special .trigger.a pply( elem , data ) = == false ) { | |
4517 | retu rn; | |
4518 | } | |
4519 | ||
4520 | // Deter mine event propagati on path in advance, per W3C ev ents spec (#9951) | |
4521 | // Bubbl e up to do cument, th en to wind ow; watch for a glob al ownerDo cument var (#9724) | |
4522 | if ( !on lyHandlers && !speci al.noBubbl e && !jQue ry.isWindo w( elem ) ) { | |
4523 | ||
4524 | bubb leType = s pecial.del egateType || type; | |
4525 | if ( !rfocusMo rph.test( bubbleType + type ) ) { | |
4526 | cur = cur. parentNode ; | |
4527 | } | |
4528 | for ( ; cur; c ur = cur.p arentNode ) { | |
4529 | eventPath. push( cur ); | |
4530 | tmp = cur; | |
4531 | } | |
4532 | ||
4533 | // O nly add wi ndow if we got to do cument (e. g., not pl ain obj or detached DOM) | |
4534 | if ( tmp === ( elem.owner Document | | document ) ) { | |
4535 | eventPath. push( tmp. defaultVie w || tmp.p arentWindo w || windo w ); | |
4536 | } | |
4537 | } | |
4538 | ||
4539 | // Fire handlers o n the even t path | |
4540 | i = 0; | |
4541 | while ( (cur = eve ntPath[i++ ]) && !eve nt.isPropa gationStop ped() ) { | |
4542 | ||
4543 | even t.type = i > 1 ? | |
4544 | bubbleType : | |
4545 | special.bi ndType || type; | |
4546 | ||
4547 | // j Query hand ler | |
4548 | hand le = ( jQu ery._data( cur, "eve nts" ) || {} )[ even t.type ] & & jQuery._ data( cur, "handle" ); | |
4549 | if ( handle ) { | |
4550 | handle.app ly( cur, d ata ); | |
4551 | } | |
4552 | ||
4553 | // N ative hand ler | |
4554 | hand le = ontyp e && cur[ ontype ]; | |
4555 | if ( handle && handle.ap ply && jQu ery.accept Data( cur ) ) { | |
4556 | event.resu lt = handl e.apply( c ur, data ) ; | |
4557 | if ( event .result == = false ) { | |
4558 | event. preventDef ault(); | |
4559 | } | |
4560 | } | |
4561 | } | |
4562 | event.ty pe = type; | |
4563 | ||
4564 | // If no body preve nted the d efault act ion, do it now | |
4565 | if ( !on lyHandlers && !event .isDefault Prevented( ) ) { | |
4566 | ||
4567 | if ( (!special ._default || special ._default. apply( eve ntPath.pop (), data ) === false ) && | |
4568 | jQuery.acc eptData( e lem ) ) { | |
4569 | ||
4570 | // Call a native DOM method on the targe t with the same name name as t he event. | |
4571 | // Can't u se an .isF unction() check here because I E6/7 fails that test . | |
4572 | // Don't d o default actions on window, t hat's wher e global v ariables b e (#6170) | |
4573 | if ( ontyp e && elem[ type ] && !jQuery.i sWindow( e lem ) ) { | |
4574 | ||
4575 | // Don 't re-trig ger an onF OO event w hen we cal l its FOO( ) method | |
4576 | tmp = elem[ onty pe ]; | |
4577 | ||
4578 | if ( t mp ) { | |
4579 | el em[ ontype ] = null; | |
4580 | } | |
4581 | ||
4582 | // Pre vent re-tr iggering o f the same event, si nce we alr eady bubbl ed it abov e | |
4583 | jQuery .event.tri ggered = t ype; | |
4584 | try { | |
4585 | el em[ type ] (); | |
4586 | } catc h ( e ) { | |
4587 | // IE<9 dies on focus/ blur to hi dden eleme nt (#1486, #12518) | |
4588 | // only repr oducible o n winXP IE 8 native, not IE9 in IE8 mode | |
4589 | } | |
4590 | jQuery .event.tri ggered = u ndefined; | |
4591 | ||
4592 | if ( t mp ) { | |
4593 | el em[ ontype ] = tmp; | |
4594 | } | |
4595 | } | |
4596 | } | |
4597 | } | |
4598 | ||
4599 | return e vent.resul t; | |
4600 | }, | |
4601 | ||
4602 | di spatch: fu nction( ev ent ) { | |
4603 | ||
4604 | // Make a writable jQuery.Ev ent from t he native event obje ct | |
4605 | event = jQuery.eve nt.fix( ev ent ); | |
4606 | ||
4607 | var i, r et, handle Obj, match ed, j, | |
4608 | hand lerQueue = [], | |
4609 | args = slice.c all( argum ents ), | |
4610 | hand lers = ( j Query._dat a( this, " events" ) || {} )[ e vent.type ] || [], | |
4611 | spec ial = jQue ry.event.s pecial[ ev ent.type ] || {}; | |
4612 | ||
4613 | // Use t he fix-ed jQuery.Eve nt rather than the ( read-only) native ev ent | |
4614 | args[0] = event; | |
4615 | event.de legateTarg et = this; | |
4616 | ||
4617 | // Call the preDis patch hook for the m apped type , and let it bail if desired | |
4618 | if ( spe cial.preDi spatch && special.pr eDispatch. call( this , event ) === false ) { | |
4619 | retu rn; | |
4620 | } | |
4621 | ||
4622 | // Deter mine handl ers | |
4623 | handlerQ ueue = jQu ery.event. handlers.c all( this, event, ha ndlers ); | |
4624 | ||
4625 | // Run d elegates f irst; they may want to stop pr opagation beneath us | |
4626 | i = 0; | |
4627 | while ( (matched = handlerQu eue[ i++ ] ) && !even t.isPropag ationStopp ed() ) { | |
4628 | even t.currentT arget = ma tched.elem ; | |
4629 | ||
4630 | j = 0; | |
4631 | whil e ( (handl eObj = mat ched.handl ers[ j++ ] ) && !even t.isImmedi atePropaga tionStoppe d() ) { | |
4632 | ||
4633 | // Trigger ed event m ust either 1) have n o namespac e, or | |
4634 | // 2) have namespace (s) a subs et or equa l to those in the bo und event (both can have no na mespace). | |
4635 | if ( !even t.namespac e_re || ev ent.namesp ace_re.tes t( handleO bj.namespa ce ) ) { | |
4636 | ||
4637 | event. handleObj = handleOb j; | |
4638 | event. data = han dleObj.dat a; | |
4639 | ||
4640 | ret = ( (jQuery. event.spec ial[ handl eObj.origT ype ] || { }).handle || handleO bj.handler ) | |
4641 | .a pply( matc hed.elem, args ); | |
4642 | ||
4643 | if ( r et !== und efined ) { | |
4644 | if ( (event. result = r et) === fa lse ) { | |
4645 | event.pr eventDefau lt(); | |
4646 | event.st opPropagat ion(); | |
4647 | } | |
4648 | } | |
4649 | } | |
4650 | } | |
4651 | } | |
4652 | ||
4653 | // Call the postDi spatch hoo k for the mapped typ e | |
4654 | if ( spe cial.postD ispatch ) { | |
4655 | spec ial.postDi spatch.cal l( this, e vent ); | |
4656 | } | |
4657 | ||
4658 | return e vent.resul t; | |
4659 | }, | |
4660 | ||
4661 | ha ndlers: fu nction( ev ent, handl ers ) { | |
4662 | var sel, handleObj , matches, i, | |
4663 | hand lerQueue = [], | |
4664 | dele gateCount = handlers .delegateC ount, | |
4665 | cur = event.ta rget; | |
4666 | ||
4667 | // Find delegate h andlers | |
4668 | // Black -hole SVG <use> inst ance trees (#13180) | |
4669 | // Avoid non-left- click bubb ling in Fi refox (#38 61) | |
4670 | if ( del egateCount && cur.no deType && (!event.bu tton || ev ent.type ! == "click" ) ) { | |
4671 | ||
4672 | /* j shint eqeq eq: false */ | |
4673 | for ( ; cur != this; cur = cur.par entNode || this ) { | |
4674 | /* jshint eqeqeq: tr ue */ | |
4675 | ||
4676 | // Don't c heck non-e lements (# 13208) | |
4677 | // Don't p rocess cli cks on dis abled elem ents (#691 1, #8165, #11382, #1 1764) | |
4678 | if ( cur.n odeType == = 1 && (cu r.disabled !== true || event.t ype !== "c lick") ) { | |
4679 | matche s = []; | |
4680 | for ( i = 0; i < delegateC ount; i++ ) { | |
4681 | ha ndleObj = handlers[ i ]; | |
4682 | ||
4683 | // Don't con flict with Object.pr ototype pr operties ( #13203) | |
4684 | se l = handle Obj.select or + " "; | |
4685 | ||
4686 | if ( matches [ sel ] == = undefine d ) { | |
4687 | matches[ sel ] = h andleObj.n eedsContex t ? | |
4688 | jQue ry( sel, t his ).inde x( cur ) > = 0 : | |
4689 | jQue ry.find( s el, this, null, [ cu r ] ).leng th; | |
4690 | } | |
4691 | if ( matches [ sel ] ) { | |
4692 | matches. push( hand leObj ); | |
4693 | } | |
4694 | } | |
4695 | if ( m atches.len gth ) { | |
4696 | ha ndlerQueue .push({ el em: cur, h andlers: m atches }); | |
4697 | } | |
4698 | } | |
4699 | } | |
4700 | } | |
4701 | ||
4702 | // Add t he remaini ng (direct ly-bound) handlers | |
4703 | if ( del egateCount < handler s.length ) { | |
4704 | hand lerQueue.p ush({ elem : this, ha ndlers: ha ndlers.sli ce( delega teCount ) }); | |
4705 | } | |
4706 | ||
4707 | return h andlerQueu e; | |
4708 | }, | |
4709 | ||
4710 | fi x: functio n( event ) { | |
4711 | if ( eve nt[ jQuery .expando ] ) { | |
4712 | retu rn event; | |
4713 | } | |
4714 | ||
4715 | // Creat e a writab le copy of the event object an d normaliz e some pro perties | |
4716 | var i, p rop, copy, | |
4717 | type = event.t ype, | |
4718 | orig inalEvent = event, | |
4719 | fixH ook = this .fixHooks[ type ]; | |
4720 | ||
4721 | if ( !fi xHook ) { | |
4722 | this .fixHooks[ type ] = fixHook = | |
4723 | rmouseEven t.test( ty pe ) ? thi s.mouseHoo ks : | |
4724 | rkeyEv ent.test( type ) ? t his.keyHoo ks : | |
4725 | {}; | |
4726 | } | |
4727 | copy = f ixHook.pro ps ? this. props.conc at( fixHoo k.props ) : this.pro ps; | |
4728 | ||
4729 | event = new jQuery .Event( or iginalEven t ); | |
4730 | ||
4731 | i = copy .length; | |
4732 | while ( i-- ) { | |
4733 | prop = copy[ i ]; | |
4734 | even t[ prop ] = original Event[ pro p ]; | |
4735 | } | |
4736 | ||
4737 | // Suppo rt: IE<9 | |
4738 | // Fix t arget prop erty (#192 5) | |
4739 | if ( !ev ent.target ) { | |
4740 | even t.target = originalE vent.srcEl ement || d ocument; | |
4741 | } | |
4742 | ||
4743 | // Suppo rt: Chrome 23+, Safa ri? | |
4744 | // Targe t should n ot be a te xt node (# 504, #1314 3) | |
4745 | if ( eve nt.target. nodeType = == 3 ) { | |
4746 | even t.target = event.tar get.parent Node; | |
4747 | } | |
4748 | ||
4749 | // Suppo rt: IE<9 | |
4750 | // For m ouse/key e vents, met aKey==fals e if it's undefined (#3368, #1 1328) | |
4751 | event.me taKey = !! event.meta Key; | |
4752 | ||
4753 | return f ixHook.fil ter ? fixH ook.filter ( event, o riginalEve nt ) : eve nt; | |
4754 | }, | |
4755 | ||
4756 | // Includes some event props sha red by Key Event and MouseEvent | |
4757 | pr ops: "altK ey bubbles cancelabl e ctrlKey currentTar get eventP hase metaK ey related Target shi ftKey targ et timeSta mp view wh ich".split (" "), | |
4758 | ||
4759 | fi xHooks: {} , | |
4760 | ||
4761 | ke yHooks: { | |
4762 | props: " char charC ode key ke yCode".spl it(" "), | |
4763 | filter: function( event, ori ginal ) { | |
4764 | ||
4765 | // A dd which f or key eve nts | |
4766 | if ( event.whi ch == null ) { | |
4767 | event.whic h = origin al.charCod e != null ? original .charCode : original .keyCode; | |
4768 | } | |
4769 | ||
4770 | retu rn event; | |
4771 | } | |
4772 | }, | |
4773 | ||
4774 | mo useHooks: { | |
4775 | props: " button but tons clien tX clientY fromEleme nt offsetX offsetY p ageX pageY screenX s creenY toE lement".sp lit(" "), | |
4776 | filter: function( event, ori ginal ) { | |
4777 | var body, even tDoc, doc, | |
4778 | button = o riginal.bu tton, | |
4779 | fromElemen t = origin al.fromEle ment; | |
4780 | ||
4781 | // C alculate p ageX/Y if missing an d clientX/ Y availabl e | |
4782 | if ( event.pag eX == null && origin al.clientX != null ) { | |
4783 | eventDoc = event.tar get.ownerD ocument || document; | |
4784 | doc = even tDoc.docum entElement ; | |
4785 | body = eve ntDoc.body ; | |
4786 | ||
4787 | event.page X = origin al.clientX + ( doc & & doc.scro llLeft || body && bo dy.scrollL eft || 0 ) - ( doc & & doc.clie ntLeft || body && bo dy.clientL eft || 0 ) ; | |
4788 | event.page Y = origin al.clientY + ( doc & & doc.scro llTop || body && bo dy.scrollT op || 0 ) - ( doc & & doc.clie ntTop || body && bo dy.clientT op || 0 ) ; | |
4789 | } | |
4790 | ||
4791 | // A dd related Target, if necessary | |
4792 | if ( !event.re latedTarge t && fromE lement ) { | |
4793 | event.rela tedTarget = fromElem ent === ev ent.target ? origina l.toElemen t : fromEl ement; | |
4794 | } | |
4795 | ||
4796 | // A dd which f or click: 1 === left ; 2 === mi ddle; 3 == = right | |
4797 | // N ote: butto n is not n ormalized, so don't use it | |
4798 | if ( !event.wh ich && but ton !== un defined ) { | |
4799 | event.whic h = ( butt on & 1 ? 1 : ( butto n & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); | |
4800 | } | |
4801 | ||
4802 | retu rn event; | |
4803 | } | |
4804 | }, | |
4805 | ||
4806 | sp ecial: { | |
4807 | load: { | |
4808 | // P revent tri ggered ima ge.load ev ents from bubbling t o window.l oad | |
4809 | noBu bble: true | |
4810 | }, | |
4811 | focus: { | |
4812 | // F ire native event if possible s o blur/foc us sequenc e is corre ct | |
4813 | trig ger: funct ion() { | |
4814 | if ( this !== safeAc tiveElemen t() && thi s.focus ) { | |
4815 | try { | |
4816 | th is.focus() ; | |
4817 | re turn false ; | |
4818 | } catc h ( e ) { | |
4819 | // Support: IE<9 | |
4820 | // If we err or on focu s to hidde n element (#1486, #1 2518), | |
4821 | // let .trig ger() run the handle rs | |
4822 | } | |
4823 | } | |
4824 | }, | |
4825 | dele gateType: "focusin" | |
4826 | }, | |
4827 | blur: { | |
4828 | trig ger: funct ion() { | |
4829 | if ( this === safeAc tiveElemen t() && thi s.blur ) { | |
4830 | this.b lur(); | |
4831 | return false; | |
4832 | } | |
4833 | }, | |
4834 | dele gateType: "focusout" | |
4835 | }, | |
4836 | click: { | |
4837 | // F or checkbo x, fire na tive event so checke d state wi ll be righ t | |
4838 | trig ger: funct ion() { | |
4839 | if ( jQuer y.nodeName ( this, "i nput" ) && this.type === "chec kbox" && t his.click ) { | |
4840 | this.c lick(); | |
4841 | return false; | |
4842 | } | |
4843 | }, | |
4844 | ||
4845 | // F or cross-b rowser con sistency, don't fire native .c lick() on links | |
4846 | _def ault: func tion( even t ) { | |
4847 | return jQu ery.nodeNa me( event. target, "a " ); | |
4848 | } | |
4849 | }, | |
4850 | ||
4851 | beforeun load: { | |
4852 | post Dispatch: function( event ) { | |
4853 | ||
4854 | // Support : Firefox 20+ | |
4855 | // Firefox doesn't a lert if th e returnVa lue field is not set . | |
4856 | if ( event .result != = undefine d && event .originalE vent ) { | |
4857 | event. originalEv ent.return Value = ev ent.result ; | |
4858 | } | |
4859 | } | |
4860 | } | |
4861 | }, | |
4862 | ||
4863 | si mulate: fu nction( ty pe, elem, event, bub ble ) { | |
4864 | // Piggy back on a donor even t to simul ate a diff erent one. | |
4865 | // Fake originalEv ent to avo id donor's stopPropa gation, bu t if the | |
4866 | // simul ated event prevents default th en we do t he same on the donor . | |
4867 | var e = jQuery.ext end( | |
4868 | new jQuery.Eve nt(), | |
4869 | even t, | |
4870 | { | |
4871 | type: type , | |
4872 | isSimulate d: true, | |
4873 | originalEv ent: {} | |
4874 | } | |
4875 | ); | |
4876 | if ( bub ble ) { | |
4877 | jQue ry.event.t rigger( e, null, ele m ); | |
4878 | } else { | |
4879 | jQue ry.event.d ispatch.ca ll( elem, e ); | |
4880 | } | |
4881 | if ( e.i sDefaultPr evented() ) { | |
4882 | even t.preventD efault(); | |
4883 | } | |
4884 | } | |
4885 | }; | |
4886 | ||
4887 | jQuery .removeEve nt = docum ent.remove EventListe ner ? | |
4888 | fu nction( el em, type, handle ) { | |
4889 | if ( ele m.removeEv entListene r ) { | |
4890 | elem .removeEve ntListener ( type, ha ndle, fals e ); | |
4891 | } | |
4892 | } : | |
4893 | fu nction( el em, type, handle ) { | |
4894 | var name = "on" + type; | |
4895 | ||
4896 | if ( ele m.detachEv ent ) { | |
4897 | ||
4898 | // # 8545, #705 4, prevent ing memory leaks for custom ev ents in IE 6-8 | |
4899 | // d etachEvent needed pr operty on element, b y name of that event , to prope rly expose it to GC | |
4900 | if ( typeof el em[ name ] === strun defined ) { | |
4901 | elem[ name ] = null; | |
4902 | } | |
4903 | ||
4904 | elem .detachEve nt( name, handle ); | |
4905 | } | |
4906 | }; | |
4907 | ||
4908 | jQuery .Event = f unction( s rc, props ) { | |
4909 | // Allow ins tantiation without t he 'new' k eyword | |
4910 | if ( !(this instanceof jQuery.Ev ent) ) { | |
4911 | return n ew jQuery. Event( src , props ); | |
4912 | } | |
4913 | ||
4914 | // Event obj ect | |
4915 | if ( src && src.type ) { | |
4916 | this.ori ginalEvent = src; | |
4917 | this.typ e = src.ty pe; | |
4918 | ||
4919 | // Event s bubbling up the do cument may have been marked as prevented | |
4920 | // by a handler lo wer down t he tree; r eflect the correct v alue. | |
4921 | this.isD efaultPrev ented = sr c.defaultP revented | | | |
4922 | src. defaultPre vented === undefined && | |
4923 | // S upport: IE < 9, Andr oid < 4.0 | |
4924 | src. returnValu e === fals e ? | |
4925 | retu rnTrue : | |
4926 | retu rnFalse; | |
4927 | ||
4928 | // Event type | |
4929 | } else { | |
4930 | this.typ e = src; | |
4931 | } | |
4932 | ||
4933 | // Put expli citly prov ided prope rties onto the event object | |
4934 | if ( props ) { | |
4935 | jQuery.e xtend( thi s, props ) ; | |
4936 | } | |
4937 | ||
4938 | // Create a timestamp if incomin g event do esn't have one | |
4939 | th is.timeSta mp = src & & src.time Stamp || j Query.now( ); | |
4940 | ||
4941 | // Mark it a s fixed | |
4942 | th is[ jQuery .expando ] = true; | |
4943 | }; | |
4944 | ||
4945 | // jQuery. Event is b ased on DO M3 Events as specifi ed by the ECMAScript Language Binding | |
4946 | // http:// www.w3.org /TR/2003/W D-DOM-Leve l-3-Events -20030331/ ecma-scrip t-binding. html | |
4947 | jQuery .Event.pro totype = { | |
4948 | is DefaultPre vented: re turnFalse, | |
4949 | is Propagatio nStopped: returnFals e, | |
4950 | is ImmediateP ropagation Stopped: r eturnFalse , | |
4951 | ||
4952 | pr eventDefau lt: functi on() { | |
4953 | var e = this.origi nalEvent; | |
4954 | ||
4955 | this.isD efaultPrev ented = re turnTrue; | |
4956 | if ( !e ) { | |
4957 | retu rn; | |
4958 | } | |
4959 | ||
4960 | // If pr eventDefau lt exists, run it on the origi nal event | |
4961 | if ( e.p reventDefa ult ) { | |
4962 | e.pr eventDefau lt(); | |
4963 | ||
4964 | // S upport: IE | |
4965 | // O therwise s et the ret urnValue p roperty of the origi nal event to false | |
4966 | } else { | |
4967 | e.re turnValue = false; | |
4968 | } | |
4969 | }, | |
4970 | st opPropagat ion: funct ion() { | |
4971 | var e = this.origi nalEvent; | |
4972 | ||
4973 | this.isP ropagation Stopped = returnTrue ; | |
4974 | if ( !e ) { | |
4975 | retu rn; | |
4976 | } | |
4977 | // If st opPropagat ion exists , run it o n the orig inal event | |
4978 | if ( e.s topPropaga tion ) { | |
4979 | e.st opPropagat ion(); | |
4980 | } | |
4981 | ||
4982 | // Suppo rt: IE | |
4983 | // Set t he cancelB ubble prop erty of th e original event to true | |
4984 | e.cancel Bubble = t rue; | |
4985 | }, | |
4986 | st opImmediat ePropagati on: functi on() { | |
4987 | var e = this.origi nalEvent; | |
4988 | ||
4989 | this.isI mmediatePr opagationS topped = r eturnTrue; | |
4990 | ||
4991 | if ( e & & e.stopIm mediatePro pagation ) { | |
4992 | e.st opImmediat ePropagati on(); | |
4993 | } | |
4994 | ||
4995 | this.sto pPropagati on(); | |
4996 | } | |
4997 | }; | |
4998 | ||
4999 | // Create mouseenter /leave eve nts using mouseover/ out and ev ent-time c hecks | |
5000 | jQuery .each({ | |
5001 | mo useenter: "mouseover ", | |
5002 | mo useleave: "mouseout" , | |
5003 | po interenter : "pointer over", | |
5004 | po interleave : "pointer out" | |
5005 | }, fun ction( ori g, fix ) { | |
5006 | jQ uery.event .special[ orig ] = { | |
5007 | delegate Type: fix, | |
5008 | bindType : fix, | |
5009 | ||
5010 | handle: function( event ) { | |
5011 | var ret, | |
5012 | target = t his, | |
5013 | related = event.rela tedTarget, | |
5014 | handleObj = event.ha ndleObj; | |
5015 | ||
5016 | // F or mousent er/leave c all the ha ndler if r elated is outside th e target. | |
5017 | // N B: No rela tedTarget if the mou se left/en tered the browser wi ndow | |
5018 | if ( !related || (relate d !== targ et && !jQu ery.contai ns( target , related )) ) { | |
5019 | event.type = handleO bj.origTyp e; | |
5020 | ret = hand leObj.hand ler.apply( this, arg uments ); | |
5021 | event.type = fix; | |
5022 | } | |
5023 | retu rn ret; | |
5024 | } | |
5025 | }; | |
5026 | }); | |
5027 | ||
5028 | // IE subm it delegat ion | |
5029 | if ( ! support.su bmitBubble s ) { | |
5030 | ||
5031 | jQ uery.event .special.s ubmit = { | |
5032 | setup: f unction() { | |
5033 | // O nly need t his for de legated fo rm submit events | |
5034 | if ( jQuery.no deName( th is, "form" ) ) { | |
5035 | return fal se; | |
5036 | } | |
5037 | ||
5038 | // L azy-add a submit han dler when a descenda nt form ma y potentia lly be sub mitted | |
5039 | jQue ry.event.a dd( this, "click._su bmit keypr ess._submi t", functi on( e ) { | |
5040 | // Node na me check a voids a VM L-related crash in I E (#9807) | |
5041 | var elem = e.target, | |
5042 | form = jQuery.no deName( el em, "input " ) || jQu ery.nodeNa me( elem, "button" ) ? elem.fo rm : undef ined; | |
5043 | if ( form && !jQuery ._data( fo rm, "submi tBubbles" ) ) { | |
5044 | jQuery .event.add ( form, "s ubmit._sub mit", func tion( even t ) { | |
5045 | ev ent._submi t_bubble = true; | |
5046 | }); | |
5047 | jQuery ._data( fo rm, "submi tBubbles", true ); | |
5048 | } | |
5049 | }); | |
5050 | // r eturn unde fined sinc e we don't need an e vent liste ner | |
5051 | }, | |
5052 | ||
5053 | postDisp atch: func tion( even t ) { | |
5054 | // I f form was submitted by the us er, bubble the event up the tr ee | |
5055 | if ( event._su bmit_bubbl e ) { | |
5056 | delete eve nt._submit _bubble; | |
5057 | if ( this. parentNode && !event .isTrigger ) { | |
5058 | jQuery .event.sim ulate( "su bmit", thi s.parentNo de, event, true ); | |
5059 | } | |
5060 | } | |
5061 | }, | |
5062 | ||
5063 | teardown : function () { | |
5064 | // O nly need t his for de legated fo rm submit events | |
5065 | if ( jQuery.no deName( th is, "form" ) ) { | |
5066 | return fal se; | |
5067 | } | |
5068 | ||
5069 | // R emove dele gated hand lers; clea nData even tually rea ps submit handlers a ttached ab ove | |
5070 | jQue ry.event.r emove( thi s, "._subm it" ); | |
5071 | } | |
5072 | }; | |
5073 | } | |
5074 | ||
5075 | // IE chan ge delegat ion and ch eckbox/rad io fix | |
5076 | if ( ! support.ch angeBubble s ) { | |
5077 | ||
5078 | jQ uery.event .special.c hange = { | |
5079 | ||
5080 | setup: f unction() { | |
5081 | ||
5082 | if ( rformElem s.test( th is.nodeNam e ) ) { | |
5083 | // IE does n't fire c hange on a check/rad io until b lur; trigg er it on c lick | |
5084 | // after a propertyc hange. Eat the blur- change in special.ch ange.handl e. | |
5085 | // This st ill fires onchange a second ti me for che ck/radio a fter blur. | |
5086 | if ( this. type === " checkbox" || this.ty pe === "ra dio" ) { | |
5087 | jQuery .event.add ( this, "p ropertycha nge._chang e", functi on( event ) { | |
5088 | if ( event.o riginalEve nt.propert yName === "checked" ) { | |
5089 | this._ju st_changed = true; | |
5090 | } | |
5091 | }); | |
5092 | jQuery .event.add ( this, "c lick._chan ge", funct ion( event ) { | |
5093 | if ( this._j ust_change d && !even t.isTrigge r ) { | |
5094 | this._ju st_changed = false; | |
5095 | } | |
5096 | // Allow tri ggered, si mulated ch ange event s (#11500) | |
5097 | jQ uery.event .simulate( "change", this, eve nt, true ) ; | |
5098 | }); | |
5099 | } | |
5100 | return fal se; | |
5101 | } | |
5102 | // D elegated e vent; lazy -add a cha nge handle r on desce ndant inpu ts | |
5103 | jQue ry.event.a dd( this, "beforeact ivate._cha nge", func tion( e ) { | |
5104 | var elem = e.target; | |
5105 | ||
5106 | if ( rform Elems.test ( elem.nod eName ) && !jQuery._ data( elem , "changeB ubbles" ) ) { | |
5107 | jQuery .event.add ( elem, "c hange._cha nge", func tion( even t ) { | |
5108 | if ( this.pa rentNode & & !event.i sSimulated && !event .isTrigger ) { | |
5109 | jQuery.e vent.simul ate( "chan ge", this. parentNode , event, t rue ); | |
5110 | } | |
5111 | }); | |
5112 | jQuery ._data( el em, "chang eBubbles", true ); | |
5113 | } | |
5114 | }); | |
5115 | }, | |
5116 | ||
5117 | handle: function( event ) { | |
5118 | var elem = eve nt.target; | |
5119 | ||
5120 | // S wallow nat ive change events fr om checkbo x/radio, w e already triggered them above | |
5121 | if ( this !== elem || ev ent.isSimu lated || e vent.isTri gger || (e lem.type ! == "radio" && elem.t ype !== "c heckbox") ) { | |
5122 | return eve nt.handleO bj.handler .apply( th is, argume nts ); | |
5123 | } | |
5124 | }, | |
5125 | ||
5126 | teardown : function () { | |
5127 | jQue ry.event.r emove( thi s, "._chan ge" ); | |
5128 | ||
5129 | retu rn !rformE lems.test( this.node Name ); | |
5130 | } | |
5131 | }; | |
5132 | } | |
5133 | ||
5134 | // Create "bubbling" focus and blur even ts | |
5135 | if ( ! support.fo cusinBubbl es ) { | |
5136 | jQ uery.each( { focus: " focusin", blur: "foc usout" }, function( orig, fix ) { | |
5137 | ||
5138 | // Attac h a single capturing handler o n the docu ment while someone w ants focus in/focusou t | |
5139 | var hand ler = func tion( even t ) { | |
5140 | jQue ry.event.s imulate( f ix, event. target, jQ uery.event .fix( even t ), true ); | |
5141 | }; | |
5142 | ||
5143 | jQuery.e vent.speci al[ fix ] = { | |
5144 | setu p: functio n() { | |
5145 | var doc = this.owner Document | | this, | |
5146 | attach es = jQuer y._data( d oc, fix ); | |
5147 | ||
5148 | if ( !atta ches ) { | |
5149 | doc.ad dEventList ener( orig , handler, true ); | |
5150 | } | |
5151 | jQuery._da ta( doc, f ix, ( atta ches || 0 ) + 1 ); | |
5152 | }, | |
5153 | tear down: func tion() { | |
5154 | var doc = this.owner Document | | this, | |
5155 | attach es = jQuer y._data( d oc, fix ) - 1; | |
5156 | ||
5157 | if ( !atta ches ) { | |
5158 | doc.re moveEventL istener( o rig, handl er, true ) ; | |
5159 | jQuery ._removeDa ta( doc, f ix ); | |
5160 | } else { | |
5161 | jQuery ._data( do c, fix, at taches ); | |
5162 | } | |
5163 | } | |
5164 | }; | |
5165 | }) ; | |
5166 | } | |
5167 | ||
5168 | jQuery .fn.extend ({ | |
5169 | ||
5170 | on : function ( types, s elector, d ata, fn, / *INTERNAL* / one ) { | |
5171 | var type , origFn; | |
5172 | ||
5173 | // Types can be a map of typ es/handler s | |
5174 | if ( typ eof types === "objec t" ) { | |
5175 | // ( types-Obj ect, selec tor, data ) | |
5176 | if ( typeof se lector !== "string" ) { | |
5177 | // ( types -Object, d ata ) | |
5178 | data = dat a || selec tor; | |
5179 | selector = undefined ; | |
5180 | } | |
5181 | for ( type in types ) { | |
5182 | this.on( t ype, selec tor, data, types[ ty pe ], one ); | |
5183 | } | |
5184 | retu rn this; | |
5185 | } | |
5186 | ||
5187 | if ( dat a == null && fn == n ull ) { | |
5188 | // ( types, fn ) | |
5189 | fn = selector; | |
5190 | data = selecto r = undefi ned; | |
5191 | } else i f ( fn == null ) { | |
5192 | if ( typeof se lector === "string" ) { | |
5193 | // ( types , selector , fn ) | |
5194 | fn = data; | |
5195 | data = und efined; | |
5196 | } el se { | |
5197 | // ( types , data, fn ) | |
5198 | fn = data; | |
5199 | data = sel ector; | |
5200 | selector = undefined ; | |
5201 | } | |
5202 | } | |
5203 | if ( fn === false ) { | |
5204 | fn = returnFal se; | |
5205 | } else i f ( !fn ) { | |
5206 | retu rn this; | |
5207 | } | |
5208 | ||
5209 | if ( one === 1 ) { | |
5210 | orig Fn = fn; | |
5211 | fn = function( event ) { | |
5212 | // Can use an empty set, since event con tains the info | |
5213 | jQuery().o ff( event ); | |
5214 | return ori gFn.apply( this, arg uments ); | |
5215 | }; | |
5216 | // U se same gu id so call er can rem ove using origFn | |
5217 | fn.g uid = orig Fn.guid || ( origFn. guid = jQu ery.guid++ ); | |
5218 | } | |
5219 | return t his.each( function() { | |
5220 | jQue ry.event.a dd( this, types, fn, data, sel ector ); | |
5221 | }); | |
5222 | }, | |
5223 | on e: functio n( types, selector, data, fn ) { | |
5224 | return t his.on( ty pes, selec tor, data, fn, 1 ); | |
5225 | }, | |
5226 | of f: functio n( types, selector, fn ) { | |
5227 | var hand leObj, typ e; | |
5228 | if ( typ es && type s.preventD efault && types.hand leObj ) { | |
5229 | // ( event ) dispatched jQuery.Ev ent | |
5230 | hand leObj = ty pes.handle Obj; | |
5231 | jQue ry( types. delegateTa rget ).off ( | |
5232 | handleObj. namespace ? handleOb j.origType + "." + h andleObj.n amespace : handleObj .origType, | |
5233 | handleObj. selector, | |
5234 | handleObj. handler | |
5235 | ); | |
5236 | retu rn this; | |
5237 | } | |
5238 | if ( typ eof types === "objec t" ) { | |
5239 | // ( types-obj ect [, sel ector] ) | |
5240 | for ( type in types ) { | |
5241 | this.off( type, sele ctor, type s[ type ] ); | |
5242 | } | |
5243 | retu rn this; | |
5244 | } | |
5245 | if ( sel ector === false || t ypeof sele ctor === " function" ) { | |
5246 | // ( types [, fn] ) | |
5247 | fn = selector; | |
5248 | sele ctor = und efined; | |
5249 | } | |
5250 | if ( fn === false ) { | |
5251 | fn = returnFal se; | |
5252 | } | |
5253 | return t his.each(f unction() { | |
5254 | jQue ry.event.r emove( thi s, types, fn, select or ); | |
5255 | }); | |
5256 | }, | |
5257 | ||
5258 | tr igger: fun ction( typ e, data ) { | |
5259 | return t his.each(f unction() { | |
5260 | jQue ry.event.t rigger( ty pe, data, this ); | |
5261 | }); | |
5262 | }, | |
5263 | tr iggerHandl er: functi on( type, data ) { | |
5264 | var elem = this[0] ; | |
5265 | if ( ele m ) { | |
5266 | retu rn jQuery. event.trig ger( type, data, ele m, true ); | |
5267 | } | |
5268 | } | |
5269 | }); | |
5270 | ||
5271 | ||
5272 | functi on createS afeFragmen t( documen t ) { | |
5273 | va r list = n odeNames.s plit( "|" ), | |
5274 | safeFrag = documen t.createDo cumentFrag ment(); | |
5275 | ||
5276 | if ( safeFra g.createEl ement ) { | |
5277 | while ( list.lengt h ) { | |
5278 | safe Frag.creat eElement( | |
5279 | list.pop() | |
5280 | ); | |
5281 | } | |
5282 | } | |
5283 | re turn safeF rag; | |
5284 | } | |
5285 | ||
5286 | var no deNames = "abbr|arti cle|aside| audio|bdi| canvas|dat a|datalist |details|f igcaption| figure|foo ter|" + | |
5287 | "header| hgroup|mar k|meter|na v|output|p rogress|se ction|summ ary|time|v ideo", | |
5288 | ri nlinejQuer y = / jQue ry\d+="(?: null|\d+)" /g, | |
5289 | rn oshimcache = new Reg Exp("<(?:" + nodeNam es + ")[\\ s/>]", "i" ), | |
5290 | rl eadingWhit espace = / ^\s+/, | |
5291 | rx htmlTag = /<(?!area| br|col|emb ed|hr|img| input|link |meta|para m)(([\w:]+ )[^>]*)\/> /gi, | |
5292 | rt agName = / <([\w:]+)/ , | |
5293 | rt body = /<t body/i, | |
5294 | rh tml = /<|& #?\w+;/, | |
5295 | rn oInnerhtml = /<(?:sc ript|style |link)/i, | |
5296 | // che cked="chec ked" or ch ecked | |
5297 | rc hecked = / checked\s* (?:[^=]|=\ s*.checked .)/i, | |
5298 | rs criptType = /^$|\/(? :java|ecma )script/i, | |
5299 | rs criptTypeM asked = /^ true\/(.*) /, | |
5300 | rc leanScript = /^\s*<! (?:\[CDATA \[|--)|(?: \]\]|--)>\ s*$/g, | |
5301 | ||
5302 | // We have to cl ose these tags to su pport XHTM L (#13200) | |
5303 | wr apMap = { | |
5304 | option: [ 1, "<sel ect multip le='multip le'>", "</ select>" ] , | |
5305 | legend: [ 1, "<fie ldset>", " </fieldset >" ], | |
5306 | area: [ 1, "<map>" , "</map>" ], | |
5307 | param: [ 1, "<obje ct>", "</o bject>" ], | |
5308 | thead: [ 1, "<tabl e>", "</ta ble>" ], | |
5309 | tr: [ 2, "<table>< tbody>", " </tbody></ table>" ], | |
5310 | col: [ 2 , "<table> <tbody></t body><colg roup>", "< /colgroup> </table>" ], | |
5311 | td: [ 3, "<table>< tbody><tr> ", "</tr>< /tbody></t able>" ], | |
5312 | ||
5313 | // IE6-8 can't ser ialize lin k, script, style, or any html5 (NoScope) tags, | |
5314 | // unles s wrapped in a div w ith non-br eaking cha racters in front of it. | |
5315 | _default : support. htmlSerial ize ? [ 0, "", "" ] : [ 1, "X< div>", "</ div>" ] | |
5316 | }, | |
5317 | sa feFragment = createS afeFragmen t( documen t ), | |
5318 | fr agmentDiv = safeFrag ment.appen dChild( do cument.cre ateElement ("div") ); | |
5319 | ||
5320 | wrapMa p.optgroup = wrapMap .option; | |
5321 | wrapMa p.tbody = wrapMap.tf oot = wrap Map.colgro up = wrapM ap.caption = wrapMap .thead; | |
5322 | wrapMa p.th = wra pMap.td; | |
5323 | ||
5324 | functi on getAll( context, tag ) { | |
5325 | va r elems, e lem, | |
5326 | i = 0, | |
5327 | found = typeof con text.getEl ementsByTa gName !== strundefin ed ? conte xt.getElem entsByTagN ame( tag | | "*" ) : | |
5328 | typeof con text.query SelectorAl l !== stru ndefined ? context.q uerySelect orAll( tag || "*" ) : | |
5329 | unde fined; | |
5330 | ||
5331 | if ( !found ) { | |
5332 | for ( fo und = [], elems = co ntext.chil dNodes || context; ( elem = ele ms[i]) != null; i++ ) { | |
5333 | if ( !tag || j Query.node Name( elem , tag ) ) { | |
5334 | found.push ( elem ); | |
5335 | } el se { | |
5336 | jQuery.mer ge( found, getAll( e lem, tag ) ); | |
5337 | } | |
5338 | } | |
5339 | } | |
5340 | ||
5341 | re turn tag = == undefin ed || tag && jQuery. nodeName( context, t ag ) ? | |
5342 | jQuery.m erge( [ co ntext ], f ound ) : | |
5343 | found; | |
5344 | } | |
5345 | ||
5346 | // Used in buildFrag ment, fixe s the defa ultChecked property | |
5347 | functi on fixDefa ultChecked ( elem ) { | |
5348 | if ( rchecka bleType.te st( elem.t ype ) ) { | |
5349 | elem.def aultChecke d = elem.c hecked; | |
5350 | } | |
5351 | } | |
5352 | ||
5353 | // Support : IE<8 | |
5354 | // Manipul ating tabl es require s a tbody | |
5355 | functi on manipul ationTarge t( elem, c ontent ) { | |
5356 | re turn jQuer y.nodeName ( elem, "t able" ) && | |
5357 | jQuery.n odeName( c ontent.nod eType !== 11 ? conte nt : conte nt.firstCh ild, "tr" ) ? | |
5358 | ||
5359 | elem.get ElementsBy TagName("t body")[0] || | |
5360 | elem.app endChild( elem.owner Document.c reateEleme nt("tbody" ) ) : | |
5361 | elem; | |
5362 | } | |
5363 | ||
5364 | // Replace /restore t he type at tribute of script el ements for safe DOM manipulati on | |
5365 | functi on disable Script( el em ) { | |
5366 | el em.type = (jQuery.fi nd.attr( e lem, "type " ) !== nu ll) + "/" + elem.typ e; | |
5367 | re turn elem; | |
5368 | } | |
5369 | functi on restore Script( el em ) { | |
5370 | va r match = rscriptTyp eMasked.ex ec( elem.t ype ); | |
5371 | if ( match ) { | |
5372 | elem.typ e = match[ 1]; | |
5373 | } else { | |
5374 | elem.rem oveAttribu te("type") ; | |
5375 | } | |
5376 | re turn elem; | |
5377 | } | |
5378 | ||
5379 | // Mark ve ndor as ha ving alrea dy been ev aluated | |
5380 | functi on setGlob alEval( el ems, refEl ements ) { | |
5381 | va r elem, | |
5382 | i = 0; | |
5383 | fo r ( ; (ele m = elems[ i]) != nul l; i++ ) { | |
5384 | jQuery._ data( elem , "globalE val", !ref Elements | | jQuery._ data( refE lements[i] , "globalE val" ) ); | |
5385 | } | |
5386 | } | |
5387 | ||
5388 | functi on cloneCo pyEvent( s rc, dest ) { | |
5389 | ||
5390 | if ( dest.no deType !== 1 || !jQu ery.hasDat a( src ) ) { | |
5391 | return; | |
5392 | } | |
5393 | ||
5394 | va r type, i, l, | |
5395 | oldData = jQuery._ data( src ), | |
5396 | curData = jQuery._ data( dest , oldData ), | |
5397 | events = oldData.e vents; | |
5398 | ||
5399 | if ( events ) { | |
5400 | delete c urData.han dle; | |
5401 | curData. events = { }; | |
5402 | ||
5403 | for ( ty pe in even ts ) { | |
5404 | for ( i = 0, l = events[ type ].le ngth; i < l; i++ ) { | |
5405 | jQuery.eve nt.add( de st, type, events[ ty pe ][ i ] ); | |
5406 | } | |
5407 | } | |
5408 | } | |
5409 | ||
5410 | // make the cloned pub lic data o bject a co py from th e original | |
5411 | if ( curData .data ) { | |
5412 | curData. data = jQu ery.extend ( {}, curD ata.data ) ; | |
5413 | } | |
5414 | } | |
5415 | ||
5416 | functi on fixClon eNodeIssue s( src, de st ) { | |
5417 | va r nodeName , e, data; | |
5418 | ||
5419 | // We do not need to d o anything for non-E lements | |
5420 | if ( dest.no deType !== 1 ) { | |
5421 | return; | |
5422 | } | |
5423 | ||
5424 | no deName = d est.nodeNa me.toLower Case(); | |
5425 | ||
5426 | // IE6-8 cop ies events bound via attachEve nt when us ing cloneN ode. | |
5427 | if ( !suppor t.noCloneE vent && de st[ jQuery .expando ] ) { | |
5428 | data = j Query._dat a( dest ); | |
5429 | ||
5430 | for ( e in data.ev ents ) { | |
5431 | jQue ry.removeE vent( dest , e, data. handle ); | |
5432 | } | |
5433 | ||
5434 | // Event data gets reference d instead of copied if the exp ando gets copied too | |
5435 | dest.rem oveAttribu te( jQuery .expando ) ; | |
5436 | } | |
5437 | ||
5438 | // IE blanks contents when cloni ng vendor, and tries to evalua te newly-s et text | |
5439 | if ( nodeNam e === "scr ipt" && de st.text != = src.text ) { | |
5440 | disableS cript( des t ).text = src.text; | |
5441 | restoreS cript( des t ); | |
5442 | ||
5443 | // IE6-1 0 improper ly clones children o f object e lements us ing classi d. | |
5444 | // IE10 throws NoM odificatio nAllowedEr ror if par ent is nul l, #12132. | |
5445 | } else if ( nodeName = == "object " ) { | |
5446 | if ( des t.parentNo de ) { | |
5447 | dest .outerHTML = src.out erHTML; | |
5448 | } | |
5449 | ||
5450 | // This path appea rs unavoid able for I E9. When c loning an object | |
5451 | // eleme nt in IE9, the outer HTML strat egy above is not suf ficient. | |
5452 | // If th e src has innerHTML and the de stination does not, | |
5453 | // copy the src.in nerHTML in to the des t.innerHTM L. #10324 | |
5454 | if ( sup port.html5 Clone && ( src.inner HTML && !j Query.trim (dest.inne rHTML) ) ) { | |
5455 | dest .innerHTML = src.inn erHTML; | |
5456 | } | |
5457 | ||
5458 | } else if ( nodeName = == "input" && rcheck ableType.t est( src.t ype ) ) { | |
5459 | // IE6-8 fails to persist th e checked state of a cloned ch eckbox | |
5460 | // or ra dio button . Worse, I E6-7 fail to give th e cloned e lement | |
5461 | // a che cked appea rance if t he default Checked va lue isn't also set | |
5462 | ||
5463 | dest.def aultChecke d = dest.c hecked = s rc.checked ; | |
5464 | ||
5465 | // IE6-7 get confu sed and en d up setti ng the val ue of a cl oned | |
5466 | // check box/radio button to an empty s tring inst ead of "on " | |
5467 | if ( des t.value != = src.valu e ) { | |
5468 | dest .value = s rc.value; | |
5469 | } | |
5470 | ||
5471 | // IE6-8 fails to return the selected option to the defaul t selected | |
5472 | // state when clon ing option s | |
5473 | } else if ( nodeName = == "option " ) { | |
5474 | dest.def aultSelect ed = dest. selected = src.defau ltSelected ; | |
5475 | ||
5476 | // IE6-8 fails to set the de faultValue to the co rrect valu e when | |
5477 | // cloni ng other t ypes of in put fields | |
5478 | } else if ( nodeName = == "input" || nodeNa me === "te xtarea" ) { | |
5479 | dest.def aultValue = src.defa ultValue; | |
5480 | } | |
5481 | } | |
5482 | ||
5483 | jQuery .extend({ | |
5484 | cl one: funct ion( elem, dataAndEv ents, deep DataAndEve nts ) { | |
5485 | var dest Elements, node, clon e, i, srcE lements, | |
5486 | inPa ge = jQuer y.contains ( elem.own erDocument , elem ); | |
5487 | ||
5488 | if ( sup port.html5 Clone || j Query.isXM LDoc(elem) || !rnosh imcache.te st( "<" + elem.nodeN ame + ">" ) ) { | |
5489 | clon e = elem.c loneNode( true ); | |
5490 | ||
5491 | // I E<=8 does not proper ly clone d etached, u nknown ele ment nodes | |
5492 | } else { | |
5493 | frag mentDiv.in nerHTML = elem.outer HTML; | |
5494 | frag mentDiv.re moveChild( clone = f ragmentDiv .firstChil d ); | |
5495 | } | |
5496 | ||
5497 | if ( (!s upport.noC loneEvent || !suppor t.noCloneC hecked) && | |
5498 | (ele m.nodeType === 1 || elem.nodeT ype === 11 ) && !jQue ry.isXMLDo c(elem) ) { | |
5499 | ||
5500 | // W e eschew S izzle here for perfo rmance rea sons: http ://jsperf. com/getall -vs-sizzle /2 | |
5501 | dest Elements = getAll( c lone ); | |
5502 | srcE lements = getAll( el em ); | |
5503 | ||
5504 | // F ix all IE cloning is sues | |
5505 | for ( i = 0; ( node = src Elements[i ]) != null ; ++i ) { | |
5506 | // Ensure that the d estination node is n ot null; F ixes #9587 | |
5507 | if ( destE lements[i] ) { | |
5508 | fixClo neNodeIssu es( node, destElemen ts[i] ); | |
5509 | } | |
5510 | } | |
5511 | } | |
5512 | ||
5513 | // Copy the events from the original t o the clon e | |
5514 | if ( dat aAndEvents ) { | |
5515 | if ( deepDataA ndEvents ) { | |
5516 | srcElement s = srcEle ments || g etAll( ele m ); | |
5517 | destElemen ts = destE lements || getAll( c lone ); | |
5518 | ||
5519 | for ( i = 0; (node = srcElemen ts[i]) != null; i++ ) { | |
5520 | cloneC opyEvent( node, dest Elements[i ] ); | |
5521 | } | |
5522 | } el se { | |
5523 | cloneCopyE vent( elem , clone ); | |
5524 | } | |
5525 | } | |
5526 | ||
5527 | // Prese rve script evaluatio n history | |
5528 | destElem ents = get All( clone , "script" ); | |
5529 | if ( des tElements. length > 0 ) { | |
5530 | setG lobalEval( destEleme nts, !inPa ge && getA ll( elem, "script" ) ); | |
5531 | } | |
5532 | ||
5533 | destElem ents = src Elements = node = nu ll; | |
5534 | ||
5535 | // Retur n the clon ed set | |
5536 | return c lone; | |
5537 | }, | |
5538 | ||
5539 | bu ildFragmen t: functio n( elems, context, s cripts, se lection ) { | |
5540 | var j, e lem, conta ins, | |
5541 | tmp, tag, tbod y, wrap, | |
5542 | l = elems.leng th, | |
5543 | ||
5544 | // Ensur e a safe f ragment | |
5545 | safe = createS afeFragmen t( context ), | |
5546 | ||
5547 | node s = [], | |
5548 | i = 0; | |
5549 | ||
5550 | for ( ; i < l; i++ ) { | |
5551 | elem = elems[ i ]; | |
5552 | ||
5553 | if ( elem || e lem === 0 ) { | |
5554 | ||
5555 | // Add nod es directl y | |
5556 | if ( jQuer y.type( el em ) === " object" ) { | |
5557 | jQuery .merge( no des, elem. nodeType ? [ elem ] : elem ); | |
5558 | ||
5559 | // Con vert non-h tml into a text node | |
5560 | } else if ( !rhtml.t est( elem ) ) { | |
5561 | nodes. push( cont ext.create TextNode( elem ) ); | |
5562 | ||
5563 | // Con vert html into DOM n odes | |
5564 | } else { | |
5565 | tmp = tmp || saf e.appendCh ild( conte xt.createE lement("di v") ); | |
5566 | ||
5567 | // Des erialize a standard representa tion | |
5568 | tag = (rtagName. exec( elem ) || [ "" , "" ])[ 1 ].toLower Case(); | |
5569 | wrap = wrapMap[ tag ] || w rapMap._de fault; | |
5570 | ||
5571 | tmp.in nerHTML = wrap[1] + elem.repla ce( rxhtml Tag, "<$1> </$2>" ) + wrap[2]; | |
5572 | ||
5573 | // Des cend throu gh wrapper s to the r ight resou rces | |
5574 | j = wr ap[0]; | |
5575 | while ( j-- ) { | |
5576 | tm p = tmp.la stChild; | |
5577 | } | |
5578 | ||
5579 | // Man ually add leading wh itespace r emoved by IE | |
5580 | if ( ! support.le adingWhite space && r leadingWhi tespace.te st( elem ) ) { | |
5581 | no des.push( context.cr eateTextNo de( rleadi ngWhitespa ce.exec( e lem )[0] ) ); | |
5582 | } | |
5583 | ||
5584 | // Rem ove IE's a utoinserte d <tbody> from table fragments | |
5585 | if ( ! support.tb ody ) { | |
5586 | ||
5587 | // String wa s a <table >, *may* h ave spurio us <tbody> | |
5588 | el em = tag = == "table" && !rtbod y.test( el em ) ? | |
5589 | tmp.firs tChild : | |
5590 | ||
5591 | // Strin g was a ba re <thead> or <tfoot > | |
5592 | wrap [1] === "< table>" && !rtbody.t est( elem ) ? | |
5593 | tmp : | |
5594 | 0; | |
5595 | ||
5596 | j = elem && elem.child Nodes.leng th; | |
5597 | wh ile ( j-- ) { | |
5598 | if ( jQu ery.nodeNa me( (tbody = elem.ch ildNodes[j ]), "tbody " ) && !tb ody.childN odes.lengt h ) { | |
5599 | elem .removeChi ld( tbody ); | |
5600 | } | |
5601 | } | |
5602 | } | |
5603 | ||
5604 | jQuery .merge( no des, tmp.c hildNodes ); | |
5605 | ||
5606 | // Fix #12392 fo r WebKit a nd IE > 9 | |
5607 | tmp.te xtContent = ""; | |
5608 | ||
5609 | // Fix #12392 fo r oldIE | |
5610 | while ( tmp.firs tChild ) { | |
5611 | tm p.removeCh ild( tmp.f irstChild ); | |
5612 | } | |
5613 | ||
5614 | // Rem ember the top-level container for proper cleanup | |
5615 | tmp = safe.lastC hild; | |
5616 | } | |
5617 | } | |
5618 | } | |
5619 | ||
5620 | // Fix # 11356: Cle ar element s from fra gment | |
5621 | if ( tmp ) { | |
5622 | safe .removeChi ld( tmp ); | |
5623 | } | |
5624 | ||
5625 | // Reset defaultCh ecked for any radios and check boxes | |
5626 | // about to be app ended to t he DOM in IE 6/7 (#8 060) | |
5627 | if ( !su pport.appe ndChecked ) { | |
5628 | jQue ry.grep( g etAll( nod es, "input " ), fixDe faultCheck ed ); | |
5629 | } | |
5630 | ||
5631 | i = 0; | |
5632 | while ( (elem = no des[ i++ ] ) ) { | |
5633 | ||
5634 | // # 4087 - If origin and destinati on element s are the same, and this is | |
5635 | // t hat elemen t, do not do anythin g | |
5636 | if ( selection && jQuery .inArray( elem, sele ction ) != = -1 ) { | |
5637 | continue; | |
5638 | } | |
5639 | ||
5640 | cont ains = jQu ery.contai ns( elem.o wnerDocume nt, elem ) ; | |
5641 | ||
5642 | // A ppend to f ragment | |
5643 | tmp = getAll( safe.appen dChild( el em ), "scr ipt" ); | |
5644 | ||
5645 | // P reserve sc ript evalu ation hist ory | |
5646 | if ( contains ) { | |
5647 | setGlobalE val( tmp ) ; | |
5648 | } | |
5649 | ||
5650 | // C apture exe cutables | |
5651 | if ( scripts ) { | |
5652 | j = 0; | |
5653 | while ( (e lem = tmp[ j++ ]) ) { | |
5654 | if ( r scriptType .test( ele m.type || "" ) ) { | |
5655 | sc ripts.push ( elem ); | |
5656 | } | |
5657 | } | |
5658 | } | |
5659 | } | |
5660 | ||
5661 | tmp = nu ll; | |
5662 | ||
5663 | return s afe; | |
5664 | }, | |
5665 | ||
5666 | cl eanData: f unction( e lems, /* i nternal */ acceptDat a ) { | |
5667 | var elem , type, id , data, | |
5668 | i = 0, | |
5669 | inte rnalKey = jQuery.exp ando, | |
5670 | cach e = jQuery .cache, | |
5671 | dele teExpando = support. deleteExpa ndo, | |
5672 | spec ial = jQue ry.event.s pecial; | |
5673 | ||
5674 | for ( ; (elem = el ems[i]) != null; i++ ) { | |
5675 | if ( acceptDat a || jQuer y.acceptDa ta( elem ) ) { | |
5676 | ||
5677 | id = elem[ internalK ey ]; | |
5678 | data = id && cache[ id ]; | |
5679 | ||
5680 | if ( data ) { | |
5681 | if ( d ata.events ) { | |
5682 | fo r ( type i n data.eve nts ) { | |
5683 | if ( spe cial[ type ] ) { | |
5684 | jQue ry.event.r emove( ele m, type ); | |
5685 | ||
5686 | // T his is a s hortcut to avoid jQu ery.event. remove's o verhead | |
5687 | } else { | |
5688 | jQue ry.removeE vent( elem , type, da ta.handle ); | |
5689 | } | |
5690 | } | |
5691 | } | |
5692 | ||
5693 | // Rem ove cache only if it was not a lready rem oved by jQ uery.event .remove | |
5694 | if ( c ache[ id ] ) { | |
5695 | ||
5696 | de lete cache [ id ]; | |
5697 | ||
5698 | // IE does n ot allow u s to delet e expando properties from node s, | |
5699 | // nor does it have a removeAttr ibute func tion on Do cument nod es; | |
5700 | // we must h andle all of these c ases | |
5701 | if ( deleteE xpando ) { | |
5702 | delete e lem[ inter nalKey ]; | |
5703 | ||
5704 | } else if ( typeof ele m.removeAt tribute != = strundef ined ) { | |
5705 | elem.rem oveAttribu te( intern alKey ); | |
5706 | ||
5707 | } else { | |
5708 | elem[ in ternalKey ] = null; | |
5709 | } | |
5710 | ||
5711 | de letedIds.p ush( id ); | |
5712 | } | |
5713 | } | |
5714 | } | |
5715 | } | |
5716 | } | |
5717 | }); | |
5718 | ||
5719 | jQuery .fn.extend ({ | |
5720 | te xt: functi on( value ) { | |
5721 | return a ccess( thi s, functio n( value ) { | |
5722 | retu rn value = == undefin ed ? | |
5723 | jQuery.tex t( this ) : | |
5724 | this.empty ().append( ( this[0] && this[0 ].ownerDoc ument || d ocument ). createText Node( valu e ) ); | |
5725 | }, null, value, ar guments.le ngth ); | |
5726 | }, | |
5727 | ||
5728 | ap pend: func tion() { | |
5729 | return t his.domMan ip( argume nts, funct ion( elem ) { | |
5730 | if ( this.node Type === 1 || this.n odeType == = 11 || th is.nodeTyp e === 9 ) { | |
5731 | var target = manipul ationTarge t( this, e lem ); | |
5732 | target.app endChild( elem ); | |
5733 | } | |
5734 | }); | |
5735 | }, | |
5736 | ||
5737 | pr epend: fun ction() { | |
5738 | return t his.domMan ip( argume nts, funct ion( elem ) { | |
5739 | if ( this.node Type === 1 || this.n odeType == = 11 || th is.nodeTyp e === 9 ) { | |
5740 | var target = manipul ationTarge t( this, e lem ); | |
5741 | target.ins ertBefore( elem, tar get.firstC hild ); | |
5742 | } | |
5743 | }); | |
5744 | }, | |
5745 | ||
5746 | be fore: func tion() { | |
5747 | return t his.domMan ip( argume nts, funct ion( elem ) { | |
5748 | if ( this.pare ntNode ) { | |
5749 | this.paren tNode.inse rtBefore( elem, this ); | |
5750 | } | |
5751 | }); | |
5752 | }, | |
5753 | ||
5754 | af ter: funct ion() { | |
5755 | return t his.domMan ip( argume nts, funct ion( elem ) { | |
5756 | if ( this.pare ntNode ) { | |
5757 | this.paren tNode.inse rtBefore( elem, this .nextSibli ng ); | |
5758 | } | |
5759 | }); | |
5760 | }, | |
5761 | ||
5762 | re move: func tion( sele ctor, keep Data /* In ternal Use Only */ ) { | |
5763 | var elem , | |
5764 | elem s = select or ? jQuer y.filter( selector, this ) : t his, | |
5765 | i = 0; | |
5766 | ||
5767 | for ( ; (elem = el ems[i]) != null; i++ ) { | |
5768 | ||
5769 | if ( !keepData && elem.n odeType == = 1 ) { | |
5770 | jQuery.cle anData( ge tAll( elem ) ); | |
5771 | } | |
5772 | ||
5773 | if ( elem.pare ntNode ) { | |
5774 | if ( keepD ata && jQu ery.contai ns( elem.o wnerDocume nt, elem ) ) { | |
5775 | setGlo balEval( g etAll( ele m, "script " ) ); | |
5776 | } | |
5777 | elem.paren tNode.remo veChild( e lem ); | |
5778 | } | |
5779 | } | |
5780 | ||
5781 | return t his; | |
5782 | }, | |
5783 | ||
5784 | em pty: funct ion() { | |
5785 | var elem , | |
5786 | i = 0; | |
5787 | ||
5788 | for ( ; (elem = th is[i]) != null; i++ ) { | |
5789 | // R emove elem ent nodes and preven t memory l eaks | |
5790 | if ( elem.node Type === 1 ) { | |
5791 | jQuery.cle anData( ge tAll( elem , false ) ); | |
5792 | } | |
5793 | ||
5794 | // R emove any remaining nodes | |
5795 | whil e ( elem.f irstChild ) { | |
5796 | elem.remov eChild( el em.firstCh ild ); | |
5797 | } | |
5798 | ||
5799 | // I f this is a select, ensure tha t it displ ays empty (#12336) | |
5800 | // S upport: IE <9 | |
5801 | if ( elem.opti ons && jQu ery.nodeNa me( elem, "select" ) ) { | |
5802 | elem.optio ns.length = 0; | |
5803 | } | |
5804 | } | |
5805 | ||
5806 | return t his; | |
5807 | }, | |
5808 | ||
5809 | cl one: funct ion( dataA ndEvents, deepDataAn dEvents ) { | |
5810 | dataAndE vents = da taAndEvent s == null ? false : dataAndEve nts; | |
5811 | deepData AndEvents = deepData AndEvents == null ? dataAndEve nts : deep DataAndEve nts; | |
5812 | ||
5813 | return t his.map(fu nction() { | |
5814 | retu rn jQuery. clone( thi s, dataAnd Events, de epDataAndE vents ); | |
5815 | }); | |
5816 | }, | |
5817 | ||
5818 | ht ml: functi on( value ) { | |
5819 | return a ccess( thi s, functio n( value ) { | |
5820 | var elem = thi s[ 0 ] || {}, | |
5821 | i = 0, | |
5822 | l = this.l ength; | |
5823 | ||
5824 | if ( value === undefined ) { | |
5825 | return ele m.nodeType === 1 ? | |
5826 | elem.i nnerHTML.r eplace( ri nlinejQuer y, "" ) : | |
5827 | undefi ned; | |
5828 | } | |
5829 | ||
5830 | // S ee if we c an take a shortcut a nd just us e innerHTM L | |
5831 | if ( typeof va lue === "s tring" && !rnoInnerh tml.test( value ) && | |
5832 | ( support. htmlSerial ize || !rn oshimcache .test( val ue ) ) && | |
5833 | ( support. leadingWhi tespace || !rleading Whitespace .test( val ue ) ) && | |
5834 | !wrapMap[ (rtagName. exec( valu e ) || [ " ", "" ])[ 1 ].toLowe rCase() ] ) { | |
5835 | ||
5836 | value = va lue.replac e( rxhtmlT ag, "<$1>< /$2>" ); | |
5837 | ||
5838 | try { | |
5839 | for (; i < l; i+ + ) { | |
5840 | // Remove el ement node s and prev ent memory leaks | |
5841 | el em = this[ i] || {}; | |
5842 | if ( elem.no deType === 1 ) { | |
5843 | jQuery.c leanData( getAll( el em, false ) ); | |
5844 | elem.inn erHTML = v alue; | |
5845 | } | |
5846 | } | |
5847 | ||
5848 | elem = 0; | |
5849 | ||
5850 | // If using inne rHTML thro ws an exce ption, use the fallb ack method | |
5851 | } catch(e) {} | |
5852 | } | |
5853 | ||
5854 | if ( elem ) { | |
5855 | this.empty ().append( value ); | |
5856 | } | |
5857 | }, null, value, ar guments.le ngth ); | |
5858 | }, | |
5859 | ||
5860 | re placeWith: function( ) { | |
5861 | var arg = argument s[ 0 ]; | |
5862 | ||
5863 | // Make the change s, replaci ng each co ntext elem ent with t he new res ources | |
5864 | this.dom Manip( arg uments, fu nction( el em ) { | |
5865 | arg = this.par entNode; | |
5866 | ||
5867 | jQue ry.cleanDa ta( getAll ( this ) ) ; | |
5868 | ||
5869 | if ( arg ) { | |
5870 | arg.replac eChild( el em, this ) ; | |
5871 | } | |
5872 | }); | |
5873 | ||
5874 | // Force removal i f there wa s no new r esources ( e.g., from empty arg uments) | |
5875 | return a rg && (arg .length || arg.nodeT ype) ? thi s : this.r emove(); | |
5876 | }, | |
5877 | ||
5878 | de tach: func tion( sele ctor ) { | |
5879 | return t his.remove ( selector , true ); | |
5880 | }, | |
5881 | ||
5882 | do mManip: fu nction( ar gs, callba ck ) { | |
5883 | ||
5884 | // Flatt en any nes ted arrays | |
5885 | args = c oncat.appl y( [], arg s ); | |
5886 | ||
5887 | var firs t, node, h asScripts, | |
5888 | scri pts, doc, fragment, | |
5889 | i = 0, | |
5890 | l = this.lengt h, | |
5891 | set = this, | |
5892 | iNoC lone = l - 1, | |
5893 | valu e = args[0 ], | |
5894 | isFu nction = j Query.isFu nction( va lue ); | |
5895 | ||
5896 | // We ca n't cloneN ode fragme nts that c ontain che cked, in W ebKit | |
5897 | if ( isF unction || | |
5898 | ( l > 1 && typ eof value === "strin g" && | |
5899 | !support.c heckClone && rchecke d.test( va lue ) ) ) { | |
5900 | retu rn this.ea ch(functio n( index ) { | |
5901 | var self = set.eq( i ndex ); | |
5902 | if ( isFun ction ) { | |
5903 | args[0 ] = value. call( this , index, s elf.html() ); | |
5904 | } | |
5905 | self.domMa nip( args, callback ); | |
5906 | }); | |
5907 | } | |
5908 | ||
5909 | if ( l ) { | |
5910 | frag ment = jQu ery.buildF ragment( a rgs, this[ 0 ].owner Document, false, thi s ); | |
5911 | firs t = fragme nt.firstCh ild; | |
5912 | ||
5913 | if ( fragment. childNodes .length == = 1 ) { | |
5914 | fragment = first; | |
5915 | } | |
5916 | ||
5917 | if ( first ) { | |
5918 | scripts = jQuery.map ( getAll( fragment, "script" ) , disableS cript ); | |
5919 | hasScripts = scripts .length; | |
5920 | ||
5921 | // Use the original fragment f or the las t item ins tead of th e first be cause it c an end up | |
5922 | // being e mptied inc orrectly i n certain situations (#8070). | |
5923 | for ( ; i < l; i++ ) { | |
5924 | node = fragment; | |
5925 | ||
5926 | if ( i !== iNoCl one ) { | |
5927 | no de = jQuer y.clone( n ode, true, true ); | |
5928 | ||
5929 | // Keep refe rences to cloned ven dor for la ter restor ation | |
5930 | if ( hasScri pts ) { | |
5931 | jQuery.m erge( scri pts, getAl l( node, " script" ) ); | |
5932 | } | |
5933 | } | |
5934 | ||
5935 | callba ck.call( t his[i], no de, i ); | |
5936 | } | |
5937 | ||
5938 | if ( hasSc ripts ) { | |
5939 | doc = scripts[ s cripts.len gth - 1 ]. ownerDocum ent; | |
5940 | ||
5941 | // Ree nable vend or | |
5942 | jQuery .map( scri pts, resto reScript ) ; | |
5943 | ||
5944 | // Eva luate exec utable ven dor on fir st documen t insertio n | |
5945 | for ( i = 0; i < hasScript s; i++ ) { | |
5946 | no de = scrip ts[ i ]; | |
5947 | if ( rscript Type.test( node.type || "" ) & & | |
5948 | !jQuery. _data( nod e, "global Eval" ) && jQuery.co ntains( do c, node ) ) { | |
5949 | ||
5950 | if ( nod e.src ) { | |
5951 | // O ptional AJ AX depende ncy, but w on't run v endor if n ot present | |
5952 | if ( jQuery._e valUrl ) { | |
5953 | jQuery._ev alUrl( nod e.src ); | |
5954 | } | |
5955 | } else { | |
5956 | jQue ry.globalE val( ( nod e.text || node.textC ontent || node.inner HTML || "" ).replace ( rcleanSc ript, "" ) ); | |
5957 | } | |
5958 | } | |
5959 | } | |
5960 | } | |
5961 | ||
5962 | // Fix #11 809: Avoid leaking m emory | |
5963 | fragment = first = n ull; | |
5964 | } | |
5965 | } | |
5966 | ||
5967 | return t his; | |
5968 | } | |
5969 | }); | |
5970 | ||
5971 | jQuery .each({ | |
5972 | ap pendTo: "a ppend", | |
5973 | pr ependTo: " prepend", | |
5974 | in sertBefore : "before" , | |
5975 | in sertAfter: "after", | |
5976 | re placeAll: "replaceWi th" | |
5977 | }, fun ction( nam e, origina l ) { | |
5978 | jQ uery.fn[ n ame ] = fu nction( se lector ) { | |
5979 | var elem s, | |
5980 | i = 0, | |
5981 | ret = [], | |
5982 | inse rt = jQuer y( selecto r ), | |
5983 | last = insert. length - 1 ; | |
5984 | ||
5985 | for ( ; i <= last; i++ ) { | |
5986 | elem s = i === last ? thi s : this.c lone(true) ; | |
5987 | jQue ry( insert [i] )[ ori ginal ]( e lems ); | |
5988 | ||
5989 | // M odern brow sers can a pply jQuer y collecti ons as arr ays, but o ldIE needs a .get() | |
5990 | push .apply( re t, elems.g et() ); | |
5991 | } | |
5992 | ||
5993 | return t his.pushSt ack( ret ) ; | |
5994 | }; | |
5995 | }); | |
5996 | ||
5997 | ||
5998 | var if rame, | |
5999 | el emdisplay = {}; | |
6000 | ||
6001 | /** | |
6002 | * Ret rieve the actual dis play of a element | |
6003 | * @pa ram {Strin g} name no deName of the elemen t | |
6004 | * @pa ram {Objec t} doc Doc ument obje ct | |
6005 | */ | |
6006 | // Called only from within def aultDispla y | |
6007 | functi on actualD isplay( na me, doc ) { | |
6008 | va r style, | |
6009 | elem = j Query( doc .createEle ment( name ) ).appen dTo( doc.b ody ), | |
6010 | ||
6011 | // getDefaul tComputedS tyle might be reliab ly used on ly on atta ched eleme nt | |
6012 | display = window.g etDefaultC omputedSty le && ( st yle = wind ow.getDefa ultCompute dStyle( el em[ 0 ] ) ) ? | |
6013 | ||
6014 | // U se of this method is a tempora ry fix (mo re like op tmization) until som ething bet ter comes along, | |
6015 | // s ince it wa s removed from speci fication a nd support ed only in FF | |
6016 | styl e.display : jQuery.c ss( elem[ 0 ], "disp lay" ); | |
6017 | ||
6018 | // We don't have any d ata stored on the el ement, | |
6019 | // so use "d etach" met hod as fas t way to g et rid of the elemen t | |
6020 | el em.detach( ); | |
6021 | ||
6022 | re turn displ ay; | |
6023 | } | |
6024 | ||
6025 | /** | |
6026 | * Try to determ ine the de fault disp lay value of an elem ent | |
6027 | * @pa ram {Strin g} nodeNam e | |
6028 | */ | |
6029 | functi on default Display( n odeName ) { | |
6030 | va r doc = do cument, | |
6031 | display = elemdisp lay[ nodeN ame ]; | |
6032 | ||
6033 | if ( !displa y ) { | |
6034 | display = actualDi splay( nod eName, doc ); | |
6035 | ||
6036 | // If th e simple w ay fails, read from inside an iframe | |
6037 | if ( dis play === " none" || ! display ) { | |
6038 | ||
6039 | // U se the alr eady-creat ed iframe if possibl e | |
6040 | ifra me = (ifra me || jQue ry( "<ifra me framebo rder='0' w idth='0' h eight='0'/ >" )).appe ndTo( doc. documentEl ement ); | |
6041 | ||
6042 | // A lways writ e a new HT ML skeleto n so Webki t and Fire fox don't choke on r euse | |
6043 | doc = ( iframe [ 0 ].cont entWindow || iframe[ 0 ].conte ntDocument ).documen t; | |
6044 | ||
6045 | // S upport: IE | |
6046 | doc. write(); | |
6047 | doc. close(); | |
6048 | ||
6049 | disp lay = actu alDisplay( nodeName, doc ); | |
6050 | ifra me.detach( ); | |
6051 | } | |
6052 | ||
6053 | // Store the corre ct default display | |
6054 | elemdisp lay[ nodeN ame ] = di splay; | |
6055 | } | |
6056 | ||
6057 | re turn displ ay; | |
6058 | } | |
6059 | ||
6060 | ||
6061 | (funct ion() { | |
6062 | va r shrinkWr apBlocksVa l; | |
6063 | ||
6064 | su pport.shri nkWrapBloc ks = funct ion() { | |
6065 | if ( shr inkWrapBlo cksVal != null ) { | |
6066 | retu rn shrinkW rapBlocksV al; | |
6067 | } | |
6068 | ||
6069 | // Will be changed later if needed. | |
6070 | shrinkWr apBlocksVa l = false; | |
6071 | ||
6072 | // Minif ied: var b ,c,d | |
6073 | var div, body, con tainer; | |
6074 | ||
6075 | body = d ocument.ge tElementsB yTagName( "body" )[ 0 ]; | |
6076 | if ( !bo dy || !bod y.style ) { | |
6077 | // T est fired too early or in an u nsupported environme nt, exit. | |
6078 | retu rn; | |
6079 | } | |
6080 | ||
6081 | // Setup | |
6082 | div = do cument.cre ateElement ( "div" ); | |
6083 | containe r = docume nt.createE lement( "d iv" ); | |
6084 | containe r.style.cs sText = "p osition:ab solute;bor der:0;widt h:0;height :0;top:0;l eft:-9999p x"; | |
6085 | body.app endChild( container ).appendCh ild( div ) ; | |
6086 | ||
6087 | // Suppo rt: IE6 | |
6088 | // Check if elemen ts with la yout shrin k-wrap the ir childre n | |
6089 | if ( typ eof div.st yle.zoom ! == strunde fined ) { | |
6090 | // R eset CSS: box-sizing ; display; margin; b order | |
6091 | div. style.cssT ext = | |
6092 | // Support : Firefox< 29, Androi d 2.3 | |
6093 | // Vendor- prefix box -sizing | |
6094 | "-webkit-b ox-sizing: resources- box;-moz-b ox-sizing: resources- box;" + | |
6095 | "box-sizin g:resource s-box;disp lay:block; margin:0;b order:0;" + | |
6096 | "padding:1 px;width:1 px;zoom:1" ; | |
6097 | div. appendChil d( documen t.createEl ement( "di v" ) ).sty le.width = "5px"; | |
6098 | shri nkWrapBloc ksVal = di v.offsetWi dth !== 3; | |
6099 | } | |
6100 | ||
6101 | body.rem oveChild( container ); | |
6102 | ||
6103 | return s hrinkWrapB locksVal; | |
6104 | }; | |
6105 | ||
6106 | })(); | |
6107 | var rm argin = (/ ^margin/); | |
6108 | ||
6109 | var rn umnonpx = new RegExp ( "^(" + p num + ")(? !px)[a-z%] +$", "i" ) ; | |
6110 | ||
6111 | ||
6112 | ||
6113 | var ge tStyles, c urCSS, | |
6114 | rp osition = /^(top|rig ht|bottom| left)$/; | |
6115 | ||
6116 | if ( w indow.getC omputedSty le ) { | |
6117 | ge tStyles = function( elem ) { | |
6118 | return e lem.ownerD ocument.de faultView. getCompute dStyle( el em, null ) ; | |
6119 | }; | |
6120 | ||
6121 | cu rCSS = fun ction( ele m, name, c omputed ) { | |
6122 | var widt h, minWidt h, maxWidt h, ret, | |
6123 | styl e = elem.s tyle; | |
6124 | ||
6125 | computed = compute d || getSt yles( elem ); | |
6126 | ||
6127 | // getPr opertyValu e is only needed for .css('fil ter') in I E9, see #1 2537 | |
6128 | ret = co mputed ? c omputed.ge tPropertyV alue( name ) || comp uted[ name ] : undef ined; | |
6129 | ||
6130 | if ( com puted ) { | |
6131 | ||
6132 | if ( ret === " " && !jQue ry.contain s( elem.ow nerDocumen t, elem ) ) { | |
6133 | ret = jQue ry.style( elem, name ); | |
6134 | } | |
6135 | ||
6136 | // A tribute t o the "awe some hack by Dean Ed wards" | |
6137 | // C hrome < 17 and Safar i 5.0 uses "computed value" in stead of " used value " for marg in-right | |
6138 | // S afari 5.1. 7 (at leas t) returns percentag e for a la rger set o f values, but width seems to b e reliably pixels | |
6139 | // t his is aga inst the C SSOM draft spec: htt p://dev.w3 .org/csswg /cssom/#re solved-val ues | |
6140 | if ( rnumnonpx .test( ret ) && rmar gin.test( name ) ) { | |
6141 | ||
6142 | // Remembe r the orig inal value s | |
6143 | width = st yle.width; | |
6144 | minWidth = style.min Width; | |
6145 | maxWidth = style.max Width; | |
6146 | ||
6147 | // Put in the new va lues to ge t a comput ed value o ut | |
6148 | style.minW idth = sty le.maxWidt h = style. width = re t; | |
6149 | ret = comp uted.width ; | |
6150 | ||
6151 | // Revert the change d values | |
6152 | style.widt h = width; | |
6153 | style.minW idth = min Width; | |
6154 | style.maxW idth = max Width; | |
6155 | } | |
6156 | } | |
6157 | ||
6158 | // Suppo rt: IE | |
6159 | // IE re turns zInd ex value a s an integ er. | |
6160 | return r et === und efined ? | |
6161 | ret : | |
6162 | ret + ""; | |
6163 | }; | |
6164 | } else if ( docu ment.docum entElement .currentSt yle ) { | |
6165 | ge tStyles = function( elem ) { | |
6166 | return e lem.curren tStyle; | |
6167 | }; | |
6168 | ||
6169 | cu rCSS = fun ction( ele m, name, c omputed ) { | |
6170 | var left , rs, rsLe ft, ret, | |
6171 | styl e = elem.s tyle; | |
6172 | ||
6173 | computed = compute d || getSt yles( elem ); | |
6174 | ret = co mputed ? c omputed[ n ame ] : un defined; | |
6175 | ||
6176 | // Avoid setting r et to empt y string h ere | |
6177 | // so we don't def ault to au to | |
6178 | if ( ret == null & & style && style[ na me ] ) { | |
6179 | ret = style[ n ame ]; | |
6180 | } | |
6181 | ||
6182 | // From the awesom e hack by Dean Edwar ds | |
6183 | // http: //erik.eae .net/archi ves/2007/0 7/27/18.54 .15/#comme nt-102291 | |
6184 | ||
6185 | // If we 're not de aling with a regular pixel num ber | |
6186 | // but a number th at has a w eird endin g, we need to conver t it to pi xels | |
6187 | // but n ot positio n css attr ibutes, as those are proportio nal to the parent el ement inst ead | |
6188 | // and w e can't me asure the parent ins tead becau se it migh t trigger a "stackin g dolls" p roblem | |
6189 | if ( rnu mnonpx.tes t( ret ) & & !rpositi on.test( n ame ) ) { | |
6190 | ||
6191 | // R emember th e original values | |
6192 | left = style.l eft; | |
6193 | rs = elem.runt imeStyle; | |
6194 | rsLe ft = rs && rs.left; | |
6195 | ||
6196 | // P ut in the new values to get a computed v alue out | |
6197 | if ( rsLeft ) { | |
6198 | rs.left = elem.curre ntStyle.le ft; | |
6199 | } | |
6200 | styl e.left = n ame === "f ontSize" ? "1em" : r et; | |
6201 | ret = style.pi xelLeft + "px"; | |
6202 | ||
6203 | // R evert the changed va lues | |
6204 | styl e.left = l eft; | |
6205 | if ( rsLeft ) { | |
6206 | rs.left = rsLeft; | |
6207 | } | |
6208 | } | |
6209 | ||
6210 | // Suppo rt: IE | |
6211 | // IE re turns zInd ex value a s an integ er. | |
6212 | return r et === und efined ? | |
6213 | ret : | |
6214 | ret + "" || "a uto"; | |
6215 | }; | |
6216 | } | |
6217 | ||
6218 | ||
6219 | ||
6220 | ||
6221 | functi on addGetH ookIf( con ditionFn, hookFn ) { | |
6222 | // Define th e hook, we 'll check on the fir st run if it's reall y needed. | |
6223 | re turn { | |
6224 | get: fun ction() { | |
6225 | var condition = conditio nFn(); | |
6226 | ||
6227 | if ( condition == null ) { | |
6228 | // The tes t was not ready at t his point; screw the hook this time | |
6229 | // but che ck again w hen needed next time . | |
6230 | return; | |
6231 | } | |
6232 | ||
6233 | if ( condition ) { | |
6234 | // Hook no t needed ( or it's no t possible to use it due to mi ssing depe ndency), | |
6235 | // remove it. | |
6236 | // Since t here are n o other ho oks for ma rginRight, remove th e whole ob ject. | |
6237 | delete thi s.get; | |
6238 | return; | |
6239 | } | |
6240 | ||
6241 | // H ook needed ; redefine it so tha t the supp ort test i s not exec uted again . | |
6242 | ||
6243 | retu rn (this.g et = hookF n).apply( this, argu ments ); | |
6244 | } | |
6245 | }; | |
6246 | } | |
6247 | ||
6248 | ||
6249 | (funct ion() { | |
6250 | // Minified: var b,c,d ,e,f,g, h, i | |
6251 | va r div, sty le, a, pix elPosition Val, boxSi zingReliab leVal, | |
6252 | reliable HiddenOffs etsVal, re liableMarg inRightVal ; | |
6253 | ||
6254 | // Setup | |
6255 | di v = docume nt.createE lement( "d iv" ); | |
6256 | di v.innerHTM L = " <li nk/><table ></table>< a href='/a '>a</a><in put type=' checkbox'/ >"; | |
6257 | a = div.getE lementsByT agName( "a " )[ 0 ]; | |
6258 | st yle = a && a.style; | |
6259 | ||
6260 | // Finish ea rly in lim ited (non- browser) e nvironment s | |
6261 | if ( !style ) { | |
6262 | return; | |
6263 | } | |
6264 | ||
6265 | st yle.cssTex t = "float :left;opac ity:.5"; | |
6266 | ||
6267 | // Support: IE<9 | |
6268 | // Make sure that elem ent opacit y exists ( as opposed to filter ) | |
6269 | su pport.opac ity = styl e.opacity === "0.5"; | |
6270 | ||
6271 | // Verify st yle float existence | |
6272 | // (IE uses styleFloat instead o f cssFloat ) | |
6273 | su pport.cssF loat = !!s tyle.cssFl oat; | |
6274 | ||
6275 | di v.style.ba ckgroundCl ip = "reso urces-box" ; | |
6276 | di v.cloneNod e( true ). style.back groundClip = ""; | |
6277 | su pport.clea rCloneStyl e = div.st yle.backgr oundClip = == "resour ces-box"; | |
6278 | ||
6279 | // Support: Firefox<29 , Android 2.3 | |
6280 | // Vendor-pr efix box-s izing | |
6281 | su pport.boxS izing = st yle.boxSiz ing === "" || style. MozBoxSizi ng === "" || | |
6282 | style.We bkitBoxSiz ing === "" ; | |
6283 | ||
6284 | jQ uery.exten d(support, { | |
6285 | reliable HiddenOffs ets: funct ion() { | |
6286 | if ( reliableH iddenOffse tsVal == n ull ) { | |
6287 | computeSty leTests(); | |
6288 | } | |
6289 | retu rn reliabl eHiddenOff setsVal; | |
6290 | }, | |
6291 | ||
6292 | boxSizin gReliable: function( ) { | |
6293 | if ( boxSizing ReliableVa l == null ) { | |
6294 | computeSty leTests(); | |
6295 | } | |
6296 | retu rn boxSizi ngReliable Val; | |
6297 | }, | |
6298 | ||
6299 | pixelPos ition: fun ction() { | |
6300 | if ( pixelPosi tionVal == null ) { | |
6301 | computeSty leTests(); | |
6302 | } | |
6303 | retu rn pixelPo sitionVal; | |
6304 | }, | |
6305 | ||
6306 | // Suppo rt: Androi d 2.3 | |
6307 | reliable MarginRigh t: functio n() { | |
6308 | if ( reliableM arginRight Val == nul l ) { | |
6309 | computeSty leTests(); | |
6310 | } | |
6311 | retu rn reliabl eMarginRig htVal; | |
6312 | } | |
6313 | }) ; | |
6314 | ||
6315 | fu nction com puteStyleT ests() { | |
6316 | // Minif ied: var b ,c,d,j | |
6317 | var div, body, con tainer, co ntents; | |
6318 | ||
6319 | body = d ocument.ge tElementsB yTagName( "body" )[ 0 ]; | |
6320 | if ( !bo dy || !bod y.style ) { | |
6321 | // T est fired too early or in an u nsupported environme nt, exit. | |
6322 | retu rn; | |
6323 | } | |
6324 | ||
6325 | // Setup | |
6326 | div = do cument.cre ateElement ( "div" ); | |
6327 | containe r = docume nt.createE lement( "d iv" ); | |
6328 | containe r.style.cs sText = "p osition:ab solute;bor der:0;widt h:0;height :0;top:0;l eft:-9999p x"; | |
6329 | body.app endChild( container ).appendCh ild( div ) ; | |
6330 | ||
6331 | div.styl e.cssText = | |
6332 | // S upport: Fi refox<29, Android 2. 3 | |
6333 | // V endor-pref ix box-siz ing | |
6334 | "-we bkit-box-s izing:bord er-box;-mo z-box-sizi ng:border- box;" + | |
6335 | "box -sizing:bo rder-box;d isplay:blo ck;margin- top:1%;top :1%;" + | |
6336 | "bor der:1px;pa dding:1px; width:4px; position:a bsolute"; | |
6337 | ||
6338 | // Suppo rt: IE<9 | |
6339 | // Assum e reasonab le values in the abs ence of ge tComputedS tyle | |
6340 | pixelPos itionVal = boxSizing ReliableVa l = false; | |
6341 | reliable MarginRigh tVal = tru e; | |
6342 | ||
6343 | // Check for getCo mputedStyl e so that this code is not run in IE<9. | |
6344 | if ( win dow.getCom putedStyle ) { | |
6345 | pixe lPositionV al = ( win dow.getCom putedStyle ( div, nul l ) || {} ).top !== "1%"; | |
6346 | boxS izingRelia bleVal = | |
6347 | ( window.g etComputed Style( div , null ) | | { width: "4px" } ) .width === "4px"; | |
6348 | ||
6349 | // S upport: An droid 2.3 | |
6350 | // D iv with ex plicit wid th and no margin-rig ht incorre ctly | |
6351 | // g ets comput ed margin- right base d on width of contai ner (#3333 ) | |
6352 | // W ebKit Bug 13343 - ge tComputedS tyle retur ns wrong v alue for m argin-righ t | |
6353 | cont ents = div .appendChi ld( docume nt.createE lement( "d iv" ) ); | |
6354 | ||
6355 | // R eset CSS: box-sizing ; display; margin; b order; pad ding | |
6356 | cont ents.style .cssText = div.style .cssText = | |
6357 | // Support : Firefox< 29, Androi d 2.3 | |
6358 | // Vendor- prefix box -sizing | |
6359 | "-webkit-b ox-sizing: resources- box;-moz-b ox-sizing: resources- box;" + | |
6360 | "box-sizin g:resource s-box;disp lay:block; margin:0;b order:0;pa dding:0"; | |
6361 | cont ents.style .marginRig ht = conte nts.style. width = "0 "; | |
6362 | div. style.widt h = "1px"; | |
6363 | ||
6364 | reli ableMargin RightVal = | |
6365 | !parseFloa t( ( windo w.getCompu tedStyle( contents, null ) || {} ).margi nRight ); | |
6366 | } | |
6367 | ||
6368 | // Suppo rt: IE8 | |
6369 | // Check if table cells stil l have off setWidth/H eight when they are set | |
6370 | // to di splay:none and there are still other vis ible table cells in a | |
6371 | // table row; if s o, offsetW idth/Heigh t are not reliable f or use whe n | |
6372 | // deter mining if an element has been hidden dir ectly usin g | |
6373 | // displ ay:none (i t is still safe to u se offsets if a pare nt element is | |
6374 | // hidde n; don saf ety goggle s and see bug #4512 for more i nformation ). | |
6375 | div.inne rHTML = "< table><tr> <td></td>< td>t</td>< /tr></tabl e>"; | |
6376 | contents = div.get ElementsBy TagName( " td" ); | |
6377 | contents [ 0 ].styl e.cssText = "margin: 0;border:0 ;padding:0 ;display:n one"; | |
6378 | reliable HiddenOffs etsVal = c ontents[ 0 ].offsetH eight === 0; | |
6379 | if ( rel iableHidde nOffsetsVa l ) { | |
6380 | cont ents[ 0 ]. style.disp lay = ""; | |
6381 | cont ents[ 1 ]. style.disp lay = "non e"; | |
6382 | reli ableHidden OffsetsVal = content s[ 0 ].off setHeight === 0; | |
6383 | } | |
6384 | ||
6385 | body.rem oveChild( container ); | |
6386 | } | |
6387 | ||
6388 | })(); | |
6389 | ||
6390 | ||
6391 | // A metho d for quic kly swappi ng in/out CSS proper ties to ge t correct calculatio ns. | |
6392 | jQuery .swap = fu nction( el em, option s, callbac k, args ) { | |
6393 | va r ret, nam e, | |
6394 | old = {} ; | |
6395 | ||
6396 | // Remember the old va lues, and insert the new ones | |
6397 | fo r ( name i n options ) { | |
6398 | old[ nam e ] = elem .style[ na me ]; | |
6399 | elem.sty le[ name ] = options [ name ]; | |
6400 | } | |
6401 | ||
6402 | re t = callba ck.apply( elem, args || [] ); | |
6403 | ||
6404 | // Revert th e old valu es | |
6405 | fo r ( name i n options ) { | |
6406 | elem.sty le[ name ] = old[ na me ]; | |
6407 | } | |
6408 | ||
6409 | re turn ret; | |
6410 | }; | |
6411 | ||
6412 | ||
6413 | var | |
6414 | ra lpha = /al pha\([^)]* \)/i, | |
6415 | ro pacity = / opacity\s* =\s*([^)]* )/, | |
6416 | ||
6417 | // swa ppable if display is none or s tarts with table exc ept "table ", "table- cell", or "table-cap tion" | |
6418 | // see here for display va lues: http s://develo per.mozill a.org/en-U S/docs/CSS /display | |
6419 | rd isplayswap = /^(none |table(?!- c[ea]).+)/ , | |
6420 | rn umsplit = new RegExp ( "^(" + p num + ")(. *)$", "i" ), | |
6421 | rr elNum = ne w RegExp( "^([+-])=( " + pnum + ")", "i" ), | |
6422 | ||
6423 | cs sShow = { position: "absolute" , visibili ty: "hidde n", displa y: "block" }, | |
6424 | cs sNormalTra nsform = { | |
6425 | letterSp acing: "0" , | |
6426 | fontWeig ht: "400" | |
6427 | }, | |
6428 | ||
6429 | cs sPrefixes = [ "Webki t", "O", " Moz", "ms" ]; | |
6430 | ||
6431 | ||
6432 | // return a css prop erty mappe d to a pot entially v endor pref ixed prope rty | |
6433 | functi on vendorP ropName( s tyle, name ) { | |
6434 | ||
6435 | // shortcut for names that are n ot vendor prefixed | |
6436 | if ( name in style ) { | |
6437 | return n ame; | |
6438 | } | |
6439 | ||
6440 | // check for vendor pr efixed nam es | |
6441 | va r capName = name.cha rAt(0).toU pperCase() + name.sl ice(1), | |
6442 | origName = name, | |
6443 | i = cssP refixes.le ngth; | |
6444 | ||
6445 | wh ile ( i-- ) { | |
6446 | name = c ssPrefixes [ i ] + ca pName; | |
6447 | if ( nam e in style ) { | |
6448 | retu rn name; | |
6449 | } | |
6450 | } | |
6451 | ||
6452 | re turn origN ame; | |
6453 | } | |
6454 | ||
6455 | functi on showHid e( element s, show ) { | |
6456 | va r display, elem, hid den, | |
6457 | values = [], | |
6458 | index = 0, | |
6459 | length = elements. length; | |
6460 | ||
6461 | fo r ( ; inde x < length ; index++ ) { | |
6462 | elem = e lements[ i ndex ]; | |
6463 | if ( !el em.style ) { | |
6464 | cont inue; | |
6465 | } | |
6466 | ||
6467 | values[ index ] = jQuery._da ta( elem, "olddispla y" ); | |
6468 | display = elem.sty le.display ; | |
6469 | if ( sho w ) { | |
6470 | // R eset the i nline disp lay of thi s element to learn i f it is | |
6471 | // b eing hidde n by casca ded rules or not | |
6472 | if ( !values[ index ] && display = == "none" ) { | |
6473 | elem.style .display = ""; | |
6474 | } | |
6475 | ||
6476 | // S et element s which ha ve been ov erridden w ith displa y: none | |
6477 | // i n a styles heet to wh atever the default b rowser sty le is | |
6478 | // f or such an element | |
6479 | if ( elem.styl e.display === "" && isHidden( elem ) ) { | |
6480 | values[ in dex ] = jQ uery._data ( elem, "o lddisplay" , defaultD isplay(ele m.nodeName ) ); | |
6481 | } | |
6482 | } else { | |
6483 | hidd en = isHid den( elem ); | |
6484 | ||
6485 | if ( display & & display !== "none" || !hidde n ) { | |
6486 | jQuery._da ta( elem, "olddispla y", hidden ? display : jQuery. css( elem, "display" ) ); | |
6487 | } | |
6488 | } | |
6489 | } | |
6490 | ||
6491 | // Set the d isplay of most of th e elements in a seco nd loop | |
6492 | // to avoid the consta nt reflow | |
6493 | fo r ( index = 0; index < length; index++ ) { | |
6494 | elem = e lements[ i ndex ]; | |
6495 | if ( !el em.style ) { | |
6496 | cont inue; | |
6497 | } | |
6498 | if ( !sh ow || elem .style.dis play === " none" || e lem.style. display == = "" ) { | |
6499 | elem .style.dis play = sho w ? values [ index ] || "" : "n one"; | |
6500 | } | |
6501 | } | |
6502 | ||
6503 | re turn eleme nts; | |
6504 | } | |
6505 | ||
6506 | functi on setPosi tiveNumber ( elem, va lue, subtr act ) { | |
6507 | va r matches = rnumspli t.exec( va lue ); | |
6508 | re turn match es ? | |
6509 | // Guard against u ndefined " subtract", e.g., whe n used as in cssHook s | |
6510 | Math.max ( 0, match es[ 1 ] - ( subtract || 0 ) ) + ( matche s[ 2 ] || "px" ) : | |
6511 | value; | |
6512 | } | |
6513 | ||
6514 | functi on augment WidthOrHei ght( elem, name, ext ra, isBord erBox, sty les ) { | |
6515 | va r i = extr a === ( is BorderBox ? "border" : "conten t" ) ? | |
6516 | // I f we alrea dy have th e right me asurement, avoid aug mentation | |
6517 | 4 : | |
6518 | // O therwise i nitialize for horizo ntal or ve rtical pro perties | |
6519 | name === " width" ? 1 : 0, | |
6520 | ||
6521 | val = 0; | |
6522 | ||
6523 | fo r ( ; i < 4; i += 2 ) { | |
6524 | // both box models exclude m argin, so add it if we want it | |
6525 | if ( ext ra === "ma rgin" ) { | |
6526 | val += jQuery. css( elem, extra + c ssExpand[ i ], true, styles ); | |
6527 | } | |
6528 | ||
6529 | if ( isB orderBox ) { | |
6530 | // b order-box includes p adding, so remove it if we wan t resource s | |
6531 | if ( extra === "content" ) { | |
6532 | val -= jQu ery.css( e lem, "padd ing" + css Expand[ i ], true, s tyles ); | |
6533 | } | |
6534 | ||
6535 | // a t this poi nt, extra isn't bord er nor mar gin, so re move borde r | |
6536 | if ( extra !== "margin" ) { | |
6537 | val -= jQu ery.css( e lem, "bord er" + cssE xpand[ i ] + "Width" , true, st yles ); | |
6538 | } | |
6539 | } else { | |
6540 | // a t this poi nt, extra isn't reso urces, so add paddin g | |
6541 | val += jQuery. css( elem, "padding" + cssExpa nd[ i ], t rue, style s ); | |
6542 | ||
6543 | // a t this poi nt, extra isn't reso urces nor padding, s o add bord er | |
6544 | if ( extra !== "padding" ) { | |
6545 | val += jQu ery.css( e lem, "bord er" + cssE xpand[ i ] + "Width" , true, st yles ); | |
6546 | } | |
6547 | } | |
6548 | } | |
6549 | ||
6550 | re turn val; | |
6551 | } | |
6552 | ||
6553 | functi on getWidt hOrHeight( elem, nam e, extra ) { | |
6554 | ||
6555 | // Start wit h offset p roperty, w hich is eq uivalent t o the bord er-box val ue | |
6556 | va r valueIsB orderBox = true, | |
6557 | val = na me === "wi dth" ? ele m.offsetWi dth : elem .offsetHei ght, | |
6558 | styles = getStyles ( elem ), | |
6559 | isBorder Box = supp ort.boxSiz ing && jQu ery.css( e lem, "boxS izing", fa lse, style s ) === "b order-box" ; | |
6560 | ||
6561 | // some non- html eleme nts return undefined for offse tWidth, so check for null/unde fined | |
6562 | // svg - htt ps://bugzi lla.mozill a.org/show _bug.cgi?i d=649285 | |
6563 | // MathML - https://bu gzilla.moz illa.org/s how_bug.cg i?id=49166 8 | |
6564 | if ( val <= 0 || val = = null ) { | |
6565 | // Fall back to co mputed the n uncomput ed css if necessary | |
6566 | val = cu rCSS( elem , name, st yles ); | |
6567 | if ( val < 0 || va l == null ) { | |
6568 | val = elem.sty le[ name ] ; | |
6569 | } | |
6570 | ||
6571 | // Compu ted unit i s not pixe ls. Stop h ere and re turn. | |
6572 | if ( rnu mnonpx.tes t(val) ) { | |
6573 | retu rn val; | |
6574 | } | |
6575 | ||
6576 | // we ne ed the che ck for sty le in case a browser which ret urns unrel iable valu es | |
6577 | // for g etComputed Style sile ntly falls back to t he reliabl e elem.sty le | |
6578 | valueIsB orderBox = isBorderB ox && ( su pport.boxS izingRelia ble() || v al === ele m.style[ n ame ] ); | |
6579 | ||
6580 | // Norma lize "", a uto, and p repare for extra | |
6581 | val = pa rseFloat( val ) || 0 ; | |
6582 | } | |
6583 | ||
6584 | // use the a ctive box- sizing mod el to add/ subtract i rrelevant styles | |
6585 | re turn ( val + | |
6586 | augmentW idthOrHeig ht( | |
6587 | elem , | |
6588 | name , | |
6589 | extra || ( isBorderB ox ? "bord er" : "con tent" ), | |
6590 | valu eIsBorderB ox, | |
6591 | styl es | |
6592 | ) | |
6593 | ) + "px" ; | |
6594 | } | |
6595 | ||
6596 | jQuery .extend({ | |
6597 | // Add in st yle proper ty hooks f or overrid ing the de fault | |
6598 | // behavior of getting and setti ng a style property | |
6599 | cs sHooks: { | |
6600 | opacity: { | |
6601 | get: function( elem, com puted ) { | |
6602 | if ( compu ted ) { | |
6603 | // We should alw ays get a number bac k from opa city | |
6604 | var re t = curCSS ( elem, "o pacity" ); | |
6605 | return ret === " " ? "1" : ret; | |
6606 | } | |
6607 | } | |
6608 | } | |
6609 | }, | |
6610 | ||
6611 | // Don't aut omatically add "px" to these p ossibly-un itless pro perties | |
6612 | cs sNumber: { | |
6613 | "columnC ount": tru e, | |
6614 | "fillOpa city": tru e, | |
6615 | "flexGro w": true, | |
6616 | "flexShr ink": true , | |
6617 | "fontWei ght": true , | |
6618 | "lineHei ght": true , | |
6619 | "opacity ": true, | |
6620 | "order": true, | |
6621 | "orphans ": true, | |
6622 | "widows" : true, | |
6623 | "zIndex" : true, | |
6624 | "zoom": true | |
6625 | }, | |
6626 | ||
6627 | // Add in pr operties w hose names you wish to fix bef ore | |
6628 | // setting o r getting the value | |
6629 | cs sProps: { | |
6630 | // norma lize float css prope rty | |
6631 | "float": support.c ssFloat ? "cssFloat" : "styleF loat" | |
6632 | }, | |
6633 | ||
6634 | // Get and s et the sty le propert y on a DOM Node | |
6635 | st yle: funct ion( elem, name, val ue, extra ) { | |
6636 | // Don't set style s on text and commen t nodes | |
6637 | if ( !el em || elem .nodeType === 3 || e lem.nodeTy pe === 8 | | !elem.st yle ) { | |
6638 | retu rn; | |
6639 | } | |
6640 | ||
6641 | // Make sure that we're work ing with t he right n ame | |
6642 | var ret, type, hoo ks, | |
6643 | orig Name = jQu ery.camelC ase( name ), | |
6644 | styl e = elem.s tyle; | |
6645 | ||
6646 | name = j Query.cssP rops[ orig Name ] || ( jQuery.c ssProps[ o rigName ] = vendorPr opName( st yle, origN ame ) ); | |
6647 | ||
6648 | // gets hook for t he prefixe d version | |
6649 | // follo wed by the unprefixe d version | |
6650 | hooks = jQuery.css Hooks[ nam e ] || jQu ery.cssHoo ks[ origNa me ]; | |
6651 | ||
6652 | // Check if we're setting a value | |
6653 | if ( val ue !== und efined ) { | |
6654 | type = typeof value; | |
6655 | ||
6656 | // c onvert rel ative numb er strings (+= or -= ) to relat ive number s. #7345 | |
6657 | if ( type === "string" & & (ret = r relNum.exe c( value ) ) ) { | |
6658 | value = ( ret[1] + 1 ) * ret[2 ] + parseF loat( jQue ry.css( el em, name ) ); | |
6659 | // Fixes b ug #9237 | |
6660 | type = "nu mber"; | |
6661 | } | |
6662 | ||
6663 | // M ake sure t hat null a nd NaN val ues aren't set. See: #7116 | |
6664 | if ( value == null || va lue !== va lue ) { | |
6665 | return; | |
6666 | } | |
6667 | ||
6668 | // I f a number was passe d in, add 'px' to th e (except for certai n CSS prop erties) | |
6669 | if ( type === "number" & & !jQuery. cssNumber[ origName ] ) { | |
6670 | value += " px"; | |
6671 | } | |
6672 | ||
6673 | // F ixes #8908 , it can b e done mor e correctl y by speci fing sette rs in cssH ooks, | |
6674 | // b ut it woul d mean to define eig ht (for ev ery proble matic prop erty) iden tical func tions | |
6675 | if ( !support. clearClone Style && v alue === " " && name. indexOf("b ackground" ) === 0 ) { | |
6676 | style[ nam e ] = "inh erit"; | |
6677 | } | |
6678 | ||
6679 | // I f a hook w as provide d, use tha t value, o therwise j ust set th e specifie d value | |
6680 | if ( !hooks || !("set" i n hooks) | | (value = hooks.set ( elem, va lue, extra )) !== un defined ) { | |
6681 | ||
6682 | // Support : IE | |
6683 | // Swallow errors fr om 'invali d' CSS val ues (#5509 ) | |
6684 | try { | |
6685 | style[ name ] = value; | |
6686 | } catch(e) {} | |
6687 | } | |
6688 | ||
6689 | } else { | |
6690 | // I f a hook w as provide d get the non-comput ed value f rom there | |
6691 | if ( hooks && "get" in h ooks && (r et = hooks .get( elem , false, e xtra )) != = undefine d ) { | |
6692 | return ret ; | |
6693 | } | |
6694 | ||
6695 | // O therwise j ust get th e value fr om the sty le object | |
6696 | retu rn style[ name ]; | |
6697 | } | |
6698 | }, | |
6699 | ||
6700 | cs s: functio n( elem, n ame, extra , styles ) { | |
6701 | var num, val, hook s, | |
6702 | orig Name = jQu ery.camelC ase( name ); | |
6703 | ||
6704 | // Make sure that we're work ing with t he right n ame | |
6705 | name = j Query.cssP rops[ orig Name ] || ( jQuery.c ssProps[ o rigName ] = vendorPr opName( el em.style, origName ) ); | |
6706 | ||
6707 | // gets hook for t he prefixe d version | |
6708 | // follo wed by the unprefixe d version | |
6709 | hooks = jQuery.css Hooks[ nam e ] || jQu ery.cssHoo ks[ origNa me ]; | |
6710 | ||
6711 | // If a hook was p rovided ge t the comp uted value from ther e | |
6712 | if ( hoo ks && "get " in hooks ) { | |
6713 | val = hooks.ge t( elem, t rue, extra ); | |
6714 | } | |
6715 | ||
6716 | // Other wise, if a way to ge t the comp uted value exists, u se that | |
6717 | if ( val === undef ined ) { | |
6718 | val = curCSS( elem, name , styles ) ; | |
6719 | } | |
6720 | ||
6721 | //conver t "normal" to comput ed value | |
6722 | if ( val === "norm al" && nam e in cssNo rmalTransf orm ) { | |
6723 | val = cssNorma lTransform [ name ]; | |
6724 | } | |
6725 | ||
6726 | // Retur n, convert ing to num ber if for ced or a q ualifier w as provide d and val looks nume ric | |
6727 | if ( ext ra === "" || extra ) { | |
6728 | num = parseFlo at( val ); | |
6729 | retu rn extra = == true || jQuery.is Numeric( n um ) ? num || 0 : va l; | |
6730 | } | |
6731 | return v al; | |
6732 | } | |
6733 | }); | |
6734 | ||
6735 | jQuery .each([ "h eight", "w idth" ], f unction( i , name ) { | |
6736 | jQ uery.cssHo oks[ name ] = { | |
6737 | get: fun ction( ele m, compute d, extra ) { | |
6738 | if ( computed ) { | |
6739 | // certain elements can have d imension i nfo if we invisibly show them | |
6740 | // however , it must have a cur rent displ ay style t hat would benefit fr om this | |
6741 | return rdi splayswap. test( jQue ry.css( el em, "displ ay" ) ) && elem.offs etWidth == = 0 ? | |
6742 | jQuery .swap( ele m, cssShow , function () { | |
6743 | re turn getWi dthOrHeigh t( elem, n ame, extra ); | |
6744 | }) : | |
6745 | getWid thOrHeight ( elem, na me, extra ); | |
6746 | } | |
6747 | }, | |
6748 | ||
6749 | set: fun ction( ele m, value, extra ) { | |
6750 | var styles = e xtra && ge tStyles( e lem ); | |
6751 | retu rn setPosi tiveNumber ( elem, va lue, extra ? | |
6752 | augmen tWidthOrHe ight( | |
6753 | el em, | |
6754 | na me, | |
6755 | ex tra, | |
6756 | support. boxSizing && jQuery. css( elem, "boxSizin g", false, styles ) === "borde r-box", | |
6757 | st yles | |
6758 | ) : 0 | |
6759 | ); | |
6760 | } | |
6761 | }; | |
6762 | }); | |
6763 | ||
6764 | if ( ! support.op acity ) { | |
6765 | jQ uery.cssHo oks.opacit y = { | |
6766 | get: fun ction( ele m, compute d ) { | |
6767 | // I E uses fil ters for o pacity | |
6768 | retu rn ropacit y.test( (c omputed && elem.curr entStyle ? elem.curr entStyle.f ilter : el em.style.f ilter) || "" ) ? | |
6769 | ( 0.01 * p arseFloat( RegExp.$1 ) ) + "" : | |
6770 | computed ? "1" : ""; | |
6771 | }, | |
6772 | ||
6773 | set: fun ction( ele m, value ) { | |
6774 | var style = el em.style, | |
6775 | currentSty le = elem. currentSty le, | |
6776 | opacity = jQuery.isN umeric( va lue ) ? "a lpha(opaci ty=" + val ue * 100 + ")" : "", | |
6777 | filter = c urrentStyl e && curre ntStyle.fi lter || st yle.filter || ""; | |
6778 | ||
6779 | // I E has trou ble with o pacity if it does no t have lay out | |
6780 | // F orce it by setting t he zoom le vel | |
6781 | styl e.zoom = 1 ; | |
6782 | ||
6783 | // i f setting opacity to 1, and no other fil ters exist - attempt to remove filter at tribute #6 652 | |
6784 | // i f value == = "", then remove in line opaci ty #12685 | |
6785 | if ( ( value > = 1 || val ue === "" ) && | |
6786 | jQuery.tri m( filter. replace( r alpha, "" ) ) === "" && | |
6787 | style.remo veAttribut e ) { | |
6788 | ||
6789 | // Setting style.fil ter to nul l, "" & " " still le ave "filte r:" in the cssText | |
6790 | // if "fil ter:" is p resent at all, clear Type is di sabled, we want to a void this | |
6791 | // style.r emoveAttri bute is IE Only, but so appare ntly is th is code pa th... | |
6792 | style.remo veAttribut e( "filter " ); | |
6793 | ||
6794 | // if ther e is no fi lter style applied i n a css ru le or unse t inline o pacity, we are done | |
6795 | if ( value === "" || currentSt yle && !cu rrentStyle .filter ) { | |
6796 | return ; | |
6797 | } | |
6798 | } | |
6799 | ||
6800 | // o therwise, set new fi lter value s | |
6801 | styl e.filter = ralpha.te st( filter ) ? | |
6802 | filter.rep lace( ralp ha, opacit y ) : | |
6803 | filter + " " + opaci ty; | |
6804 | } | |
6805 | }; | |
6806 | } | |
6807 | ||
6808 | jQuery .cssHooks. marginRigh t = addGet HookIf( su pport.reli ableMargin Right, | |
6809 | fu nction( el em, comput ed ) { | |
6810 | if ( com puted ) { | |
6811 | // W ebKit Bug 13343 - ge tComputedS tyle retur ns wrong v alue for m argin-righ t | |
6812 | // W ork around by tempor arily sett ing elemen t display to inline- block | |
6813 | retu rn jQuery. swap( elem , { "displ ay": "inli ne-block" }, | |
6814 | curCSS, [ elem, "mar ginRight" ] ); | |
6815 | } | |
6816 | } | |
6817 | ); | |
6818 | ||
6819 | // These h ooks are u sed by ani mate to ex pand prope rties | |
6820 | jQuery .each({ | |
6821 | ma rgin: "", | |
6822 | pa dding: "", | |
6823 | bo rder: "Wid th" | |
6824 | }, fun ction( pre fix, suffi x ) { | |
6825 | jQ uery.cssHo oks[ prefi x + suffix ] = { | |
6826 | expand: function( value ) { | |
6827 | var i = 0, | |
6828 | expanded = {}, | |
6829 | ||
6830 | // a ssumes a s ingle numb er if not a string | |
6831 | parts = ty peof value === "stri ng" ? valu e.split(" ") : [ val ue ]; | |
6832 | ||
6833 | for ( ; i < 4; i++ ) { | |
6834 | expanded[ prefix + c ssExpand[ i ] + suff ix ] = | |
6835 | parts[ i ] || pa rts[ i - 2 ] || part s[ 0 ]; | |
6836 | } | |
6837 | ||
6838 | retu rn expande d; | |
6839 | } | |
6840 | }; | |
6841 | ||
6842 | if ( !rmargi n.test( pr efix ) ) { | |
6843 | jQuery.c ssHooks[ p refix + su ffix ].set = setPosi tiveNumber ; | |
6844 | } | |
6845 | }); | |
6846 | ||
6847 | jQuery .fn.extend ({ | |
6848 | cs s: functio n( name, v alue ) { | |
6849 | return a ccess( thi s, functio n( elem, n ame, value ) { | |
6850 | var styles, le n, | |
6851 | map = {}, | |
6852 | i = 0; | |
6853 | ||
6854 | if ( jQuery.is Array( nam e ) ) { | |
6855 | styles = g etStyles( elem ); | |
6856 | len = name .length; | |
6857 | ||
6858 | for ( ; i < len; i++ ) { | |
6859 | map[ n ame[ i ] ] = jQuery. css( elem, name[ i ] , false, s tyles ); | |
6860 | } | |
6861 | ||
6862 | return map ; | |
6863 | } | |
6864 | ||
6865 | retu rn value ! == undefin ed ? | |
6866 | jQuery.sty le( elem, name, valu e ) : | |
6867 | jQuery.css ( elem, na me ); | |
6868 | }, name, value, ar guments.le ngth > 1 ) ; | |
6869 | }, | |
6870 | sh ow: functi on() { | |
6871 | return s howHide( t his, true ); | |
6872 | }, | |
6873 | hi de: functi on() { | |
6874 | return s howHide( t his ); | |
6875 | }, | |
6876 | to ggle: func tion( stat e ) { | |
6877 | if ( typ eof state === "boole an" ) { | |
6878 | retu rn state ? this.show () : this. hide(); | |
6879 | } | |
6880 | ||
6881 | return t his.each(f unction() { | |
6882 | if ( isHidden( this ) ) { | |
6883 | jQuery( th is ).show( ); | |
6884 | } el se { | |
6885 | jQuery( th is ).hide( ); | |
6886 | } | |
6887 | }); | |
6888 | } | |
6889 | }); | |
6890 | ||
6891 | ||
6892 | functi on Tween( elem, opti ons, prop, end, easi ng ) { | |
6893 | re turn new T ween.proto type.init( elem, opt ions, prop , end, eas ing ); | |
6894 | } | |
6895 | jQuery .Tween = T ween; | |
6896 | ||
6897 | Tween. prototype = { | |
6898 | co nstructor: Tween, | |
6899 | in it: functi on( elem, options, p rop, end, easing, un it ) { | |
6900 | this.ele m = elem; | |
6901 | this.pro p = prop; | |
6902 | this.eas ing = easi ng || "swi ng"; | |
6903 | this.opt ions = opt ions; | |
6904 | this.sta rt = this. now = this .cur(); | |
6905 | this.end = end; | |
6906 | this.uni t = unit | | ( jQuery .cssNumber [ prop ] ? "" : "px" ); | |
6907 | }, | |
6908 | cu r: functio n() { | |
6909 | var hook s = Tween. propHooks[ this.prop ]; | |
6910 | ||
6911 | return h ooks && ho oks.get ? | |
6912 | hook s.get( thi s ) : | |
6913 | Twee n.propHook s._default .get( this ); | |
6914 | }, | |
6915 | ru n: functio n( percent ) { | |
6916 | var ease d, | |
6917 | hook s = Tween. propHooks[ this.prop ]; | |
6918 | ||
6919 | if ( thi s.options. duration ) { | |
6920 | this .pos = eas ed = jQuer y.easing[ this.easin g ]( | |
6921 | percent, t his.option s.duration * percent , 0, 1, th is.options .duration | |
6922 | ); | |
6923 | } else { | |
6924 | this .pos = eas ed = perce nt; | |
6925 | } | |
6926 | this.now = ( this. end - this .start ) * eased + t his.start; | |
6927 | ||
6928 | if ( thi s.options. step ) { | |
6929 | this .options.s tep.call( this.elem, this.now, this ); | |
6930 | } | |
6931 | ||
6932 | if ( hoo ks && hook s.set ) { | |
6933 | hook s.set( thi s ); | |
6934 | } else { | |
6935 | Twee n.propHook s._default .set( this ); | |
6936 | } | |
6937 | return t his; | |
6938 | } | |
6939 | }; | |
6940 | ||
6941 | Tween. prototype. init.proto type = Twe en.prototy pe; | |
6942 | ||
6943 | Tween. propHooks = { | |
6944 | _d efault: { | |
6945 | get: fun ction( twe en ) { | |
6946 | var result; | |
6947 | ||
6948 | if ( tween.ele m[ tween.p rop ] != n ull && | |
6949 | (!tween.el em.style | | tween.el em.style[ tween.prop ] == null ) ) { | |
6950 | return twe en.elem[ t ween.prop ]; | |
6951 | } | |
6952 | ||
6953 | // p assing an empty stri ng as a 3r d paramete r to .css will autom atically | |
6954 | // a ttempt a p arseFloat and fallba ck to a st ring if th e parse fa ils | |
6955 | // s o, simple values suc h as "10px " are pars ed to Floa t. | |
6956 | // c omplex val ues such a s "rotate( 1rad)" are returned as is. | |
6957 | resu lt = jQuer y.css( twe en.elem, t ween.prop, "" ); | |
6958 | // E mpty strin gs, null, undefined and "auto" are conve rted to 0. | |
6959 | retu rn !result || result === "auto " ? 0 : re sult; | |
6960 | }, | |
6961 | set: fun ction( twe en ) { | |
6962 | // u se step ho ok for bac k compat - use cssHo ok if its there - us e .style i f its | |
6963 | // a vailable a nd use pla in propert ies where available | |
6964 | if ( jQuery.fx .step[ twe en.prop ] ) { | |
6965 | jQuery.fx. step[ twee n.prop ]( tween ); | |
6966 | } el se if ( tw een.elem.s tyle && ( tween.elem .style[ jQ uery.cssPr ops[ tween .prop ] ] != null || jQuery.cs sHooks[ tw een.prop ] ) ) { | |
6967 | jQuery.sty le( tween. elem, twee n.prop, tw een.now + tween.unit ); | |
6968 | } el se { | |
6969 | tween.elem [ tween.pr op ] = twe en.now; | |
6970 | } | |
6971 | } | |
6972 | } | |
6973 | }; | |
6974 | ||
6975 | // Support : IE <=9 | |
6976 | // Panic b ased appro ach to set ting thing s on disco nnected no des | |
6977 | ||
6978 | Tween. propHooks. scrollTop = Tween.pr opHooks.sc rollLeft = { | |
6979 | se t: functio n( tween ) { | |
6980 | if ( twe en.elem.no deType && tween.elem .parentNod e ) { | |
6981 | twee n.elem[ tw een.prop ] = tween.n ow; | |
6982 | } | |
6983 | } | |
6984 | }; | |
6985 | ||
6986 | jQuery .easing = { | |
6987 | li near: func tion( p ) { | |
6988 | return p ; | |
6989 | }, | |
6990 | sw ing: funct ion( p ) { | |
6991 | return 0 .5 - Math. cos( p * M ath.PI ) / 2; | |
6992 | } | |
6993 | }; | |
6994 | ||
6995 | jQuery .fx = Twee n.prototyp e.init; | |
6996 | ||
6997 | // Back Co mpat <1.8 extension point | |
6998 | jQuery .fx.step = {}; | |
6999 | ||
7000 | ||
7001 | ||
7002 | ||
7003 | var | |
7004 | fx Now, timer Id, | |
7005 | rf xtypes = / ^(?:toggle |show|hide )$/, | |
7006 | rf xnum = new RegExp( " ^(?:([+-]) =|)(" + pn um + ")([a -z%]*)$", "i" ), | |
7007 | rr un = /queu eHooks$/, | |
7008 | an imationPre filters = [ defaultP refilter ] , | |
7009 | tw eeners = { | |
7010 | "*": [ f unction( p rop, value ) { | |
7011 | var tween = th is.createT ween( prop , value ), | |
7012 | target = t ween.cur() , | |
7013 | parts = rf xnum.exec( value ), | |
7014 | unit = par ts && part s[ 3 ] || ( jQuery.c ssNumber[ prop ] ? " " : "px" ) , | |
7015 | ||
7016 | // S tarting va lue comput ation is r equired fo r potentia l unit mis matches | |
7017 | start = ( jQuery.css Number[ pr op ] || un it !== "px " && +targ et ) && | |
7018 | rfxnum .exec( jQu ery.css( t ween.elem, prop ) ), | |
7019 | scale = 1, | |
7020 | maxIterati ons = 20; | |
7021 | ||
7022 | if ( start && start[ 3 ] !== unit ) { | |
7023 | // Trust u nits repor ted by jQu ery.css | |
7024 | unit = uni t || start [ 3 ]; | |
7025 | ||
7026 | // Make su re we upda te the twe en propert ies later on | |
7027 | parts = pa rts || []; | |
7028 | ||
7029 | // Iterati vely appro ximate fro m a nonzer o starting point | |
7030 | start = +t arget || 1 ; | |
7031 | ||
7032 | do { | |
7033 | // If previous i teration z eroed out, double un til we get *somethin g* | |
7034 | // Use a string for doubli ng factor so we don' t accident ally see s cale as un changed be low | |
7035 | scale = scale || ".5"; | |
7036 | ||
7037 | // Adj ust and ap ply | |
7038 | start = start / scale; | |
7039 | jQuery .style( tw een.elem, prop, star t + unit ) ; | |
7040 | ||
7041 | // Upd ate scale, toleratin g zero or NaN from t ween.cur() | |
7042 | // And breaking the loop i f scale is unchanged or perfec t, or if w e've just had enough | |
7043 | } while ( scale !== (scale = t ween.cur() / target) && scale !== 1 && - -maxIterat ions ); | |
7044 | } | |
7045 | ||
7046 | // U pdate twee n properti es | |
7047 | if ( parts ) { | |
7048 | start = tw een.start = +start | | +target || 0; | |
7049 | tween.unit = unit; | |
7050 | // If a += /-= token was provid ed, we're doing a re lative ani mation | |
7051 | tween.end = parts[ 1 ] ? | |
7052 | start + ( parts[ 1 ] + 1 ) * parts[ 2 ] : | |
7053 | +parts [ 2 ]; | |
7054 | } | |
7055 | ||
7056 | retu rn tween; | |
7057 | } ] | |
7058 | }; | |
7059 | ||
7060 | // Animati ons create d synchron ously will run synch ronously | |
7061 | functi on createF xNow() { | |
7062 | se tTimeout(f unction() { | |
7063 | fxNow = undefined; | |
7064 | }) ; | |
7065 | re turn ( fxN ow = jQuer y.now() ); | |
7066 | } | |
7067 | ||
7068 | // Generat e paramete rs to crea te a stand ard animat ion | |
7069 | functi on genFx( type, incl udeWidth ) { | |
7070 | va r which, | |
7071 | attrs = { height: type }, | |
7072 | i = 0; | |
7073 | ||
7074 | // if we inc lude width , step val ue is 1 to do all cs sExpand va lues, | |
7075 | // if we don 't include width, st ep value i s 2 to ski p over Lef t and Righ t | |
7076 | in cludeWidth = include Width ? 1 : 0; | |
7077 | fo r ( ; i < 4 ; i += 2 - include Width ) { | |
7078 | which = cssExpand[ i ]; | |
7079 | attrs[ " margin" + which ] = attrs[ "pa dding" + w hich ] = t ype; | |
7080 | } | |
7081 | ||
7082 | if ( include Width ) { | |
7083 | attrs.op acity = at trs.width = type; | |
7084 | } | |
7085 | ||
7086 | re turn attrs ; | |
7087 | } | |
7088 | ||
7089 | functi on createT ween( valu e, prop, a nimation ) { | |
7090 | va r tween, | |
7091 | collecti on = ( twe eners[ pro p ] || [] ).concat( tweeners[ "*" ] ), | |
7092 | index = 0, | |
7093 | length = collectio n.length; | |
7094 | fo r ( ; inde x < length ; index++ ) { | |
7095 | if ( (tw een = coll ection[ in dex ].call ( animatio n, prop, v alue )) ) { | |
7096 | ||
7097 | // w e're done with this property | |
7098 | retu rn tween; | |
7099 | } | |
7100 | } | |
7101 | } | |
7102 | ||
7103 | functi on default Prefilter( elem, pro ps, opts ) { | |
7104 | /* jshint va lidthis: t rue */ | |
7105 | va r prop, va lue, toggl e, tween, hooks, old fire, disp lay, check Display, | |
7106 | anim = t his, | |
7107 | orig = { }, | |
7108 | style = elem.style , | |
7109 | hidden = elem.node Type && is Hidden( el em ), | |
7110 | dataShow = jQuery. _data( ele m, "fxshow " ); | |
7111 | ||
7112 | // handle qu eue: false promises | |
7113 | if ( !opts.q ueue ) { | |
7114 | hooks = jQuery._qu eueHooks( elem, "fx" ); | |
7115 | if ( hoo ks.unqueue d == null ) { | |
7116 | hook s.unqueued = 0; | |
7117 | oldf ire = hook s.empty.fi re; | |
7118 | hook s.empty.fi re = funct ion() { | |
7119 | if ( !hook s.unqueued ) { | |
7120 | oldfir e(); | |
7121 | } | |
7122 | }; | |
7123 | } | |
7124 | hooks.un queued++; | |
7125 | ||
7126 | anim.alw ays(functi on() { | |
7127 | // d oing this makes sure that the complete h andler wil l be calle d | |
7128 | // b efore this completes | |
7129 | anim .always(fu nction() { | |
7130 | hooks.unqu eued--; | |
7131 | if ( !jQue ry.queue( elem, "fx" ).length ) { | |
7132 | hooks. empty.fire (); | |
7133 | } | |
7134 | }); | |
7135 | }); | |
7136 | } | |
7137 | ||
7138 | // height/wi dth overfl ow pass | |
7139 | if ( elem.no deType === 1 && ( "h eight" in props || " width" in props ) ) { | |
7140 | // Make sure that nothing sn eaks out | |
7141 | // Recor d all 3 ov erflow att ributes be cause IE d oes not | |
7142 | // chang e the over flow attri bute when overflowX and | |
7143 | // overf lowY are s et to the same value | |
7144 | opts.ove rflow = [ style.over flow, styl e.overflow X, style.o verflowY ] ; | |
7145 | ||
7146 | // Set d isplay pro perty to i nline-bloc k for heig ht/width | |
7147 | // anima tions on i nline elem ents that are having width/hei ght animat ed | |
7148 | display = jQuery.c ss( elem, "display" ); | |
7149 | ||
7150 | // Test default di splay if d isplay is currently "none" | |
7151 | checkDis play = dis play === " none" ? | |
7152 | jQue ry._data( elem, "old display" ) || defaul tDisplay( elem.nodeN ame ) : di splay; | |
7153 | ||
7154 | if ( che ckDisplay === "inlin e" && jQue ry.css( el em, "float " ) === "n one" ) { | |
7155 | ||
7156 | // i nline-leve l elements accept in line-block ; | |
7157 | // b lock-level elements need to be inline wi th layout | |
7158 | if ( !support. inlineBloc kNeedsLayo ut || defa ultDisplay ( elem.nod eName ) == = "inline" ) { | |
7159 | style.disp lay = "inl ine-block" ; | |
7160 | } el se { | |
7161 | style.zoom = 1; | |
7162 | } | |
7163 | } | |
7164 | } | |
7165 | ||
7166 | if ( opts.ov erflow ) { | |
7167 | style.ov erflow = " hidden"; | |
7168 | if ( !su pport.shri nkWrapBloc ks() ) { | |
7169 | anim .always(fu nction() { | |
7170 | style.over flow = opt s.overflow [ 0 ]; | |
7171 | style.over flowX = op ts.overflo w[ 1 ]; | |
7172 | style.over flowY = op ts.overflo w[ 2 ]; | |
7173 | }); | |
7174 | } | |
7175 | } | |
7176 | ||
7177 | // show/hide pass | |
7178 | fo r ( prop i n props ) { | |
7179 | value = props[ pro p ]; | |
7180 | if ( rfx types.exec ( value ) ) { | |
7181 | dele te props[ prop ]; | |
7182 | togg le = toggl e || value === "togg le"; | |
7183 | if ( value === ( hidden ? "hide" : "show" ) ) { | |
7184 | ||
7185 | // If ther e is dataS how left o ver from a stopped h ide or sho w and we a re going t o proceed with show, we should pretend t o be hidde n | |
7186 | if ( value === "show " && dataS how && dat aShow[ pro p ] !== un defined ) { | |
7187 | hidden = true; | |
7188 | } else { | |
7189 | contin ue; | |
7190 | } | |
7191 | } | |
7192 | orig [ prop ] = dataShow && dataSho w[ prop ] || jQuery. style( ele m, prop ); | |
7193 | ||
7194 | // A ny non-fx value stop s us from restoring the origin al display value | |
7195 | } else { | |
7196 | disp lay = unde fined; | |
7197 | } | |
7198 | } | |
7199 | ||
7200 | if ( !jQuery .isEmptyOb ject( orig ) ) { | |
7201 | if ( dat aShow ) { | |
7202 | if ( "hidden" in dataSho w ) { | |
7203 | hidden = d ataShow.hi dden; | |
7204 | } | |
7205 | } else { | |
7206 | data Show = jQu ery._data( elem, "fx show", {} ); | |
7207 | } | |
7208 | ||
7209 | // store state if its toggle - enables .stop().t oggle() to "reverse" | |
7210 | if ( tog gle ) { | |
7211 | data Show.hidde n = !hidde n; | |
7212 | } | |
7213 | if ( hid den ) { | |
7214 | jQue ry( elem ) .show(); | |
7215 | } else { | |
7216 | anim .done(func tion() { | |
7217 | jQuery( el em ).hide( ); | |
7218 | }); | |
7219 | } | |
7220 | anim.don e(function () { | |
7221 | var prop; | |
7222 | jQue ry._remove Data( elem , "fxshow" ); | |
7223 | for ( prop in orig ) { | |
7224 | jQuery.sty le( elem, prop, orig [ prop ] ) ; | |
7225 | } | |
7226 | }); | |
7227 | for ( pr op in orig ) { | |
7228 | twee n = create Tween( hid den ? data Show[ prop ] : 0, pr op, anim ) ; | |
7229 | ||
7230 | if ( !( prop i n dataShow ) ) { | |
7231 | dataShow[ prop ] = t ween.start ; | |
7232 | if ( hidde n ) { | |
7233 | tween. end = twee n.start; | |
7234 | tween. start = pr op === "wi dth" || pr op === "he ight" ? 1 : 0; | |
7235 | } | |
7236 | } | |
7237 | } | |
7238 | ||
7239 | // If th is is a no op like .h ide().hide (), restor e an overw ritten dis play value | |
7240 | } else if ( (display = == "none" ? defaultD isplay( el em.nodeNam e ) : disp lay) === " inline" ) { | |
7241 | style.di splay = di splay; | |
7242 | } | |
7243 | } | |
7244 | ||
7245 | functi on propFil ter( props , specialE asing ) { | |
7246 | va r index, n ame, easin g, value, hooks; | |
7247 | ||
7248 | // camelCase , specialE asing and expand css Hook pass | |
7249 | fo r ( index in props ) { | |
7250 | name = j Query.came lCase( ind ex ); | |
7251 | easing = specialEa sing[ name ]; | |
7252 | value = props[ ind ex ]; | |
7253 | if ( jQu ery.isArra y( value ) ) { | |
7254 | easi ng = value [ 1 ]; | |
7255 | valu e = props[ index ] = value[ 0 ]; | |
7256 | } | |
7257 | ||
7258 | if ( ind ex !== nam e ) { | |
7259 | prop s[ name ] = value; | |
7260 | dele te props[ index ]; | |
7261 | } | |
7262 | ||
7263 | hooks = jQuery.css Hooks[ nam e ]; | |
7264 | if ( hoo ks && "exp and" in ho oks ) { | |
7265 | valu e = hooks. expand( va lue ); | |
7266 | dele te props[ name ]; | |
7267 | ||
7268 | // n ot quite $ .extend, t his wont o verwrite k eys alread y present. | |
7269 | // a lso - reus ing 'index ' from abo ve because we have t he correct "name" | |
7270 | for ( index in value ) { | |
7271 | if ( !( in dex in pro ps ) ) { | |
7272 | props[ index ] = value[ in dex ]; | |
7273 | specia lEasing[ i ndex ] = e asing; | |
7274 | } | |
7275 | } | |
7276 | } else { | |
7277 | spec ialEasing[ name ] = easing; | |
7278 | } | |
7279 | } | |
7280 | } | |
7281 | ||
7282 | functi on Animati on( elem, properties , options ) { | |
7283 | va r result, | |
7284 | stopped, | |
7285 | index = 0, | |
7286 | length = animation Prefilters .length, | |
7287 | deferred = jQuery. Deferred() .always( f unction() { | |
7288 | // d on't match elem in t he :animat ed selecto r | |
7289 | dele te tick.el em; | |
7290 | }), | |
7291 | tick = f unction() { | |
7292 | if ( stopped ) { | |
7293 | return fal se; | |
7294 | } | |
7295 | var currentTim e = fxNow || createF xNow(), | |
7296 | remaining = Math.max ( 0, anima tion.start Time + ani mation.dur ation - cu rrentTime ), | |
7297 | // a rchaic cra sh bug won 't allow u s to use 1 - ( 0.5 | | 0 ) (#12 497) | |
7298 | temp = rem aining / a nimation.d uration || 0, | |
7299 | percent = 1 - temp, | |
7300 | index = 0, | |
7301 | length = a nimation.t weens.leng th; | |
7302 | ||
7303 | for ( ; index < length ; index++ ) { | |
7304 | animation. tweens[ in dex ].run( percent ) ; | |
7305 | } | |
7306 | ||
7307 | defe rred.notif yWith( ele m, [ anima tion, perc ent, remai ning ]); | |
7308 | ||
7309 | if ( percent < 1 && leng th ) { | |
7310 | return rem aining; | |
7311 | } el se { | |
7312 | deferred.r esolveWith ( elem, [ animation ] ); | |
7313 | return fal se; | |
7314 | } | |
7315 | }, | |
7316 | animatio n = deferr ed.promise ({ | |
7317 | elem : elem, | |
7318 | prop s: jQuery. extend( {} , properti es ), | |
7319 | opts : jQuery.e xtend( tru e, { speci alEasing: {} }, opti ons ), | |
7320 | orig inalProper ties: prop erties, | |
7321 | orig inalOption s: options , | |
7322 | star tTime: fxN ow || crea teFxNow(), | |
7323 | dura tion: opti ons.durati on, | |
7324 | twee ns: [], | |
7325 | crea teTween: f unction( p rop, end ) { | |
7326 | var tween = jQuery.T ween( elem , animatio n.opts, pr op, end, | |
7327 | an imation.op ts.special Easing[ pr op ] || an imation.op ts.easing ); | |
7328 | animation. tweens.pus h( tween ) ; | |
7329 | return twe en; | |
7330 | }, | |
7331 | stop : function ( gotoEnd ) { | |
7332 | var index = 0, | |
7333 | // if we a re going t o the end, we want t o run all the tweens | |
7334 | // otherwi se we skip this part | |
7335 | length = gotoEnd ? animati on.tweens. length : 0 ; | |
7336 | if ( stopp ed ) { | |
7337 | return this; | |
7338 | } | |
7339 | stopped = true; | |
7340 | for ( ; in dex < leng th ; index ++ ) { | |
7341 | animat ion.tweens [ index ]. run( 1 ); | |
7342 | } | |
7343 | ||
7344 | // resolve when we p layed the last frame | |
7345 | // otherwi se, reject | |
7346 | if ( gotoE nd ) { | |
7347 | deferr ed.resolve With( elem , [ animat ion, gotoE nd ] ); | |
7348 | } else { | |
7349 | deferr ed.rejectW ith( elem, [ animati on, gotoEn d ] ); | |
7350 | } | |
7351 | return thi s; | |
7352 | } | |
7353 | }), | |
7354 | props = animation. props; | |
7355 | ||
7356 | pr opFilter( props, ani mation.opt s.specialE asing ); | |
7357 | ||
7358 | fo r ( ; inde x < length ; index++ ) { | |
7359 | result = animation Prefilters [ index ]. call( anim ation, ele m, props, animation. opts ); | |
7360 | if ( res ult ) { | |
7361 | retu rn result; | |
7362 | } | |
7363 | } | |
7364 | ||
7365 | jQ uery.map( props, cre ateTween, animation ); | |
7366 | ||
7367 | if ( jQuery. isFunction ( animatio n.opts.sta rt ) ) { | |
7368 | animatio n.opts.sta rt.call( e lem, anima tion ); | |
7369 | } | |
7370 | ||
7371 | jQ uery.fx.ti mer( | |
7372 | jQuery.e xtend( tic k, { | |
7373 | elem : elem, | |
7374 | anim : animatio n, | |
7375 | queu e: animati on.opts.qu eue | |
7376 | }) | |
7377 | ); | |
7378 | ||
7379 | // attach ca llbacks fr om options | |
7380 | re turn anima tion.progr ess( anima tion.opts. progress ) | |
7381 | .done( a nimation.o pts.done, animation. opts.compl ete ) | |
7382 | .fail( a nimation.o pts.fail ) | |
7383 | .always( animation .opts.alwa ys ); | |
7384 | } | |
7385 | ||
7386 | jQuery .Animation = jQuery. extend( An imation, { | |
7387 | tw eener: fun ction( pro ps, callba ck ) { | |
7388 | if ( jQu ery.isFunc tion( prop s ) ) { | |
7389 | call back = pro ps; | |
7390 | prop s = [ "*" ]; | |
7391 | } else { | |
7392 | prop s = props. split(" ") ; | |
7393 | } | |
7394 | ||
7395 | var prop , | |
7396 | inde x = 0, | |
7397 | leng th = props .length; | |
7398 | ||
7399 | for ( ; index < le ngth ; ind ex++ ) { | |
7400 | prop = props[ index ]; | |
7401 | twee ners[ prop ] = tween ers[ prop ] || []; | |
7402 | twee ners[ prop ].unshift ( callback ); | |
7403 | } | |
7404 | }, | |
7405 | ||
7406 | pr efilter: f unction( c allback, p repend ) { | |
7407 | if ( pre pend ) { | |
7408 | anim ationPrefi lters.unsh ift( callb ack ); | |
7409 | } else { | |
7410 | anim ationPrefi lters.push ( callback ); | |
7411 | } | |
7412 | } | |
7413 | }); | |
7414 | ||
7415 | jQuery .speed = f unction( s peed, easi ng, fn ) { | |
7416 | va r opt = sp eed && typ eof speed === "objec t" ? jQuer y.extend( {}, speed ) : { | |
7417 | complete : fn || !f n && easin g || | |
7418 | jQue ry.isFunct ion( speed ) && spee d, | |
7419 | duration : speed, | |
7420 | easing: fn && easi ng || easi ng && !jQu ery.isFunc tion( easi ng ) && ea sing | |
7421 | }; | |
7422 | ||
7423 | op t.duration = jQuery. fx.off ? 0 : typeof opt.durati on === "nu mber" ? op t.duration : | |
7424 | opt. duration i n jQuery.f x.speeds ? jQuery.fx .speeds[ o pt.duratio n ] : jQue ry.fx.spee ds._defaul t; | |
7425 | ||
7426 | // normalize opt.queue - true/un defined/nu ll -> "fx" | |
7427 | if ( opt.que ue == null || opt.qu eue === tr ue ) { | |
7428 | opt.queu e = "fx"; | |
7429 | } | |
7430 | ||
7431 | // Queueing | |
7432 | op t.old = op t.complete ; | |
7433 | ||
7434 | op t.complete = functio n() { | |
7435 | if ( jQu ery.isFunc tion( opt. old ) ) { | |
7436 | opt. old.call( this ); | |
7437 | } | |
7438 | ||
7439 | if ( opt .queue ) { | |
7440 | jQue ry.dequeue ( this, op t.queue ); | |
7441 | } | |
7442 | }; | |
7443 | ||
7444 | re turn opt; | |
7445 | }; | |
7446 | ||
7447 | jQuery .fn.extend ({ | |
7448 | fa deTo: func tion( spee d, to, eas ing, callb ack ) { | |
7449 | ||
7450 | // show any hidden elements after sett ing opacit y to 0 | |
7451 | return t his.filter ( isHidden ).css( "o pacity", 0 ).show() | |
7452 | ||
7453 | // a nimate to the value specified | |
7454 | .end ().animate ({ opacity : to }, sp eed, easin g, callbac k ); | |
7455 | }, | |
7456 | an imate: fun ction( pro p, speed, easing, ca llback ) { | |
7457 | var empt y = jQuery .isEmptyOb ject( prop ), | |
7458 | opta ll = jQuer y.speed( s peed, easi ng, callba ck ), | |
7459 | doAn imation = function() { | |
7460 | // Operate on a copy of prop s o per-prop erty easin g won't be lost | |
7461 | var anim = Animation ( this, jQ uery.exten d( {}, pro p ), optal l ); | |
7462 | ||
7463 | // Empty a nimations, or finish ing resolv es immedia tely | |
7464 | if ( empty || jQuery ._data( th is, "finis h" ) ) { | |
7465 | anim.s top( true ); | |
7466 | } | |
7467 | }; | |
7468 | doAnimat ion.finish = doAnima tion; | |
7469 | ||
7470 | return e mpty || op tall.queue === false ? | |
7471 | this .each( doA nimation ) : | |
7472 | this .queue( op tall.queue , doAnimat ion ); | |
7473 | }, | |
7474 | st op: functi on( type, clearQueue , gotoEnd ) { | |
7475 | var stop Queue = fu nction( ho oks ) { | |
7476 | var stop = hoo ks.stop; | |
7477 | dele te hooks.s top; | |
7478 | stop ( gotoEnd ); | |
7479 | }; | |
7480 | ||
7481 | if ( typ eof type ! == "string " ) { | |
7482 | goto End = clea rQueue; | |
7483 | clea rQueue = t ype; | |
7484 | type = undefin ed; | |
7485 | } | |
7486 | if ( cle arQueue && type !== false ) { | |
7487 | this .queue( ty pe || "fx" , [] ); | |
7488 | } | |
7489 | ||
7490 | return t his.each(f unction() { | |
7491 | var dequeue = true, | |
7492 | index = ty pe != null && type + "queueHoo ks", | |
7493 | timers = j Query.time rs, | |
7494 | data = jQu ery._data( this ); | |
7495 | ||
7496 | if ( index ) { | |
7497 | if ( data[ index ] & & data[ in dex ].stop ) { | |
7498 | stopQu eue( data[ index ] ) ; | |
7499 | } | |
7500 | } el se { | |
7501 | for ( inde x in data ) { | |
7502 | if ( d ata[ index ] && data [ index ]. stop && rr un.test( i ndex ) ) { | |
7503 | st opQueue( d ata[ index ] ); | |
7504 | } | |
7505 | } | |
7506 | } | |
7507 | ||
7508 | for ( index = timers.len gth; index --; ) { | |
7509 | if ( timer s[ index ] .elem === this && (t ype == nul l || timer s[ index ] .queue === type) ) { | |
7510 | timers [ index ]. anim.stop( gotoEnd ) ; | |
7511 | dequeu e = false; | |
7512 | timers .splice( i ndex, 1 ); | |
7513 | } | |
7514 | } | |
7515 | ||
7516 | // s tart the n ext in the queue if the last s tep wasn't forced | |
7517 | // t imers curr ently will call thei r complete callbacks , which wi ll dequeue | |
7518 | // b ut only if they were gotoEnd | |
7519 | if ( dequeue | | !gotoEnd ) { | |
7520 | jQuery.deq ueue( this , type ); | |
7521 | } | |
7522 | }); | |
7523 | }, | |
7524 | fi nish: func tion( type ) { | |
7525 | if ( typ e !== fals e ) { | |
7526 | type = type || "fx"; | |
7527 | } | |
7528 | return t his.each(f unction() { | |
7529 | var index, | |
7530 | data = jQu ery._data( this ), | |
7531 | queue = da ta[ type + "queue" ] , | |
7532 | hooks = da ta[ type + "queueHoo ks" ], | |
7533 | timers = j Query.time rs, | |
7534 | length = q ueue ? que ue.length : 0; | |
7535 | ||
7536 | // e nable fini shing flag on privat e data | |
7537 | data .finish = true; | |
7538 | ||
7539 | // e mpty the q ueue first | |
7540 | jQue ry.queue( this, type , [] ); | |
7541 | ||
7542 | if ( hooks && hooks.stop ) { | |
7543 | hooks.stop .call( thi s, true ); | |
7544 | } | |
7545 | ||
7546 | // l ook for an y active a nimations, and finis h them | |
7547 | for ( index = timers.len gth; index --; ) { | |
7548 | if ( timer s[ index ] .elem === this && ti mers[ inde x ].queue === type ) { | |
7549 | timers [ index ]. anim.stop( true ); | |
7550 | timers .splice( i ndex, 1 ); | |
7551 | } | |
7552 | } | |
7553 | ||
7554 | // l ook for an y animatio ns in the old queue and finish them | |
7555 | for ( index = 0; index < length; i ndex++ ) { | |
7556 | if ( queue [ index ] && queue[ index ].fi nish ) { | |
7557 | queue[ index ].f inish.call ( this ); | |
7558 | } | |
7559 | } | |
7560 | ||
7561 | // t urn off fi nishing fl ag | |
7562 | dele te data.fi nish; | |
7563 | }); | |
7564 | } | |
7565 | }); | |
7566 | ||
7567 | jQuery .each([ "t oggle", "s how", "hid e" ], func tion( i, n ame ) { | |
7568 | va r cssFn = jQuery.fn[ name ]; | |
7569 | jQ uery.fn[ n ame ] = fu nction( sp eed, easin g, callbac k ) { | |
7570 | return s peed == nu ll || type of speed = == "boolea n" ? | |
7571 | cssF n.apply( t his, argum ents ) : | |
7572 | this .animate( genFx( nam e, true ), speed, ea sing, call back ); | |
7573 | }; | |
7574 | }); | |
7575 | ||
7576 | // Generat e shortcut s for cust om animati ons | |
7577 | jQuery .each({ | |
7578 | sl ideDown: g enFx("show "), | |
7579 | sl ideUp: gen Fx("hide") , | |
7580 | sl ideToggle: genFx("to ggle"), | |
7581 | fa deIn: { op acity: "sh ow" }, | |
7582 | fa deOut: { o pacity: "h ide" }, | |
7583 | fa deToggle: { opacity: "toggle" } | |
7584 | }, fun ction( nam e, props ) { | |
7585 | jQ uery.fn[ n ame ] = fu nction( sp eed, easin g, callbac k ) { | |
7586 | return t his.animat e( props, speed, eas ing, callb ack ); | |
7587 | }; | |
7588 | }); | |
7589 | ||
7590 | jQuery .timers = []; | |
7591 | jQuery .fx.tick = function( ) { | |
7592 | va r timer, | |
7593 | timers = jQuery.ti mers, | |
7594 | i = 0; | |
7595 | ||
7596 | fx Now = jQue ry.now(); | |
7597 | ||
7598 | fo r ( ; i < timers.len gth; i++ ) { | |
7599 | timer = timers[ i ]; | |
7600 | // Check s the time r has not already be en removed | |
7601 | if ( !ti mer() && t imers[ i ] === timer ) { | |
7602 | time rs.splice( i--, 1 ); | |
7603 | } | |
7604 | } | |
7605 | ||
7606 | if ( !timers .length ) { | |
7607 | jQuery.f x.stop(); | |
7608 | } | |
7609 | fx Now = unde fined; | |
7610 | }; | |
7611 | ||
7612 | jQuery .fx.timer = function ( timer ) { | |
7613 | jQ uery.timer s.push( ti mer ); | |
7614 | if ( timer() ) { | |
7615 | jQuery.f x.start(); | |
7616 | } else { | |
7617 | jQuery.t imers.pop( ); | |
7618 | } | |
7619 | }; | |
7620 | ||
7621 | jQuery .fx.interv al = 13; | |
7622 | ||
7623 | jQuery .fx.start = function () { | |
7624 | if ( !timerI d ) { | |
7625 | timerId = setInter val( jQuer y.fx.tick, jQuery.fx .interval ); | |
7626 | } | |
7627 | }; | |
7628 | ||
7629 | jQuery .fx.stop = function( ) { | |
7630 | cl earInterva l( timerId ); | |
7631 | ti merId = nu ll; | |
7632 | }; | |
7633 | ||
7634 | jQuery .fx.speeds = { | |
7635 | sl ow: 600, | |
7636 | fa st: 200, | |
7637 | // Default s peed | |
7638 | _d efault: 40 0 | |
7639 | }; | |
7640 | ||
7641 | ||
7642 | // Based o ff of the plugin by Clint Helf ers, with permission . | |
7643 | // http:// blindsigna ls.com/ind ex.php/200 9/07/jquer y-delay/ | |
7644 | jQuery .fn.delay = function ( time, ty pe ) { | |
7645 | ti me = jQuer y.fx ? jQu ery.fx.spe eds[ time ] || time : time; | |
7646 | ty pe = type || "fx"; | |
7647 | ||
7648 | re turn this. queue( typ e, functio n( next, h ooks ) { | |
7649 | var time out = setT imeout( ne xt, time ) ; | |
7650 | hooks.st op = funct ion() { | |
7651 | clea rTimeout( timeout ); | |
7652 | }; | |
7653 | }) ; | |
7654 | }; | |
7655 | ||
7656 | ||
7657 | (funct ion() { | |
7658 | // Minified: var a,b,c ,d,e | |
7659 | va r input, d iv, select , a, opt; | |
7660 | ||
7661 | // Setup | |
7662 | di v = docume nt.createE lement( "d iv" ); | |
7663 | di v.setAttri bute( "cla ssName", " t" ); | |
7664 | di v.innerHTM L = " <li nk/><table ></table>< a href='/a '>a</a><in put type=' checkbox'/ >"; | |
7665 | a = div.getE lementsByT agName("a" )[ 0 ]; | |
7666 | ||
7667 | // First bat ch of test s. | |
7668 | se lect = doc ument.crea teElement( "select"); | |
7669 | op t = select .appendChi ld( docume nt.createE lement("op tion") ); | |
7670 | in put = div. getElement sByTagName ("input")[ 0 ]; | |
7671 | ||
7672 | a. style.cssT ext = "top :1px"; | |
7673 | ||
7674 | // Test setA ttribute o n camelCas e class. I f it works , we need attrFixes when doing get/setAt tribute (i e6/7) | |
7675 | su pport.getS etAttribut e = div.cl assName != = "t"; | |
7676 | ||
7677 | // Get the s tyle infor mation fro m getAttri bute | |
7678 | // (IE uses .cssText i nstead) | |
7679 | su pport.styl e = /top/. test( a.ge tAttribute ("style") ); | |
7680 | ||
7681 | // Make sure that URLs aren't ma nipulated | |
7682 | // (IE norma lizes it b y default) | |
7683 | su pport.href Normalized = a.getAt tribute("h ref") === "/a"; | |
7684 | ||
7685 | // Check the default c heckbox/ra dio value ("" on Web Kit; "on" elsewhere) | |
7686 | su pport.chec kOn = !!in put.value; | |
7687 | ||
7688 | // Make sure that a se lected-by- default op tion has a working s elected pr operty. | |
7689 | // (WebKit d efaults to false ins tead of tr ue, IE too , if it's in an optg roup) | |
7690 | su pport.optS elected = opt.select ed; | |
7691 | ||
7692 | // Tests for enctype s upport on a form (#6 743) | |
7693 | su pport.enct ype = !!do cument.cre ateElement ("form").e nctype; | |
7694 | ||
7695 | // Make sure that the options in side disab led select s aren't m arked as d isabled | |
7696 | // (WebKit m arks them as disable d) | |
7697 | se lect.disab led = true ; | |
7698 | su pport.optD isabled = !opt.disab led; | |
7699 | ||
7700 | // Support: IE8 only | |
7701 | // Check if we can tru st getAttr ibute("val ue") | |
7702 | in put = docu ment.creat eElement( "input" ); | |
7703 | in put.setAtt ribute( "v alue", "" ); | |
7704 | su pport.inpu t = input. getAttribu te( "value " ) === "" ; | |
7705 | ||
7706 | // Check if an input m aintains i ts value a fter becom ing a radi o | |
7707 | in put.value = "t"; | |
7708 | in put.setAtt ribute( "t ype", "rad io" ); | |
7709 | su pport.radi oValue = i nput.value === "t"; | |
7710 | })(); | |
7711 | ||
7712 | ||
7713 | var rr eturn = /\ r/g; | |
7714 | ||
7715 | jQuery .fn.extend ({ | |
7716 | va l: functio n( value ) { | |
7717 | var hook s, ret, is Function, | |
7718 | elem = this[0] ; | |
7719 | ||
7720 | if ( !ar guments.le ngth ) { | |
7721 | if ( elem ) { | |
7722 | hooks = jQ uery.valHo oks[ elem. type ] || jQuery.val Hooks[ ele m.nodeName .toLowerCa se() ]; | |
7723 | ||
7724 | if ( hooks && "get" in hooks & & (ret = h ooks.get( elem, "val ue" )) !== undefined ) { | |
7725 | return ret; | |
7726 | } | |
7727 | ||
7728 | ret = elem .value; | |
7729 | ||
7730 | return typ eof ret == = "string" ? | |
7731 | // han dle most c ommon stri ng cases | |
7732 | ret.re place(rret urn, "") : | |
7733 | // han dle cases where valu e is null/ undef or n umber | |
7734 | re t == null ? "" : ret ; | |
7735 | } | |
7736 | ||
7737 | retu rn; | |
7738 | } | |
7739 | ||
7740 | isFuncti on = jQuer y.isFuncti on( value ); | |
7741 | ||
7742 | return t his.each(f unction( i ) { | |
7743 | var val; | |
7744 | ||
7745 | if ( this.node Type !== 1 ) { | |
7746 | return; | |
7747 | } | |
7748 | ||
7749 | if ( isFunctio n ) { | |
7750 | val = valu e.call( th is, i, jQu ery( this ).val() ); | |
7751 | } el se { | |
7752 | val = valu e; | |
7753 | } | |
7754 | ||
7755 | // T reat null/ undefined as ""; con vert numbe rs to stri ng | |
7756 | if ( val == nu ll ) { | |
7757 | val = ""; | |
7758 | } el se if ( ty peof val = == "number " ) { | |
7759 | val += ""; | |
7760 | } el se if ( jQ uery.isArr ay( val ) ) { | |
7761 | val = jQue ry.map( va l, functio n( value ) { | |
7762 | return value == null ? "" : value + ""; | |
7763 | }); | |
7764 | } | |
7765 | ||
7766 | hook s = jQuery .valHooks[ this.type ] || jQue ry.valHook s[ this.no deName.toL owerCase() ]; | |
7767 | ||
7768 | // I f set retu rns undefi ned, fall back to no rmal setti ng | |
7769 | if ( !hooks || !("set" i n hooks) | | hooks.se t( this, v al, "value " ) === un defined ) { | |
7770 | this.value = val; | |
7771 | } | |
7772 | }); | |
7773 | } | |
7774 | }); | |
7775 | ||
7776 | jQuery .extend({ | |
7777 | va lHooks: { | |
7778 | option: { | |
7779 | get: function( elem ) { | |
7780 | var val = jQuery.fin d.attr( el em, "value " ); | |
7781 | return val != null ? | |
7782 | val : | |
7783 | // Sup port: IE10 -11+ | |
7784 | // opt ion.text t hrows exce ptions (#1 4686, #148 58) | |
7785 | jQuery .trim( jQu ery.text( elem ) ); | |
7786 | } | |
7787 | }, | |
7788 | select: { | |
7789 | get: function( elem ) { | |
7790 | var value, option, | |
7791 | option s = elem.o ptions, | |
7792 | index = elem.sel ectedIndex , | |
7793 | one = elem.type === "selec t-one" || index < 0, | |
7794 | values = one ? n ull : [], | |
7795 | max = one ? inde x + 1 : op tions.leng th, | |
7796 | i = in dex < 0 ? | |
7797 | ma x : | |
7798 | on e ? index : 0; | |
7799 | ||
7800 | // Loop th rough all the select ed options | |
7801 | for ( ; i < max; i++ ) { | |
7802 | option = options [ i ]; | |
7803 | ||
7804 | // old IE doesn't update se lected aft er form re set (#2551 ) | |
7805 | if ( ( option.se lected || i === inde x ) && | |
7806 | // Don't ret urn option s that are disabled or in a di sabled opt group | |
7807 | ( support.op tDisabled ? !option. disabled : option.ge tAttribute ("disabled ") === nul l ) && | |
7808 | ( !option.pa rentNode.d isabled || !jQuery.n odeName( o ption.pare ntNode, "o ptgroup" ) ) ) { | |
7809 | ||
7810 | // Get the s pecific va lue for th e option | |
7811 | va lue = jQue ry( option ).val(); | |
7812 | ||
7813 | // We don't need an ar ray for on e selects | |
7814 | if ( one ) { | |
7815 | return v alue; | |
7816 | } | |
7817 | ||
7818 | // Multi-Sel ects retur n an array | |
7819 | va lues.push( value ); | |
7820 | } | |
7821 | } | |
7822 | ||
7823 | return val ues; | |
7824 | }, | |
7825 | ||
7826 | set: function( elem, val ue ) { | |
7827 | var option Set, optio n, | |
7828 | option s = elem.o ptions, | |
7829 | values = jQuery. makeArray( value ), | |
7830 | i = op tions.leng th; | |
7831 | ||
7832 | while ( i- - ) { | |
7833 | option = options [ i ]; | |
7834 | ||
7835 | if ( j Query.inAr ray( jQuer y.valHooks .option.ge t( option ), values ) >= 0 ) { | |
7836 | ||
7837 | // Support: IE6 | |
7838 | // When new option ele ment is ad ded to sel ect box we need to | |
7839 | // force ref low of new ly added n ode in ord er to work around del ay | |
7840 | // of initia lization p roperties | |
7841 | tr y { | |
7842 | option.s elected = optionSet = true; | |
7843 | ||
7844 | } catch ( _ ) { | |
7845 | ||
7846 | // Will be execute d only in IE6 | |
7847 | option.s crollHeigh t; | |
7848 | } | |
7849 | ||
7850 | } else { | |
7851 | op tion.selec ted = fals e; | |
7852 | } | |
7853 | } | |
7854 | ||
7855 | // Force b rowsers to behave co nsistently when non- matching v alue is se t | |
7856 | if ( !opti onSet ) { | |
7857 | elem.s electedInd ex = -1; | |
7858 | } | |
7859 | ||
7860 | return opt ions; | |
7861 | } | |
7862 | } | |
7863 | } | |
7864 | }); | |
7865 | ||
7866 | // Radios and checkb oxes gette r/setter | |
7867 | jQuery .each([ "r adio", "ch eckbox" ], function( ) { | |
7868 | jQ uery.valHo oks[ this ] = { | |
7869 | set: fun ction( ele m, value ) { | |
7870 | if ( jQuery.is Array( val ue ) ) { | |
7871 | return ( e lem.checke d = jQuery .inArray( jQuery(ele m).val(), value ) >= 0 ); | |
7872 | } | |
7873 | } | |
7874 | }; | |
7875 | if ( !suppor t.checkOn ) { | |
7876 | jQuery.v alHooks[ t his ].get = function ( elem ) { | |
7877 | // S upport: We bkit | |
7878 | // " " is retur ned instea d of "on" if a value isn't spe cified | |
7879 | retu rn elem.ge tAttribute ("value") === null ? "on" : el em.value; | |
7880 | }; | |
7881 | } | |
7882 | }); | |
7883 | ||
7884 | ||
7885 | ||
7886 | ||
7887 | var no deHook, bo olHook, | |
7888 | at trHandle = jQuery.ex pr.attrHan dle, | |
7889 | ru seDefault = /^(?:che cked|selec ted)$/i, | |
7890 | ge tSetAttrib ute = supp ort.getSet Attribute, | |
7891 | ge tSetInput = support. input; | |
7892 | ||
7893 | jQuery .fn.extend ({ | |
7894 | at tr: functi on( name, value ) { | |
7895 | return a ccess( thi s, jQuery. attr, name , value, a rguments.l ength > 1 ); | |
7896 | }, | |
7897 | ||
7898 | re moveAttr: function( name ) { | |
7899 | return t his.each(f unction() { | |
7900 | jQue ry.removeA ttr( this, name ); | |
7901 | }); | |
7902 | } | |
7903 | }); | |
7904 | ||
7905 | jQuery .extend({ | |
7906 | at tr: functi on( elem, name, valu e ) { | |
7907 | var hook s, ret, | |
7908 | nTyp e = elem.n odeType; | |
7909 | ||
7910 | // don't get/set a ttributes on text, c omment and attribute nodes | |
7911 | if ( !el em || nTyp e === 3 || nType === 8 || nTyp e === 2 ) { | |
7912 | retu rn; | |
7913 | } | |
7914 | ||
7915 | // Fallb ack to pro p when att ributes ar e not supp orted | |
7916 | if ( typ eof elem.g etAttribut e === stru ndefined ) { | |
7917 | retu rn jQuery. prop( elem , name, va lue ); | |
7918 | } | |
7919 | ||
7920 | // All a ttributes are lowerc ase | |
7921 | // Grab necessary hook if on e is defin ed | |
7922 | if ( nTy pe !== 1 | | !jQuery. isXMLDoc( elem ) ) { | |
7923 | name = name.to LowerCase( ); | |
7924 | hook s = jQuery .attrHooks [ name ] | | | |
7925 | ( jQuery.e xpr.match. bool.test( name ) ? boolHook : nodeHook ); | |
7926 | } | |
7927 | ||
7928 | if ( val ue !== und efined ) { | |
7929 | ||
7930 | if ( value === null ) { | |
7931 | jQuery.rem oveAttr( e lem, name ); | |
7932 | ||
7933 | } el se if ( ho oks && "se t" in hook s && (ret = hooks.se t( elem, v alue, name )) !== un defined ) { | |
7934 | return ret ; | |
7935 | ||
7936 | } el se { | |
7937 | elem.setAt tribute( n ame, value + "" ); | |
7938 | return val ue; | |
7939 | } | |
7940 | ||
7941 | } else i f ( hooks && "get" i n hooks && (ret = ho oks.get( e lem, name )) !== nul l ) { | |
7942 | retu rn ret; | |
7943 | ||
7944 | } else { | |
7945 | ret = jQuery.f ind.attr( elem, name ); | |
7946 | ||
7947 | // N on-existen t attribut es return null, we n ormalize t o undefine d | |
7948 | retu rn ret == null ? | |
7949 | undefined : | |
7950 | ret; | |
7951 | } | |
7952 | }, | |
7953 | ||
7954 | re moveAttr: function( elem, valu e ) { | |
7955 | var name , propName , | |
7956 | i = 0, | |
7957 | attr Names = va lue && val ue.match( rnotwhite ); | |
7958 | ||
7959 | if ( att rNames && elem.nodeT ype === 1 ) { | |
7960 | whil e ( (name = attrName s[i++]) ) { | |
7961 | propName = jQuery.pr opFix[ nam e ] || nam e; | |
7962 | ||
7963 | // Boolean attribute s get spec ial treatm ent (#1087 0) | |
7964 | if ( jQuer y.expr.mat ch.bool.te st( name ) ) { | |
7965 | // Set correspon ding prope rty to fal se | |
7966 | if ( g etSetInput && getSet Attribute || !ruseDe fault.test ( name ) ) { | |
7967 | el em[ propNa me ] = fal se; | |
7968 | // Support: IE<9 | |
7969 | // Also clea r defaultC hecked/def aultSelect ed (if app ropriate) | |
7970 | } else { | |
7971 | el em[ jQuery .camelCase ( "default -" + name ) ] = | |
7972 | elem[ pr opName ] = false; | |
7973 | } | |
7974 | ||
7975 | // See #9699 for explanati on of this approach (setting f irst, then removal) | |
7976 | } else { | |
7977 | jQuery .attr( ele m, name, " " ); | |
7978 | } | |
7979 | ||
7980 | elem.remov eAttribute ( getSetAt tribute ? name : pro pName ); | |
7981 | } | |
7982 | } | |
7983 | }, | |
7984 | ||
7985 | at trHooks: { | |
7986 | type: { | |
7987 | set: function( elem, val ue ) { | |
7988 | if ( !supp ort.radioV alue && va lue === "r adio" && j Query.node Name(elem, "input") ) { | |
7989 | // Set ting the t ype on a r adio butto n after th e value re sets the v alue in IE 6-9 | |
7990 | // Res et value t o default in case ty pe is set after valu e during c reation | |
7991 | var va l = elem.v alue; | |
7992 | elem.s etAttribut e( "type", value ); | |
7993 | if ( v al ) { | |
7994 | el em.value = val; | |
7995 | } | |
7996 | return value; | |
7997 | } | |
7998 | } | |
7999 | } | |
8000 | } | |
8001 | }); | |
8002 | ||
8003 | // Hook fo r boolean attributes | |
8004 | boolHo ok = { | |
8005 | se t: functio n( elem, v alue, name ) { | |
8006 | if ( val ue === fal se ) { | |
8007 | // R emove bool ean attrib utes when set to fal se | |
8008 | jQue ry.removeA ttr( elem, name ); | |
8009 | } else i f ( getSet Input && g etSetAttri bute || !r useDefault .test( nam e ) ) { | |
8010 | // I E<8 needs the *prope rty* name | |
8011 | elem .setAttrib ute( !getS etAttribut e && jQuer y.propFix[ name ] || name, nam e ); | |
8012 | ||
8013 | // U se default Checked an d defaultS elected fo r oldIE | |
8014 | } else { | |
8015 | elem [ jQuery.c amelCase( "default-" + name ) ] = elem[ name ] = t rue; | |
8016 | } | |
8017 | ||
8018 | return n ame; | |
8019 | } | |
8020 | }; | |
8021 | ||
8022 | // Retriev e booleans specially | |
8023 | jQuery .each( jQu ery.expr.m atch.bool. source.mat ch( /\w+/g ), functi on( i, nam e ) { | |
8024 | ||
8025 | va r getter = attrHandl e[ name ] || jQuery. find.attr; | |
8026 | ||
8027 | at trHandle[ name ] = g etSetInput && getSet Attribute || !ruseDe fault.test ( name ) ? | |
8028 | function ( elem, na me, isXML ) { | |
8029 | var ret, handl e; | |
8030 | if ( !isXML ) { | |
8031 | // Avoid a n infinite loop by t emporarily removing this funct ion from t he getter | |
8032 | handle = a ttrHandle[ name ]; | |
8033 | attrHandle [ name ] = ret; | |
8034 | ret = gett er( elem, name, isXM L ) != nul l ? | |
8035 | name.t oLowerCase () : | |
8036 | null; | |
8037 | attrHandle [ name ] = handle; | |
8038 | } | |
8039 | retu rn ret; | |
8040 | } : | |
8041 | function ( elem, na me, isXML ) { | |
8042 | if ( !isXML ) { | |
8043 | return ele m[ jQuery. camelCase( "default- " + name ) ] ? | |
8044 | name.t oLowerCase () : | |
8045 | null; | |
8046 | } | |
8047 | }; | |
8048 | }); | |
8049 | ||
8050 | // fix old IE attrope rties | |
8051 | if ( ! getSetInpu t || !getS etAttribut e ) { | |
8052 | jQ uery.attrH ooks.value = { | |
8053 | set: fun ction( ele m, value, name ) { | |
8054 | if ( jQuery.no deName( el em, "input " ) ) { | |
8055 | // Does no t return s o that set Attribute is also us ed | |
8056 | elem.defau ltValue = value; | |
8057 | } el se { | |
8058 | // Use nod eHook if d efined (#1 954); othe rwise setA ttribute i s fine | |
8059 | return nod eHook && n odeHook.se t( elem, v alue, name ); | |
8060 | } | |
8061 | } | |
8062 | }; | |
8063 | } | |
8064 | ||
8065 | // IE6/7 d o not supp ort gettin g/setting some attri butes with get/setAt tribute | |
8066 | if ( ! getSetAttr ibute ) { | |
8067 | ||
8068 | // Use this for any at tribute in IE6/7 | |
8069 | // This fixe s almost e very IE6/7 issue | |
8070 | no deHook = { | |
8071 | set: fun ction( ele m, value, name ) { | |
8072 | // S et the exi sting or c reate a ne w attribut e node | |
8073 | var ret = elem .getAttrib uteNode( n ame ); | |
8074 | if ( !ret ) { | |
8075 | elem.setAt tributeNod e( | |
8076 | (ret = elem.owne rDocument. createAttr ibute( nam e )) | |
8077 | ); | |
8078 | } | |
8079 | ||
8080 | ret. value = va lue += ""; | |
8081 | ||
8082 | // B reak assoc iation wit h cloned e lements by also usin g setAttri bute (#964 6) | |
8083 | if ( name === "value" || value === elem.getA ttribute( name ) ) { | |
8084 | return val ue; | |
8085 | } | |
8086 | } | |
8087 | }; | |
8088 | ||
8089 | // Some attr ibutes are construct ed with em pty-string values wh en not def ined | |
8090 | at trHandle.i d = attrHa ndle.name = attrHand le.coords = | |
8091 | function ( elem, na me, isXML ) { | |
8092 | var ret; | |
8093 | if ( !isXML ) { | |
8094 | return (re t = elem.g etAttribut eNode( nam e )) && re t.value != = "" ? | |
8095 | ret.va lue : | |
8096 | null; | |
8097 | } | |
8098 | }; | |
8099 | ||
8100 | // Fixing va lue retrie val on a b utton requ ires this module | |
8101 | jQ uery.valHo oks.button = { | |
8102 | get: fun ction( ele m, name ) { | |
8103 | var ret = elem .getAttrib uteNode( n ame ); | |
8104 | if ( ret && re t.specifie d ) { | |
8105 | return ret .value; | |
8106 | } | |
8107 | }, | |
8108 | set: nod eHook.set | |
8109 | }; | |
8110 | ||
8111 | // Set conte nteditable to false on removal s(#10429) | |
8112 | // Setting t o empty st ring throw s an error as an inv alid value | |
8113 | jQ uery.attrH ooks.conte nteditable = { | |
8114 | set: fun ction( ele m, value, name ) { | |
8115 | node Hook.set( elem, valu e === "" ? false : v alue, name ); | |
8116 | } | |
8117 | }; | |
8118 | ||
8119 | // Set width and heigh t to auto instead of 0 on empt y string( Bug #8150 ) | |
8120 | // This is f or removal s | |
8121 | jQ uery.each( [ "width", "height" ], functio n( i, name ) { | |
8122 | jQuery.a ttrHooks[ name ] = { | |
8123 | set: function( elem, val ue ) { | |
8124 | if ( value === "" ) { | |
8125 | elem.s etAttribut e( name, " auto" ); | |
8126 | return value; | |
8127 | } | |
8128 | } | |
8129 | }; | |
8130 | }) ; | |
8131 | } | |
8132 | ||
8133 | if ( ! support.st yle ) { | |
8134 | jQ uery.attrH ooks.style = { | |
8135 | get: fun ction( ele m ) { | |
8136 | // R eturn unde fined in t he case of empty str ing | |
8137 | // N ote: IE up percases c ss propert y names, b ut if we w ere to .to LowerCase( ) | |
8138 | // . cssText, t hat would destroy ca se senstit ivity in U RL's, like in "backg round" | |
8139 | retu rn elem.st yle.cssTex t || undef ined; | |
8140 | }, | |
8141 | set: fun ction( ele m, value ) { | |
8142 | retu rn ( elem. style.cssT ext = valu e + "" ); | |
8143 | } | |
8144 | }; | |
8145 | } | |
8146 | ||
8147 | ||
8148 | ||
8149 | ||
8150 | var rf ocusable = /^(?:inpu t|select|t extarea|bu tton|objec t)$/i, | |
8151 | rc lickable = /^(?:a|ar ea)$/i; | |
8152 | ||
8153 | jQuery .fn.extend ({ | |
8154 | pr op: functi on( name, value ) { | |
8155 | return a ccess( thi s, jQuery. prop, name , value, a rguments.l ength > 1 ); | |
8156 | }, | |
8157 | ||
8158 | re moveProp: function( name ) { | |
8159 | name = j Query.prop Fix[ name ] || name; | |
8160 | return t his.each(f unction() { | |
8161 | // t ry/catch h andles cas es where I E balks (s uch as rem oving a pr operty on window) | |
8162 | try { | |
8163 | this[ name ] = undef ined; | |
8164 | delete thi s[ name ]; | |
8165 | } ca tch( e ) { } | |
8166 | }); | |
8167 | } | |
8168 | }); | |
8169 | ||
8170 | jQuery .extend({ | |
8171 | pr opFix: { | |
8172 | "for": " htmlFor", | |
8173 | "class": "classNam e" | |
8174 | }, | |
8175 | ||
8176 | pr op: functi on( elem, name, valu e ) { | |
8177 | var ret, hooks, no txml, | |
8178 | nTyp e = elem.n odeType; | |
8179 | ||
8180 | // don't get/set p roperties on text, c omment and attribute nodes | |
8181 | if ( !el em || nTyp e === 3 || nType === 8 || nTyp e === 2 ) { | |
8182 | retu rn; | |
8183 | } | |
8184 | ||
8185 | notxml = nType !== 1 || !jQu ery.isXMLD oc( elem ) ; | |
8186 | ||
8187 | if ( not xml ) { | |
8188 | // F ix name an d attach h ooks | |
8189 | name = jQuery. propFix[ n ame ] || n ame; | |
8190 | hook s = jQuery .propHooks [ name ]; | |
8191 | } | |
8192 | ||
8193 | if ( val ue !== und efined ) { | |
8194 | retu rn hooks & & "set" in hooks && (ret = hoo ks.set( el em, value, name )) ! == undefin ed ? | |
8195 | ret : | |
8196 | ( elem[ na me ] = val ue ); | |
8197 | ||
8198 | } else { | |
8199 | retu rn hooks & & "get" in hooks && (ret = hoo ks.get( el em, name ) ) !== null ? | |
8200 | ret : | |
8201 | elem[ name ]; | |
8202 | } | |
8203 | }, | |
8204 | ||
8205 | pr opHooks: { | |
8206 | tabIndex : { | |
8207 | get: function( elem ) { | |
8208 | // elem.ta bIndex doe sn't alway s return t he correct value whe n it hasn' t been exp licitly se t | |
8209 | // http:// fluidproje ct.org/blo g/2008/01/ 09/getting -setting-a nd-removin g-tabindex -values-wi th-javascr ipt/ | |
8210 | // Use pro per attrib ute retrie val(#12072 ) | |
8211 | var tabind ex = jQuer y.find.att r( elem, " tabindex" ); | |
8212 | ||
8213 | return tab index ? | |
8214 | parseI nt( tabind ex, 10 ) : | |
8215 | rf ocusable.t est( elem. nodeName ) || rclick able.test( elem.node Name ) && elem.href ? | |
8216 | 0 : | |
8217 | -1; | |
8218 | } | |
8219 | } | |
8220 | } | |
8221 | }); | |
8222 | ||
8223 | // Some at tributes r equire a s pecial cal l on IE | |
8224 | // http:// msdn.micro soft.com/e n-us/libra ry/ms53642 9%28VS.85% 29.aspx | |
8225 | if ( ! support.hr efNormaliz ed ) { | |
8226 | // href/src property s hould get the full n ormalized URL (#1029 9/#12915) | |
8227 | jQ uery.each( [ "href", "src" ], f unction( i , name ) { | |
8228 | jQuery.p ropHooks[ name ] = { | |
8229 | get: function( elem ) { | |
8230 | return ele m.getAttri bute( name , 4 ); | |
8231 | } | |
8232 | }; | |
8233 | }) ; | |
8234 | } | |
8235 | ||
8236 | // Support : Safari, IE9+ | |
8237 | // mis-rep orts the d efault sel ected prop erty of an option | |
8238 | // Accessi ng the par ent's sele ctedIndex property f ixes it | |
8239 | if ( ! support.op tSelected ) { | |
8240 | jQ uery.propH ooks.selec ted = { | |
8241 | get: fun ction( ele m ) { | |
8242 | var parent = e lem.parent Node; | |
8243 | ||
8244 | if ( parent ) { | |
8245 | parent.sel ectedIndex ; | |
8246 | ||
8247 | // Make su re that it also work s with opt groups, se e #5701 | |
8248 | if ( paren t.parentNo de ) { | |
8249 | parent .parentNod e.selected Index; | |
8250 | } | |
8251 | } | |
8252 | retu rn null; | |
8253 | } | |
8254 | }; | |
8255 | } | |
8256 | ||
8257 | jQuery .each([ | |
8258 | "t abIndex", | |
8259 | "r eadOnly", | |
8260 | "m axLength", | |
8261 | "c ellSpacing ", | |
8262 | "c ellPadding ", | |
8263 | "r owSpan", | |
8264 | "c olSpan", | |
8265 | "u seMap", | |
8266 | "f rameBorder ", | |
8267 | "c ontentEdit able" | |
8268 | ], fun ction() { | |
8269 | jQ uery.propF ix[ this.t oLowerCase () ] = thi s; | |
8270 | }); | |
8271 | ||
8272 | // IE6/7 c all enctyp e encoding | |
8273 | if ( ! support.en ctype ) { | |
8274 | jQ uery.propF ix.enctype = "encodi ng"; | |
8275 | } | |
8276 | ||
8277 | ||
8278 | ||
8279 | ||
8280 | var rc lass = /[\ t\r\n\f]/g ; | |
8281 | ||
8282 | jQuery .fn.extend ({ | |
8283 | ad dClass: fu nction( va lue ) { | |
8284 | var clas ses, elem, cur, claz z, j, fina lValue, | |
8285 | i = 0, | |
8286 | len = this.len gth, | |
8287 | proc eed = type of value = == "string " && value ; | |
8288 | ||
8289 | if ( jQu ery.isFunc tion( valu e ) ) { | |
8290 | retu rn this.ea ch(functio n( j ) { | |
8291 | jQuery( th is ).addCl ass( value .call( thi s, j, this .className ) ); | |
8292 | }); | |
8293 | } | |
8294 | ||
8295 | if ( pro ceed ) { | |
8296 | // T he disjunc tion here is for bet ter compre ssibility (see remov eClass) | |
8297 | clas ses = ( va lue || "" ).match( r notwhite ) || []; | |
8298 | ||
8299 | for ( ; i < le n; i++ ) { | |
8300 | elem = thi s[ i ]; | |
8301 | cur = elem .nodeType === 1 && ( elem.clas sName ? | |
8302 | ( " " + elem.cla ssName + " " ).repla ce( rclass , " " ) : | |
8303 | " " | |
8304 | ); | |
8305 | ||
8306 | if ( cur ) { | |
8307 | j = 0; | |
8308 | while ( (clazz = classes[j ++]) ) { | |
8309 | if ( cur.ind exOf( " " + clazz + " " ) < 0 ) { | |
8310 | cur += c lazz + " " ; | |
8311 | } | |
8312 | } | |
8313 | ||
8314 | // onl y assign i f differen t to avoid unneeded rendering. | |
8315 | finalV alue = jQu ery.trim( cur ); | |
8316 | if ( e lem.classN ame !== fi nalValue ) { | |
8317 | el em.classNa me = final Value; | |
8318 | } | |
8319 | } | |
8320 | } | |
8321 | } | |
8322 | ||
8323 | return t his; | |
8324 | }, | |
8325 | ||
8326 | re moveClass: function( value ) { | |
8327 | var clas ses, elem, cur, claz z, j, fina lValue, | |
8328 | i = 0, | |
8329 | len = this.len gth, | |
8330 | proc eed = argu ments.leng th === 0 | | typeof v alue === " string" && value; | |
8331 | ||
8332 | if ( jQu ery.isFunc tion( valu e ) ) { | |
8333 | retu rn this.ea ch(functio n( j ) { | |
8334 | jQuery( th is ).remov eClass( va lue.call( this, j, t his.classN ame ) ); | |
8335 | }); | |
8336 | } | |
8337 | if ( pro ceed ) { | |
8338 | clas ses = ( va lue || "" ).match( r notwhite ) || []; | |
8339 | ||
8340 | for ( ; i < le n; i++ ) { | |
8341 | elem = thi s[ i ]; | |
8342 | // This ex pression i s here for better co mpressibil ity (see a ddClass) | |
8343 | cur = elem .nodeType === 1 && ( elem.clas sName ? | |
8344 | ( " " + elem.cla ssName + " " ).repla ce( rclass , " " ) : | |
8345 | "" | |
8346 | ); | |
8347 | ||
8348 | if ( cur ) { | |
8349 | j = 0; | |
8350 | while ( (clazz = classes[j ++]) ) { | |
8351 | // Remove *a ll* instan ces | |
8352 | wh ile ( cur. indexOf( " " + clazz + " " ) > = 0 ) { | |
8353 | cur = cu r.replace( " " + cla zz + " ", " " ); | |
8354 | } | |
8355 | } | |
8356 | ||
8357 | // onl y assign i f differen t to avoid unneeded rendering. | |
8358 | finalV alue = val ue ? jQuer y.trim( cu r ) : ""; | |
8359 | if ( e lem.classN ame !== fi nalValue ) { | |
8360 | el em.classNa me = final Value; | |
8361 | } | |
8362 | } | |
8363 | } | |
8364 | } | |
8365 | ||
8366 | return t his; | |
8367 | }, | |
8368 | ||
8369 | to ggleClass: function( value, st ateVal ) { | |
8370 | var type = typeof value; | |
8371 | ||
8372 | if ( typ eof stateV al === "bo olean" && type === " string" ) { | |
8373 | retu rn stateVa l ? this.a ddClass( v alue ) : t his.remove Class( val ue ); | |
8374 | } | |
8375 | ||
8376 | if ( jQu ery.isFunc tion( valu e ) ) { | |
8377 | retu rn this.ea ch(functio n( i ) { | |
8378 | jQuery( th is ).toggl eClass( va lue.call(t his, i, th is.classNa me, stateV al), state Val ); | |
8379 | }); | |
8380 | } | |
8381 | ||
8382 | return t his.each(f unction() { | |
8383 | if ( type === "string" ) { | |
8384 | // toggle individual class nam es | |
8385 | var classN ame, | |
8386 | i = 0, | |
8387 | self = jQuery( t his ), | |
8388 | classN ames = val ue.match( rnotwhite ) || []; | |
8389 | ||
8390 | while ( (c lassName = className s[ i++ ]) ) { | |
8391 | // che ck each cl assName gi ven, space separated list | |
8392 | if ( s elf.hasCla ss( classN ame ) ) { | |
8393 | se lf.removeC lass( clas sName ); | |
8394 | } else { | |
8395 | se lf.addClas s( classNa me ); | |
8396 | } | |
8397 | } | |
8398 | ||
8399 | // Toggle whole clas s name | |
8400 | } el se if ( ty pe === str undefined || type == = "boolean " ) { | |
8401 | if ( this. className ) { | |
8402 | // sto re classNa me if set | |
8403 | jQuery ._data( th is, "__cla ssName__", this.clas sName ); | |
8404 | } | |
8405 | ||
8406 | // If the element ha s a class name or if we're pas sed "false ", | |
8407 | // then re move the w hole class name (if t here was o ne, the ab ove saved it). | |
8408 | // Otherwi se bring b ack whatev er was pre viously sa ved (if an ything), | |
8409 | // falling back to t he empty s tring if n othing was stored. | |
8410 | this.class Name = thi s.classNam e || value === false ? "" : jQ uery._data ( this, "_ _className __" ) || " "; | |
8411 | } | |
8412 | }); | |
8413 | }, | |
8414 | ||
8415 | ha sClass: fu nction( se lector ) { | |
8416 | var clas sName = " " + select or + " ", | |
8417 | i = 0, | |
8418 | l = this.lengt h; | |
8419 | for ( ; i < l; i++ ) { | |
8420 | if ( this[i].n odeType == = 1 && (" " + this[i ].classNam e + " ").r eplace(rcl ass, " "). indexOf( c lassName ) >= 0 ) { | |
8421 | return tru e; | |
8422 | } | |
8423 | } | |
8424 | ||
8425 | return f alse; | |
8426 | } | |
8427 | }); | |
8428 | ||
8429 | ||
8430 | ||
8431 | ||
8432 | // Return jQuery for attribute s-only inc lusion | |
8433 | ||
8434 | ||
8435 | jQuery .each( ("b lur focus focusin fo cusout loa d resize s croll unlo ad click d blclick " + | |
8436 | "m ousedown m ouseup mou semove mou seover mou seout mous eenter mou seleave " + | |
8437 | "c hange sele ct submit keydown ke ypress key up error c ontextmenu ").split(" "), funct ion( i, na me ) { | |
8438 | ||
8439 | // Handle ev ent bindin g | |
8440 | jQ uery.fn[ n ame ] = fu nction( da ta, fn ) { | |
8441 | return a rguments.l ength > 0 ? | |
8442 | this .on( name, null, dat a, fn ) : | |
8443 | this .trigger( name ); | |
8444 | }; | |
8445 | }); | |
8446 | ||
8447 | jQuery .fn.extend ({ | |
8448 | ho ver: funct ion( fnOve r, fnOut ) { | |
8449 | return t his.mousee nter( fnOv er ).mouse leave( fnO ut || fnOv er ); | |
8450 | }, | |
8451 | ||
8452 | bi nd: functi on( types, data, fn ) { | |
8453 | return t his.on( ty pes, null, data, fn ); | |
8454 | }, | |
8455 | un bind: func tion( type s, fn ) { | |
8456 | return t his.off( t ypes, null , fn ); | |
8457 | }, | |
8458 | ||
8459 | de legate: fu nction( se lector, ty pes, data, fn ) { | |
8460 | return t his.on( ty pes, selec tor, data, fn ); | |
8461 | }, | |
8462 | un delegate: function( selector, types, fn ) { | |
8463 | // ( nam espace ) o r ( select or, types [, fn] ) | |
8464 | return a rguments.l ength === 1 ? this.o ff( select or, "**" ) : this.of f( types, selector | | "**", fn ); | |
8465 | } | |
8466 | }); | |
8467 | ||
8468 | ||
8469 | var no nce = jQue ry.now(); | |
8470 | ||
8471 | var rq uery = (/\ ?/); | |
8472 | ||
8473 | ||
8474 | ||
8475 | var rv alidtokens = /(,)|(\ [|{)|(}|]) |"(?:[^"\\ \r\n]|\\[" \\\/bfnrt] |\\u[\da-f A-F]{4})*" \s*:?|true |false|nul l|-?(?!0\d )\d+(?:\.\ d+|)(?:[eE ][+-]?\d+| )/g; | |
8476 | ||
8477 | jQuery .parseJSON = functio n( data ) { | |
8478 | // Attempt t o parse us ing the na tive JSON parser fir st | |
8479 | if ( window. JSON && wi ndow.JSON. parse ) { | |
8480 | // Suppo rt: Androi d 2.3 | |
8481 | // Worka round fail ure to str ing-cast n ull input | |
8482 | return w indow.JSON .parse( da ta + "" ); | |
8483 | } | |
8484 | ||
8485 | va r requireN onComma, | |
8486 | depth = null, | |
8487 | str = jQ uery.trim( data + "" ); | |
8488 | ||
8489 | // Guard aga inst inval id (and po ssibly dan gerous) in put by ens uring that nothing r emains | |
8490 | // after rem oving vali d tokens | |
8491 | re turn str & & !jQuery. trim( str. replace( r validtoken s, functio n( token, comma, ope n, close ) { | |
8492 | ||
8493 | // Force terminati on if we s ee a mispl aced comma | |
8494 | if ( req uireNonCom ma && comm a ) { | |
8495 | dept h = 0; | |
8496 | } | |
8497 | ||
8498 | // Perfo rm no more replaceme nts after returning to outermo st depth | |
8499 | if ( dep th === 0 ) { | |
8500 | retu rn token; | |
8501 | } | |
8502 | ||
8503 | // Comma s must not follow "[ ", "{", or "," | |
8504 | requireN onComma = open || co mma; | |
8505 | ||
8506 | // Deter mine new d epth | |
8507 | // array /object op en ("[" or "{"): dep th += true - false ( increment) | |
8508 | // array /object cl ose ("]" o r "}"): de pth += fal se - true (decrement ) | |
8509 | // other cases (", " or primi tive): dep th += true - true (n umeric cas t) | |
8510 | depth += !close - !open; | |
8511 | ||
8512 | // Remov e this tok en | |
8513 | return " "; | |
8514 | }) ) ? | |
8515 | ( Functi on( "retur n " + str ) )() : | |
8516 | jQuery.e rror( "Inv alid JSON: " + data ); | |
8517 | }; | |
8518 | ||
8519 | ||
8520 | // Cross-b rowser xml parsing | |
8521 | jQuery .parseXML = function ( data ) { | |
8522 | va r xml, tmp ; | |
8523 | if ( !data | | typeof d ata !== "s tring" ) { | |
8524 | return n ull; | |
8525 | } | |
8526 | tr y { | |
8527 | if ( win dow.DOMPar ser ) { // Standard | |
8528 | tmp = new DOMP arser(); | |
8529 | xml = tmp.pars eFromStrin g( data, " text/xml" ); | |
8530 | } else { // IE | |
8531 | xml = new Acti veXObject( "Microsof t.XMLDOM" ); | |
8532 | xml. async = "f alse"; | |
8533 | xml. loadXML( d ata ); | |
8534 | } | |
8535 | } catch( e ) { | |
8536 | xml = un defined; | |
8537 | } | |
8538 | if ( !xml || !xml.docu mentElemen t || xml.g etElements ByTagName( "parserer ror" ).len gth ) { | |
8539 | jQuery.e rror( "Inv alid XML: " + data ) ; | |
8540 | } | |
8541 | re turn xml; | |
8542 | }; | |
8543 | ||
8544 | ||
8545 | var | |
8546 | // Doc ument loca tion | |
8547 | aj axLocParts , | |
8548 | aj axLocation , | |
8549 | ||
8550 | rh ash = /#.* $/, | |
8551 | rt s = /([?&] )_=[^&]*/, | |
8552 | rh eaders = / ^(.*?):[ \ t]*([^\r\n ]*)\r?$/mg , // IE le aves an \r character at EOL | |
8553 | // #76 53, #8125, #8152: lo cal protoc ol detecti on | |
8554 | rl ocalProtoc ol = /^(?: about|app| app-storag e|.+-exten sion|file| res|widget ):$/, | |
8555 | rn oContent = /^(?:GET| HEAD)$/, | |
8556 | rp rotocol = /^\/\//, | |
8557 | ru rl = /^([\ w.+-]+:)(? :\/\/(?:[^ \/?#]*@|)( [^\/?#:]*) (?::(\d+)| )|)/, | |
8558 | ||
8559 | /* Pre filters | |
8560 | * 1) They are u seful to i ntroduce c ustom data Types (see ajax/json p.vendor f or an exam ple) | |
8561 | * 2) These are called: | |
8562 | * - BEFORE a sking for a transpor t | |
8563 | * - AFTER pa ram serial ization (s .data is a string if s.process Data is tr ue) | |
8564 | * 3) key is the dataType | |
8565 | * 4) the catcha ll symbol "*" can be used | |
8566 | * 5) execution will start with tran sport data Type and T HEN contin ue down to "*" if ne eded | |
8567 | */ | |
8568 | pr efilters = {}, | |
8569 | ||
8570 | /* Tra nsports bi ndings | |
8571 | * 1) key is the dataType | |
8572 | * 2) the catcha ll symbol "*" can be used | |
8573 | * 3) selection will start with tran sport data Type and T HEN go to "*" if nee ded | |
8574 | */ | |
8575 | tr ansports = {}, | |
8576 | ||
8577 | // Avo id comment -prolog ch ar sequenc e (#10098) ; must app ease lint and evade compressio n | |
8578 | al lTypes = " */".concat ("*"); | |
8579 | ||
8580 | // #8138, IE may thr ow an exce ption when accessing | |
8581 | // a field from wind ow.locatio n if docum ent.domain has been set | |
8582 | try { | |
8583 | aj axLocation = locatio n.href; | |
8584 | } catc h( e ) { | |
8585 | // Use the h ref attrib ute of an A element | |
8586 | // since IE will modif y it given document. location | |
8587 | aj axLocation = documen t.createEl ement( "a" ); | |
8588 | aj axLocation .href = "" ; | |
8589 | aj axLocation = ajaxLoc ation.href ; | |
8590 | } | |
8591 | ||
8592 | // Segment location into parts | |
8593 | ajaxLo cParts = r url.exec( ajaxLocati on.toLower Case() ) | | []; | |
8594 | ||
8595 | // Base "c onstructor " for jQue ry.ajaxPre filter and jQuery.aj axTranspor t | |
8596 | functi on addToPr efiltersOr Transports ( structur e ) { | |
8597 | ||
8598 | // dataTypeE xpression is optiona l and defa ults to "* " | |
8599 | re turn funct ion( dataT ypeExpress ion, func ) { | |
8600 | ||
8601 | if ( typ eof dataTy peExpressi on !== "st ring" ) { | |
8602 | func = dataTyp eExpressio n; | |
8603 | data TypeExpres sion = "*" ; | |
8604 | } | |
8605 | ||
8606 | var data Type, | |
8607 | i = 0, | |
8608 | data Types = da taTypeExpr ession.toL owerCase() .match( rn otwhite ) || []; | |
8609 | ||
8610 | if ( jQu ery.isFunc tion( func ) ) { | |
8611 | // F or each da taType in the dataTy peExpressi on | |
8612 | whil e ( (dataT ype = data Types[i++] ) ) { | |
8613 | // Prepend if reques ted | |
8614 | if ( dataT ype.charAt ( 0 ) === "+" ) { | |
8615 | dataTy pe = dataT ype.slice( 1 ) || "* "; | |
8616 | (struc ture[ data Type ] = s tructure[ dataType ] || []).un shift( fun c ); | |
8617 | ||
8618 | // Oth erwise app end | |
8619 | } else { | |
8620 | (struc ture[ data Type ] = s tructure[ dataType ] || []).pu sh( func ) ; | |
8621 | } | |
8622 | } | |
8623 | } | |
8624 | }; | |
8625 | } | |
8626 | ||
8627 | // Base in spection f unction fo r prefilte rs and tra nsports | |
8628 | functi on inspect Prefilters OrTranspor ts( struct ure, optio ns, origin alOptions, jqXHR ) { | |
8629 | ||
8630 | va r inspecte d = {}, | |
8631 | seekingT ransport = ( structu re === tra nsports ); | |
8632 | ||
8633 | fu nction ins pect( data Type ) { | |
8634 | var sele cted; | |
8635 | inspecte d[ dataTyp e ] = true ; | |
8636 | jQuery.e ach( struc ture[ data Type ] || [], functi on( _, pre filterOrFa ctory ) { | |
8637 | var dataTypeOr Transport = prefilte rOrFactory ( options, originalO ptions, jq XHR ); | |
8638 | if ( typeof da taTypeOrTr ansport == = "string" && !seeki ngTranspor t && !insp ected[ dat aTypeOrTra nsport ] ) { | |
8639 | options.da taTypes.un shift( dat aTypeOrTra nsport ); | |
8640 | inspect( d ataTypeOrT ransport ) ; | |
8641 | return fal se; | |
8642 | } el se if ( se ekingTrans port ) { | |
8643 | return !( selected = dataTypeO rTransport ); | |
8644 | } | |
8645 | }); | |
8646 | return s elected; | |
8647 | } | |
8648 | ||
8649 | re turn inspe ct( option s.dataType s[ 0 ] ) | | !inspect ed[ "*" ] && inspect ( "*" ); | |
8650 | } | |
8651 | ||
8652 | // A speci al extend for ajax o ptions | |
8653 | // that ta kes "flat" options ( not to be deep exten ded) | |
8654 | // Fixes # 9887 | |
8655 | functi on ajaxExt end( targe t, src ) { | |
8656 | va r deep, ke y, | |
8657 | flatOpti ons = jQue ry.ajaxSet tings.flat Options || {}; | |
8658 | ||
8659 | fo r ( key in src ) { | |
8660 | if ( src [ key ] != = undefine d ) { | |
8661 | ( fl atOptions[ key ] ? t arget : ( deep || (d eep = {}) ) )[ key ] = src[ ke y ]; | |
8662 | } | |
8663 | } | |
8664 | if ( deep ) { | |
8665 | jQuery.e xtend( tru e, target, deep ); | |
8666 | } | |
8667 | ||
8668 | re turn targe t; | |
8669 | } | |
8670 | ||
8671 | /* Han dles respo nses to an ajax requ est: | |
8672 | * - f inds the r ight dataT ype (media tes betwee n resource s-type and expected dataType) | |
8673 | * - r eturns the correspon ding respo nse | |
8674 | */ | |
8675 | functi on ajaxHan dleRespons es( s, jqX HR, respon ses ) { | |
8676 | va r firstDat aType, ct, finalData Type, type , | |
8677 | contents = s.conte nts, | |
8678 | dataType s = s.data Types; | |
8679 | ||
8680 | // Remove au to dataTyp e and get resources- type in th e process | |
8681 | wh ile ( data Types[ 0 ] === "*" ) { | |
8682 | dataType s.shift(); | |
8683 | if ( ct === undefi ned ) { | |
8684 | ct = s.mimeTyp e || jqXHR .getRespon seHeader(" Content-Ty pe"); | |
8685 | } | |
8686 | } | |
8687 | ||
8688 | // Check if we're deal ing with a known res ources-typ e | |
8689 | if ( ct ) { | |
8690 | for ( ty pe in cont ents ) { | |
8691 | if ( contents[ type ] && contents[ type ].te st( ct ) ) { | |
8692 | dataTypes. unshift( t ype ); | |
8693 | break; | |
8694 | } | |
8695 | } | |
8696 | } | |
8697 | ||
8698 | // Check to see if we have a res ponse for the expect ed dataTyp e | |
8699 | if ( dataTyp es[ 0 ] in responses ) { | |
8700 | finalDat aType = da taTypes[ 0 ]; | |
8701 | } else { | |
8702 | // Try c onvertible dataTypes | |
8703 | for ( ty pe in resp onses ) { | |
8704 | if ( !dataType s[ 0 ] || s.converte rs[ type + " " + dat aTypes[0] ] ) { | |
8705 | finalDataT ype = type ; | |
8706 | break; | |
8707 | } | |
8708 | if ( !firstDat aType ) { | |
8709 | firstDataT ype = type ; | |
8710 | } | |
8711 | } | |
8712 | // Or ju st use fir st one | |
8713 | finalDat aType = fi nalDataTyp e || first DataType; | |
8714 | } | |
8715 | ||
8716 | // If we fou nd a dataT ype | |
8717 | // We add th e dataType to the li st if need ed | |
8718 | // and retur n the corr esponding response | |
8719 | if ( finalDa taType ) { | |
8720 | if ( fin alDataType !== dataT ypes[ 0 ] ) { | |
8721 | data Types.unsh ift( final DataType ) ; | |
8722 | } | |
8723 | return r esponses[ finalDataT ype ]; | |
8724 | } | |
8725 | } | |
8726 | ||
8727 | /* Cha in convers ions given the reque st and the original response | |
8728 | * Als o sets the responseX XX fields on the jqX HR instanc e | |
8729 | */ | |
8730 | functi on ajaxCon vert( s, r esponse, j qXHR, isSu ccess ) { | |
8731 | va r conv2, c urrent, co nv, tmp, p rev, | |
8732 | converte rs = {}, | |
8733 | // Work with a copy of dataTypes in case w e need to modify it for conver sion | |
8734 | dataType s = s.data Types.slic e(); | |
8735 | ||
8736 | // Create co nverters m ap with lo wercased k eys | |
8737 | if ( dataTyp es[ 1 ] ) { | |
8738 | for ( co nv in s.co nverters ) { | |
8739 | conv erters[ co nv.toLower Case() ] = s.convert ers[ conv ]; | |
8740 | } | |
8741 | } | |
8742 | ||
8743 | cu rrent = da taTypes.sh ift(); | |
8744 | ||
8745 | // Convert t o each seq uential da taType | |
8746 | wh ile ( curr ent ) { | |
8747 | ||
8748 | if ( s.r esponseFie lds[ curre nt ] ) { | |
8749 | jqXH R[ s.respo nseFields[ current ] ] = respo nse; | |
8750 | } | |
8751 | ||
8752 | // Apply the dataF ilter if p rovided | |
8753 | if ( !pr ev && isSu ccess && s .dataFilte r ) { | |
8754 | resp onse = s.d ataFilter( response, s.dataTyp e ); | |
8755 | } | |
8756 | ||
8757 | prev = c urrent; | |
8758 | current = dataType s.shift(); | |
8759 | ||
8760 | if ( cur rent ) { | |
8761 | ||
8762 | // T here's onl y work to do if curr ent dataTy pe is non- auto | |
8763 | if ( current = == "*" ) { | |
8764 | ||
8765 | current = prev; | |
8766 | ||
8767 | // Convert response if prev da taType is non-auto a nd differs from curr ent | |
8768 | } el se if ( pr ev !== "*" && prev ! == current ) { | |
8769 | ||
8770 | // Seek a direct con verter | |
8771 | conv = con verters[ p rev + " " + current ] || conve rters[ "* " + curren t ]; | |
8772 | ||
8773 | // If none found, se ek a pair | |
8774 | if ( !conv ) { | |
8775 | for ( conv2 in c onverters ) { | |
8776 | ||
8777 | // If conv2 outputs cu rrent | |
8778 | tm p = conv2. split( " " ); | |
8779 | if ( tmp[ 1 ] === curr ent ) { | |
8780 | ||
8781 | // If pr ev can be converted to accepte d input | |
8782 | conv = c onverters[ prev + " " + tmp[ 0 ] ] || | |
8783 | conv erters[ "* " + tmp[ 0 ] ]; | |
8784 | if ( con v ) { | |
8785 | // C ondense eq uivalence converters | |
8786 | if ( conv === true ) { | |
8787 | conv = con verters[ c onv2 ]; | |
8788 | ||
8789 | // Otherwi se, insert the inter mediate da taType | |
8790 | } el se if ( co nverters[ conv2 ] != = true ) { | |
8791 | current = tmp[ 0 ]; | |
8792 | dataTypes. unshift( t mp[ 1 ] ); | |
8793 | } | |
8794 | brea k; | |
8795 | } | |
8796 | } | |
8797 | } | |
8798 | } | |
8799 | ||
8800 | // Apply c onverter ( if not an equivalenc e) | |
8801 | if ( conv !== true ) { | |
8802 | ||
8803 | // Unl ess errors are allow ed to bubb le, catch and return them | |
8804 | if ( c onv && s[ "throws" ] ) { | |
8805 | re sponse = c onv( respo nse ); | |
8806 | } else { | |
8807 | tr y { | |
8808 | response = conv( r esponse ); | |
8809 | } catch ( e ) { | |
8810 | return { state: "p arsererror ", error: conv ? e : "No conve rsion from " + prev + " to " + current } ; | |
8811 | } | |
8812 | } | |
8813 | } | |
8814 | } | |
8815 | } | |
8816 | } | |
8817 | ||
8818 | re turn { sta te: "succe ss", data: response }; | |
8819 | } | |
8820 | ||
8821 | jQuery .extend({ | |
8822 | ||
8823 | // Counter f or holding the numbe r of activ e queries | |
8824 | ac tive: 0, | |
8825 | ||
8826 | // Last-Modi fied heade r cache fo r next req uest | |
8827 | la stModified : {}, | |
8828 | et ag: {}, | |
8829 | ||
8830 | aj axSettings : { | |
8831 | url: aja xLocation, | |
8832 | type: "G ET", | |
8833 | isLocal: rlocalPro tocol.test ( ajaxLocP arts[ 1 ] ), | |
8834 | global: true, | |
8835 | processD ata: true, | |
8836 | async: t rue, | |
8837 | contentT ype: "appl ication/x- www-form-u rlencoded; charset=U TF-8", | |
8838 | /* | |
8839 | timeout : 0, | |
8840 | data: n ull, | |
8841 | dataTyp e: null, | |
8842 | username: AI , | |
8843 | password: AI , | |
8844 | cache: null, | |
8845 | throws: false, | |
8846 | traditi onal: fals e, | |
8847 | headers : {}, | |
8848 | */ | |
8849 | ||
8850 | accepts: { | |
8851 | "*": allTypes, | |
8852 | text : "text/pl ain", | |
8853 | html : "text/ht ml", | |
8854 | xml: "applicat ion/xml, t ext/xml", | |
8855 | json : "applica tion/json, text/java script" | |
8856 | }, | |
8857 | ||
8858 | contents : { | |
8859 | xml: /xml/, | |
8860 | html : /html/, | |
8861 | json : /json/ | |
8862 | }, | |
8863 | ||
8864 | response Fields: { | |
8865 | xml: "response XML", | |
8866 | text : "respons eText", | |
8867 | json : "respons eJSON" | |
8868 | }, | |
8869 | ||
8870 | // Data converters | |
8871 | // Keys separate s ource (or catchall " *") and de stination types with a single space | |
8872 | converte rs: { | |
8873 | ||
8874 | // C onvert any thing to t ext | |
8875 | "* t ext": Stri ng, | |
8876 | ||
8877 | // T ext to htm l (true = no transfo rmation) | |
8878 | "tex t html": t rue, | |
8879 | ||
8880 | // E valuate te xt as a js on express ion | |
8881 | "tex t json": j Query.pars eJSON, | |
8882 | ||
8883 | // P arse text as xml | |
8884 | "tex t xml": jQ uery.parse XML | |
8885 | }, | |
8886 | ||
8887 | // For o ptions tha t shouldn' t be deep extended: | |
8888 | // you c an add you r own cust om options here if | |
8889 | // and w hen you cr eate one t hat should n't be | |
8890 | // deep extended ( see ajaxEx tend) | |
8891 | flatOpti ons: { | |
8892 | url: true, | |
8893 | cont ext: true | |
8894 | } | |
8895 | }, | |
8896 | ||
8897 | // Creates a full fled ged settin gs object into targe t | |
8898 | // with both ajaxSetti ngs and se ttings fie lds. | |
8899 | // If target is omitte d, writes into ajaxS ettings. | |
8900 | aj axSetup: f unction( t arget, set tings ) { | |
8901 | return s ettings ? | |
8902 | ||
8903 | // B uilding a settings o bject | |
8904 | ajax Extend( aj axExtend( target, jQ uery.ajaxS ettings ), settings ) : | |
8905 | ||
8906 | // E xtending a jaxSetting s | |
8907 | ajax Extend( jQ uery.ajaxS ettings, t arget ); | |
8908 | }, | |
8909 | ||
8910 | aj axPrefilte r: addToPr efiltersOr Transports ( prefilte rs ), | |
8911 | aj axTranspor t: addToPr efiltersOr Transports ( transpor ts ), | |
8912 | ||
8913 | // Main meth od | |
8914 | aj ax: functi on( url, o ptions ) { | |
8915 | ||
8916 | // If ur l is an ob ject, simu late pre-1 .5 signatu re | |
8917 | if ( typ eof url == = "object" ) { | |
8918 | opti ons = url; | |
8919 | url = undefine d; | |
8920 | } | |
8921 | ||
8922 | // Force options t o be an ob ject | |
8923 | options = options || {}; | |
8924 | ||
8925 | var // C ross-domai n detectio n vars | |
8926 | part s, | |
8927 | // Loop variable | |
8928 | i, | |
8929 | // URL w ithout ant i-cache pa ram | |
8930 | cach eURL, | |
8931 | // Respo nse header s as strin g | |
8932 | resp onseHeader sString, | |
8933 | // timeo ut handle | |
8934 | time outTimer, | |
8935 | ||
8936 | // To kn ow if glob al events are to be dispatched | |
8937 | fire Globals, | |
8938 | ||
8939 | tran sport, | |
8940 | // Respo nse header s | |
8941 | resp onseHeader s, | |
8942 | // Creat e the fina l options object | |
8943 | s = jQuery.aja xSetup( {} , options ), | |
8944 | // Callb acks conte xt | |
8945 | call backContex t = s.cont ext || s, | |
8946 | // Conte xt for glo bal events is callba ckContext if it is a DOM node or jQuery collection | |
8947 | glob alEventCon text = s.c ontext && ( callback Context.no deType || callbackCo ntext.jque ry ) ? | |
8948 | jQuery( ca llbackCont ext ) : | |
8949 | jQuery.eve nt, | |
8950 | // Defer reds | |
8951 | defe rred = jQu ery.Deferr ed(), | |
8952 | comp leteDeferr ed = jQuer y.Callback s("once me mory"), | |
8953 | // Statu s-dependen t callback s | |
8954 | stat usCode = s .statusCod e || {}, | |
8955 | // Heade rs (they a re sent al l at once) | |
8956 | requ estHeaders = {}, | |
8957 | requ estHeaders Names = {} , | |
8958 | // The j qXHR state | |
8959 | stat e = 0, | |
8960 | // Defau lt abort m essage | |
8961 | strA bort = "ca nceled", | |
8962 | // Fake xhr | |
8963 | jqXH R = { | |
8964 | readyState : 0, | |
8965 | ||
8966 | // Builds headers ha shtable if needed | |
8967 | getRespons eHeader: f unction( k ey ) { | |
8968 | var ma tch; | |
8969 | if ( s tate === 2 ) { | |
8970 | if ( !respon seHeaders ) { | |
8971 | response Headers = {}; | |
8972 | while ( (match = r headers.ex ec( respon seHeadersS tring )) ) { | |
8973 | resp onseHeader s[ match[1 ].toLowerC ase() ] = match[ 2 ] ; | |
8974 | } | |
8975 | } | |
8976 | ma tch = resp onseHeader s[ key.toL owerCase() ]; | |
8977 | } | |
8978 | return match == null ? nul l : match; | |
8979 | }, | |
8980 | ||
8981 | // Raw str ing | |
8982 | getAllResp onseHeader s: functio n() { | |
8983 | return state === 2 ? respo nseHeaders String : n ull; | |
8984 | }, | |
8985 | ||
8986 | // Caches the header | |
8987 | setRequest Header: fu nction( na me, value ) { | |
8988 | var ln ame = name .toLowerCa se(); | |
8989 | if ( ! state ) { | |
8990 | na me = reque stHeadersN ames[ lnam e ] = requ estHeaders Names[ lna me ] || na me; | |
8991 | re questHeade rs[ name ] = value; | |
8992 | } | |
8993 | return this; | |
8994 | }, | |
8995 | ||
8996 | // Overrid es respons e resource s-type hea der | |
8997 | overrideMi meType: fu nction( ty pe ) { | |
8998 | if ( ! state ) { | |
8999 | s. mimeType = type; | |
9000 | } | |
9001 | return this; | |
9002 | }, | |
9003 | ||
9004 | // Status- dependent callbacks | |
9005 | statusCode : function ( map ) { | |
9006 | var co de; | |
9007 | if ( m ap ) { | |
9008 | if ( state < 2 ) { | |
9009 | for ( co de in map ) { | |
9010 | // L azy-add th e new call back in a way that p reserves o ld ones | |
9011 | stat usCode[ co de ] = [ s tatusCode[ code ], m ap[ code ] ]; | |
9012 | } | |
9013 | } else { | |
9014 | // Execu te the app ropriate c allbacks | |
9015 | jqXHR.al ways( map[ jqXHR.sta tus ] ); | |
9016 | } | |
9017 | } | |
9018 | return this; | |
9019 | }, | |
9020 | ||
9021 | // Cancel the reques t | |
9022 | abort: fun ction( sta tusText ) { | |
9023 | var fi nalText = statusText || strAbo rt; | |
9024 | if ( t ransport ) { | |
9025 | tr ansport.ab ort( final Text ); | |
9026 | } | |
9027 | done( 0, finalTe xt ); | |
9028 | return this; | |
9029 | } | |
9030 | }; | |
9031 | ||
9032 | // Attac h deferred s | |
9033 | deferred .promise( jqXHR ).co mplete = c ompleteDef erred.add; | |
9034 | jqXHR.su ccess = jq XHR.done; | |
9035 | jqXHR.er ror = jqXH R.fail; | |
9036 | ||
9037 | // Remov e hash cha racter (#7 531: and s tring prom otion) | |
9038 | // Add p rotocol if not provi ded (#5866 : IE7 issu e with pro tocol-less urls) | |
9039 | // Handl e falsy ur l in the s ettings ob ject (#100 93: consis tency with old signa ture) | |
9040 | // We al so use the url param eter if av ailable | |
9041 | s.url = ( ( url || s.url || ajaxLocati on ) + "" ).replace( rhash, "" ).replace ( rprotoco l, ajaxLoc Parts[ 1 ] + "//" ); | |
9042 | ||
9043 | // Alias method op tion to ty pe as per ticket #12 004 | |
9044 | s.type = options.m ethod || o ptions.typ e || s.met hod || s.t ype; | |
9045 | ||
9046 | // Extra ct dataTyp es list | |
9047 | s.dataTy pes = jQue ry.trim( s .dataType || "*" ).t oLowerCase ().match( rnotwhite ) || [ "" ]; | |
9048 | ||
9049 | // A cro ss-domain request is in order when we ha ve a proto col:host:p ort mismat ch | |
9050 | if ( s.c rossDomain == null ) { | |
9051 | part s = rurl.e xec( s.url .toLowerCa se() ); | |
9052 | s.cr ossDomain = !!( part s && | |
9053 | ( parts[ 1 ] !== aja xLocParts[ 1 ] || pa rts[ 2 ] ! == ajaxLoc Parts[ 2 ] || | |
9054 | ( part s[ 3 ] || ( parts[ 1 ] === "ht tp:" ? "80 " : "443" ) ) !== | |
9055 | ( ajax LocParts[ 3 ] || ( a jaxLocPart s[ 1 ] === "http:" ? "80" : "4 43" ) ) ) | |
9056 | ); | |
9057 | } | |
9058 | ||
9059 | // Conve rt data if not alrea dy a strin g | |
9060 | if ( s.d ata && s.p rocessData && typeof s.data != = "string" ) { | |
9061 | s.da ta = jQuer y.param( s .data, s.t raditional ); | |
9062 | } | |
9063 | ||
9064 | // Apply prefilter s | |
9065 | inspectP refiltersO rTransport s( prefilt ers, s, op tions, jqX HR ); | |
9066 | ||
9067 | // If re quest was aborted in side a pre filter, st op there | |
9068 | if ( sta te === 2 ) { | |
9069 | retu rn jqXHR; | |
9070 | } | |
9071 | ||
9072 | // We ca n fire glo bal events as of now if asked to | |
9073 | fireGlob als = s.gl obal; | |
9074 | ||
9075 | // Watch for a new set of re quests | |
9076 | if ( fir eGlobals & & jQuery.a ctive++ == = 0 ) { | |
9077 | jQue ry.event.t rigger("aj axStart"); | |
9078 | } | |
9079 | ||
9080 | // Upper case the t ype | |
9081 | s.type = s.type.to UpperCase( ); | |
9082 | ||
9083 | // Deter mine if re quest has resources | |
9084 | s.hasCon tent = !rn oContent.t est( s.typ e ); | |
9085 | ||
9086 | // Save the URL in case we'r e toying w ith the If -Modified- Since | |
9087 | // and/o r If-None- Match head er later o n | |
9088 | cacheURL = s.url; | |
9089 | ||
9090 | // More options ha ndling for requests with no re sources | |
9091 | if ( !s. hasContent ) { | |
9092 | ||
9093 | // I f data is available, append da ta to url | |
9094 | if ( s.data ) { | |
9095 | cacheURL = ( s.url + = ( rquery .test( cac heURL ) ? "&" : "?" ) + s.data ); | |
9096 | // #9682: remove dat a so that it's not u sed in an eventual r etry | |
9097 | delete s.d ata; | |
9098 | } | |
9099 | ||
9100 | // A dd anti-ca che in url if needed | |
9101 | if ( s.cache = == false ) { | |
9102 | s.url = rt s.test( ca cheURL ) ? | |
9103 | ||
9104 | // If there is a lready a ' _' paramet er, set it s value | |
9105 | cacheU RL.replace ( rts, "$1 _=" + nonc e++ ) : | |
9106 | ||
9107 | // Oth erwise add one to th e end | |
9108 | cacheU RL + ( rqu ery.test( cacheURL ) ? "&" : " ?" ) + "_= " + nonce+ +; | |
9109 | } | |
9110 | } | |
9111 | ||
9112 | // Set t he If-Modi fied-Since and/or If -None-Matc h header, if in ifMo dified mod e. | |
9113 | if ( s.i fModified ) { | |
9114 | if ( jQuery.la stModified [ cacheURL ] ) { | |
9115 | jqXHR.setR equestHead er( "If-Mo dified-Sin ce", jQuer y.lastModi fied[ cach eURL ] ); | |
9116 | } | |
9117 | if ( jQuery.et ag[ cacheU RL ] ) { | |
9118 | jqXHR.setR equestHead er( "If-No ne-Match", jQuery.et ag[ cacheU RL ] ); | |
9119 | } | |
9120 | } | |
9121 | ||
9122 | // Set t he correct header, i f data is being sent | |
9123 | if ( s.d ata && s.h asContent && s.conte ntType !== false || options.co ntentType ) { | |
9124 | jqXH R.setReque stHeader( "Content-T ype", s.co ntentType ); | |
9125 | } | |
9126 | ||
9127 | // Set t he Accepts header fo r the serv er, depend ing on the dataType | |
9128 | jqXHR.se tRequestHe ader( | |
9129 | "Acc ept", | |
9130 | s.dataType s[ 0 ] && s.accepts[ s.dataTyp es[0] ] ? | |
9131 | s.accepts[ s.dataTyp es[0] ] + ( s.dataTy pes[ 0 ] ! == "*" ? " , " + allT ypes + "; q=0.01" : "" ) : | |
9132 | s.accepts[ "*" ] | |
9133 | ); | |
9134 | ||
9135 | // Check for heade rs option | |
9136 | for ( i in s.heade rs ) { | |
9137 | jqXH R.setReque stHeader( i, s.heade rs[ i ] ); | |
9138 | } | |
9139 | ||
9140 | // Allow custom he aders/mime types and early abor t | |
9141 | if ( s.b eforeSend && ( s.bef oreSend.ca ll( callba ckContext, jqXHR, s ) === fals e || state === 2 ) ) { | |
9142 | // A bort if no t done alr eady and r eturn | |
9143 | retu rn jqXHR.a bort(); | |
9144 | } | |
9145 | ||
9146 | // abort ing is no longer a c ancellatio n | |
9147 | strAbort = "abort" ; | |
9148 | ||
9149 | // Insta ll callbac ks on defe rreds | |
9150 | for ( i in { succe ss: 1, err or: 1, com plete: 1 } ) { | |
9151 | jqXH R[ i ]( s[ i ] ); | |
9152 | } | |
9153 | ||
9154 | // Get t ransport | |
9155 | transpor t = inspec tPrefilter sOrTranspo rts( trans ports, s, options, j qXHR ); | |
9156 | ||
9157 | // If no transport , we auto- abort | |
9158 | if ( !tr ansport ) { | |
9159 | done ( -1, "No Transport" ); | |
9160 | } else { | |
9161 | jqXH R.readySta te = 1; | |
9162 | ||
9163 | // S end global event | |
9164 | if ( fireGloba ls ) { | |
9165 | globalEven tContext.t rigger( "a jaxSend", [ jqXHR, s ] ); | |
9166 | } | |
9167 | // T imeout | |
9168 | if ( s.async & & s.timeou t > 0 ) { | |
9169 | timeoutTim er = setTi meout(func tion() { | |
9170 | jqXHR. abort("tim eout"); | |
9171 | }, s.timeo ut ); | |
9172 | } | |
9173 | ||
9174 | try { | |
9175 | state = 1; | |
9176 | transport. send( requ estHeaders , done ); | |
9177 | } ca tch ( e ) { | |
9178 | // Propaga te excepti on as erro r if not d one | |
9179 | if ( state < 2 ) { | |
9180 | done( -1, e ); | |
9181 | // Sim ply rethro w otherwis e | |
9182 | } else { | |
9183 | throw e; | |
9184 | } | |
9185 | } | |
9186 | } | |
9187 | ||
9188 | // Callb ack for wh en everyth ing is don e | |
9189 | function done( sta tus, nativ eStatusTex t, respons es, header s ) { | |
9190 | var isSuccess, success, error, res ponse, mod ified, | |
9191 | statusText = nativeS tatusText; | |
9192 | ||
9193 | // C alled once | |
9194 | if ( state === 2 ) { | |
9195 | return; | |
9196 | } | |
9197 | ||
9198 | // S tate is "d one" now | |
9199 | stat e = 2; | |
9200 | ||
9201 | // C lear timeo ut if it e xists | |
9202 | if ( timeoutTi mer ) { | |
9203 | clearTimeo ut( timeou tTimer ); | |
9204 | } | |
9205 | ||
9206 | // D ereference transport for early garbage c ollection | |
9207 | // ( no matter how long t he jqXHR o bject will be used) | |
9208 | tran sport = un defined; | |
9209 | ||
9210 | // C ache respo nse header s | |
9211 | resp onseHeader sString = headers || ""; | |
9212 | ||
9213 | // S et readySt ate | |
9214 | jqXH R.readySta te = statu s > 0 ? 4 : 0; | |
9215 | ||
9216 | // D etermine i f successf ul | |
9217 | isSu ccess = st atus >= 20 0 && statu s < 300 || status == = 304; | |
9218 | ||
9219 | // G et respons e data | |
9220 | if ( responses ) { | |
9221 | response = ajaxHandl eResponses ( s, jqXHR , response s ); | |
9222 | } | |
9223 | ||
9224 | // C onvert no matter wha t (that wa y response XXX fields are alway s set) | |
9225 | resp onse = aja xConvert( s, respons e, jqXHR, isSuccess ); | |
9226 | ||
9227 | // I f successf ul, handle type chai ning | |
9228 | if ( isSuccess ) { | |
9229 | ||
9230 | // Set the If-Modifi ed-Since a nd/or If-N one-Match header, if in ifModi fied mode. | |
9231 | if ( s.ifM odified ) { | |
9232 | modifi ed = jqXHR .getRespon seHeader(" Last-Modif ied"); | |
9233 | if ( m odified ) { | |
9234 | jQ uery.lastM odified[ c acheURL ] = modified ; | |
9235 | } | |
9236 | modifi ed = jqXHR .getRespon seHeader(" etag"); | |
9237 | if ( m odified ) { | |
9238 | jQ uery.etag[ cacheURL ] = modifi ed; | |
9239 | } | |
9240 | } | |
9241 | ||
9242 | // if no r esources | |
9243 | if ( statu s === 204 || s.type === "HEAD" ) { | |
9244 | status Text = "no content"; | |
9245 | ||
9246 | // if not modifi ed | |
9247 | } else if ( status = == 304 ) { | |
9248 | status Text = "no tmodified" ; | |
9249 | ||
9250 | // If we have da ta, let's convert it | |
9251 | } else { | |
9252 | status Text = res ponse.stat e; | |
9253 | succes s = respon se.data; | |
9254 | error = response .error; | |
9255 | isSucc ess = !err or; | |
9256 | } | |
9257 | } el se { | |
9258 | // We extr act error from statu sText | |
9259 | // then no rmalize st atusText a nd status for non-ab orts | |
9260 | error = st atusText; | |
9261 | if ( statu s || !stat usText ) { | |
9262 | status Text = "er ror"; | |
9263 | if ( s tatus < 0 ) { | |
9264 | st atus = 0; | |
9265 | } | |
9266 | } | |
9267 | } | |
9268 | ||
9269 | // S et data fo r the fake xhr objec t | |
9270 | jqXH R.status = status; | |
9271 | jqXH R.statusTe xt = ( nat iveStatusT ext || sta tusText ) + ""; | |
9272 | ||
9273 | // S uccess/Err or | |
9274 | if ( isSuccess ) { | |
9275 | deferred.r esolveWith ( callback Context, [ success, statusText , jqXHR ] ); | |
9276 | } el se { | |
9277 | deferred.r ejectWith( callbackC ontext, [ jqXHR, sta tusText, e rror ] ); | |
9278 | } | |
9279 | ||
9280 | // S tatus-depe ndent call backs | |
9281 | jqXH R.statusCo de( status Code ); | |
9282 | stat usCode = u ndefined; | |
9283 | ||
9284 | if ( fireGloba ls ) { | |
9285 | globalEven tContext.t rigger( is Success ? "ajaxSucce ss" : "aja xError", | |
9286 | [ jqXH R, s, isSu ccess ? su ccess : er ror ] ); | |
9287 | } | |
9288 | ||
9289 | // C omplete | |
9290 | comp leteDeferr ed.fireWit h( callbac kContext, [ jqXHR, s tatusText ] ); | |
9291 | ||
9292 | if ( fireGloba ls ) { | |
9293 | globalEven tContext.t rigger( "a jaxComplet e", [ jqXH R, s ] ); | |
9294 | // Handle the global AJAX coun ter | |
9295 | if ( !( -- jQuery.act ive ) ) { | |
9296 | jQuery .event.tri gger("ajax Stop"); | |
9297 | } | |
9298 | } | |
9299 | } | |
9300 | ||
9301 | return j qXHR; | |
9302 | }, | |
9303 | ||
9304 | ge tJSON: fun ction( url , data, ca llback ) { | |
9305 | return j Query.get( url, data , callback , "json" ) ; | |
9306 | }, | |
9307 | ||
9308 | ge tScript: f unction( u rl, callba ck ) { | |
9309 | return j Query.get( url, unde fined, cal lback, "sc ript" ); | |
9310 | } | |
9311 | }); | |
9312 | ||
9313 | jQuery .each( [ " get", "pos t" ], func tion( i, m ethod ) { | |
9314 | jQ uery[ meth od ] = fun ction( url , data, ca llback, ty pe ) { | |
9315 | // shift arguments if data a rgument wa s omitted | |
9316 | if ( jQu ery.isFunc tion( data ) ) { | |
9317 | type = type || callback; | |
9318 | call back = dat a; | |
9319 | data = undefin ed; | |
9320 | } | |
9321 | ||
9322 | return j Query.ajax ({ | |
9323 | url: url, | |
9324 | type : method, | |
9325 | data Type: type , | |
9326 | data : data, | |
9327 | succ ess: callb ack | |
9328 | }); | |
9329 | }; | |
9330 | }); | |
9331 | ||
9332 | // Attach a bunch of functions for handl ing common AJAX even ts | |
9333 | jQuery .each( [ " ajaxStart" , "ajaxSto p", "ajaxC omplete", "ajaxError ", "ajaxSu ccess", "a jaxSend" ] , function ( i, type ) { | |
9334 | jQ uery.fn[ t ype ] = fu nction( fn ) { | |
9335 | return t his.on( ty pe, fn ); | |
9336 | }; | |
9337 | }); | |
9338 | ||
9339 | ||
9340 | jQuery ._evalUrl = function ( url ) { | |
9341 | re turn jQuer y.ajax({ | |
9342 | url: url , | |
9343 | type: "G ET", | |
9344 | dataType : "script" , | |
9345 | async: f alse, | |
9346 | global: false, | |
9347 | "throws" : true | |
9348 | }) ; | |
9349 | }; | |
9350 | ||
9351 | ||
9352 | jQuery .fn.extend ({ | |
9353 | wr apAll: fun ction( htm l ) { | |
9354 | if ( jQu ery.isFunc tion( html ) ) { | |
9355 | retu rn this.ea ch(functio n(i) { | |
9356 | jQuery(thi s).wrapAll ( html.cal l(this, i) ); | |
9357 | }); | |
9358 | } | |
9359 | ||
9360 | if ( thi s[0] ) { | |
9361 | // T he element s to wrap the target around | |
9362 | var wrap = jQu ery( html, this[0].o wnerDocume nt ).eq(0) .clone(tru e); | |
9363 | ||
9364 | if ( this[0].p arentNode ) { | |
9365 | wrap.inser tBefore( t his[0] ); | |
9366 | } | |
9367 | ||
9368 | wrap .map(funct ion() { | |
9369 | var elem = this; | |
9370 | ||
9371 | while ( el em.firstCh ild && ele m.firstChi ld.nodeTyp e === 1 ) { | |
9372 | elem = elem.firs tChild; | |
9373 | } | |
9374 | ||
9375 | return ele m; | |
9376 | }).a ppend( thi s ); | |
9377 | } | |
9378 | ||
9379 | return t his; | |
9380 | }, | |
9381 | ||
9382 | wr apInner: f unction( h tml ) { | |
9383 | if ( jQu ery.isFunc tion( html ) ) { | |
9384 | retu rn this.ea ch(functio n(i) { | |
9385 | jQuery(thi s).wrapInn er( html.c all(this, i) ); | |
9386 | }); | |
9387 | } | |
9388 | ||
9389 | return t his.each(f unction() { | |
9390 | var self = jQu ery( this ), | |
9391 | contents = self.cont ents(); | |
9392 | ||
9393 | if ( contents. length ) { | |
9394 | contents.w rapAll( ht ml ); | |
9395 | ||
9396 | } el se { | |
9397 | self.appen d( html ); | |
9398 | } | |
9399 | }); | |
9400 | }, | |
9401 | ||
9402 | wr ap: functi on( html ) { | |
9403 | var isFu nction = j Query.isFu nction( ht ml ); | |
9404 | ||
9405 | return t his.each(f unction(i) { | |
9406 | jQue ry( this ) .wrapAll( isFunction ? html.ca ll(this, i ) : html ) ; | |
9407 | }); | |
9408 | }, | |
9409 | ||
9410 | un wrap: func tion() { | |
9411 | return t his.parent ().each(fu nction() { | |
9412 | if ( !jQuery.n odeName( t his, "body " ) ) { | |
9413 | jQuery( th is ).repla ceWith( th is.childNo des ); | |
9414 | } | |
9415 | }).end() ; | |
9416 | } | |
9417 | }); | |
9418 | ||
9419 | ||
9420 | jQuery .expr.filt ers.hidden = functio n( elem ) { | |
9421 | // Support: Opera <= 1 2.12 | |
9422 | // Opera rep orts offse tWidths an d offsetHe ights less than zero on some e lements | |
9423 | re turn elem. offsetWidt h <= 0 && elem.offse tHeight <= 0 || | |
9424 | (!suppor t.reliable HiddenOffs ets() && | |
9425 | ((el em.style & & elem.sty le.display ) || jQuer y.css( ele m, "displa y" )) === "none"); | |
9426 | }; | |
9427 | ||
9428 | jQuery .expr.filt ers.visibl e = functi on( elem ) { | |
9429 | re turn !jQue ry.expr.fi lters.hidd en( elem ) ; | |
9430 | }; | |
9431 | ||
9432 | ||
9433 | ||
9434 | ||
9435 | var r2 0 = /%20/g , | |
9436 | rb racket = / \[\]$/, | |
9437 | rC RLF = /\r? \n/g, | |
9438 | rs ubmitterTy pes = /^(? :submit|bu tton|image |reset|fil e)$/i, | |
9439 | rs ubmittable = /^(?:in put|select |textarea| keygen)/i; | |
9440 | ||
9441 | functi on buildPa rams( pref ix, obj, t raditional , add ) { | |
9442 | va r name; | |
9443 | ||
9444 | if ( jQuery. isArray( o bj ) ) { | |
9445 | // Seria lize array item. | |
9446 | jQuery.e ach( obj, function( i, v ) { | |
9447 | if ( tradition al || rbra cket.test( prefix ) ) { | |
9448 | // Treat e ach array item as a scalar. | |
9449 | add( prefi x, v ); | |
9450 | ||
9451 | } el se { | |
9452 | // Item is non-scala r (array o r object), encode it s numeric index. | |
9453 | buildParam s( prefix + "[" + ( typeof v = == "object " ? i : "" ) + "]", v, traditi onal, add ); | |
9454 | } | |
9455 | }); | |
9456 | ||
9457 | } else if ( !tradition al && jQue ry.type( o bj ) === " object" ) { | |
9458 | // Seria lize objec t item. | |
9459 | for ( na me in obj ) { | |
9460 | buil dParams( p refix + "[ " + name + "]", obj[ name ], t raditional , add ); | |
9461 | } | |
9462 | ||
9463 | } else { | |
9464 | // Seria lize scala r item. | |
9465 | add( pre fix, obj ) ; | |
9466 | } | |
9467 | } | |
9468 | ||
9469 | // Seriali ze an arra y of form elements o r a set of | |
9470 | // key/val ues into a query str ing | |
9471 | jQuery .param = f unction( a , traditio nal ) { | |
9472 | va r prefix, | |
9473 | s = [], | |
9474 | add = fu nction( ke y, value ) { | |
9475 | // I f value is a functio n, invoke it and ret urn its va lue | |
9476 | valu e = jQuery .isFunctio n( value ) ? value() : ( value == null ? "" : valu e ); | |
9477 | s[ s .length ] = encodeUR IComponent ( key ) + "=" + enco deURICompo nent( valu e ); | |
9478 | }; | |
9479 | ||
9480 | // Set tradi tional to true for j Query <= 1 .3.2 behav ior. | |
9481 | if ( traditi onal === u ndefined ) { | |
9482 | traditio nal = jQue ry.ajaxSet tings && j Query.ajax Settings.t raditional ; | |
9483 | } | |
9484 | ||
9485 | // If an arr ay was pas sed in, as sume that it is an a rray of fo rm element s. | |
9486 | if ( jQuery. isArray( a ) || ( a. jquery && !jQuery.is PlainObjec t( a ) ) ) { | |
9487 | // Seria lize the f orm elemen ts | |
9488 | jQuery.e ach( a, fu nction() { | |
9489 | add( this.name , this.val ue ); | |
9490 | }); | |
9491 | ||
9492 | } else { | |
9493 | // If tr aditional, encode th e "old" wa y (the way 1.3.2 or older | |
9494 | // did i t), otherw ise encode params re cursively. | |
9495 | for ( pr efix in a ) { | |
9496 | buil dParams( p refix, a[ prefix ], traditiona l, add ); | |
9497 | } | |
9498 | } | |
9499 | ||
9500 | // Return th e resultin g serializ ation | |
9501 | re turn s.joi n( "&" ).r eplace( r2 0, "+" ); | |
9502 | }; | |
9503 | ||
9504 | jQuery .fn.extend ({ | |
9505 | se rialize: f unction() { | |
9506 | return j Query.para m( this.se rializeArr ay() ); | |
9507 | }, | |
9508 | se rializeArr ay: functi on() { | |
9509 | return t his.map(fu nction() { | |
9510 | // C an add pro pHook for "elements" to filter or add fo rm element s | |
9511 | var elements = jQuery.pr op( this, "elements" ); | |
9512 | retu rn element s ? jQuery .makeArray ( elements ) : this; | |
9513 | }) | |
9514 | .fil ter(functi on() { | |
9515 | var type = this.type ; | |
9516 | // Use .is (":disable d") so tha t fieldset [disabled] works | |
9517 | return thi s.name && !jQuery( t his ).is( ":disabled " ) && | |
9518 | rsubmi ttable.tes t( this.no deName ) & & !rsubmit terTypes.t est( type ) && | |
9519 | ( this .checked | | !rchecka bleType.te st( type ) ); | |
9520 | }) | |
9521 | .map (function( i, elem ) { | |
9522 | var val = jQuery( th is ).val() ; | |
9523 | ||
9524 | return val == null ? | |
9525 | null : | |
9526 | jQuery .isArray( val ) ? | |
9527 | jQ uery.map( val, funct ion( val ) { | |
9528 | return { name: ele m.name, va lue: val.r eplace( rC RLF, "\r\n " ) }; | |
9529 | }) : | |
9530 | { name : elem.nam e, value: val.replac e( rCRLF, "\r\n" ) } ; | |
9531 | }).g et(); | |
9532 | } | |
9533 | }); | |
9534 | ||
9535 | ||
9536 | // Create the reques t object | |
9537 | // (This i s still at tached to ajaxSettin gs for bac kward comp atibility) | |
9538 | jQuery .ajaxSetti ngs.xhr = window.Act iveXObject !== undef ined ? | |
9539 | // Support: IE6+ | |
9540 | fu nction() { | |
9541 | ||
9542 | // XHR c annot acce ss local f iles, alwa ys use Act iveX for t hat case | |
9543 | return ! this.isLoc al && | |
9544 | ||
9545 | // S upport: IE 7-8 | |
9546 | // o ldIE XHR d oes not su pport non- RFC2616 me thods (#13 240) | |
9547 | // S ee http:// msdn.micro soft.com/e n-us/libra ry/ie/ms53 6648(v=vs. 85).aspx | |
9548 | // a nd http:// www.w3.org /Protocols /rfc2616/r fc2616-sec 9.html#sec 9 | |
9549 | // A lthough th is check f or six met hods inste ad of eigh t | |
9550 | // s ince IE al so does no t support "trace" an d "connect " | |
9551 | /^(g et|post|he ad|put|del ete|option s)$/i.test ( this.typ e ) && | |
9552 | ||
9553 | crea teStandard XHR() || c reateActiv eXHR(); | |
9554 | } : | |
9555 | // For all o ther brows ers, use t he standar d XMLHttpR equest obj ect | |
9556 | cr eateStanda rdXHR; | |
9557 | ||
9558 | var xh rId = 0, | |
9559 | xh rCallbacks = {}, | |
9560 | xh rSupported = jQuery. ajaxSettin gs.xhr(); | |
9561 | ||
9562 | // Support : IE<10 | |
9563 | // Open re quests mus t be manua lly aborte d on unloa d (#5280) | |
9564 | if ( w indow.Acti veXObject ) { | |
9565 | jQ uery( wind ow ).on( " unload", f unction() { | |
9566 | for ( va r key in x hrCallback s ) { | |
9567 | xhrC allbacks[ key ]( und efined, tr ue ); | |
9568 | } | |
9569 | }) ; | |
9570 | } | |
9571 | ||
9572 | // Determi ne support propertie s | |
9573 | suppor t.cors = ! !xhrSuppor ted && ( " withCreden tials" in xhrSupport ed ); | |
9574 | xhrSup ported = s upport.aja x = !!xhrS upported; | |
9575 | ||
9576 | // Create transport if the bro wser can p rovide an xhr | |
9577 | if ( x hrSupporte d ) { | |
9578 | ||
9579 | jQ uery.ajaxT ransport(f unction( o ptions ) { | |
9580 | // Cross domain on ly allowed if suppor ted throug h XMLHttpR equest | |
9581 | if ( !op tions.cros sDomain || support.c ors ) { | |
9582 | ||
9583 | var callback; | |
9584 | ||
9585 | retu rn { | |
9586 | send: func tion( head ers, compl ete ) { | |
9587 | var i, | |
9588 | xh r = option s.xhr(), | |
9589 | id = ++xhrId ; | |
9590 | ||
9591 | // Ope n the sock et | |
9592 | xhr.op en( option s.type, op tions.url, options.a sync, opti ons.userna me, option s.password ); | |
9593 | ||
9594 | // App ly custom fields if provided | |
9595 | if ( o ptions.xhr Fields ) { | |
9596 | fo r ( i in o ptions.xhr Fields ) { | |
9597 | xhr[ i ] = options .xhrFields [ i ]; | |
9598 | } | |
9599 | } | |
9600 | ||
9601 | // Ove rride mime type if n eeded | |
9602 | if ( o ptions.mim eType && x hr.overrid eMimeType ) { | |
9603 | xh r.override MimeType( options.mi meType ); | |
9604 | } | |
9605 | ||
9606 | // X-R equested-W ith header | |
9607 | // For cross-dom ain reques ts, seeing as condit ions for a preflight are | |
9608 | // aki n to a jig saw puzzle , we simpl y never se t it to be sure. | |
9609 | // (it can alway s be set o n a per-re quest basi s or even using ajax Setup) | |
9610 | // For same-doma in request s, won't c hange head er if alre ady provid ed. | |
9611 | if ( ! options.cr ossDomain && !header s["X-Reque sted-With" ] ) { | |
9612 | he aders["X-R equested-W ith"] = "X MLHttpRequ est"; | |
9613 | } | |
9614 | ||
9615 | // Set headers | |
9616 | for ( i in heade rs ) { | |
9617 | // Support: IE<9 | |
9618 | // IE's Acti veXObject throws a ' Type Misma tch' excep tion when setting | |
9619 | // request h eader to a null-valu e. | |
9620 | // | |
9621 | // To keep c onsistent with other XHR imple mentations , cast the value | |
9622 | // to string and ignor e `undefin ed`. | |
9623 | if ( headers [ i ] !== undefined ) { | |
9624 | xhr.setR equestHead er( i, hea ders[ i ] + "" ); | |
9625 | } | |
9626 | } | |
9627 | ||
9628 | // Do send the r equest | |
9629 | // Thi s may rais e an excep tion which is actual ly | |
9630 | // han dled in jQ uery.ajax (so no try /catch her e) | |
9631 | xhr.se nd( ( opti ons.hasCon tent && op tions.data ) || null ); | |
9632 | ||
9633 | // Lis tener | |
9634 | callba ck = funct ion( _, is Abort ) { | |
9635 | va r status, statusText , response s; | |
9636 | ||
9637 | // Was never called an d is abort ed or comp lete | |
9638 | if ( callbac k && ( isA bort || xh r.readySta te === 4 ) ) { | |
9639 | // Clean up | |
9640 | delete x hrCallback s[ id ]; | |
9641 | callback = undefin ed; | |
9642 | xhr.onre adystatech ange = jQu ery.noop; | |
9643 | ||
9644 | // Abort manually if needed | |
9645 | if ( isA bort ) { | |
9646 | if ( xhr.ready State !== 4 ) { | |
9647 | xhr.abort( ); | |
9648 | } | |
9649 | } else { | |
9650 | resp onses = {} ; | |
9651 | stat us = xhr.s tatus; | |
9652 | ||
9653 | // S upport: IE <10 | |
9654 | // A ccessing b inary-data responseT ext throws an except ion | |
9655 | // ( #11426) | |
9656 | if ( typeof xh r.response Text === " string" ) { | |
9657 | responses. text = xhr .responseT ext; | |
9658 | } | |
9659 | ||
9660 | // F irefox thr ows an exc eption whe n accessin g | |
9661 | // s tatusText for faulty cross-dom ain reques ts | |
9662 | try { | |
9663 | statusText = xhr.sta tusText; | |
9664 | } ca tch( e ) { | |
9665 | // We norm alize with Webkit gi ving an em pty status Text | |
9666 | statusText = ""; | |
9667 | } | |
9668 | ||
9669 | // F ilter stat us for non standard behaviors | |
9670 | ||
9671 | // I f the requ est is loc al and we have data: assume a success | |
9672 | // ( success wi th no data won't get notified, that's th e best we | |
9673 | // c an do give n current implementa tions) | |
9674 | if ( !status & & options. isLocal && !options. crossDomai n ) { | |
9675 | status = r esponses.t ext ? 200 : 404; | |
9676 | // IE - #1 450: somet imes retur ns 1223 wh en it shou ld be 204 | |
9677 | } el se if ( st atus === 1 223 ) { | |
9678 | status = 2 04; | |
9679 | } | |
9680 | } | |
9681 | } | |
9682 | ||
9683 | // Call comp lete if ne eded | |
9684 | if ( respons es ) { | |
9685 | complete ( status, statusText , response s, xhr.get AllRespons eHeaders() ); | |
9686 | } | |
9687 | }; | |
9688 | ||
9689 | if ( ! options.as ync ) { | |
9690 | // if we're in sync mo de we fire the callb ack | |
9691 | ca llback(); | |
9692 | } else if ( xhr. readyState === 4 ) { | |
9693 | // (IE6 & IE 7) if it's in cache and has be en | |
9694 | // retrieved directly we need to fire the callback | |
9695 | se tTimeout( callback ) ; | |
9696 | } else { | |
9697 | // Add to th e list of active xhr callbacks | |
9698 | xh r.onreadys tatechange = xhrCall backs[ id ] = callba ck; | |
9699 | } | |
9700 | }, | |
9701 | ||
9702 | abort: fun ction() { | |
9703 | if ( c allback ) { | |
9704 | ca llback( un defined, t rue ); | |
9705 | } | |
9706 | } | |
9707 | }; | |
9708 | } | |
9709 | }) ; | |
9710 | } | |
9711 | ||
9712 | // Functio ns to crea te xhrs | |
9713 | functi on createS tandardXHR () { | |
9714 | tr y { | |
9715 | return n ew window. XMLHttpReq uest(); | |
9716 | } catch( e ) {} | |
9717 | } | |
9718 | ||
9719 | functi on createA ctiveXHR() { | |
9720 | tr y { | |
9721 | return n ew window. ActiveXObj ect( "Micr osoft.XMLH TTP" ); | |
9722 | } catch( e ) {} | |
9723 | } | |
9724 | ||
9725 | ||
9726 | ||
9727 | ||
9728 | // Install script da taType | |
9729 | jQuery .ajaxSetup ({ | |
9730 | ac cepts: { | |
9731 | script: "text/java script, ap plication/ javascript , applicat ion/ecmasc ript, appl ication/x- ecmascript " | |
9732 | }, | |
9733 | co ntents: { | |
9734 | script: /(?:java|e cma)script / | |
9735 | }, | |
9736 | co nverters: { | |
9737 | "text sc ript": fun ction( tex t ) { | |
9738 | jQue ry.globalE val( text ); | |
9739 | retu rn text; | |
9740 | } | |
9741 | } | |
9742 | }); | |
9743 | ||
9744 | // Handle cache's sp ecial case and globa l | |
9745 | jQuery .ajaxPrefi lter( "scr ipt", func tion( s ) { | |
9746 | if ( s.cache === undef ined ) { | |
9747 | s.cache = false; | |
9748 | } | |
9749 | if ( s.cross Domain ) { | |
9750 | s.type = "GET"; | |
9751 | s.global = false; | |
9752 | } | |
9753 | }); | |
9754 | ||
9755 | // Bind sc ript tag h ack transp ort | |
9756 | jQuery .ajaxTrans port( "scr ipt", func tion(s) { | |
9757 | ||
9758 | // This tran sport only deals wit h cross do main reque sts | |
9759 | if ( s.cross Domain ) { | |
9760 | ||
9761 | var scri pt, | |
9762 | head = documen t.head || jQuery("he ad")[0] || document. documentEl ement; | |
9763 | ||
9764 | return { | |
9765 | ||
9766 | send : function ( _, callb ack ) { | |
9767 | ||
9768 | script = d ocument.cr eateElemen t("script" ); | |
9769 | ||
9770 | script.asy nc = true; | |
9771 | ||
9772 | if ( s.scr iptCharset ) { | |
9773 | script .charset = s.scriptC harset; | |
9774 | } | |
9775 | ||
9776 | script.src = s.url; | |
9777 | ||
9778 | // Attach handlers f or all bro wsers | |
9779 | script.onl oad = scri pt.onready statechang e = functi on( _, isA bort ) { | |
9780 | ||
9781 | if ( i sAbort || !script.re adyState | | /loaded| complete/. test( scri pt.readySt ate ) ) { | |
9782 | ||
9783 | // Handle me mory leak in IE | |
9784 | sc ript.onloa d = script .onreadyst atechange = null; | |
9785 | ||
9786 | // Remove th e script | |
9787 | if ( script. parentNode ) { | |
9788 | script.p arentNode. removeChil d( script ); | |
9789 | } | |
9790 | ||
9791 | // Dereferen ce the scr ipt | |
9792 | sc ript = nul l; | |
9793 | ||
9794 | // Callback if not abo rt | |
9795 | if ( !isAbor t ) { | |
9796 | callback ( 200, "su ccess" ); | |
9797 | } | |
9798 | } | |
9799 | }; | |
9800 | ||
9801 | // Circumv ent IE6 bu gs with ba se element s (#2709 a nd #4378) by prepend ing | |
9802 | // Use nat ive DOM ma nipulation to avoid our domMan ip AJAX tr ickery | |
9803 | head.inser tBefore( s cript, hea d.firstChi ld ); | |
9804 | }, | |
9805 | ||
9806 | abor t: functio n() { | |
9807 | if ( scrip t ) { | |
9808 | script .onload( u ndefined, true ); | |
9809 | } | |
9810 | } | |
9811 | }; | |
9812 | } | |
9813 | }); | |
9814 | ||
9815 | ||
9816 | ||
9817 | ||
9818 | var ol dCallbacks = [], | |
9819 | rj sonp = /(= )\?(?=&|$) |\?\?/; | |
9820 | ||
9821 | // Default jsonp set tings | |
9822 | jQuery .ajaxSetup ({ | |
9823 | js onp: "call back", | |
9824 | js onpCallbac k: functio n() { | |
9825 | var call back = old Callbacks. pop() || ( jQuery.ex pando + "_ " + ( nonc e++ ) ); | |
9826 | this[ ca llback ] = true; | |
9827 | return c allback; | |
9828 | } | |
9829 | }); | |
9830 | ||
9831 | // Detect, normalize options a nd install callbacks for jsonp requests | |
9832 | jQuery .ajaxPrefi lter( "jso n jsonp", function( s, origina lSettings, jqXHR ) { | |
9833 | ||
9834 | va r callback Name, over written, r esponseCon tainer, | |
9835 | jsonProp = s.jsonp !== false && ( rjso np.test( s .url ) ? | |
9836 | "url " : | |
9837 | type of s.data === "strin g" && !( s .contentTy pe || "" ) .indexOf(" applicatio n/x-www-fo rm-urlenco ded") && r jsonp.test ( s.data ) && "data" | |
9838 | ); | |
9839 | ||
9840 | // Handle if f the expe cted data type is "j sonp" or w e have a p arameter t o set | |
9841 | if ( jsonPro p || s.dat aTypes[ 0 ] === "jso np" ) { | |
9842 | ||
9843 | // Get c allback na me, rememb ering pree xisting va lue associ ated with it | |
9844 | callback Name = s.j sonpCallba ck = jQuer y.isFuncti on( s.json pCallback ) ? | |
9845 | s.js onpCallbac k() : | |
9846 | s.js onpCallbac k; | |
9847 | ||
9848 | // Inser t callback into url or form da ta | |
9849 | if ( jso nProp ) { | |
9850 | s[ j sonProp ] = s[ jsonP rop ].repl ace( rjson p, "$1" + callbackNa me ); | |
9851 | } else i f ( s.json p !== fals e ) { | |
9852 | s.ur l += ( rqu ery.test( s.url ) ? "&" : "?" ) + s.json p + "=" + callbackNa me; | |
9853 | } | |
9854 | ||
9855 | // Use d ata conver ter to ret rieve json after scr ipt execut ion | |
9856 | s.conver ters["scri pt json"] = function () { | |
9857 | if ( !response Container ) { | |
9858 | jQuery.err or( callba ckName + " was not c alled" ); | |
9859 | } | |
9860 | retu rn respons eContainer [ 0 ]; | |
9861 | }; | |
9862 | ||
9863 | // force json data Type | |
9864 | s.dataTy pes[ 0 ] = "json"; | |
9865 | ||
9866 | // Insta ll callbac k | |
9867 | overwrit ten = wind ow[ callba ckName ]; | |
9868 | window[ callbackNa me ] = fun ction() { | |
9869 | resp onseContai ner = argu ments; | |
9870 | }; | |
9871 | ||
9872 | // Clean -up functi on (fires after conv erters) | |
9873 | jqXHR.al ways(funct ion() { | |
9874 | // R estore pre existing v alue | |
9875 | wind ow[ callba ckName ] = overwritt en; | |
9876 | ||
9877 | // S ave back a s free | |
9878 | if ( s[ callba ckName ] ) { | |
9879 | // make su re that re -using the options d oesn't scr ew things around | |
9880 | s.jsonpCal lback = or iginalSett ings.jsonp Callback; | |
9881 | ||
9882 | // save th e callback name for future use | |
9883 | oldCallbac ks.push( c allbackNam e ); | |
9884 | } | |
9885 | ||
9886 | // C all if it was a func tion and w e have a r esponse | |
9887 | if ( responseC ontainer & & jQuery.i sFunction( overwritt en ) ) { | |
9888 | overwritte n( respons eContainer [ 0 ] ); | |
9889 | } | |
9890 | ||
9891 | resp onseContai ner = over written = undefined; | |
9892 | }); | |
9893 | ||
9894 | // Deleg ate to scr ipt | |
9895 | return " script"; | |
9896 | } | |
9897 | }); | |
9898 | ||
9899 | ||
9900 | ||
9901 | ||
9902 | // data: s tring of h tml | |
9903 | // context (optional ): If spec ified, the fragment will be cr eated in t his contex t, default s to docum ent | |
9904 | // keepScr ipts (opti onal): If true, will include v endor pass ed in the html strin g | |
9905 | jQuery .parseHTML = functio n( data, c ontext, ke epScripts ) { | |
9906 | if ( !data | | typeof d ata !== "s tring" ) { | |
9907 | return n ull; | |
9908 | } | |
9909 | if ( typeof context == = "boolean " ) { | |
9910 | keepScri pts = cont ext; | |
9911 | context = false; | |
9912 | } | |
9913 | co ntext = co ntext || d ocument; | |
9914 | ||
9915 | va r parsed = rsingleTa g.exec( da ta ), | |
9916 | scripts = !keepScr ipts && [] ; | |
9917 | ||
9918 | // Single ta g | |
9919 | if ( parsed ) { | |
9920 | return [ context.c reateEleme nt( parsed [1] ) ]; | |
9921 | } | |
9922 | ||
9923 | pa rsed = jQu ery.buildF ragment( [ data ], c ontext, sc ripts ); | |
9924 | ||
9925 | if ( scripts && script s.length ) { | |
9926 | jQuery( scripts ). remove(); | |
9927 | } | |
9928 | ||
9929 | re turn jQuer y.merge( [ ], parsed. childNodes ); | |
9930 | }; | |
9931 | ||
9932 | ||
9933 | // Keep a copy of th e old load method | |
9934 | var _l oad = jQue ry.fn.load ; | |
9935 | ||
9936 | /** | |
9937 | * Loa d a url in to a page | |
9938 | */ | |
9939 | jQuery .fn.load = function( url, para ms, callba ck ) { | |
9940 | if ( typeof url !== "s tring" && _load ) { | |
9941 | return _ load.apply ( this, ar guments ); | |
9942 | } | |
9943 | ||
9944 | va r selector , response , type, | |
9945 | self = t his, | |
9946 | off = ur l.indexOf( " "); | |
9947 | ||
9948 | if ( off >= 0 ) { | |
9949 | selector = jQuery. trim( url. slice( off , url.leng th ) ); | |
9950 | url = ur l.slice( 0 , off ); | |
9951 | } | |
9952 | ||
9953 | // If it's a function | |
9954 | if ( jQuery. isFunction ( params ) ) { | |
9955 | ||
9956 | // We as sume that it's the c allback | |
9957 | callback = params; | |
9958 | params = undefined ; | |
9959 | ||
9960 | // Other wise, buil d a param string | |
9961 | } else if ( params && typeof par ams === "o bject" ) { | |
9962 | type = " POST"; | |
9963 | } | |
9964 | ||
9965 | // If we hav e elements to modify , make the request | |
9966 | if ( self.le ngth > 0 ) { | |
9967 | jQuery.a jax({ | |
9968 | url: url, | |
9969 | ||
9970 | // i f "type" v ariable is undefined , then "GE T" method will be us ed | |
9971 | type : type, | |
9972 | data Type: "htm l", | |
9973 | data : params | |
9974 | }).done( function( responseTe xt ) { | |
9975 | ||
9976 | // S ave respon se for use in comple te callbac k | |
9977 | resp onse = arg uments; | |
9978 | ||
9979 | self .html( sel ector ? | |
9980 | ||
9981 | // If a se lector was specified , locate t he right e lements in a dummy d iv | |
9982 | // Exclude vendor to avoid IE 'Permissio n Denied' errors | |
9983 | jQuery("<d iv>").appe nd( jQuery .parseHTML ( response Text ) ).f ind( selec tor ) : | |
9984 | ||
9985 | // Otherwi se use the full resu lt | |
9986 | responseTe xt ); | |
9987 | ||
9988 | }).compl ete( callb ack && fun ction( jqX HR, status ) { | |
9989 | self .each( cal lback, res ponse || [ jqXHR.res ponseText, status, j qXHR ] ); | |
9990 | }); | |
9991 | } | |
9992 | ||
9993 | re turn this; | |
9994 | }; | |
9995 | ||
9996 | ||
9997 | ||
9998 | ||
9999 | jQuery .expr.filt ers.animat ed = funct ion( elem ) { | |
10000 | re turn jQuer y.grep(jQu ery.timers , function ( fn ) { | |
10001 | return e lem === fn .elem; | |
10002 | }) .length; | |
10003 | }; | |
10004 | ||
10005 | ||
10006 | ||
10007 | ||
10008 | ||
10009 | var do cElem = wi ndow.docum ent.docume ntElement; | |
10010 | ||
10011 | /** | |
10012 | * Get s a window from an e lement | |
10013 | */ | |
10014 | functi on getWind ow( elem ) { | |
10015 | re turn jQuer y.isWindow ( elem ) ? | |
10016 | elem : | |
10017 | elem .nodeType === 9 ? | |
10018 | elem.def aultView | | elem.par entWindow : | |
10019 | false; | |
10020 | } | |
10021 | ||
10022 | jQuery .offset = { | |
10023 | se tOffset: f unction( e lem, optio ns, i ) { | |
10024 | var curP osition, c urLeft, cu rCSSTop, c urTop, cur Offset, cu rCSSLeft, calculateP osition, | |
10025 | posi tion = jQu ery.css( e lem, "posi tion" ), | |
10026 | curE lem = jQue ry( elem ) , | |
10027 | prop s = {}; | |
10028 | ||
10029 | // set p osition fi rst, in-ca se top/lef t are set even on st atic elem | |
10030 | if ( pos ition === "static" ) { | |
10031 | elem .style.pos ition = "r elative"; | |
10032 | } | |
10033 | ||
10034 | curOffse t = curEle m.offset() ; | |
10035 | curCSSTo p = jQuery .css( elem , "top" ); | |
10036 | curCSSLe ft = jQuer y.css( ele m, "left" ); | |
10037 | calculat ePosition = ( positi on === "ab solute" || position === "fixed " ) && | |
10038 | jQue ry.inArray ("auto", [ curCSSTop , curCSSLe ft ] ) > - 1; | |
10039 | ||
10040 | // need to be able to calcul ate positi on if eith er top or left is au to and pos ition is e ither abso lute or fi xed | |
10041 | if ( cal culatePosi tion ) { | |
10042 | curP osition = curElem.po sition(); | |
10043 | curT op = curPo sition.top ; | |
10044 | curL eft = curP osition.le ft; | |
10045 | } else { | |
10046 | curT op = parse Float( cur CSSTop ) | | 0; | |
10047 | curL eft = pars eFloat( cu rCSSLeft ) || 0; | |
10048 | } | |
10049 | ||
10050 | if ( jQu ery.isFunc tion( opti ons ) ) { | |
10051 | opti ons = opti ons.call( elem, i, c urOffset ) ; | |
10052 | } | |
10053 | ||
10054 | if ( opt ions.top ! = null ) { | |
10055 | prop s.top = ( options.to p - curOff set.top ) + curTop; | |
10056 | } | |
10057 | if ( opt ions.left != null ) { | |
10058 | prop s.left = ( options.l eft - curO ffset.left ) + curLe ft; | |
10059 | } | |
10060 | ||
10061 | if ( "us ing" in op tions ) { | |
10062 | opti ons.using. call( elem , props ); | |
10063 | } else { | |
10064 | curE lem.css( p rops ); | |
10065 | } | |
10066 | } | |
10067 | }; | |
10068 | ||
10069 | jQuery .fn.extend ({ | |
10070 | of fset: func tion( opti ons ) { | |
10071 | if ( arg uments.len gth ) { | |
10072 | retu rn options === undef ined ? | |
10073 | this : | |
10074 | this.each( function( i ) { | |
10075 | jQuery .offset.se tOffset( t his, optio ns, i ); | |
10076 | }); | |
10077 | } | |
10078 | ||
10079 | var docE lem, win, | |
10080 | box = { top: 0 , left: 0 }, | |
10081 | elem = this[ 0 ], | |
10082 | doc = elem && elem.owner Document; | |
10083 | ||
10084 | if ( !do c ) { | |
10085 | retu rn; | |
10086 | } | |
10087 | ||
10088 | docElem = doc.docu mentElemen t; | |
10089 | ||
10090 | // Make sure it's not a disc onnected D OM node | |
10091 | if ( !jQ uery.conta ins( docEl em, elem ) ) { | |
10092 | retu rn box; | |
10093 | } | |
10094 | ||
10095 | // If we don't hav e gBCR, ju st use 0,0 rather th an error | |
10096 | // Black Berry 5, i OS 3 (orig inal iPhon e) | |
10097 | if ( typ eof elem.g etBounding ClientRect !== strun defined ) { | |
10098 | box = elem.get BoundingCl ientRect() ; | |
10099 | } | |
10100 | win = ge tWindow( d oc ); | |
10101 | return { | |
10102 | top: box.top + ( win.pa geYOffset || docElem .scrollTop ) - ( do cElem.clie ntTop || 0 ), | |
10103 | left : box.left + ( win.p ageXOffset || docEle m.scrollLe ft ) - ( d ocElem.cli entLeft || 0 ) | |
10104 | }; | |
10105 | }, | |
10106 | ||
10107 | po sition: fu nction() { | |
10108 | if ( !th is[ 0 ] ) { | |
10109 | retu rn; | |
10110 | } | |
10111 | ||
10112 | var offs etParent, offset, | |
10113 | pare ntOffset = { top: 0, left: 0 } , | |
10114 | elem = this[ 0 ]; | |
10115 | ||
10116 | // fixed elements are offset from wind ow (parent Offset = { top:0, lef t: 0}, bec ause it is its only offset par ent | |
10117 | if ( jQu ery.css( e lem, "posi tion" ) == = "fixed" ) { | |
10118 | // w e assume t hat getBou ndingClien tRect is a vailable w hen comput ed positio n is fixed | |
10119 | offs et = elem. getBoundin gClientRec t(); | |
10120 | } else { | |
10121 | // G et *real* offsetPare nt | |
10122 | offs etParent = this.offs etParent() ; | |
10123 | ||
10124 | // G et correct offsets | |
10125 | offs et = this. offset(); | |
10126 | if ( !jQuery.n odeName( o ffsetParen t[ 0 ], "h tml" ) ) { | |
10127 | parentOffs et = offse tParent.of fset(); | |
10128 | } | |
10129 | ||
10130 | // A dd offsetP arent bord ers | |
10131 | pare ntOffset.t op += jQu ery.css( o ffsetParen t[ 0 ], "b orderTopWi dth", true ); | |
10132 | pare ntOffset.l eft += jQu ery.css( o ffsetParen t[ 0 ], "b orderLeftW idth", tru e ); | |
10133 | } | |
10134 | ||
10135 | // Subtr act parent offsets a nd element margins | |
10136 | // note: when an e lement has margin: a uto the of fsetLeft a nd marginL eft | |
10137 | // are t he same in Safari ca using offs et.left to incorrect ly be 0 | |
10138 | return { | |
10139 | top: offset.t op - pare ntOffset.t op - jQuer y.css( ele m, "margin Top", true ), | |
10140 | left : offset.l eft - pare ntOffset.l eft - jQue ry.css( el em, "margi nLeft", tr ue) | |
10141 | }; | |
10142 | }, | |
10143 | ||
10144 | of fsetParent : function () { | |
10145 | return t his.map(fu nction() { | |
10146 | var offsetPare nt = this. offsetPare nt || docE lem; | |
10147 | ||
10148 | whil e ( offset Parent && ( !jQuery. nodeName( offsetPare nt, "html" ) && jQue ry.css( of fsetParent , "positio n" ) === " static" ) ) { | |
10149 | offsetPare nt = offse tParent.of fsetParent ; | |
10150 | } | |
10151 | retu rn offsetP arent || d ocElem; | |
10152 | }); | |
10153 | } | |
10154 | }); | |
10155 | ||
10156 | // Create scrollLeft and scrol lTop metho ds | |
10157 | jQuery .each( { s crollLeft: "pageXOff set", scro llTop: "pa geYOffset" }, functi on( method , prop ) { | |
10158 | va r top = /Y /.test( pr op ); | |
10159 | ||
10160 | jQ uery.fn[ m ethod ] = function( val ) { | |
10161 | return a ccess( thi s, functio n( elem, m ethod, val ) { | |
10162 | var win = getW indow( ele m ); | |
10163 | ||
10164 | if ( val === u ndefined ) { | |
10165 | return win ? (prop i n win) ? w in[ prop ] : | |
10166 | win.do cument.doc umentEleme nt[ method ] : | |
10167 | elem[ method ]; | |
10168 | } | |
10169 | ||
10170 | if ( win ) { | |
10171 | win.scroll To( | |
10172 | !top ? val : jQu ery( win ) .scrollLef t(), | |
10173 | top ? val : jQue ry( win ). scrollTop( ) | |
10174 | ); | |
10175 | ||
10176 | } el se { | |
10177 | elem[ meth od ] = val ; | |
10178 | } | |
10179 | }, metho d, val, ar guments.le ngth, null ); | |
10180 | }; | |
10181 | }); | |
10182 | ||
10183 | // Add the top/left cssHooks u sing jQuer y.fn.posit ion | |
10184 | // Webkit bug: https ://bugs.we bkit.org/s how_bug.cg i?id=29084 | |
10185 | // getComp utedStyle returns pe rcent when specified for top/l eft/bottom /right | |
10186 | // rather than make the css mo dule depen d on the o ffset modu le, we jus t check fo r it here | |
10187 | jQuery .each( [ " top", "lef t" ], func tion( i, p rop ) { | |
10188 | jQ uery.cssHo oks[ prop ] = addGet HookIf( su pport.pixe lPosition, | |
10189 | function ( elem, co mputed ) { | |
10190 | if ( computed ) { | |
10191 | computed = curCSS( e lem, prop ); | |
10192 | // if curC SS returns percentag e, fallbac k to offse t | |
10193 | return rnu mnonpx.tes t( compute d ) ? | |
10194 | jQuery ( elem ).p osition()[ prop ] + "px" : | |
10195 | comput ed; | |
10196 | } | |
10197 | } | |
10198 | ); | |
10199 | }); | |
10200 | ||
10201 | ||
10202 | // Create innerHeigh t, innerWi dth, heigh t, width, outerHeigh t and oute rWidth met hods | |
10203 | jQuery .each( { H eight: "he ight", Wid th: "width " }, funct ion( name, type ) { | |
10204 | jQ uery.each( { padding : "inner" + name, co ntent: typ e, "": "ou ter" + nam e }, funct ion( defau ltExtra, f uncName ) { | |
10205 | // margi n is only for outerH eight, out erWidth | |
10206 | jQuery.f n[ funcNam e ] = func tion( marg in, value ) { | |
10207 | var chainable = argument s.length & & ( defaul tExtra || typeof mar gin !== "b oolean" ), | |
10208 | extra = de faultExtra || ( marg in === tru e || value === true ? "margin" : "border " ); | |
10209 | ||
10210 | retu rn access( this, fun ction( ele m, type, v alue ) { | |
10211 | var doc; | |
10212 | ||
10213 | if ( jQuer y.isWindow ( elem ) ) { | |
10214 | // As of 5/8/201 2 this wil l yield in correct re sults for Mobile Saf ari, but t here | |
10215 | // isn 't a whole lot we ca n do. See pull reque st at this URL for d iscussion: | |
10216 | // htt ps://githu b.com/jque ry/jquery/ pull/764 | |
10217 | return elem.docu ment.docum entElement [ "client" + name ]; | |
10218 | } | |
10219 | ||
10220 | // Get doc ument widt h or heigh t | |
10221 | if ( elem. nodeType = == 9 ) { | |
10222 | doc = elem.docum entElement ; | |
10223 | ||
10224 | // Eit her scroll [Width/Hei ght] or of fset[Width /Height] o r client[W idth/Heigh t], whiche ver is gre atest | |
10225 | // unf ortunately , this cau ses bug #3 838 in IE6 /8 only, b ut there i s currentl y no good, small way to fix it . | |
10226 | return Math.max( | |
10227 | el em.body[ " scroll" + name ], do c[ "scroll " + name ] , | |
10228 | el em.body[ " offset" + name ], do c[ "offset " + name ] , | |
10229 | do c[ "client " + name ] | |
10230 | ); | |
10231 | } | |
10232 | ||
10233 | return val ue === und efined ? | |
10234 | // Get width or height on the elemen t, request ing but no t forcing parseFloat | |
10235 | jQuery .css( elem , type, ex tra ) : | |
10236 | ||
10237 | // Set width or height on the elemen t | |
10238 | jQuery .style( el em, type, value, ext ra ); | |
10239 | }, t ype, chain able ? mar gin : unde fined, cha inable, nu ll ); | |
10240 | }; | |
10241 | }) ; | |
10242 | }); | |
10243 | ||
10244 | ||
10245 | // The num ber of ele ments cont ained in t he matched element s et | |
10246 | jQuery .fn.size = function( ) { | |
10247 | re turn this. length; | |
10248 | }; | |
10249 | ||
10250 | jQuery .fn.andSel f = jQuery .fn.addBac k; | |
10251 | ||
10252 | ||
10253 | ||
10254 | ||
10255 | // Registe r as a nam ed AMD mod ule, since jQuery ca n be conca tenated wi th other | |
10256 | // files t hat may us e define, but not vi a a proper concatena tion scrip t that | |
10257 | // underst ands anony mous AMD m odules. A named AMD is safest and most r obust | |
10258 | // way to register. Lowercase jquery is used becau se AMD mod ule names are | |
10259 | // derived from file names, an d jQuery i s normally delivered in a lowe rcase | |
10260 | // file na me. Do thi s after cr eating the global so that if a n AMD modu le wants | |
10261 | // to call noConflic t to hide this versi on of jQue ry, it wil l work. | |
10262 | ||
10263 | // Note th at for max imum porta bility, li braries th at are not jQuery sh ould | |
10264 | // declare themselve s as anony mous modul es, and av oid settin g a global if an | |
10265 | // AMD loa der is pre sent. jQue ry is a sp ecial case . For more informati on, see | |
10266 | // https:/ /github.co m/jrburke/ requirejs/ wiki/Updat ing-existi ng-librari es#wiki-an on | |
10267 | ||
10268 | if ( t ypeof defi ne === "fu nction" && define.am d ) { | |
10269 | de fine( "jqu ery", [], function() { | |
10270 | return j Query; | |
10271 | }) ; | |
10272 | } | |
10273 | ||
10274 | ||
10275 | ||
10276 | ||
10277 | var | |
10278 | // Map over jQue ry in case of overwr ite | |
10279 | _j Query = wi ndow.jQuer y, | |
10280 | ||
10281 | // Map over the $ in case of overwri te | |
10282 | _$ = window. $; | |
10283 | ||
10284 | jQuery .noConflic t = functi on( deep ) { | |
10285 | if ( window. $ === jQue ry ) { | |
10286 | window.$ = _$; | |
10287 | } | |
10288 | ||
10289 | if ( deep && window.jQ uery === j Query ) { | |
10290 | window.j Query = _j Query; | |
10291 | } | |
10292 | ||
10293 | re turn jQuer y; | |
10294 | }; | |
10295 | ||
10296 | // Expose jQuery and $ identif iers, even in | |
10297 | // AMD (#7 102#commen t:10, http s://github .com/jquer y/jquery/p ull/557) | |
10298 | // and Com monJS for browser em ulators (# 13566) | |
10299 | if ( t ypeof noGl obal === s trundefine d ) { | |
10300 | wi ndow.jQuer y = window .$ = jQuer y; | |
10301 | } | |
10302 | ||
10303 | ||
10304 | ||
10305 | ||
10306 | return jQuery; | |
10307 | ||
10308 | })); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.