|
1 /*eslint-disable no-unused-vars*/ |
|
2 /*! |
|
3 * jQuery JavaScript Library v3.1.0 |
|
4 * https://jquery.com/ |
|
5 * |
|
6 * Includes Sizzle.js |
|
7 * https://sizzlejs.com/ |
|
8 * |
|
9 * Copyright jQuery Foundation and other contributors |
|
10 * Released under the MIT license |
|
11 * https://jquery.org/license |
|
12 * |
|
13 * Date: 2016-07-07T21:44Z |
|
14 */ |
|
15 ( function( global, factory ) { |
|
16 |
|
17 "use strict"; |
|
18 |
|
19 if ( typeof module === "object" && typeof module.exports === "object" ) { |
|
20 |
|
21 // For CommonJS and CommonJS-like environments where a proper `window` |
|
22 // is present, execute the factory and get jQuery. |
|
23 // For environments that do not have a `window` with a `document` |
|
24 // (such as Node.js), expose a factory as module.exports. |
|
25 // This accentuates the need for the creation of a real `window`. |
|
26 // e.g. var jQuery = require("jquery")(window); |
|
27 // See ticket #14549 for more info. |
|
28 module.exports = global.document ? |
|
29 factory( global, true ) : |
|
30 function( w ) { |
|
31 if ( !w.document ) { |
|
32 throw new Error( "jQuery requires a window with a document" ); |
|
33 } |
|
34 return factory( w ); |
|
35 }; |
|
36 } else { |
|
37 factory( global ); |
|
38 } |
|
39 |
|
40 // Pass this if window is not defined yet |
|
41 } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { |
|
42 |
|
43 // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 |
|
44 // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode |
|
45 // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common |
|
46 // enough that all such attempts are guarded in a try block. |
|
47 "use strict"; |
|
48 |
|
49 var arr = []; |
|
50 |
|
51 var document = window.document; |
|
52 |
|
53 var getProto = Object.getPrototypeOf; |
|
54 |
|
55 var slice = arr.slice; |
|
56 |
|
57 var concat = arr.concat; |
|
58 |
|
59 var push = arr.push; |
|
60 |
|
61 var indexOf = arr.indexOf; |
|
62 |
|
63 var class2type = {}; |
|
64 |
|
65 var toString = class2type.toString; |
|
66 |
|
67 var hasOwn = class2type.hasOwnProperty; |
|
68 |
|
69 var fnToString = hasOwn.toString; |
|
70 |
|
71 var ObjectFunctionString = fnToString.call( Object ); |
|
72 |
|
73 var support = {}; |
|
74 |
|
75 |
|
76 |
|
77 function DOMEval( code, doc ) { |
|
78 doc = doc || document; |
|
79 |
|
80 var script = doc.createElement( "script" ); |
|
81 |
|
82 script.text = code; |
|
83 doc.head.appendChild( script ).parentNode.removeChild( script ); |
|
84 } |
|
85 /* global Symbol */ |
|
86 // Defining this global in .eslintrc would create a danger of using the global |
|
87 // unguarded in another place, it seems safer to define global only for this module |
|
88 |
|
89 |
|
90 |
|
91 var |
|
92 version = "3.1.0", |
|
93 |
|
94 // Define a local copy of jQuery |
|
95 jQuery = function( selector, context ) { |
|
96 |
|
97 // The jQuery object is actually just the init constructor 'enhanced' |
|
98 // Need init if jQuery is called (just allow error to be thrown if not included) |
|
99 return new jQuery.fn.init( selector, context ); |
|
100 }, |
|
101 |
|
102 // Support: Android <=4.0 only |
|
103 // Make sure we trim BOM and NBSP |
|
104 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, |
|
105 |
|
106 // Matches dashed string for camelizing |
|
107 rmsPrefix = /^-ms-/, |
|
108 rdashAlpha = /-([a-z])/g, |
|
109 |
|
110 // Used by jQuery.camelCase as callback to replace() |
|
111 fcamelCase = function( all, letter ) { |
|
112 return letter.toUpperCase(); |
|
113 }; |
|
114 |
|
115 jQuery.fn = jQuery.prototype = { |
|
116 |
|
117 // The current version of jQuery being used |
|
118 jquery: version, |
|
119 |
|
120 constructor: jQuery, |
|
121 |
|
122 // The default length of a jQuery object is 0 |
|
123 length: 0, |
|
124 |
|
125 toArray: function() { |
|
126 return slice.call( this ); |
|
127 }, |
|
128 |
|
129 // Get the Nth element in the matched element set OR |
|
130 // Get the whole matched element set as a clean array |
|
131 get: function( num ) { |
|
132 return num != null ? |
|
133 |
|
134 // Return just the one element from the set |
|
135 ( num < 0 ? this[ num + this.length ] : this[ num ] ) : |
|
136 |
|
137 // Return all the elements in a clean array |
|
138 slice.call( this ); |
|
139 }, |
|
140 |
|
141 // Take an array of elements and push it onto the stack |
|
142 // (returning the new matched element set) |
|
143 pushStack: function( elems ) { |
|
144 |
|
145 // Build a new jQuery matched element set |
|
146 var ret = jQuery.merge( this.constructor(), elems ); |
|
147 |
|
148 // Add the old object onto the stack (as a reference) |
|
149 ret.prevObject = this; |
|
150 |
|
151 // Return the newly-formed element set |
|
152 return ret; |
|
153 }, |
|
154 |
|
155 // Execute a callback for every element in the matched set. |
|
156 each: function( callback ) { |
|
157 return jQuery.each( this, callback ); |
|
158 }, |
|
159 |
|
160 map: function( callback ) { |
|
161 return this.pushStack( jQuery.map( this, function( elem, i ) { |
|
162 return callback.call( elem, i, elem ); |
|
163 } ) ); |
|
164 }, |
|
165 |
|
166 slice: function() { |
|
167 return this.pushStack( slice.apply( this, arguments ) ); |
|
168 }, |
|
169 |
|
170 first: function() { |
|
171 return this.eq( 0 ); |
|
172 }, |
|
173 |
|
174 last: function() { |
|
175 return this.eq( -1 ); |
|
176 }, |
|
177 |
|
178 eq: function( i ) { |
|
179 var len = this.length, |
|
180 j = +i + ( i < 0 ? len : 0 ); |
|
181 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); |
|
182 }, |
|
183 |
|
184 end: function() { |
|
185 return this.prevObject || this.constructor(); |
|
186 }, |
|
187 |
|
188 // For internal use only. |
|
189 // Behaves like an Array's method, not like a jQuery method. |
|
190 push: push, |
|
191 sort: arr.sort, |
|
192 splice: arr.splice |
|
193 }; |
|
194 |
|
195 jQuery.extend = jQuery.fn.extend = function() { |
|
196 var options, name, src, copy, copyIsArray, clone, |
|
197 target = arguments[ 0 ] || {}, |
|
198 i = 1, |
|
199 length = arguments.length, |
|
200 deep = false; |
|
201 |
|
202 // Handle a deep copy situation |
|
203 if ( typeof target === "boolean" ) { |
|
204 deep = target; |
|
205 |
|
206 // Skip the boolean and the target |
|
207 target = arguments[ i ] || {}; |
|
208 i++; |
|
209 } |
|
210 |
|
211 // Handle case when target is a string or something (possible in deep copy) |
|
212 if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { |
|
213 target = {}; |
|
214 } |
|
215 |
|
216 // Extend jQuery itself if only one argument is passed |
|
217 if ( i === length ) { |
|
218 target = this; |
|
219 i--; |
|
220 } |
|
221 |
|
222 for ( ; i < length; i++ ) { |
|
223 |
|
224 // Only deal with non-null/undefined values |
|
225 if ( ( options = arguments[ i ] ) != null ) { |
|
226 |
|
227 // Extend the base object |
|
228 for ( name in options ) { |
|
229 src = target[ name ]; |
|
230 copy = options[ name ]; |
|
231 |
|
232 // Prevent never-ending loop |
|
233 if ( target === copy ) { |
|
234 continue; |
|
235 } |
|
236 |
|
237 // Recurse if we're merging plain objects or arrays |
|
238 if ( deep && copy && ( jQuery.isPlainObject( copy ) || |
|
239 ( copyIsArray = jQuery.isArray( copy ) ) ) ) { |
|
240 |
|
241 if ( copyIsArray ) { |
|
242 copyIsArray = false; |
|
243 clone = src && jQuery.isArray( src ) ? src : []; |
|
244 |
|
245 } else { |
|
246 clone = src && jQuery.isPlainObject( src ) ? src : {}; |
|
247 } |
|
248 |
|
249 // Never move original objects, clone them |
|
250 target[ name ] = jQuery.extend( deep, clone, copy ); |
|
251 |
|
252 // Don't bring in undefined values |
|
253 } else if ( copy !== undefined ) { |
|
254 target[ name ] = copy; |
|
255 } |
|
256 } |
|
257 } |
|
258 } |
|
259 |
|
260 // Return the modified object |
|
261 return target; |
|
262 }; |
|
263 |
|
264 jQuery.extend( { |
|
265 |
|
266 // Unique for each copy of jQuery on the page |
|
267 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), |
|
268 |
|
269 // Assume jQuery is ready without the ready module |
|
270 isReady: true, |
|
271 |
|
272 error: function( msg ) { |
|
273 throw new Error( msg ); |
|
274 }, |
|
275 |
|
276 noop: function() {}, |
|
277 |
|
278 isFunction: function( obj ) { |
|
279 return jQuery.type( obj ) === "function"; |
|
280 }, |
|
281 |
|
282 isArray: Array.isArray, |
|
283 |
|
284 isWindow: function( obj ) { |
|
285 return obj != null && obj === obj.window; |
|
286 }, |
|
287 |
|
288 isNumeric: function( obj ) { |
|
289 |
|
290 // As of jQuery 3.0, isNumeric is limited to |
|
291 // strings and numbers (primitives or objects) |
|
292 // that can be coerced to finite numbers (gh-2662) |
|
293 var type = jQuery.type( obj ); |
|
294 return ( type === "number" || type === "string" ) && |
|
295 |
|
296 // parseFloat NaNs numeric-cast false positives ("") |
|
297 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") |
|
298 // subtraction forces infinities to NaN |
|
299 !isNaN( obj - parseFloat( obj ) ); |
|
300 }, |
|
301 |
|
302 isPlainObject: function( obj ) { |
|
303 var proto, Ctor; |
|
304 |
|
305 // Detect obvious negatives |
|
306 // Use toString instead of jQuery.type to catch host objects |
|
307 if ( !obj || toString.call( obj ) !== "[object Object]" ) { |
|
308 return false; |
|
309 } |
|
310 |
|
311 proto = getProto( obj ); |
|
312 |
|
313 // Objects with no prototype (e.g., `Object.create( null )`) are plain |
|
314 if ( !proto ) { |
|
315 return true; |
|
316 } |
|
317 |
|
318 // Objects with prototype are plain iff they were constructed by a global Object function |
|
319 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; |
|
320 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; |
|
321 }, |
|
322 |
|
323 isEmptyObject: function( obj ) { |
|
324 |
|
325 /* eslint-disable no-unused-vars */ |
|
326 // See https://github.com/eslint/eslint/issues/6125 |
|
327 var name; |
|
328 |
|
329 for ( name in obj ) { |
|
330 return false; |
|
331 } |
|
332 return true; |
|
333 }, |
|
334 |
|
335 type: function( obj ) { |
|
336 if ( obj == null ) { |
|
337 return obj + ""; |
|
338 } |
|
339 |
|
340 // Support: Android <=2.3 only (functionish RegExp) |
|
341 return typeof obj === "object" || typeof obj === "function" ? |
|
342 class2type[ toString.call( obj ) ] || "object" : |
|
343 typeof obj; |
|
344 }, |
|
345 |
|
346 // Evaluates a script in a global context |
|
347 globalEval: function( code ) { |
|
348 DOMEval( code ); |
|
349 }, |
|
350 |
|
351 // Convert dashed to camelCase; used by the css and data modules |
|
352 // Support: IE <=9 - 11, Edge 12 - 13 |
|
353 // Microsoft forgot to hump their vendor prefix (#9572) |
|
354 camelCase: function( string ) { |
|
355 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); |
|
356 }, |
|
357 |
|
358 nodeName: function( elem, name ) { |
|
359 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); |
|
360 }, |
|
361 |
|
362 each: function( obj, callback ) { |
|
363 var length, i = 0; |
|
364 |
|
365 if ( isArrayLike( obj ) ) { |
|
366 length = obj.length; |
|
367 for ( ; i < length; i++ ) { |
|
368 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { |
|
369 break; |
|
370 } |
|
371 } |
|
372 } else { |
|
373 for ( i in obj ) { |
|
374 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { |
|
375 break; |
|
376 } |
|
377 } |
|
378 } |
|
379 |
|
380 return obj; |
|
381 }, |
|
382 |
|
383 // Support: Android <=4.0 only |
|
384 trim: function( text ) { |
|
385 return text == null ? |
|
386 "" : |
|
387 ( text + "" ).replace( rtrim, "" ); |
|
388 }, |
|
389 |
|
390 // results is for internal usage only |
|
391 makeArray: function( arr, results ) { |
|
392 var ret = results || []; |
|
393 |
|
394 if ( arr != null ) { |
|
395 if ( isArrayLike( Object( arr ) ) ) { |
|
396 jQuery.merge( ret, |
|
397 typeof arr === "string" ? |
|
398 [ arr ] : arr |
|
399 ); |
|
400 } else { |
|
401 push.call( ret, arr ); |
|
402 } |
|
403 } |
|
404 |
|
405 return ret; |
|
406 }, |
|
407 |
|
408 inArray: function( elem, arr, i ) { |
|
409 return arr == null ? -1 : indexOf.call( arr, elem, i ); |
|
410 }, |
|
411 |
|
412 // Support: Android <=4.0 only, PhantomJS 1 only |
|
413 // push.apply(_, arraylike) throws on ancient WebKit |
|
414 merge: function( first, second ) { |
|
415 var len = +second.length, |
|
416 j = 0, |
|
417 i = first.length; |
|
418 |
|
419 for ( ; j < len; j++ ) { |
|
420 first[ i++ ] = second[ j ]; |
|
421 } |
|
422 |
|
423 first.length = i; |
|
424 |
|
425 return first; |
|
426 }, |
|
427 |
|
428 grep: function( elems, callback, invert ) { |
|
429 var callbackInverse, |
|
430 matches = [], |
|
431 i = 0, |
|
432 length = elems.length, |
|
433 callbackExpect = !invert; |
|
434 |
|
435 // Go through the array, only saving the items |
|
436 // that pass the validator function |
|
437 for ( ; i < length; i++ ) { |
|
438 callbackInverse = !callback( elems[ i ], i ); |
|
439 if ( callbackInverse !== callbackExpect ) { |
|
440 matches.push( elems[ i ] ); |
|
441 } |
|
442 } |
|
443 |
|
444 return matches; |
|
445 }, |
|
446 |
|
447 // arg is for internal usage only |
|
448 map: function( elems, callback, arg ) { |
|
449 var length, value, |
|
450 i = 0, |
|
451 ret = []; |
|
452 |
|
453 // Go through the array, translating each of the items to their new values |
|
454 if ( isArrayLike( elems ) ) { |
|
455 length = elems.length; |
|
456 for ( ; i < length; i++ ) { |
|
457 value = callback( elems[ i ], i, arg ); |
|
458 |
|
459 if ( value != null ) { |
|
460 ret.push( value ); |
|
461 } |
|
462 } |
|
463 |
|
464 // Go through every key on the object, |
|
465 } else { |
|
466 for ( i in elems ) { |
|
467 value = callback( elems[ i ], i, arg ); |
|
468 |
|
469 if ( value != null ) { |
|
470 ret.push( value ); |
|
471 } |
|
472 } |
|
473 } |
|
474 |
|
475 // Flatten any nested arrays |
|
476 return concat.apply( [], ret ); |
|
477 }, |
|
478 |
|
479 // A global GUID counter for objects |
|
480 guid: 1, |
|
481 |
|
482 // Bind a function to a context, optionally partially applying any |
|
483 // arguments. |
|
484 proxy: function( fn, context ) { |
|
485 var tmp, args, proxy; |
|
486 |
|
487 if ( typeof context === "string" ) { |
|
488 tmp = fn[ context ]; |
|
489 context = fn; |
|
490 fn = tmp; |
|
491 } |
|
492 |
|
493 // Quick check to determine if target is callable, in the spec |
|
494 // this throws a TypeError, but we will just return undefined. |
|
495 if ( !jQuery.isFunction( fn ) ) { |
|
496 return undefined; |
|
497 } |
|
498 |
|
499 // Simulated bind |
|
500 args = slice.call( arguments, 2 ); |
|
501 proxy = function() { |
|
502 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); |
|
503 }; |
|
504 |
|
505 // Set the guid of unique handler to the same of original handler, so it can be removed |
|
506 proxy.guid = fn.guid = fn.guid || jQuery.guid++; |
|
507 |
|
508 return proxy; |
|
509 }, |
|
510 |
|
511 now: Date.now, |
|
512 |
|
513 // jQuery.support is not used in Core but other projects attach their |
|
514 // properties to it so it needs to exist. |
|
515 support: support |
|
516 } ); |
|
517 |
|
518 if ( typeof Symbol === "function" ) { |
|
519 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; |
|
520 } |
|
521 |
|
522 // Populate the class2type map |
|
523 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), |
|
524 function( i, name ) { |
|
525 class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
|
526 } ); |
|
527 |
|
528 function isArrayLike( obj ) { |
|
529 |
|
530 // Support: real iOS 8.2 only (not reproducible in simulator) |
|
531 // `in` check used to prevent JIT error (gh-2145) |
|
532 // hasOwn isn't used here due to false negatives |
|
533 // regarding Nodelist length in IE |
|
534 var length = !!obj && "length" in obj && obj.length, |
|
535 type = jQuery.type( obj ); |
|
536 |
|
537 if ( type === "function" || jQuery.isWindow( obj ) ) { |
|
538 return false; |
|
539 } |
|
540 |
|
541 return type === "array" || length === 0 || |
|
542 typeof length === "number" && length > 0 && ( length - 1 ) in obj; |
|
543 } |
|
544 var Sizzle = |
|
545 /*! |
|
546 * Sizzle CSS Selector Engine v2.3.0 |
|
547 * https://sizzlejs.com/ |
|
548 * |
|
549 * Copyright jQuery Foundation and other contributors |
|
550 * Released under the MIT license |
|
551 * http://jquery.org/license |
|
552 * |
|
553 * Date: 2016-01-04 |
|
554 */ |
|
555 (function( window ) { |
|
556 |
|
557 var i, |
|
558 support, |
|
559 Expr, |
|
560 getText, |
|
561 isXML, |
|
562 tokenize, |
|
563 compile, |
|
564 select, |
|
565 outermostContext, |
|
566 sortInput, |
|
567 hasDuplicate, |
|
568 |
|
569 // Local document vars |
|
570 setDocument, |
|
571 document, |
|
572 docElem, |
|
573 documentIsHTML, |
|
574 rbuggyQSA, |
|
575 rbuggyMatches, |
|
576 matches, |
|
577 contains, |
|
578 |
|
579 // Instance-specific data |
|
580 expando = "sizzle" + 1 * new Date(), |
|
581 preferredDoc = window.document, |
|
582 dirruns = 0, |
|
583 done = 0, |
|
584 classCache = createCache(), |
|
585 tokenCache = createCache(), |
|
586 compilerCache = createCache(), |
|
587 sortOrder = function( a, b ) { |
|
588 if ( a === b ) { |
|
589 hasDuplicate = true; |
|
590 } |
|
591 return 0; |
|
592 }, |
|
593 |
|
594 // Instance methods |
|
595 hasOwn = ({}).hasOwnProperty, |
|
596 arr = [], |
|
597 pop = arr.pop, |
|
598 push_native = arr.push, |
|
599 push = arr.push, |
|
600 slice = arr.slice, |
|
601 // Use a stripped-down indexOf as it's faster than native |
|
602 // https://jsperf.com/thor-indexof-vs-for/5 |
|
603 indexOf = function( list, elem ) { |
|
604 var i = 0, |
|
605 len = list.length; |
|
606 for ( ; i < len; i++ ) { |
|
607 if ( list[i] === elem ) { |
|
608 return i; |
|
609 } |
|
610 } |
|
611 return -1; |
|
612 }, |
|
613 |
|
614 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", |
|
615 |
|
616 // Regular expressions |
|
617 |
|
618 // http://www.w3.org/TR/css3-selectors/#whitespace |
|
619 whitespace = "[\\x20\\t\\r\\n\\f]", |
|
620 |
|
621 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier |
|
622 identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+", |
|
623 |
|
624 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors |
|
625 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + |
|
626 // Operator (capture 2) |
|
627 "*([*^$|!~]?=)" + whitespace + |
|
628 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" |
|
629 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + |
|
630 "*\\]", |
|
631 |
|
632 pseudos = ":(" + identifier + ")(?:\\((" + |
|
633 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: |
|
634 // 1. quoted (capture 3; capture 4 or capture 5) |
|
635 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + |
|
636 // 2. simple (capture 6) |
|
637 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + |
|
638 // 3. anything else (capture 2) |
|
639 ".*" + |
|
640 ")\\)|)", |
|
641 |
|
642 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter |
|
643 rwhitespace = new RegExp( whitespace + "+", "g" ), |
|
644 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), |
|
645 |
|
646 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), |
|
647 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), |
|
648 |
|
649 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), |
|
650 |
|
651 rpseudo = new RegExp( pseudos ), |
|
652 ridentifier = new RegExp( "^" + identifier + "$" ), |
|
653 |
|
654 matchExpr = { |
|
655 "ID": new RegExp( "^#(" + identifier + ")" ), |
|
656 "CLASS": new RegExp( "^\\.(" + identifier + ")" ), |
|
657 "TAG": new RegExp( "^(" + identifier + "|[*])" ), |
|
658 "ATTR": new RegExp( "^" + attributes ), |
|
659 "PSEUDO": new RegExp( "^" + pseudos ), |
|
660 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + |
|
661 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + |
|
662 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), |
|
663 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), |
|
664 // For use in libraries implementing .is() |
|
665 // We use this for POS matching in `select` |
|
666 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + |
|
667 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) |
|
668 }, |
|
669 |
|
670 rinputs = /^(?:input|select|textarea|button)$/i, |
|
671 rheader = /^h\d$/i, |
|
672 |
|
673 rnative = /^[^{]+\{\s*\[native \w/, |
|
674 |
|
675 // Easily-parseable/retrievable ID or TAG or CLASS selectors |
|
676 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, |
|
677 |
|
678 rsibling = /[+~]/, |
|
679 |
|
680 // CSS escapes |
|
681 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters |
|
682 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), |
|
683 funescape = function( _, escaped, escapedWhitespace ) { |
|
684 var high = "0x" + escaped - 0x10000; |
|
685 // NaN means non-codepoint |
|
686 // Support: Firefox<24 |
|
687 // Workaround erroneous numeric interpretation of +"0x" |
|
688 return high !== high || escapedWhitespace ? |
|
689 escaped : |
|
690 high < 0 ? |
|
691 // BMP codepoint |
|
692 String.fromCharCode( high + 0x10000 ) : |
|
693 // Supplemental Plane codepoint (surrogate pair) |
|
694 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); |
|
695 }, |
|
696 |
|
697 // CSS string/identifier serialization |
|
698 // https://drafts.csswg.org/cssom/#common-serializing-idioms |
|
699 rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g, |
|
700 fcssescape = function( ch, asCodePoint ) { |
|
701 if ( asCodePoint ) { |
|
702 |
|
703 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER |
|
704 if ( ch === "\0" ) { |
|
705 return "\uFFFD"; |
|
706 } |
|
707 |
|
708 // Control characters and (dependent upon position) numbers get escaped as code points |
|
709 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; |
|
710 } |
|
711 |
|
712 // Other potentially-special ASCII characters get backslash-escaped |
|
713 return "\\" + ch; |
|
714 }, |
|
715 |
|
716 // Used for iframes |
|
717 // See setDocument() |
|
718 // Removing the function wrapper causes a "Permission Denied" |
|
719 // error in IE |
|
720 unloadHandler = function() { |
|
721 setDocument(); |
|
722 }, |
|
723 |
|
724 disabledAncestor = addCombinator( |
|
725 function( elem ) { |
|
726 return elem.disabled === true; |
|
727 }, |
|
728 { dir: "parentNode", next: "legend" } |
|
729 ); |
|
730 |
|
731 // Optimize for push.apply( _, NodeList ) |
|
732 try { |
|
733 push.apply( |
|
734 (arr = slice.call( preferredDoc.childNodes )), |
|
735 preferredDoc.childNodes |
|
736 ); |
|
737 // Support: Android<4.0 |
|
738 // Detect silently failing push.apply |
|
739 arr[ preferredDoc.childNodes.length ].nodeType; |
|
740 } catch ( e ) { |
|
741 push = { apply: arr.length ? |
|
742 |
|
743 // Leverage slice if possible |
|
744 function( target, els ) { |
|
745 push_native.apply( target, slice.call(els) ); |
|
746 } : |
|
747 |
|
748 // Support: IE<9 |
|
749 // Otherwise append directly |
|
750 function( target, els ) { |
|
751 var j = target.length, |
|
752 i = 0; |
|
753 // Can't trust NodeList.length |
|
754 while ( (target[j++] = els[i++]) ) {} |
|
755 target.length = j - 1; |
|
756 } |
|
757 }; |
|
758 } |
|
759 |
|
760 function Sizzle( selector, context, results, seed ) { |
|
761 var m, i, elem, nid, match, groups, newSelector, |
|
762 newContext = context && context.ownerDocument, |
|
763 |
|
764 // nodeType defaults to 9, since context defaults to document |
|
765 nodeType = context ? context.nodeType : 9; |
|
766 |
|
767 results = results || []; |
|
768 |
|
769 // Return early from calls with invalid selector or context |
|
770 if ( typeof selector !== "string" || !selector || |
|
771 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { |
|
772 |
|
773 return results; |
|
774 } |
|
775 |
|
776 // Try to shortcut find operations (as opposed to filters) in HTML documents |
|
777 if ( !seed ) { |
|
778 |
|
779 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { |
|
780 setDocument( context ); |
|
781 } |
|
782 context = context || document; |
|
783 |
|
784 if ( documentIsHTML ) { |
|
785 |
|
786 // If the selector is sufficiently simple, try using a "get*By*" DOM method |
|
787 // (excepting DocumentFragment context, where the methods don't exist) |
|
788 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { |
|
789 |
|
790 // ID selector |
|
791 if ( (m = match[1]) ) { |
|
792 |
|
793 // Document context |
|
794 if ( nodeType === 9 ) { |
|
795 if ( (elem = context.getElementById( m )) ) { |
|
796 |
|
797 // Support: IE, Opera, Webkit |
|
798 // TODO: identify versions |
|
799 // getElementById can match elements by name instead of ID |
|
800 if ( elem.id === m ) { |
|
801 results.push( elem ); |
|
802 return results; |
|
803 } |
|
804 } else { |
|
805 return results; |
|
806 } |
|
807 |
|
808 // Element context |
|
809 } else { |
|
810 |
|
811 // Support: IE, Opera, Webkit |
|
812 // TODO: identify versions |
|
813 // getElementById can match elements by name instead of ID |
|
814 if ( newContext && (elem = newContext.getElementById( m )) && |
|
815 contains( context, elem ) && |
|
816 elem.id === m ) { |
|
817 |
|
818 results.push( elem ); |
|
819 return results; |
|
820 } |
|
821 } |
|
822 |
|
823 // Type selector |
|
824 } else if ( match[2] ) { |
|
825 push.apply( results, context.getElementsByTagName( selector ) ); |
|
826 return results; |
|
827 |
|
828 // Class selector |
|
829 } else if ( (m = match[3]) && support.getElementsByClassName && |
|
830 context.getElementsByClassName ) { |
|
831 |
|
832 push.apply( results, context.getElementsByClassName( m ) ); |
|
833 return results; |
|
834 } |
|
835 } |
|
836 |
|
837 // Take advantage of querySelectorAll |
|
838 if ( support.qsa && |
|
839 !compilerCache[ selector + " " ] && |
|
840 (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { |
|
841 |
|
842 if ( nodeType !== 1 ) { |
|
843 newContext = context; |
|
844 newSelector = selector; |
|
845 |
|
846 // qSA looks outside Element context, which is not what we want |
|
847 // Thanks to Andrew Dupont for this workaround technique |
|
848 // Support: IE <=8 |
|
849 // Exclude object elements |
|
850 } else if ( context.nodeName.toLowerCase() !== "object" ) { |
|
851 |
|
852 // Capture the context ID, setting it first if necessary |
|
853 if ( (nid = context.getAttribute( "id" )) ) { |
|
854 nid = nid.replace( rcssescape, fcssescape ); |
|
855 } else { |
|
856 context.setAttribute( "id", (nid = expando) ); |
|
857 } |
|
858 |
|
859 // Prefix every selector in the list |
|
860 groups = tokenize( selector ); |
|
861 i = groups.length; |
|
862 while ( i-- ) { |
|
863 groups[i] = "#" + nid + " " + toSelector( groups[i] ); |
|
864 } |
|
865 newSelector = groups.join( "," ); |
|
866 |
|
867 // Expand context for sibling selectors |
|
868 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || |
|
869 context; |
|
870 } |
|
871 |
|
872 if ( newSelector ) { |
|
873 try { |
|
874 push.apply( results, |
|
875 newContext.querySelectorAll( newSelector ) |
|
876 ); |
|
877 return results; |
|
878 } catch ( qsaError ) { |
|
879 } finally { |
|
880 if ( nid === expando ) { |
|
881 context.removeAttribute( "id" ); |
|
882 } |
|
883 } |
|
884 } |
|
885 } |
|
886 } |
|
887 } |
|
888 |
|
889 // All others |
|
890 return select( selector.replace( rtrim, "$1" ), context, results, seed ); |
|
891 } |
|
892 |
|
893 /** |
|
894 * Create key-value caches of limited size |
|
895 * @returns {function(string, object)} Returns the Object data after storing it on itself with |
|
896 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) |
|
897 * deleting the oldest entry |
|
898 */ |
|
899 function createCache() { |
|
900 var keys = []; |
|
901 |
|
902 function cache( key, value ) { |
|
903 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) |
|
904 if ( keys.push( key + " " ) > Expr.cacheLength ) { |
|
905 // Only keep the most recent entries |
|
906 delete cache[ keys.shift() ]; |
|
907 } |
|
908 return (cache[ key + " " ] = value); |
|
909 } |
|
910 return cache; |
|
911 } |
|
912 |
|
913 /** |
|
914 * Mark a function for special use by Sizzle |
|
915 * @param {Function} fn The function to mark |
|
916 */ |
|
917 function markFunction( fn ) { |
|
918 fn[ expando ] = true; |
|
919 return fn; |
|
920 } |
|
921 |
|
922 /** |
|
923 * Support testing using an element |
|
924 * @param {Function} fn Passed the created element and returns a boolean result |
|
925 */ |
|
926 function assert( fn ) { |
|
927 var el = document.createElement("fieldset"); |
|
928 |
|
929 try { |
|
930 return !!fn( el ); |
|
931 } catch (e) { |
|
932 return false; |
|
933 } finally { |
|
934 // Remove from its parent by default |
|
935 if ( el.parentNode ) { |
|
936 el.parentNode.removeChild( el ); |
|
937 } |
|
938 // release memory in IE |
|
939 el = null; |
|
940 } |
|
941 } |
|
942 |
|
943 /** |
|
944 * Adds the same handler for all of the specified attrs |
|
945 * @param {String} attrs Pipe-separated list of attributes |
|
946 * @param {Function} handler The method that will be applied |
|
947 */ |
|
948 function addHandle( attrs, handler ) { |
|
949 var arr = attrs.split("|"), |
|
950 i = arr.length; |
|
951 |
|
952 while ( i-- ) { |
|
953 Expr.attrHandle[ arr[i] ] = handler; |
|
954 } |
|
955 } |
|
956 |
|
957 /** |
|
958 * Checks document order of two siblings |
|
959 * @param {Element} a |
|
960 * @param {Element} b |
|
961 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
|
962 */ |
|
963 function siblingCheck( a, b ) { |
|
964 var cur = b && a, |
|
965 diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
|
966 a.sourceIndex - b.sourceIndex; |
|
967 |
|
968 // Use IE sourceIndex if available on both nodes |
|
969 if ( diff ) { |
|
970 return diff; |
|
971 } |
|
972 |
|
973 // Check if b follows a |
|
974 if ( cur ) { |
|
975 while ( (cur = cur.nextSibling) ) { |
|
976 if ( cur === b ) { |
|
977 return -1; |
|
978 } |
|
979 } |
|
980 } |
|
981 |
|
982 return a ? 1 : -1; |
|
983 } |
|
984 |
|
985 /** |
|
986 * Returns a function to use in pseudos for input types |
|
987 * @param {String} type |
|
988 */ |
|
989 function createInputPseudo( type ) { |
|
990 return function( elem ) { |
|
991 var name = elem.nodeName.toLowerCase(); |
|
992 return name === "input" && elem.type === type; |
|
993 }; |
|
994 } |
|
995 |
|
996 /** |
|
997 * Returns a function to use in pseudos for buttons |
|
998 * @param {String} type |
|
999 */ |
|
1000 function createButtonPseudo( type ) { |
|
1001 return function( elem ) { |
|
1002 var name = elem.nodeName.toLowerCase(); |
|
1003 return (name === "input" || name === "button") && elem.type === type; |
|
1004 }; |
|
1005 } |
|
1006 |
|
1007 /** |
|
1008 * Returns a function to use in pseudos for :enabled/:disabled |
|
1009 * @param {Boolean} disabled true for :disabled; false for :enabled |
|
1010 */ |
|
1011 function createDisabledPseudo( disabled ) { |
|
1012 // Known :disabled false positives: |
|
1013 // IE: *[disabled]:not(button, input, select, textarea, optgroup, option, menuitem, fieldset) |
|
1014 // not IE: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable |
|
1015 return function( elem ) { |
|
1016 |
|
1017 // Check form elements and option elements for explicit disabling |
|
1018 return "label" in elem && elem.disabled === disabled || |
|
1019 "form" in elem && elem.disabled === disabled || |
|
1020 |
|
1021 // Check non-disabled form elements for fieldset[disabled] ancestors |
|
1022 "form" in elem && elem.disabled === false && ( |
|
1023 // Support: IE6-11+ |
|
1024 // Ancestry is covered for us |
|
1025 elem.isDisabled === disabled || |
|
1026 |
|
1027 // Otherwise, assume any non-<option> under fieldset[disabled] is disabled |
|
1028 /* jshint -W018 */ |
|
1029 elem.isDisabled !== !disabled && |
|
1030 ("label" in elem || !disabledAncestor( elem )) !== disabled |
|
1031 ); |
|
1032 }; |
|
1033 } |
|
1034 |
|
1035 /** |
|
1036 * Returns a function to use in pseudos for positionals |
|
1037 * @param {Function} fn |
|
1038 */ |
|
1039 function createPositionalPseudo( fn ) { |
|
1040 return markFunction(function( argument ) { |
|
1041 argument = +argument; |
|
1042 return markFunction(function( seed, matches ) { |
|
1043 var j, |
|
1044 matchIndexes = fn( [], seed.length, argument ), |
|
1045 i = matchIndexes.length; |
|
1046 |
|
1047 // Match elements found at the specified indexes |
|
1048 while ( i-- ) { |
|
1049 if ( seed[ (j = matchIndexes[i]) ] ) { |
|
1050 seed[j] = !(matches[j] = seed[j]); |
|
1051 } |
|
1052 } |
|
1053 }); |
|
1054 }); |
|
1055 } |
|
1056 |
|
1057 /** |
|
1058 * Checks a node for validity as a Sizzle context |
|
1059 * @param {Element|Object=} context |
|
1060 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value |
|
1061 */ |
|
1062 function testContext( context ) { |
|
1063 return context && typeof context.getElementsByTagName !== "undefined" && context; |
|
1064 } |
|
1065 |
|
1066 // Expose support vars for convenience |
|
1067 support = Sizzle.support = {}; |
|
1068 |
|
1069 /** |
|
1070 * Detects XML nodes |
|
1071 * @param {Element|Object} elem An element or a document |
|
1072 * @returns {Boolean} True iff elem is a non-HTML XML node |
|
1073 */ |
|
1074 isXML = Sizzle.isXML = function( elem ) { |
|
1075 // documentElement is verified for cases where it doesn't yet exist |
|
1076 // (such as loading iframes in IE - #4833) |
|
1077 var documentElement = elem && (elem.ownerDocument || elem).documentElement; |
|
1078 return documentElement ? documentElement.nodeName !== "HTML" : false; |
|
1079 }; |
|
1080 |
|
1081 /** |
|
1082 * Sets document-related variables once based on the current document |
|
1083 * @param {Element|Object} [doc] An element or document object to use to set the document |
|
1084 * @returns {Object} Returns the current document |
|
1085 */ |
|
1086 setDocument = Sizzle.setDocument = function( node ) { |
|
1087 var hasCompare, subWindow, |
|
1088 doc = node ? node.ownerDocument || node : preferredDoc; |
|
1089 |
|
1090 // Return early if doc is invalid or already selected |
|
1091 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { |
|
1092 return document; |
|
1093 } |
|
1094 |
|
1095 // Update global variables |
|
1096 document = doc; |
|
1097 docElem = document.documentElement; |
|
1098 documentIsHTML = !isXML( document ); |
|
1099 |
|
1100 // Support: IE 9-11, Edge |
|
1101 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) |
|
1102 if ( preferredDoc !== document && |
|
1103 (subWindow = document.defaultView) && subWindow.top !== subWindow ) { |
|
1104 |
|
1105 // Support: IE 11, Edge |
|
1106 if ( subWindow.addEventListener ) { |
|
1107 subWindow.addEventListener( "unload", unloadHandler, false ); |
|
1108 |
|
1109 // Support: IE 9 - 10 only |
|
1110 } else if ( subWindow.attachEvent ) { |
|
1111 subWindow.attachEvent( "onunload", unloadHandler ); |
|
1112 } |
|
1113 } |
|
1114 |
|
1115 /* Attributes |
|
1116 ---------------------------------------------------------------------- */ |
|
1117 |
|
1118 // Support: IE<8 |
|
1119 // Verify that getAttribute really returns attributes and not properties |
|
1120 // (excepting IE8 booleans) |
|
1121 support.attributes = assert(function( el ) { |
|
1122 el.className = "i"; |
|
1123 return !el.getAttribute("className"); |
|
1124 }); |
|
1125 |
|
1126 /* getElement(s)By* |
|
1127 ---------------------------------------------------------------------- */ |
|
1128 |
|
1129 // Check if getElementsByTagName("*") returns only elements |
|
1130 support.getElementsByTagName = assert(function( el ) { |
|
1131 el.appendChild( document.createComment("") ); |
|
1132 return !el.getElementsByTagName("*").length; |
|
1133 }); |
|
1134 |
|
1135 // Support: IE<9 |
|
1136 support.getElementsByClassName = rnative.test( document.getElementsByClassName ); |
|
1137 |
|
1138 // Support: IE<10 |
|
1139 // Check if getElementById returns elements by name |
|
1140 // The broken getElementById methods don't pick up programmatically-set names, |
|
1141 // so use a roundabout getElementsByName test |
|
1142 support.getById = assert(function( el ) { |
|
1143 docElem.appendChild( el ).id = expando; |
|
1144 return !document.getElementsByName || !document.getElementsByName( expando ).length; |
|
1145 }); |
|
1146 |
|
1147 // ID find and filter |
|
1148 if ( support.getById ) { |
|
1149 Expr.find["ID"] = function( id, context ) { |
|
1150 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
|
1151 var m = context.getElementById( id ); |
|
1152 return m ? [ m ] : []; |
|
1153 } |
|
1154 }; |
|
1155 Expr.filter["ID"] = function( id ) { |
|
1156 var attrId = id.replace( runescape, funescape ); |
|
1157 return function( elem ) { |
|
1158 return elem.getAttribute("id") === attrId; |
|
1159 }; |
|
1160 }; |
|
1161 } else { |
|
1162 // Support: IE6/7 |
|
1163 // getElementById is not reliable as a find shortcut |
|
1164 delete Expr.find["ID"]; |
|
1165 |
|
1166 Expr.filter["ID"] = function( id ) { |
|
1167 var attrId = id.replace( runescape, funescape ); |
|
1168 return function( elem ) { |
|
1169 var node = typeof elem.getAttributeNode !== "undefined" && |
|
1170 elem.getAttributeNode("id"); |
|
1171 return node && node.value === attrId; |
|
1172 }; |
|
1173 }; |
|
1174 } |
|
1175 |
|
1176 // Tag |
|
1177 Expr.find["TAG"] = support.getElementsByTagName ? |
|
1178 function( tag, context ) { |
|
1179 if ( typeof context.getElementsByTagName !== "undefined" ) { |
|
1180 return context.getElementsByTagName( tag ); |
|
1181 |
|
1182 // DocumentFragment nodes don't have gEBTN |
|
1183 } else if ( support.qsa ) { |
|
1184 return context.querySelectorAll( tag ); |
|
1185 } |
|
1186 } : |
|
1187 |
|
1188 function( tag, context ) { |
|
1189 var elem, |
|
1190 tmp = [], |
|
1191 i = 0, |
|
1192 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too |
|
1193 results = context.getElementsByTagName( tag ); |
|
1194 |
|
1195 // Filter out possible comments |
|
1196 if ( tag === "*" ) { |
|
1197 while ( (elem = results[i++]) ) { |
|
1198 if ( elem.nodeType === 1 ) { |
|
1199 tmp.push( elem ); |
|
1200 } |
|
1201 } |
|
1202 |
|
1203 return tmp; |
|
1204 } |
|
1205 return results; |
|
1206 }; |
|
1207 |
|
1208 // Class |
|
1209 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { |
|
1210 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { |
|
1211 return context.getElementsByClassName( className ); |
|
1212 } |
|
1213 }; |
|
1214 |
|
1215 /* QSA/matchesSelector |
|
1216 ---------------------------------------------------------------------- */ |
|
1217 |
|
1218 // QSA and matchesSelector support |
|
1219 |
|
1220 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) |
|
1221 rbuggyMatches = []; |
|
1222 |
|
1223 // qSa(:focus) reports false when true (Chrome 21) |
|
1224 // We allow this because of a bug in IE8/9 that throws an error |
|
1225 // whenever `document.activeElement` is accessed on an iframe |
|
1226 // So, we allow :focus to pass through QSA all the time to avoid the IE error |
|
1227 // See https://bugs.jquery.com/ticket/13378 |
|
1228 rbuggyQSA = []; |
|
1229 |
|
1230 if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { |
|
1231 // Build QSA regex |
|
1232 // Regex strategy adopted from Diego Perini |
|
1233 assert(function( el ) { |
|
1234 // Select is set to empty string on purpose |
|
1235 // This is to test IE's treatment of not explicitly |
|
1236 // setting a boolean content attribute, |
|
1237 // since its presence should be enough |
|
1238 // https://bugs.jquery.com/ticket/12359 |
|
1239 docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" + |
|
1240 "<select id='" + expando + "-\r\\' msallowcapture=''>" + |
|
1241 "<option selected=''></option></select>"; |
|
1242 |
|
1243 // Support: IE8, Opera 11-12.16 |
|
1244 // Nothing should be selected when empty strings follow ^= or $= or *= |
|
1245 // The test attribute must be unknown in Opera but "safe" for WinRT |
|
1246 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section |
|
1247 if ( el.querySelectorAll("[msallowcapture^='']").length ) { |
|
1248 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); |
|
1249 } |
|
1250 |
|
1251 // Support: IE8 |
|
1252 // Boolean attributes and "value" are not treated correctly |
|
1253 if ( !el.querySelectorAll("[selected]").length ) { |
|
1254 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); |
|
1255 } |
|
1256 |
|
1257 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ |
|
1258 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { |
|
1259 rbuggyQSA.push("~="); |
|
1260 } |
|
1261 |
|
1262 // Webkit/Opera - :checked should return selected option elements |
|
1263 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
|
1264 // IE8 throws error here and will not see later tests |
|
1265 if ( !el.querySelectorAll(":checked").length ) { |
|
1266 rbuggyQSA.push(":checked"); |
|
1267 } |
|
1268 |
|
1269 // Support: Safari 8+, iOS 8+ |
|
1270 // https://bugs.webkit.org/show_bug.cgi?id=136851 |
|
1271 // In-page `selector#id sibling-combinator selector` fails |
|
1272 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { |
|
1273 rbuggyQSA.push(".#.+[+~]"); |
|
1274 } |
|
1275 }); |
|
1276 |
|
1277 assert(function( el ) { |
|
1278 el.innerHTML = "<a href='' disabled='disabled'></a>" + |
|
1279 "<select disabled='disabled'><option/></select>"; |
|
1280 |
|
1281 // Support: Windows 8 Native Apps |
|
1282 // The type and name attributes are restricted during .innerHTML assignment |
|
1283 var input = document.createElement("input"); |
|
1284 input.setAttribute( "type", "hidden" ); |
|
1285 el.appendChild( input ).setAttribute( "name", "D" ); |
|
1286 |
|
1287 // Support: IE8 |
|
1288 // Enforce case-sensitivity of name attribute |
|
1289 if ( el.querySelectorAll("[name=d]").length ) { |
|
1290 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); |
|
1291 } |
|
1292 |
|
1293 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) |
|
1294 // IE8 throws error here and will not see later tests |
|
1295 if ( el.querySelectorAll(":enabled").length !== 2 ) { |
|
1296 rbuggyQSA.push( ":enabled", ":disabled" ); |
|
1297 } |
|
1298 |
|
1299 // Support: IE9-11+ |
|
1300 // IE's :disabled selector does not pick up the children of disabled fieldsets |
|
1301 docElem.appendChild( el ).disabled = true; |
|
1302 if ( el.querySelectorAll(":disabled").length !== 2 ) { |
|
1303 rbuggyQSA.push( ":enabled", ":disabled" ); |
|
1304 } |
|
1305 |
|
1306 // Opera 10-11 does not throw on post-comma invalid pseudos |
|
1307 el.querySelectorAll("*,:x"); |
|
1308 rbuggyQSA.push(",.*:"); |
|
1309 }); |
|
1310 } |
|
1311 |
|
1312 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || |
|
1313 docElem.webkitMatchesSelector || |
|
1314 docElem.mozMatchesSelector || |
|
1315 docElem.oMatchesSelector || |
|
1316 docElem.msMatchesSelector) )) ) { |
|
1317 |
|
1318 assert(function( el ) { |
|
1319 // Check to see if it's possible to do matchesSelector |
|
1320 // on a disconnected node (IE 9) |
|
1321 support.disconnectedMatch = matches.call( el, "*" ); |
|
1322 |
|
1323 // This should fail with an exception |
|
1324 // Gecko does not error, returns false instead |
|
1325 matches.call( el, "[s!='']:x" ); |
|
1326 rbuggyMatches.push( "!=", pseudos ); |
|
1327 }); |
|
1328 } |
|
1329 |
|
1330 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); |
|
1331 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); |
|
1332 |
|
1333 /* Contains |
|
1334 ---------------------------------------------------------------------- */ |
|
1335 hasCompare = rnative.test( docElem.compareDocumentPosition ); |
|
1336 |
|
1337 // Element contains another |
|
1338 // Purposefully self-exclusive |
|
1339 // As in, an element does not contain itself |
|
1340 contains = hasCompare || rnative.test( docElem.contains ) ? |
|
1341 function( a, b ) { |
|
1342 var adown = a.nodeType === 9 ? a.documentElement : a, |
|
1343 bup = b && b.parentNode; |
|
1344 return a === bup || !!( bup && bup.nodeType === 1 && ( |
|
1345 adown.contains ? |
|
1346 adown.contains( bup ) : |
|
1347 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 |
|
1348 )); |
|
1349 } : |
|
1350 function( a, b ) { |
|
1351 if ( b ) { |
|
1352 while ( (b = b.parentNode) ) { |
|
1353 if ( b === a ) { |
|
1354 return true; |
|
1355 } |
|
1356 } |
|
1357 } |
|
1358 return false; |
|
1359 }; |
|
1360 |
|
1361 /* Sorting |
|
1362 ---------------------------------------------------------------------- */ |
|
1363 |
|
1364 // Document order sorting |
|
1365 sortOrder = hasCompare ? |
|
1366 function( a, b ) { |
|
1367 |
|
1368 // Flag for duplicate removal |
|
1369 if ( a === b ) { |
|
1370 hasDuplicate = true; |
|
1371 return 0; |
|
1372 } |
|
1373 |
|
1374 // Sort on method existence if only one input has compareDocumentPosition |
|
1375 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; |
|
1376 if ( compare ) { |
|
1377 return compare; |
|
1378 } |
|
1379 |
|
1380 // Calculate position if both inputs belong to the same document |
|
1381 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? |
|
1382 a.compareDocumentPosition( b ) : |
|
1383 |
|
1384 // Otherwise we know they are disconnected |
|
1385 1; |
|
1386 |
|
1387 // Disconnected nodes |
|
1388 if ( compare & 1 || |
|
1389 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { |
|
1390 |
|
1391 // Choose the first element that is related to our preferred document |
|
1392 if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { |
|
1393 return -1; |
|
1394 } |
|
1395 if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { |
|
1396 return 1; |
|
1397 } |
|
1398 |
|
1399 // Maintain original order |
|
1400 return sortInput ? |
|
1401 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
|
1402 0; |
|
1403 } |
|
1404 |
|
1405 return compare & 4 ? -1 : 1; |
|
1406 } : |
|
1407 function( a, b ) { |
|
1408 // Exit early if the nodes are identical |
|
1409 if ( a === b ) { |
|
1410 hasDuplicate = true; |
|
1411 return 0; |
|
1412 } |
|
1413 |
|
1414 var cur, |
|
1415 i = 0, |
|
1416 aup = a.parentNode, |
|
1417 bup = b.parentNode, |
|
1418 ap = [ a ], |
|
1419 bp = [ b ]; |
|
1420 |
|
1421 // Parentless nodes are either documents or disconnected |
|
1422 if ( !aup || !bup ) { |
|
1423 return a === document ? -1 : |
|
1424 b === document ? 1 : |
|
1425 aup ? -1 : |
|
1426 bup ? 1 : |
|
1427 sortInput ? |
|
1428 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
|
1429 0; |
|
1430 |
|
1431 // If the nodes are siblings, we can do a quick check |
|
1432 } else if ( aup === bup ) { |
|
1433 return siblingCheck( a, b ); |
|
1434 } |
|
1435 |
|
1436 // Otherwise we need full lists of their ancestors for comparison |
|
1437 cur = a; |
|
1438 while ( (cur = cur.parentNode) ) { |
|
1439 ap.unshift( cur ); |
|
1440 } |
|
1441 cur = b; |
|
1442 while ( (cur = cur.parentNode) ) { |
|
1443 bp.unshift( cur ); |
|
1444 } |
|
1445 |
|
1446 // Walk down the tree looking for a discrepancy |
|
1447 while ( ap[i] === bp[i] ) { |
|
1448 i++; |
|
1449 } |
|
1450 |
|
1451 return i ? |
|
1452 // Do a sibling check if the nodes have a common ancestor |
|
1453 siblingCheck( ap[i], bp[i] ) : |
|
1454 |
|
1455 // Otherwise nodes in our document sort first |
|
1456 ap[i] === preferredDoc ? -1 : |
|
1457 bp[i] === preferredDoc ? 1 : |
|
1458 0; |
|
1459 }; |
|
1460 |
|
1461 return document; |
|
1462 }; |
|
1463 |
|
1464 Sizzle.matches = function( expr, elements ) { |
|
1465 return Sizzle( expr, null, null, elements ); |
|
1466 }; |
|
1467 |
|
1468 Sizzle.matchesSelector = function( elem, expr ) { |
|
1469 // Set document vars if needed |
|
1470 if ( ( elem.ownerDocument || elem ) !== document ) { |
|
1471 setDocument( elem ); |
|
1472 } |
|
1473 |
|
1474 // Make sure that attribute selectors are quoted |
|
1475 expr = expr.replace( rattributeQuotes, "='$1']" ); |
|
1476 |
|
1477 if ( support.matchesSelector && documentIsHTML && |
|
1478 !compilerCache[ expr + " " ] && |
|
1479 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && |
|
1480 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { |
|
1481 |
|
1482 try { |
|
1483 var ret = matches.call( elem, expr ); |
|
1484 |
|
1485 // IE 9's matchesSelector returns false on disconnected nodes |
|
1486 if ( ret || support.disconnectedMatch || |
|
1487 // As well, disconnected nodes are said to be in a document |
|
1488 // fragment in IE 9 |
|
1489 elem.document && elem.document.nodeType !== 11 ) { |
|
1490 return ret; |
|
1491 } |
|
1492 } catch (e) {} |
|
1493 } |
|
1494 |
|
1495 return Sizzle( expr, document, null, [ elem ] ).length > 0; |
|
1496 }; |
|
1497 |
|
1498 Sizzle.contains = function( context, elem ) { |
|
1499 // Set document vars if needed |
|
1500 if ( ( context.ownerDocument || context ) !== document ) { |
|
1501 setDocument( context ); |
|
1502 } |
|
1503 return contains( context, elem ); |
|
1504 }; |
|
1505 |
|
1506 Sizzle.attr = function( elem, name ) { |
|
1507 // Set document vars if needed |
|
1508 if ( ( elem.ownerDocument || elem ) !== document ) { |
|
1509 setDocument( elem ); |
|
1510 } |
|
1511 |
|
1512 var fn = Expr.attrHandle[ name.toLowerCase() ], |
|
1513 // Don't get fooled by Object.prototype properties (jQuery #13807) |
|
1514 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? |
|
1515 fn( elem, name, !documentIsHTML ) : |
|
1516 undefined; |
|
1517 |
|
1518 return val !== undefined ? |
|
1519 val : |
|
1520 support.attributes || !documentIsHTML ? |
|
1521 elem.getAttribute( name ) : |
|
1522 (val = elem.getAttributeNode(name)) && val.specified ? |
|
1523 val.value : |
|
1524 null; |
|
1525 }; |
|
1526 |
|
1527 Sizzle.escape = function( sel ) { |
|
1528 return (sel + "").replace( rcssescape, fcssescape ); |
|
1529 }; |
|
1530 |
|
1531 Sizzle.error = function( msg ) { |
|
1532 throw new Error( "Syntax error, unrecognized expression: " + msg ); |
|
1533 }; |
|
1534 |
|
1535 /** |
|
1536 * Document sorting and removing duplicates |
|
1537 * @param {ArrayLike} results |
|
1538 */ |
|
1539 Sizzle.uniqueSort = function( results ) { |
|
1540 var elem, |
|
1541 duplicates = [], |
|
1542 j = 0, |
|
1543 i = 0; |
|
1544 |
|
1545 // Unless we *know* we can detect duplicates, assume their presence |
|
1546 hasDuplicate = !support.detectDuplicates; |
|
1547 sortInput = !support.sortStable && results.slice( 0 ); |
|
1548 results.sort( sortOrder ); |
|
1549 |
|
1550 if ( hasDuplicate ) { |
|
1551 while ( (elem = results[i++]) ) { |
|
1552 if ( elem === results[ i ] ) { |
|
1553 j = duplicates.push( i ); |
|
1554 } |
|
1555 } |
|
1556 while ( j-- ) { |
|
1557 results.splice( duplicates[ j ], 1 ); |
|
1558 } |
|
1559 } |
|
1560 |
|
1561 // Clear input after sorting to release objects |
|
1562 // See https://github.com/jquery/sizzle/pull/225 |
|
1563 sortInput = null; |
|
1564 |
|
1565 return results; |
|
1566 }; |
|
1567 |
|
1568 /** |
|
1569 * Utility function for retrieving the text value of an array of DOM nodes |
|
1570 * @param {Array|Element} elem |
|
1571 */ |
|
1572 getText = Sizzle.getText = function( elem ) { |
|
1573 var node, |
|
1574 ret = "", |
|
1575 i = 0, |
|
1576 nodeType = elem.nodeType; |
|
1577 |
|
1578 if ( !nodeType ) { |
|
1579 // If no nodeType, this is expected to be an array |
|
1580 while ( (node = elem[i++]) ) { |
|
1581 // Do not traverse comment nodes |
|
1582 ret += getText( node ); |
|
1583 } |
|
1584 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { |
|
1585 // Use textContent for elements |
|
1586 // innerText usage removed for consistency of new lines (jQuery #11153) |
|
1587 if ( typeof elem.textContent === "string" ) { |
|
1588 return elem.textContent; |
|
1589 } else { |
|
1590 // Traverse its children |
|
1591 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
|
1592 ret += getText( elem ); |
|
1593 } |
|
1594 } |
|
1595 } else if ( nodeType === 3 || nodeType === 4 ) { |
|
1596 return elem.nodeValue; |
|
1597 } |
|
1598 // Do not include comment or processing instruction nodes |
|
1599 |
|
1600 return ret; |
|
1601 }; |
|
1602 |
|
1603 Expr = Sizzle.selectors = { |
|
1604 |
|
1605 // Can be adjusted by the user |
|
1606 cacheLength: 50, |
|
1607 |
|
1608 createPseudo: markFunction, |
|
1609 |
|
1610 match: matchExpr, |
|
1611 |
|
1612 attrHandle: {}, |
|
1613 |
|
1614 find: {}, |
|
1615 |
|
1616 relative: { |
|
1617 ">": { dir: "parentNode", first: true }, |
|
1618 " ": { dir: "parentNode" }, |
|
1619 "+": { dir: "previousSibling", first: true }, |
|
1620 "~": { dir: "previousSibling" } |
|
1621 }, |
|
1622 |
|
1623 preFilter: { |
|
1624 "ATTR": function( match ) { |
|
1625 match[1] = match[1].replace( runescape, funescape ); |
|
1626 |
|
1627 // Move the given value to match[3] whether quoted or unquoted |
|
1628 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); |
|
1629 |
|
1630 if ( match[2] === "~=" ) { |
|
1631 match[3] = " " + match[3] + " "; |
|
1632 } |
|
1633 |
|
1634 return match.slice( 0, 4 ); |
|
1635 }, |
|
1636 |
|
1637 "CHILD": function( match ) { |
|
1638 /* matches from matchExpr["CHILD"] |
|
1639 1 type (only|nth|...) |
|
1640 2 what (child|of-type) |
|
1641 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) |
|
1642 4 xn-component of xn+y argument ([+-]?\d*n|) |
|
1643 5 sign of xn-component |
|
1644 6 x of xn-component |
|
1645 7 sign of y-component |
|
1646 8 y of y-component |
|
1647 */ |
|
1648 match[1] = match[1].toLowerCase(); |
|
1649 |
|
1650 if ( match[1].slice( 0, 3 ) === "nth" ) { |
|
1651 // nth-* requires argument |
|
1652 if ( !match[3] ) { |
|
1653 Sizzle.error( match[0] ); |
|
1654 } |
|
1655 |
|
1656 // numeric x and y parameters for Expr.filter.CHILD |
|
1657 // remember that false/true cast respectively to 0/1 |
|
1658 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); |
|
1659 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); |
|
1660 |
|
1661 // other types prohibit arguments |
|
1662 } else if ( match[3] ) { |
|
1663 Sizzle.error( match[0] ); |
|
1664 } |
|
1665 |
|
1666 return match; |
|
1667 }, |
|
1668 |
|
1669 "PSEUDO": function( match ) { |
|
1670 var excess, |
|
1671 unquoted = !match[6] && match[2]; |
|
1672 |
|
1673 if ( matchExpr["CHILD"].test( match[0] ) ) { |
|
1674 return null; |
|
1675 } |
|
1676 |
|
1677 // Accept quoted arguments as-is |
|
1678 if ( match[3] ) { |
|
1679 match[2] = match[4] || match[5] || ""; |
|
1680 |
|
1681 // Strip excess characters from unquoted arguments |
|
1682 } else if ( unquoted && rpseudo.test( unquoted ) && |
|
1683 // Get excess from tokenize (recursively) |
|
1684 (excess = tokenize( unquoted, true )) && |
|
1685 // advance to the next closing parenthesis |
|
1686 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { |
|
1687 |
|
1688 // excess is a negative index |
|
1689 match[0] = match[0].slice( 0, excess ); |
|
1690 match[2] = unquoted.slice( 0, excess ); |
|
1691 } |
|
1692 |
|
1693 // Return only captures needed by the pseudo filter method (type and argument) |
|
1694 return match.slice( 0, 3 ); |
|
1695 } |
|
1696 }, |
|
1697 |
|
1698 filter: { |
|
1699 |
|
1700 "TAG": function( nodeNameSelector ) { |
|
1701 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); |
|
1702 return nodeNameSelector === "*" ? |
|
1703 function() { return true; } : |
|
1704 function( elem ) { |
|
1705 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; |
|
1706 }; |
|
1707 }, |
|
1708 |
|
1709 "CLASS": function( className ) { |
|
1710 var pattern = classCache[ className + " " ]; |
|
1711 |
|
1712 return pattern || |
|
1713 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && |
|
1714 classCache( className, function( elem ) { |
|
1715 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); |
|
1716 }); |
|
1717 }, |
|
1718 |
|
1719 "ATTR": function( name, operator, check ) { |
|
1720 return function( elem ) { |
|
1721 var result = Sizzle.attr( elem, name ); |
|
1722 |
|
1723 if ( result == null ) { |
|
1724 return operator === "!="; |
|
1725 } |
|
1726 if ( !operator ) { |
|
1727 return true; |
|
1728 } |
|
1729 |
|
1730 result += ""; |
|
1731 |
|
1732 return operator === "=" ? result === check : |
|
1733 operator === "!=" ? result !== check : |
|
1734 operator === "^=" ? check && result.indexOf( check ) === 0 : |
|
1735 operator === "*=" ? check && result.indexOf( check ) > -1 : |
|
1736 operator === "$=" ? check && result.slice( -check.length ) === check : |
|
1737 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : |
|
1738 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : |
|
1739 false; |
|
1740 }; |
|
1741 }, |
|
1742 |
|
1743 "CHILD": function( type, what, argument, first, last ) { |
|
1744 var simple = type.slice( 0, 3 ) !== "nth", |
|
1745 forward = type.slice( -4 ) !== "last", |
|
1746 ofType = what === "of-type"; |
|
1747 |
|
1748 return first === 1 && last === 0 ? |
|
1749 |
|
1750 // Shortcut for :nth-*(n) |
|
1751 function( elem ) { |
|
1752 return !!elem.parentNode; |
|
1753 } : |
|
1754 |
|
1755 function( elem, context, xml ) { |
|
1756 var cache, uniqueCache, outerCache, node, nodeIndex, start, |
|
1757 dir = simple !== forward ? "nextSibling" : "previousSibling", |
|
1758 parent = elem.parentNode, |
|
1759 name = ofType && elem.nodeName.toLowerCase(), |
|
1760 useCache = !xml && !ofType, |
|
1761 diff = false; |
|
1762 |
|
1763 if ( parent ) { |
|
1764 |
|
1765 // :(first|last|only)-(child|of-type) |
|
1766 if ( simple ) { |
|
1767 while ( dir ) { |
|
1768 node = elem; |
|
1769 while ( (node = node[ dir ]) ) { |
|
1770 if ( ofType ? |
|
1771 node.nodeName.toLowerCase() === name : |
|
1772 node.nodeType === 1 ) { |
|
1773 |
|
1774 return false; |
|
1775 } |
|
1776 } |
|
1777 // Reverse direction for :only-* (if we haven't yet done so) |
|
1778 start = dir = type === "only" && !start && "nextSibling"; |
|
1779 } |
|
1780 return true; |
|
1781 } |
|
1782 |
|
1783 start = [ forward ? parent.firstChild : parent.lastChild ]; |
|
1784 |
|
1785 // non-xml :nth-child(...) stores cache data on `parent` |
|
1786 if ( forward && useCache ) { |
|
1787 |
|
1788 // Seek `elem` from a previously-cached index |
|
1789 |
|
1790 // ...in a gzip-friendly way |
|
1791 node = parent; |
|
1792 outerCache = node[ expando ] || (node[ expando ] = {}); |
|
1793 |
|
1794 // Support: IE <9 only |
|
1795 // Defend against cloned attroperties (jQuery gh-1709) |
|
1796 uniqueCache = outerCache[ node.uniqueID ] || |
|
1797 (outerCache[ node.uniqueID ] = {}); |
|
1798 |
|
1799 cache = uniqueCache[ type ] || []; |
|
1800 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
|
1801 diff = nodeIndex && cache[ 2 ]; |
|
1802 node = nodeIndex && parent.childNodes[ nodeIndex ]; |
|
1803 |
|
1804 while ( (node = ++nodeIndex && node && node[ dir ] || |
|
1805 |
|
1806 // Fallback to seeking `elem` from the start |
|
1807 (diff = nodeIndex = 0) || start.pop()) ) { |
|
1808 |
|
1809 // When found, cache indexes on `parent` and break |
|
1810 if ( node.nodeType === 1 && ++diff && node === elem ) { |
|
1811 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; |
|
1812 break; |
|
1813 } |
|
1814 } |
|
1815 |
|
1816 } else { |
|
1817 // Use previously-cached element index if available |
|
1818 if ( useCache ) { |
|
1819 // ...in a gzip-friendly way |
|
1820 node = elem; |
|
1821 outerCache = node[ expando ] || (node[ expando ] = {}); |
|
1822 |
|
1823 // Support: IE <9 only |
|
1824 // Defend against cloned attroperties (jQuery gh-1709) |
|
1825 uniqueCache = outerCache[ node.uniqueID ] || |
|
1826 (outerCache[ node.uniqueID ] = {}); |
|
1827 |
|
1828 cache = uniqueCache[ type ] || []; |
|
1829 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
|
1830 diff = nodeIndex; |
|
1831 } |
|
1832 |
|
1833 // xml :nth-child(...) |
|
1834 // or :nth-last-child(...) or :nth(-last)?-of-type(...) |
|
1835 if ( diff === false ) { |
|
1836 // Use the same loop as above to seek `elem` from the start |
|
1837 while ( (node = ++nodeIndex && node && node[ dir ] || |
|
1838 (diff = nodeIndex = 0) || start.pop()) ) { |
|
1839 |
|
1840 if ( ( ofType ? |
|
1841 node.nodeName.toLowerCase() === name : |
|
1842 node.nodeType === 1 ) && |
|
1843 ++diff ) { |
|
1844 |
|
1845 // Cache the index of each encountered element |
|
1846 if ( useCache ) { |
|
1847 outerCache = node[ expando ] || (node[ expando ] = {}); |
|
1848 |
|
1849 // Support: IE <9 only |
|
1850 // Defend against cloned attroperties (jQuery gh-1709) |
|
1851 uniqueCache = outerCache[ node.uniqueID ] || |
|
1852 (outerCache[ node.uniqueID ] = {}); |
|
1853 |
|
1854 uniqueCache[ type ] = [ dirruns, diff ]; |
|
1855 } |
|
1856 |
|
1857 if ( node === elem ) { |
|
1858 break; |
|
1859 } |
|
1860 } |
|
1861 } |
|
1862 } |
|
1863 } |
|
1864 |
|
1865 // Incorporate the offset, then check against cycle size |
|
1866 diff -= last; |
|
1867 return diff === first || ( diff % first === 0 && diff / first >= 0 ); |
|
1868 } |
|
1869 }; |
|
1870 }, |
|
1871 |
|
1872 "PSEUDO": function( pseudo, argument ) { |
|
1873 // pseudo-class names are case-insensitive |
|
1874 // http://www.w3.org/TR/selectors/#pseudo-classes |
|
1875 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters |
|
1876 // Remember that setFilters inherits from pseudos |
|
1877 var args, |
|
1878 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || |
|
1879 Sizzle.error( "unsupported pseudo: " + pseudo ); |
|
1880 |
|
1881 // The user may use createPseudo to indicate that |
|
1882 // arguments are needed to create the filter function |
|
1883 // just as Sizzle does |
|
1884 if ( fn[ expando ] ) { |
|
1885 return fn( argument ); |
|
1886 } |
|
1887 |
|
1888 // But maintain support for old signatures |
|
1889 if ( fn.length > 1 ) { |
|
1890 args = [ pseudo, pseudo, "", argument ]; |
|
1891 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? |
|
1892 markFunction(function( seed, matches ) { |
|
1893 var idx, |
|
1894 matched = fn( seed, argument ), |
|
1895 i = matched.length; |
|
1896 while ( i-- ) { |
|
1897 idx = indexOf( seed, matched[i] ); |
|
1898 seed[ idx ] = !( matches[ idx ] = matched[i] ); |
|
1899 } |
|
1900 }) : |
|
1901 function( elem ) { |
|
1902 return fn( elem, 0, args ); |
|
1903 }; |
|
1904 } |
|
1905 |
|
1906 return fn; |
|
1907 } |
|
1908 }, |
|
1909 |
|
1910 pseudos: { |
|
1911 // Potentially complex pseudos |
|
1912 "not": markFunction(function( selector ) { |
|
1913 // Trim the selector passed to compile |
|
1914 // to avoid treating leading and trailing |
|
1915 // spaces as combinators |
|
1916 var input = [], |
|
1917 results = [], |
|
1918 matcher = compile( selector.replace( rtrim, "$1" ) ); |
|
1919 |
|
1920 return matcher[ expando ] ? |
|
1921 markFunction(function( seed, matches, context, xml ) { |
|
1922 var elem, |
|
1923 unmatched = matcher( seed, null, xml, [] ), |
|
1924 i = seed.length; |
|
1925 |
|
1926 // Match elements unmatched by `matcher` |
|
1927 while ( i-- ) { |
|
1928 if ( (elem = unmatched[i]) ) { |
|
1929 seed[i] = !(matches[i] = elem); |
|
1930 } |
|
1931 } |
|
1932 }) : |
|
1933 function( elem, context, xml ) { |
|
1934 input[0] = elem; |
|
1935 matcher( input, null, xml, results ); |
|
1936 // Don't keep the element (issue #299) |
|
1937 input[0] = null; |
|
1938 return !results.pop(); |
|
1939 }; |
|
1940 }), |
|
1941 |
|
1942 "has": markFunction(function( selector ) { |
|
1943 return function( elem ) { |
|
1944 return Sizzle( selector, elem ).length > 0; |
|
1945 }; |
|
1946 }), |
|
1947 |
|
1948 "contains": markFunction(function( text ) { |
|
1949 text = text.replace( runescape, funescape ); |
|
1950 return function( elem ) { |
|
1951 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; |
|
1952 }; |
|
1953 }), |
|
1954 |
|
1955 // "Whether an element is represented by a :lang() selector |
|
1956 // is based solely on the element's language value |
|
1957 // being equal to the identifier C, |
|
1958 // or beginning with the identifier C immediately followed by "-". |
|
1959 // The matching of C against the element's language value is performed case-insensitively. |
|
1960 // The identifier C does not have to be a valid language name." |
|
1961 // http://www.w3.org/TR/selectors/#lang-pseudo |
|
1962 "lang": markFunction( function( lang ) { |
|
1963 // lang value must be a valid identifier |
|
1964 if ( !ridentifier.test(lang || "") ) { |
|
1965 Sizzle.error( "unsupported lang: " + lang ); |
|
1966 } |
|
1967 lang = lang.replace( runescape, funescape ).toLowerCase(); |
|
1968 return function( elem ) { |
|
1969 var elemLang; |
|
1970 do { |
|
1971 if ( (elemLang = documentIsHTML ? |
|
1972 elem.lang : |
|
1973 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { |
|
1974 |
|
1975 elemLang = elemLang.toLowerCase(); |
|
1976 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; |
|
1977 } |
|
1978 } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); |
|
1979 return false; |
|
1980 }; |
|
1981 }), |
|
1982 |
|
1983 // Miscellaneous |
|
1984 "target": function( elem ) { |
|
1985 var hash = window.location && window.location.hash; |
|
1986 return hash && hash.slice( 1 ) === elem.id; |
|
1987 }, |
|
1988 |
|
1989 "root": function( elem ) { |
|
1990 return elem === docElem; |
|
1991 }, |
|
1992 |
|
1993 "focus": function( elem ) { |
|
1994 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); |
|
1995 }, |
|
1996 |
|
1997 // Boolean properties |
|
1998 "enabled": createDisabledPseudo( false ), |
|
1999 "disabled": createDisabledPseudo( true ), |
|
2000 |
|
2001 "checked": function( elem ) { |
|
2002 // In CSS3, :checked should return both checked and selected elements |
|
2003 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
|
2004 var nodeName = elem.nodeName.toLowerCase(); |
|
2005 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); |
|
2006 }, |
|
2007 |
|
2008 "selected": function( elem ) { |
|
2009 // Accessing this property makes selected-by-default |
|
2010 // options in Safari work properly |
|
2011 if ( elem.parentNode ) { |
|
2012 elem.parentNode.selectedIndex; |
|
2013 } |
|
2014 |
|
2015 return elem.selected === true; |
|
2016 }, |
|
2017 |
|
2018 // Contents |
|
2019 "empty": function( elem ) { |
|
2020 // http://www.w3.org/TR/selectors/#empty-pseudo |
|
2021 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), |
|
2022 // but not by others (comment: 8; processing instruction: 7; etc.) |
|
2023 // nodeType < 6 works because attributes (2) do not appear as children |
|
2024 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
|
2025 if ( elem.nodeType < 6 ) { |
|
2026 return false; |
|
2027 } |
|
2028 } |
|
2029 return true; |
|
2030 }, |
|
2031 |
|
2032 "parent": function( elem ) { |
|
2033 return !Expr.pseudos["empty"]( elem ); |
|
2034 }, |
|
2035 |
|
2036 // Element/input types |
|
2037 "header": function( elem ) { |
|
2038 return rheader.test( elem.nodeName ); |
|
2039 }, |
|
2040 |
|
2041 "input": function( elem ) { |
|
2042 return rinputs.test( elem.nodeName ); |
|
2043 }, |
|
2044 |
|
2045 "button": function( elem ) { |
|
2046 var name = elem.nodeName.toLowerCase(); |
|
2047 return name === "input" && elem.type === "button" || name === "button"; |
|
2048 }, |
|
2049 |
|
2050 "text": function( elem ) { |
|
2051 var attr; |
|
2052 return elem.nodeName.toLowerCase() === "input" && |
|
2053 elem.type === "text" && |
|
2054 |
|
2055 // Support: IE<8 |
|
2056 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" |
|
2057 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); |
|
2058 }, |
|
2059 |
|
2060 // Position-in-collection |
|
2061 "first": createPositionalPseudo(function() { |
|
2062 return [ 0 ]; |
|
2063 }), |
|
2064 |
|
2065 "last": createPositionalPseudo(function( matchIndexes, length ) { |
|
2066 return [ length - 1 ]; |
|
2067 }), |
|
2068 |
|
2069 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { |
|
2070 return [ argument < 0 ? argument + length : argument ]; |
|
2071 }), |
|
2072 |
|
2073 "even": createPositionalPseudo(function( matchIndexes, length ) { |
|
2074 var i = 0; |
|
2075 for ( ; i < length; i += 2 ) { |
|
2076 matchIndexes.push( i ); |
|
2077 } |
|
2078 return matchIndexes; |
|
2079 }), |
|
2080 |
|
2081 "odd": createPositionalPseudo(function( matchIndexes, length ) { |
|
2082 var i = 1; |
|
2083 for ( ; i < length; i += 2 ) { |
|
2084 matchIndexes.push( i ); |
|
2085 } |
|
2086 return matchIndexes; |
|
2087 }), |
|
2088 |
|
2089 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { |
|
2090 var i = argument < 0 ? argument + length : argument; |
|
2091 for ( ; --i >= 0; ) { |
|
2092 matchIndexes.push( i ); |
|
2093 } |
|
2094 return matchIndexes; |
|
2095 }), |
|
2096 |
|
2097 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { |
|
2098 var i = argument < 0 ? argument + length : argument; |
|
2099 for ( ; ++i < length; ) { |
|
2100 matchIndexes.push( i ); |
|
2101 } |
|
2102 return matchIndexes; |
|
2103 }) |
|
2104 } |
|
2105 }; |
|
2106 |
|
2107 Expr.pseudos["nth"] = Expr.pseudos["eq"]; |
|
2108 |
|
2109 // Add button/input type pseudos |
|
2110 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { |
|
2111 Expr.pseudos[ i ] = createInputPseudo( i ); |
|
2112 } |
|
2113 for ( i in { submit: true, reset: true } ) { |
|
2114 Expr.pseudos[ i ] = createButtonPseudo( i ); |
|
2115 } |
|
2116 |
|
2117 // Easy API for creating new setFilters |
|
2118 function setFilters() {} |
|
2119 setFilters.prototype = Expr.filters = Expr.pseudos; |
|
2120 Expr.setFilters = new setFilters(); |
|
2121 |
|
2122 tokenize = Sizzle.tokenize = function( selector, parseOnly ) { |
|
2123 var matched, match, tokens, type, |
|
2124 soFar, groups, preFilters, |
|
2125 cached = tokenCache[ selector + " " ]; |
|
2126 |
|
2127 if ( cached ) { |
|
2128 return parseOnly ? 0 : cached.slice( 0 ); |
|
2129 } |
|
2130 |
|
2131 soFar = selector; |
|
2132 groups = []; |
|
2133 preFilters = Expr.preFilter; |
|
2134 |
|
2135 while ( soFar ) { |
|
2136 |
|
2137 // Comma and first run |
|
2138 if ( !matched || (match = rcomma.exec( soFar )) ) { |
|
2139 if ( match ) { |
|
2140 // Don't consume trailing commas as valid |
|
2141 soFar = soFar.slice( match[0].length ) || soFar; |
|
2142 } |
|
2143 groups.push( (tokens = []) ); |
|
2144 } |
|
2145 |
|
2146 matched = false; |
|
2147 |
|
2148 // Combinators |
|
2149 if ( (match = rcombinators.exec( soFar )) ) { |
|
2150 matched = match.shift(); |
|
2151 tokens.push({ |
|
2152 value: matched, |
|
2153 // Cast descendant combinators to space |
|
2154 type: match[0].replace( rtrim, " " ) |
|
2155 }); |
|
2156 soFar = soFar.slice( matched.length ); |
|
2157 } |
|
2158 |
|
2159 // Filters |
|
2160 for ( type in Expr.filter ) { |
|
2161 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || |
|
2162 (match = preFilters[ type ]( match ))) ) { |
|
2163 matched = match.shift(); |
|
2164 tokens.push({ |
|
2165 value: matched, |
|
2166 type: type, |
|
2167 matches: match |
|
2168 }); |
|
2169 soFar = soFar.slice( matched.length ); |
|
2170 } |
|
2171 } |
|
2172 |
|
2173 if ( !matched ) { |
|
2174 break; |
|
2175 } |
|
2176 } |
|
2177 |
|
2178 // Return the length of the invalid excess |
|
2179 // if we're just parsing |
|
2180 // Otherwise, throw an error or return tokens |
|
2181 return parseOnly ? |
|
2182 soFar.length : |
|
2183 soFar ? |
|
2184 Sizzle.error( selector ) : |
|
2185 // Cache the tokens |
|
2186 tokenCache( selector, groups ).slice( 0 ); |
|
2187 }; |
|
2188 |
|
2189 function toSelector( tokens ) { |
|
2190 var i = 0, |
|
2191 len = tokens.length, |
|
2192 selector = ""; |
|
2193 for ( ; i < len; i++ ) { |
|
2194 selector += tokens[i].value; |
|
2195 } |
|
2196 return selector; |
|
2197 } |
|
2198 |
|
2199 function addCombinator( matcher, combinator, base ) { |
|
2200 var dir = combinator.dir, |
|
2201 skip = combinator.next, |
|
2202 key = skip || dir, |
|
2203 checkNonElements = base && key === "parentNode", |
|
2204 doneName = done++; |
|
2205 |
|
2206 return combinator.first ? |
|
2207 // Check against closest ancestor/preceding element |
|
2208 function( elem, context, xml ) { |
|
2209 while ( (elem = elem[ dir ]) ) { |
|
2210 if ( elem.nodeType === 1 || checkNonElements ) { |
|
2211 return matcher( elem, context, xml ); |
|
2212 } |
|
2213 } |
|
2214 } : |
|
2215 |
|
2216 // Check against all ancestor/preceding elements |
|
2217 function( elem, context, xml ) { |
|
2218 var oldCache, uniqueCache, outerCache, |
|
2219 newCache = [ dirruns, doneName ]; |
|
2220 |
|
2221 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching |
|
2222 if ( xml ) { |
|
2223 while ( (elem = elem[ dir ]) ) { |
|
2224 if ( elem.nodeType === 1 || checkNonElements ) { |
|
2225 if ( matcher( elem, context, xml ) ) { |
|
2226 return true; |
|
2227 } |
|
2228 } |
|
2229 } |
|
2230 } else { |
|
2231 while ( (elem = elem[ dir ]) ) { |
|
2232 if ( elem.nodeType === 1 || checkNonElements ) { |
|
2233 outerCache = elem[ expando ] || (elem[ expando ] = {}); |
|
2234 |
|
2235 // Support: IE <9 only |
|
2236 // Defend against cloned attroperties (jQuery gh-1709) |
|
2237 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); |
|
2238 |
|
2239 if ( skip && skip === elem.nodeName.toLowerCase() ) { |
|
2240 elem = elem[ dir ] || elem; |
|
2241 } else if ( (oldCache = uniqueCache[ key ]) && |
|
2242 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { |
|
2243 |
|
2244 // Assign to newCache so results back-propagate to previous elements |
|
2245 return (newCache[ 2 ] = oldCache[ 2 ]); |
|
2246 } else { |
|
2247 // Reuse newcache so results back-propagate to previous elements |
|
2248 uniqueCache[ key ] = newCache; |
|
2249 |
|
2250 // A match means we're done; a fail means we have to keep checking |
|
2251 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { |
|
2252 return true; |
|
2253 } |
|
2254 } |
|
2255 } |
|
2256 } |
|
2257 } |
|
2258 }; |
|
2259 } |
|
2260 |
|
2261 function elementMatcher( matchers ) { |
|
2262 return matchers.length > 1 ? |
|
2263 function( elem, context, xml ) { |
|
2264 var i = matchers.length; |
|
2265 while ( i-- ) { |
|
2266 if ( !matchers[i]( elem, context, xml ) ) { |
|
2267 return false; |
|
2268 } |
|
2269 } |
|
2270 return true; |
|
2271 } : |
|
2272 matchers[0]; |
|
2273 } |
|
2274 |
|
2275 function multipleContexts( selector, contexts, results ) { |
|
2276 var i = 0, |
|
2277 len = contexts.length; |
|
2278 for ( ; i < len; i++ ) { |
|
2279 Sizzle( selector, contexts[i], results ); |
|
2280 } |
|
2281 return results; |
|
2282 } |
|
2283 |
|
2284 function condense( unmatched, map, filter, context, xml ) { |
|
2285 var elem, |
|
2286 newUnmatched = [], |
|
2287 i = 0, |
|
2288 len = unmatched.length, |
|
2289 mapped = map != null; |
|
2290 |
|
2291 for ( ; i < len; i++ ) { |
|
2292 if ( (elem = unmatched[i]) ) { |
|
2293 if ( !filter || filter( elem, context, xml ) ) { |
|
2294 newUnmatched.push( elem ); |
|
2295 if ( mapped ) { |
|
2296 map.push( i ); |
|
2297 } |
|
2298 } |
|
2299 } |
|
2300 } |
|
2301 |
|
2302 return newUnmatched; |
|
2303 } |
|
2304 |
|
2305 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { |
|
2306 if ( postFilter && !postFilter[ expando ] ) { |
|
2307 postFilter = setMatcher( postFilter ); |
|
2308 } |
|
2309 if ( postFinder && !postFinder[ expando ] ) { |
|
2310 postFinder = setMatcher( postFinder, postSelector ); |
|
2311 } |
|
2312 return markFunction(function( seed, results, context, xml ) { |
|
2313 var temp, i, elem, |
|
2314 preMap = [], |
|
2315 postMap = [], |
|
2316 preexisting = results.length, |
|
2317 |
|
2318 // Get initial elements from seed or context |
|
2319 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), |
|
2320 |
|
2321 // Prefilter to get matcher input, preserving a map for seed-results synchronization |
|
2322 matcherIn = preFilter && ( seed || !selector ) ? |
|
2323 condense( elems, preMap, preFilter, context, xml ) : |
|
2324 elems, |
|
2325 |
|
2326 matcherOut = matcher ? |
|
2327 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, |
|
2328 postFinder || ( seed ? preFilter : preexisting || postFilter ) ? |
|
2329 |
|
2330 // ...intermediate processing is necessary |
|
2331 [] : |
|
2332 |
|
2333 // ...otherwise use results directly |
|
2334 results : |
|
2335 matcherIn; |
|
2336 |
|
2337 // Find primary matches |
|
2338 if ( matcher ) { |
|
2339 matcher( matcherIn, matcherOut, context, xml ); |
|
2340 } |
|
2341 |
|
2342 // Apply postFilter |
|
2343 if ( postFilter ) { |
|
2344 temp = condense( matcherOut, postMap ); |
|
2345 postFilter( temp, [], context, xml ); |
|
2346 |
|
2347 // Un-match failing elements by moving them back to matcherIn |
|
2348 i = temp.length; |
|
2349 while ( i-- ) { |
|
2350 if ( (elem = temp[i]) ) { |
|
2351 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); |
|
2352 } |
|
2353 } |
|
2354 } |
|
2355 |
|
2356 if ( seed ) { |
|
2357 if ( postFinder || preFilter ) { |
|
2358 if ( postFinder ) { |
|
2359 // Get the final matcherOut by condensing this intermediate into postFinder contexts |
|
2360 temp = []; |
|
2361 i = matcherOut.length; |
|
2362 while ( i-- ) { |
|
2363 if ( (elem = matcherOut[i]) ) { |
|
2364 // Restore matcherIn since elem is not yet a final match |
|
2365 temp.push( (matcherIn[i] = elem) ); |
|
2366 } |
|
2367 } |
|
2368 postFinder( null, (matcherOut = []), temp, xml ); |
|
2369 } |
|
2370 |
|
2371 // Move matched elements from seed to results to keep them synchronized |
|
2372 i = matcherOut.length; |
|
2373 while ( i-- ) { |
|
2374 if ( (elem = matcherOut[i]) && |
|
2375 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { |
|
2376 |
|
2377 seed[temp] = !(results[temp] = elem); |
|
2378 } |
|
2379 } |
|
2380 } |
|
2381 |
|
2382 // Add elements to results, through postFinder if defined |
|
2383 } else { |
|
2384 matcherOut = condense( |
|
2385 matcherOut === results ? |
|
2386 matcherOut.splice( preexisting, matcherOut.length ) : |
|
2387 matcherOut |
|
2388 ); |
|
2389 if ( postFinder ) { |
|
2390 postFinder( null, results, matcherOut, xml ); |
|
2391 } else { |
|
2392 push.apply( results, matcherOut ); |
|
2393 } |
|
2394 } |
|
2395 }); |
|
2396 } |
|
2397 |
|
2398 function matcherFromTokens( tokens ) { |
|
2399 var checkContext, matcher, j, |
|
2400 len = tokens.length, |
|
2401 leadingRelative = Expr.relative[ tokens[0].type ], |
|
2402 implicitRelative = leadingRelative || Expr.relative[" "], |
|
2403 i = leadingRelative ? 1 : 0, |
|
2404 |
|
2405 // The foundational matcher ensures that elements are reachable from top-level context(s) |
|
2406 matchContext = addCombinator( function( elem ) { |
|
2407 return elem === checkContext; |
|
2408 }, implicitRelative, true ), |
|
2409 matchAnyContext = addCombinator( function( elem ) { |
|
2410 return indexOf( checkContext, elem ) > -1; |
|
2411 }, implicitRelative, true ), |
|
2412 matchers = [ function( elem, context, xml ) { |
|
2413 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( |
|
2414 (checkContext = context).nodeType ? |
|
2415 matchContext( elem, context, xml ) : |
|
2416 matchAnyContext( elem, context, xml ) ); |
|
2417 // Avoid hanging onto element (issue #299) |
|
2418 checkContext = null; |
|
2419 return ret; |
|
2420 } ]; |
|
2421 |
|
2422 for ( ; i < len; i++ ) { |
|
2423 if ( (matcher = Expr.relative[ tokens[i].type ]) ) { |
|
2424 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; |
|
2425 } else { |
|
2426 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); |
|
2427 |
|
2428 // Return special upon seeing a positional matcher |
|
2429 if ( matcher[ expando ] ) { |
|
2430 // Find the next relative operator (if any) for proper handling |
|
2431 j = ++i; |
|
2432 for ( ; j < len; j++ ) { |
|
2433 if ( Expr.relative[ tokens[j].type ] ) { |
|
2434 break; |
|
2435 } |
|
2436 } |
|
2437 return setMatcher( |
|
2438 i > 1 && elementMatcher( matchers ), |
|
2439 i > 1 && toSelector( |
|
2440 // If the preceding token was a descendant combinator, insert an implicit any-element `*` |
|
2441 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) |
|
2442 ).replace( rtrim, "$1" ), |
|
2443 matcher, |
|
2444 i < j && matcherFromTokens( tokens.slice( i, j ) ), |
|
2445 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), |
|
2446 j < len && toSelector( tokens ) |
|
2447 ); |
|
2448 } |
|
2449 matchers.push( matcher ); |
|
2450 } |
|
2451 } |
|
2452 |
|
2453 return elementMatcher( matchers ); |
|
2454 } |
|
2455 |
|
2456 function matcherFromGroupMatchers( elementMatchers, setMatchers ) { |
|
2457 var bySet = setMatchers.length > 0, |
|
2458 byElement = elementMatchers.length > 0, |
|
2459 superMatcher = function( seed, context, xml, results, outermost ) { |
|
2460 var elem, j, matcher, |
|
2461 matchedCount = 0, |
|
2462 i = "0", |
|
2463 unmatched = seed && [], |
|
2464 setMatched = [], |
|
2465 contextBackup = outermostContext, |
|
2466 // We must always have either seed elements or outermost context |
|
2467 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), |
|
2468 // Use integer dirruns iff this is the outermost matcher |
|
2469 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), |
|
2470 len = elems.length; |
|
2471 |
|
2472 if ( outermost ) { |
|
2473 outermostContext = context === document || context || outermost; |
|
2474 } |
|
2475 |
|
2476 // Add elements passing elementMatchers directly to results |
|
2477 // Support: IE<9, Safari |
|
2478 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id |
|
2479 for ( ; i !== len && (elem = elems[i]) != null; i++ ) { |
|
2480 if ( byElement && elem ) { |
|
2481 j = 0; |
|
2482 if ( !context && elem.ownerDocument !== document ) { |
|
2483 setDocument( elem ); |
|
2484 xml = !documentIsHTML; |
|
2485 } |
|
2486 while ( (matcher = elementMatchers[j++]) ) { |
|
2487 if ( matcher( elem, context || document, xml) ) { |
|
2488 results.push( elem ); |
|
2489 break; |
|
2490 } |
|
2491 } |
|
2492 if ( outermost ) { |
|
2493 dirruns = dirrunsUnique; |
|
2494 } |
|
2495 } |
|
2496 |
|
2497 // Track unmatched elements for set filters |
|
2498 if ( bySet ) { |
|
2499 // They will have gone through all possible matchers |
|
2500 if ( (elem = !matcher && elem) ) { |
|
2501 matchedCount--; |
|
2502 } |
|
2503 |
|
2504 // Lengthen the array for every element, matched or not |
|
2505 if ( seed ) { |
|
2506 unmatched.push( elem ); |
|
2507 } |
|
2508 } |
|
2509 } |
|
2510 |
|
2511 // `i` is now the count of elements visited above, and adding it to `matchedCount` |
|
2512 // makes the latter nonnegative. |
|
2513 matchedCount += i; |
|
2514 |
|
2515 // Apply set filters to unmatched elements |
|
2516 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` |
|
2517 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have |
|
2518 // no element matchers and no seed. |
|
2519 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that |
|
2520 // case, which will result in a "00" `matchedCount` that differs from `i` but is also |
|
2521 // numerically zero. |
|
2522 if ( bySet && i !== matchedCount ) { |
|
2523 j = 0; |
|
2524 while ( (matcher = setMatchers[j++]) ) { |
|
2525 matcher( unmatched, setMatched, context, xml ); |
|
2526 } |
|
2527 |
|
2528 if ( seed ) { |
|
2529 // Reintegrate element matches to eliminate the need for sorting |
|
2530 if ( matchedCount > 0 ) { |
|
2531 while ( i-- ) { |
|
2532 if ( !(unmatched[i] || setMatched[i]) ) { |
|
2533 setMatched[i] = pop.call( results ); |
|
2534 } |
|
2535 } |
|
2536 } |
|
2537 |
|
2538 // Discard index placeholder values to get only actual matches |
|
2539 setMatched = condense( setMatched ); |
|
2540 } |
|
2541 |
|
2542 // Add matches to results |
|
2543 push.apply( results, setMatched ); |
|
2544 |
|
2545 // Seedless set matches succeeding multiple successful matchers stipulate sorting |
|
2546 if ( outermost && !seed && setMatched.length > 0 && |
|
2547 ( matchedCount + setMatchers.length ) > 1 ) { |
|
2548 |
|
2549 Sizzle.uniqueSort( results ); |
|
2550 } |
|
2551 } |
|
2552 |
|
2553 // Override manipulation of globals by nested matchers |
|
2554 if ( outermost ) { |
|
2555 dirruns = dirrunsUnique; |
|
2556 outermostContext = contextBackup; |
|
2557 } |
|
2558 |
|
2559 return unmatched; |
|
2560 }; |
|
2561 |
|
2562 return bySet ? |
|
2563 markFunction( superMatcher ) : |
|
2564 superMatcher; |
|
2565 } |
|
2566 |
|
2567 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { |
|
2568 var i, |
|
2569 setMatchers = [], |
|
2570 elementMatchers = [], |
|
2571 cached = compilerCache[ selector + " " ]; |
|
2572 |
|
2573 if ( !cached ) { |
|
2574 // Generate a function of recursive functions that can be used to check each element |
|
2575 if ( !match ) { |
|
2576 match = tokenize( selector ); |
|
2577 } |
|
2578 i = match.length; |
|
2579 while ( i-- ) { |
|
2580 cached = matcherFromTokens( match[i] ); |
|
2581 if ( cached[ expando ] ) { |
|
2582 setMatchers.push( cached ); |
|
2583 } else { |
|
2584 elementMatchers.push( cached ); |
|
2585 } |
|
2586 } |
|
2587 |
|
2588 // Cache the compiled function |
|
2589 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); |
|
2590 |
|
2591 // Save selector and tokenization |
|
2592 cached.selector = selector; |
|
2593 } |
|
2594 return cached; |
|
2595 }; |
|
2596 |
|
2597 /** |
|
2598 * A low-level selection function that works with Sizzle's compiled |
|
2599 * selector functions |
|
2600 * @param {String|Function} selector A selector or a pre-compiled |
|
2601 * selector function built with Sizzle.compile |
|
2602 * @param {Element} context |
|
2603 * @param {Array} [results] |
|
2604 * @param {Array} [seed] A set of elements to match against |
|
2605 */ |
|
2606 select = Sizzle.select = function( selector, context, results, seed ) { |
|
2607 var i, tokens, token, type, find, |
|
2608 compiled = typeof selector === "function" && selector, |
|
2609 match = !seed && tokenize( (selector = compiled.selector || selector) ); |
|
2610 |
|
2611 results = results || []; |
|
2612 |
|
2613 // Try to minimize operations if there is only one selector in the list and no seed |
|
2614 // (the latter of which guarantees us context) |
|
2615 if ( match.length === 1 ) { |
|
2616 |
|
2617 // Reduce context if the leading compound selector is an ID |
|
2618 tokens = match[0] = match[0].slice( 0 ); |
|
2619 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && |
|
2620 support.getById && context.nodeType === 9 && documentIsHTML && |
|
2621 Expr.relative[ tokens[1].type ] ) { |
|
2622 |
|
2623 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; |
|
2624 if ( !context ) { |
|
2625 return results; |
|
2626 |
|
2627 // Precompiled matchers will still verify ancestry, so step up a level |
|
2628 } else if ( compiled ) { |
|
2629 context = context.parentNode; |
|
2630 } |
|
2631 |
|
2632 selector = selector.slice( tokens.shift().value.length ); |
|
2633 } |
|
2634 |
|
2635 // Fetch a seed set for right-to-left matching |
|
2636 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; |
|
2637 while ( i-- ) { |
|
2638 token = tokens[i]; |
|
2639 |
|
2640 // Abort if we hit a combinator |
|
2641 if ( Expr.relative[ (type = token.type) ] ) { |
|
2642 break; |
|
2643 } |
|
2644 if ( (find = Expr.find[ type ]) ) { |
|
2645 // Search, expanding context for leading sibling combinators |
|
2646 if ( (seed = find( |
|
2647 token.matches[0].replace( runescape, funescape ), |
|
2648 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context |
|
2649 )) ) { |
|
2650 |
|
2651 // If seed is empty or no tokens remain, we can return early |
|
2652 tokens.splice( i, 1 ); |
|
2653 selector = seed.length && toSelector( tokens ); |
|
2654 if ( !selector ) { |
|
2655 push.apply( results, seed ); |
|
2656 return results; |
|
2657 } |
|
2658 |
|
2659 break; |
|
2660 } |
|
2661 } |
|
2662 } |
|
2663 } |
|
2664 |
|
2665 // Compile and execute a filtering function if one is not provided |
|
2666 // Provide `match` to avoid retokenization if we modified the selector above |
|
2667 ( compiled || compile( selector, match ) )( |
|
2668 seed, |
|
2669 context, |
|
2670 !documentIsHTML, |
|
2671 results, |
|
2672 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context |
|
2673 ); |
|
2674 return results; |
|
2675 }; |
|
2676 |
|
2677 // One-time assignments |
|
2678 |
|
2679 // Sort stability |
|
2680 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; |
|
2681 |
|
2682 // Support: Chrome 14-35+ |
|
2683 // Always assume duplicates if they aren't passed to the comparison function |
|
2684 support.detectDuplicates = !!hasDuplicate; |
|
2685 |
|
2686 // Initialize against the default document |
|
2687 setDocument(); |
|
2688 |
|
2689 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) |
|
2690 // Detached nodes confoundingly follow *each other* |
|
2691 support.sortDetached = assert(function( el ) { |
|
2692 // Should return 1, but returns 4 (following) |
|
2693 return el.compareDocumentPosition( document.createElement("fieldset") ) & 1; |
|
2694 }); |
|
2695 |
|
2696 // Support: IE<8 |
|
2697 // Prevent attribute/property "interpolation" |
|
2698 // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx |
|
2699 if ( !assert(function( el ) { |
|
2700 el.innerHTML = "<a href='#'></a>"; |
|
2701 return el.firstChild.getAttribute("href") === "#" ; |
|
2702 }) ) { |
|
2703 addHandle( "type|href|height|width", function( elem, name, isXML ) { |
|
2704 if ( !isXML ) { |
|
2705 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); |
|
2706 } |
|
2707 }); |
|
2708 } |
|
2709 |
|
2710 // Support: IE<9 |
|
2711 // Use defaultValue in place of getAttribute("value") |
|
2712 if ( !support.attributes || !assert(function( el ) { |
|
2713 el.innerHTML = "<input/>"; |
|
2714 el.firstChild.setAttribute( "value", "" ); |
|
2715 return el.firstChild.getAttribute( "value" ) === ""; |
|
2716 }) ) { |
|
2717 addHandle( "value", function( elem, name, isXML ) { |
|
2718 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { |
|
2719 return elem.defaultValue; |
|
2720 } |
|
2721 }); |
|
2722 } |
|
2723 |
|
2724 // Support: IE<9 |
|
2725 // Use getAttributeNode to fetch booleans when getAttribute lies |
|
2726 if ( !assert(function( el ) { |
|
2727 return el.getAttribute("disabled") == null; |
|
2728 }) ) { |
|
2729 addHandle( booleans, function( elem, name, isXML ) { |
|
2730 var val; |
|
2731 if ( !isXML ) { |
|
2732 return elem[ name ] === true ? name.toLowerCase() : |
|
2733 (val = elem.getAttributeNode( name )) && val.specified ? |
|
2734 val.value : |
|
2735 null; |
|
2736 } |
|
2737 }); |
|
2738 } |
|
2739 |
|
2740 return Sizzle; |
|
2741 |
|
2742 })( window ); |
|
2743 |
|
2744 |
|
2745 |
|
2746 jQuery.find = Sizzle; |
|
2747 jQuery.expr = Sizzle.selectors; |
|
2748 |
|
2749 // Deprecated |
|
2750 jQuery.expr[ ":" ] = jQuery.expr.pseudos; |
|
2751 jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; |
|
2752 jQuery.text = Sizzle.getText; |
|
2753 jQuery.isXMLDoc = Sizzle.isXML; |
|
2754 jQuery.contains = Sizzle.contains; |
|
2755 jQuery.escapeSelector = Sizzle.escape; |
|
2756 |
|
2757 |
|
2758 |
|
2759 |
|
2760 var dir = function( elem, dir, until ) { |
|
2761 var matched = [], |
|
2762 truncate = until !== undefined; |
|
2763 |
|
2764 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { |
|
2765 if ( elem.nodeType === 1 ) { |
|
2766 if ( truncate && jQuery( elem ).is( until ) ) { |
|
2767 break; |
|
2768 } |
|
2769 matched.push( elem ); |
|
2770 } |
|
2771 } |
|
2772 return matched; |
|
2773 }; |
|
2774 |
|
2775 |
|
2776 var siblings = function( n, elem ) { |
|
2777 var matched = []; |
|
2778 |
|
2779 for ( ; n; n = n.nextSibling ) { |
|
2780 if ( n.nodeType === 1 && n !== elem ) { |
|
2781 matched.push( n ); |
|
2782 } |
|
2783 } |
|
2784 |
|
2785 return matched; |
|
2786 }; |
|
2787 |
|
2788 |
|
2789 var rneedsContext = jQuery.expr.match.needsContext; |
|
2790 |
|
2791 var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); |
|
2792 |
|
2793 |
|
2794 |
|
2795 var risSimple = /^.[^:#\[\.,]*$/; |
|
2796 |
|
2797 // Implement the identical functionality for filter and not |
|
2798 function winnow( elements, qualifier, not ) { |
|
2799 if ( jQuery.isFunction( qualifier ) ) { |
|
2800 return jQuery.grep( elements, function( elem, i ) { |
|
2801 return !!qualifier.call( elem, i, elem ) !== not; |
|
2802 } ); |
|
2803 |
|
2804 } |
|
2805 |
|
2806 if ( qualifier.nodeType ) { |
|
2807 return jQuery.grep( elements, function( elem ) { |
|
2808 return ( elem === qualifier ) !== not; |
|
2809 } ); |
|
2810 |
|
2811 } |
|
2812 |
|
2813 if ( typeof qualifier === "string" ) { |
|
2814 if ( risSimple.test( qualifier ) ) { |
|
2815 return jQuery.filter( qualifier, elements, not ); |
|
2816 } |
|
2817 |
|
2818 qualifier = jQuery.filter( qualifier, elements ); |
|
2819 } |
|
2820 |
|
2821 return jQuery.grep( elements, function( elem ) { |
|
2822 return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1; |
|
2823 } ); |
|
2824 } |
|
2825 |
|
2826 jQuery.filter = function( expr, elems, not ) { |
|
2827 var elem = elems[ 0 ]; |
|
2828 |
|
2829 if ( not ) { |
|
2830 expr = ":not(" + expr + ")"; |
|
2831 } |
|
2832 |
|
2833 return elems.length === 1 && elem.nodeType === 1 ? |
|
2834 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : |
|
2835 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { |
|
2836 return elem.nodeType === 1; |
|
2837 } ) ); |
|
2838 }; |
|
2839 |
|
2840 jQuery.fn.extend( { |
|
2841 find: function( selector ) { |
|
2842 var i, ret, |
|
2843 len = this.length, |
|
2844 self = this; |
|
2845 |
|
2846 if ( typeof selector !== "string" ) { |
|
2847 return this.pushStack( jQuery( selector ).filter( function() { |
|
2848 for ( i = 0; i < len; i++ ) { |
|
2849 if ( jQuery.contains( self[ i ], this ) ) { |
|
2850 return true; |
|
2851 } |
|
2852 } |
|
2853 } ) ); |
|
2854 } |
|
2855 |
|
2856 ret = this.pushStack( [] ); |
|
2857 |
|
2858 for ( i = 0; i < len; i++ ) { |
|
2859 jQuery.find( selector, self[ i ], ret ); |
|
2860 } |
|
2861 |
|
2862 return len > 1 ? jQuery.uniqueSort( ret ) : ret; |
|
2863 }, |
|
2864 filter: function( selector ) { |
|
2865 return this.pushStack( winnow( this, selector || [], false ) ); |
|
2866 }, |
|
2867 not: function( selector ) { |
|
2868 return this.pushStack( winnow( this, selector || [], true ) ); |
|
2869 }, |
|
2870 is: function( selector ) { |
|
2871 return !!winnow( |
|
2872 this, |
|
2873 |
|
2874 // If this is a positional/relative selector, check membership in the returned set |
|
2875 // so $("p:first").is("p:last") won't return true for a doc with two "p". |
|
2876 typeof selector === "string" && rneedsContext.test( selector ) ? |
|
2877 jQuery( selector ) : |
|
2878 selector || [], |
|
2879 false |
|
2880 ).length; |
|
2881 } |
|
2882 } ); |
|
2883 |
|
2884 |
|
2885 // Initialize a jQuery object |
|
2886 |
|
2887 |
|
2888 // A central reference to the root jQuery(document) |
|
2889 var rootjQuery, |
|
2890 |
|
2891 // A simple way to check for HTML strings |
|
2892 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) |
|
2893 // Strict HTML recognition (#11290: must start with <) |
|
2894 // Shortcut simple #id case for speed |
|
2895 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, |
|
2896 |
|
2897 init = jQuery.fn.init = function( selector, context, root ) { |
|
2898 var match, elem; |
|
2899 |
|
2900 // HANDLE: $(""), $(null), $(undefined), $(false) |
|
2901 if ( !selector ) { |
|
2902 return this; |
|
2903 } |
|
2904 |
|
2905 // Method init() accepts an alternate rootjQuery |
|
2906 // so migrate can support jQuery.sub (gh-2101) |
|
2907 root = root || rootjQuery; |
|
2908 |
|
2909 // Handle HTML strings |
|
2910 if ( typeof selector === "string" ) { |
|
2911 if ( selector[ 0 ] === "<" && |
|
2912 selector[ selector.length - 1 ] === ">" && |
|
2913 selector.length >= 3 ) { |
|
2914 |
|
2915 // Assume that strings that start and end with <> are HTML and skip the regex check |
|
2916 match = [ null, selector, null ]; |
|
2917 |
|
2918 } else { |
|
2919 match = rquickExpr.exec( selector ); |
|
2920 } |
|
2921 |
|
2922 // Match html or make sure no context is specified for #id |
|
2923 if ( match && ( match[ 1 ] || !context ) ) { |
|
2924 |
|
2925 // HANDLE: $(html) -> $(array) |
|
2926 if ( match[ 1 ] ) { |
|
2927 context = context instanceof jQuery ? context[ 0 ] : context; |
|
2928 |
|
2929 // Option to run scripts is true for back-compat |
|
2930 // Intentionally let the error be thrown if parseHTML is not present |
|
2931 jQuery.merge( this, jQuery.parseHTML( |
|
2932 match[ 1 ], |
|
2933 context && context.nodeType ? context.ownerDocument || context : document, |
|
2934 true |
|
2935 ) ); |
|
2936 |
|
2937 // HANDLE: $(html, props) |
|
2938 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { |
|
2939 for ( match in context ) { |
|
2940 |
|
2941 // Properties of context are called as methods if possible |
|
2942 if ( jQuery.isFunction( this[ match ] ) ) { |
|
2943 this[ match ]( context[ match ] ); |
|
2944 |
|
2945 // ...and otherwise set as attributes |
|
2946 } else { |
|
2947 this.attr( match, context[ match ] ); |
|
2948 } |
|
2949 } |
|
2950 } |
|
2951 |
|
2952 return this; |
|
2953 |
|
2954 // HANDLE: $(#id) |
|
2955 } else { |
|
2956 elem = document.getElementById( match[ 2 ] ); |
|
2957 |
|
2958 if ( elem ) { |
|
2959 |
|
2960 // Inject the element directly into the jQuery object |
|
2961 this[ 0 ] = elem; |
|
2962 this.length = 1; |
|
2963 } |
|
2964 return this; |
|
2965 } |
|
2966 |
|
2967 // HANDLE: $(expr, $(...)) |
|
2968 } else if ( !context || context.jquery ) { |
|
2969 return ( context || root ).find( selector ); |
|
2970 |
|
2971 // HANDLE: $(expr, context) |
|
2972 // (which is just equivalent to: $(context).find(expr) |
|
2973 } else { |
|
2974 return this.constructor( context ).find( selector ); |
|
2975 } |
|
2976 |
|
2977 // HANDLE: $(DOMElement) |
|
2978 } else if ( selector.nodeType ) { |
|
2979 this[ 0 ] = selector; |
|
2980 this.length = 1; |
|
2981 return this; |
|
2982 |
|
2983 // HANDLE: $(function) |
|
2984 // Shortcut for document ready |
|
2985 } else if ( jQuery.isFunction( selector ) ) { |
|
2986 return root.ready !== undefined ? |
|
2987 root.ready( selector ) : |
|
2988 |
|
2989 // Execute immediately if ready is not present |
|
2990 selector( jQuery ); |
|
2991 } |
|
2992 |
|
2993 return jQuery.makeArray( selector, this ); |
|
2994 }; |
|
2995 |
|
2996 // Give the init function the jQuery prototype for later instantiation |
|
2997 init.prototype = jQuery.fn; |
|
2998 |
|
2999 // Initialize central reference |
|
3000 rootjQuery = jQuery( document ); |
|
3001 |
|
3002 |
|
3003 var rparentsprev = /^(?:parents|prev(?:Until|All))/, |
|
3004 |
|
3005 // Methods guaranteed to produce a unique set when starting from a unique set |
|
3006 guaranteedUnique = { |
|
3007 children: true, |
|
3008 contents: true, |
|
3009 next: true, |
|
3010 prev: true |
|
3011 }; |
|
3012 |
|
3013 jQuery.fn.extend( { |
|
3014 has: function( target ) { |
|
3015 var targets = jQuery( target, this ), |
|
3016 l = targets.length; |
|
3017 |
|
3018 return this.filter( function() { |
|
3019 var i = 0; |
|
3020 for ( ; i < l; i++ ) { |
|
3021 if ( jQuery.contains( this, targets[ i ] ) ) { |
|
3022 return true; |
|
3023 } |
|
3024 } |
|
3025 } ); |
|
3026 }, |
|
3027 |
|
3028 closest: function( selectors, context ) { |
|
3029 var cur, |
|
3030 i = 0, |
|
3031 l = this.length, |
|
3032 matched = [], |
|
3033 targets = typeof selectors !== "string" && jQuery( selectors ); |
|
3034 |
|
3035 // Positional selectors never match, since there's no _selection_ context |
|
3036 if ( !rneedsContext.test( selectors ) ) { |
|
3037 for ( ; i < l; i++ ) { |
|
3038 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { |
|
3039 |
|
3040 // Always skip document fragments |
|
3041 if ( cur.nodeType < 11 && ( targets ? |
|
3042 targets.index( cur ) > -1 : |
|
3043 |
|
3044 // Don't pass non-elements to Sizzle |
|
3045 cur.nodeType === 1 && |
|
3046 jQuery.find.matchesSelector( cur, selectors ) ) ) { |
|
3047 |
|
3048 matched.push( cur ); |
|
3049 break; |
|
3050 } |
|
3051 } |
|
3052 } |
|
3053 } |
|
3054 |
|
3055 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); |
|
3056 }, |
|
3057 |
|
3058 // Determine the position of an element within the set |
|
3059 index: function( elem ) { |
|
3060 |
|
3061 // No argument, return index in parent |
|
3062 if ( !elem ) { |
|
3063 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; |
|
3064 } |
|
3065 |
|
3066 // Index in selector |
|
3067 if ( typeof elem === "string" ) { |
|
3068 return indexOf.call( jQuery( elem ), this[ 0 ] ); |
|
3069 } |
|
3070 |
|
3071 // Locate the position of the desired element |
|
3072 return indexOf.call( this, |
|
3073 |
|
3074 // If it receives a jQuery object, the first element is used |
|
3075 elem.jquery ? elem[ 0 ] : elem |
|
3076 ); |
|
3077 }, |
|
3078 |
|
3079 add: function( selector, context ) { |
|
3080 return this.pushStack( |
|
3081 jQuery.uniqueSort( |
|
3082 jQuery.merge( this.get(), jQuery( selector, context ) ) |
|
3083 ) |
|
3084 ); |
|
3085 }, |
|
3086 |
|
3087 addBack: function( selector ) { |
|
3088 return this.add( selector == null ? |
|
3089 this.prevObject : this.prevObject.filter( selector ) |
|
3090 ); |
|
3091 } |
|
3092 } ); |
|
3093 |
|
3094 function sibling( cur, dir ) { |
|
3095 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} |
|
3096 return cur; |
|
3097 } |
|
3098 |
|
3099 jQuery.each( { |
|
3100 parent: function( elem ) { |
|
3101 var parent = elem.parentNode; |
|
3102 return parent && parent.nodeType !== 11 ? parent : null; |
|
3103 }, |
|
3104 parents: function( elem ) { |
|
3105 return dir( elem, "parentNode" ); |
|
3106 }, |
|
3107 parentsUntil: function( elem, i, until ) { |
|
3108 return dir( elem, "parentNode", until ); |
|
3109 }, |
|
3110 next: function( elem ) { |
|
3111 return sibling( elem, "nextSibling" ); |
|
3112 }, |
|
3113 prev: function( elem ) { |
|
3114 return sibling( elem, "previousSibling" ); |
|
3115 }, |
|
3116 nextAll: function( elem ) { |
|
3117 return dir( elem, "nextSibling" ); |
|
3118 }, |
|
3119 prevAll: function( elem ) { |
|
3120 return dir( elem, "previousSibling" ); |
|
3121 }, |
|
3122 nextUntil: function( elem, i, until ) { |
|
3123 return dir( elem, "nextSibling", until ); |
|
3124 }, |
|
3125 prevUntil: function( elem, i, until ) { |
|
3126 return dir( elem, "previousSibling", until ); |
|
3127 }, |
|
3128 siblings: function( elem ) { |
|
3129 return siblings( ( elem.parentNode || {} ).firstChild, elem ); |
|
3130 }, |
|
3131 children: function( elem ) { |
|
3132 return siblings( elem.firstChild ); |
|
3133 }, |
|
3134 contents: function( elem ) { |
|
3135 return elem.contentDocument || jQuery.merge( [], elem.childNodes ); |
|
3136 } |
|
3137 }, function( name, fn ) { |
|
3138 jQuery.fn[ name ] = function( until, selector ) { |
|
3139 var matched = jQuery.map( this, fn, until ); |
|
3140 |
|
3141 if ( name.slice( -5 ) !== "Until" ) { |
|
3142 selector = until; |
|
3143 } |
|
3144 |
|
3145 if ( selector && typeof selector === "string" ) { |
|
3146 matched = jQuery.filter( selector, matched ); |
|
3147 } |
|
3148 |
|
3149 if ( this.length > 1 ) { |
|
3150 |
|
3151 // Remove duplicates |
|
3152 if ( !guaranteedUnique[ name ] ) { |
|
3153 jQuery.uniqueSort( matched ); |
|
3154 } |
|
3155 |
|
3156 // Reverse order for parents* and prev-derivatives |
|
3157 if ( rparentsprev.test( name ) ) { |
|
3158 matched.reverse(); |
|
3159 } |
|
3160 } |
|
3161 |
|
3162 return this.pushStack( matched ); |
|
3163 }; |
|
3164 } ); |
|
3165 var rnotwhite = ( /\S+/g ); |
|
3166 |
|
3167 |
|
3168 |
|
3169 // Convert String-formatted options into Object-formatted ones |
|
3170 function createOptions( options ) { |
|
3171 var object = {}; |
|
3172 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { |
|
3173 object[ flag ] = true; |
|
3174 } ); |
|
3175 return object; |
|
3176 } |
|
3177 |
|
3178 /* |
|
3179 * Create a callback list using the following parameters: |
|
3180 * |
|
3181 * options: an optional list of space-separated options that will change how |
|
3182 * the callback list behaves or a more traditional option object |
|
3183 * |
|
3184 * By default a callback list will act like an event callback list and can be |
|
3185 * "fired" multiple times. |
|
3186 * |
|
3187 * Possible options: |
|
3188 * |
|
3189 * once: will ensure the callback list can only be fired once (like a Deferred) |
|
3190 * |
|
3191 * memory: will keep track of previous values and will call any callback added |
|
3192 * after the list has been fired right away with the latest "memorized" |
|
3193 * values (like a Deferred) |
|
3194 * |
|
3195 * unique: will ensure a callback can only be added once (no duplicate in the list) |
|
3196 * |
|
3197 * stopOnFalse: interrupt callings when a callback returns false |
|
3198 * |
|
3199 */ |
|
3200 jQuery.Callbacks = function( options ) { |
|
3201 |
|
3202 // Convert options from String-formatted to Object-formatted if needed |
|
3203 // (we check in cache first) |
|
3204 options = typeof options === "string" ? |
|
3205 createOptions( options ) : |
|
3206 jQuery.extend( {}, options ); |
|
3207 |
|
3208 var // Flag to know if list is currently firing |
|
3209 firing, |
|
3210 |
|
3211 // Last fire value for non-forgettable lists |
|
3212 memory, |
|
3213 |
|
3214 // Flag to know if list was already fired |
|
3215 fired, |
|
3216 |
|
3217 // Flag to prevent firing |
|
3218 locked, |
|
3219 |
|
3220 // Actual callback list |
|
3221 list = [], |
|
3222 |
|
3223 // Queue of execution data for repeatable lists |
|
3224 queue = [], |
|
3225 |
|
3226 // Index of currently firing callback (modified by add/remove as needed) |
|
3227 firingIndex = -1, |
|
3228 |
|
3229 // Fire callbacks |
|
3230 fire = function() { |
|
3231 |
|
3232 // Enforce single-firing |
|
3233 locked = options.once; |
|
3234 |
|
3235 // Execute callbacks for all pending executions, |
|
3236 // respecting firingIndex overrides and runtime changes |
|
3237 fired = firing = true; |
|
3238 for ( ; queue.length; firingIndex = -1 ) { |
|
3239 memory = queue.shift(); |
|
3240 while ( ++firingIndex < list.length ) { |
|
3241 |
|
3242 // Run callback and check for early termination |
|
3243 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && |
|
3244 options.stopOnFalse ) { |
|
3245 |
|
3246 // Jump to end and forget the data so .add doesn't re-fire |
|
3247 firingIndex = list.length; |
|
3248 memory = false; |
|
3249 } |
|
3250 } |
|
3251 } |
|
3252 |
|
3253 // Forget the data if we're done with it |
|
3254 if ( !options.memory ) { |
|
3255 memory = false; |
|
3256 } |
|
3257 |
|
3258 firing = false; |
|
3259 |
|
3260 // Clean up if we're done firing for good |
|
3261 if ( locked ) { |
|
3262 |
|
3263 // Keep an empty list if we have data for future add calls |
|
3264 if ( memory ) { |
|
3265 list = []; |
|
3266 |
|
3267 // Otherwise, this object is spent |
|
3268 } else { |
|
3269 list = ""; |
|
3270 } |
|
3271 } |
|
3272 }, |
|
3273 |
|
3274 // Actual Callbacks object |
|
3275 self = { |
|
3276 |
|
3277 // Add a callback or a collection of callbacks to the list |
|
3278 add: function() { |
|
3279 if ( list ) { |
|
3280 |
|
3281 // If we have memory from a past run, we should fire after adding |
|
3282 if ( memory && !firing ) { |
|
3283 firingIndex = list.length - 1; |
|
3284 queue.push( memory ); |
|
3285 } |
|
3286 |
|
3287 ( function add( args ) { |
|
3288 jQuery.each( args, function( _, arg ) { |
|
3289 if ( jQuery.isFunction( arg ) ) { |
|
3290 if ( !options.unique || !self.has( arg ) ) { |
|
3291 list.push( arg ); |
|
3292 } |
|
3293 } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { |
|
3294 |
|
3295 // Inspect recursively |
|
3296 add( arg ); |
|
3297 } |
|
3298 } ); |
|
3299 } )( arguments ); |
|
3300 |
|
3301 if ( memory && !firing ) { |
|
3302 fire(); |
|
3303 } |
|
3304 } |
|
3305 return this; |
|
3306 }, |
|
3307 |
|
3308 // Remove a callback from the list |
|
3309 remove: function() { |
|
3310 jQuery.each( arguments, function( _, arg ) { |
|
3311 var index; |
|
3312 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { |
|
3313 list.splice( index, 1 ); |
|
3314 |
|
3315 // Handle firing indexes |
|
3316 if ( index <= firingIndex ) { |
|
3317 firingIndex--; |
|
3318 } |
|
3319 } |
|
3320 } ); |
|
3321 return this; |
|
3322 }, |
|
3323 |
|
3324 // Check if a given callback is in the list. |
|
3325 // If no argument is given, return whether or not list has callbacks attached. |
|
3326 has: function( fn ) { |
|
3327 return fn ? |
|
3328 jQuery.inArray( fn, list ) > -1 : |
|
3329 list.length > 0; |
|
3330 }, |
|
3331 |
|
3332 // Remove all callbacks from the list |
|
3333 empty: function() { |
|
3334 if ( list ) { |
|
3335 list = []; |
|
3336 } |
|
3337 return this; |
|
3338 }, |
|
3339 |
|
3340 // Disable .fire and .add |
|
3341 // Abort any current/pending executions |
|
3342 // Clear all callbacks and values |
|
3343 disable: function() { |
|
3344 locked = queue = []; |
|
3345 list = memory = ""; |
|
3346 return this; |
|
3347 }, |
|
3348 disabled: function() { |
|
3349 return !list; |
|
3350 }, |
|
3351 |
|
3352 // Disable .fire |
|
3353 // Also disable .add unless we have memory (since it would have no effect) |
|
3354 // Abort any pending executions |
|
3355 lock: function() { |
|
3356 locked = queue = []; |
|
3357 if ( !memory && !firing ) { |
|
3358 list = memory = ""; |
|
3359 } |
|
3360 return this; |
|
3361 }, |
|
3362 locked: function() { |
|
3363 return !!locked; |
|
3364 }, |
|
3365 |
|
3366 // Call all callbacks with the given context and arguments |
|
3367 fireWith: function( context, args ) { |
|
3368 if ( !locked ) { |
|
3369 args = args || []; |
|
3370 args = [ context, args.slice ? args.slice() : args ]; |
|
3371 queue.push( args ); |
|
3372 if ( !firing ) { |
|
3373 fire(); |
|
3374 } |
|
3375 } |
|
3376 return this; |
|
3377 }, |
|
3378 |
|
3379 // Call all the callbacks with the given arguments |
|
3380 fire: function() { |
|
3381 self.fireWith( this, arguments ); |
|
3382 return this; |
|
3383 }, |
|
3384 |
|
3385 // To know if the callbacks have already been called at least once |
|
3386 fired: function() { |
|
3387 return !!fired; |
|
3388 } |
|
3389 }; |
|
3390 |
|
3391 return self; |
|
3392 }; |
|
3393 |
|
3394 |
|
3395 function Identity( v ) { |
|
3396 return v; |
|
3397 } |
|
3398 function Thrower( ex ) { |
|
3399 throw ex; |
|
3400 } |
|
3401 |
|
3402 function adoptValue( value, resolve, reject ) { |
|
3403 var method; |
|
3404 |
|
3405 try { |
|
3406 |
|
3407 // Check for promise aspect first to privilege synchronous behavior |
|
3408 if ( value && jQuery.isFunction( ( method = value.promise ) ) ) { |
|
3409 method.call( value ).done( resolve ).fail( reject ); |
|
3410 |
|
3411 // Other thenables |
|
3412 } else if ( value && jQuery.isFunction( ( method = value.then ) ) ) { |
|
3413 method.call( value, resolve, reject ); |
|
3414 |
|
3415 // Other non-thenables |
|
3416 } else { |
|
3417 |
|
3418 // Support: Android 4.0 only |
|
3419 // Strict mode functions invoked without .call/.apply get global-object context |
|
3420 resolve.call( undefined, value ); |
|
3421 } |
|
3422 |
|
3423 // For Promises/A+, convert exceptions into rejections |
|
3424 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in |
|
3425 // Deferred#then to conditionally suppress rejection. |
|
3426 } catch ( value ) { |
|
3427 |
|
3428 // Support: Android 4.0 only |
|
3429 // Strict mode functions invoked without .call/.apply get global-object context |
|
3430 reject.call( undefined, value ); |
|
3431 } |
|
3432 } |
|
3433 |
|
3434 jQuery.extend( { |
|
3435 |
|
3436 Deferred: function( func ) { |
|
3437 var tuples = [ |
|
3438 |
|
3439 // action, add listener, callbacks, |
|
3440 // ... .then handlers, argument index, [final state] |
|
3441 [ "notify", "progress", jQuery.Callbacks( "memory" ), |
|
3442 jQuery.Callbacks( "memory" ), 2 ], |
|
3443 [ "resolve", "done", jQuery.Callbacks( "once memory" ), |
|
3444 jQuery.Callbacks( "once memory" ), 0, "resolved" ], |
|
3445 [ "reject", "fail", jQuery.Callbacks( "once memory" ), |
|
3446 jQuery.Callbacks( "once memory" ), 1, "rejected" ] |
|
3447 ], |
|
3448 state = "pending", |
|
3449 promise = { |
|
3450 state: function() { |
|
3451 return state; |
|
3452 }, |
|
3453 always: function() { |
|
3454 deferred.done( arguments ).fail( arguments ); |
|
3455 return this; |
|
3456 }, |
|
3457 "catch": function( fn ) { |
|
3458 return promise.then( null, fn ); |
|
3459 }, |
|
3460 |
|
3461 // Keep pipe for back-compat |
|
3462 pipe: function( /* fnDone, fnFail, fnProgress */ ) { |
|
3463 var fns = arguments; |
|
3464 |
|
3465 return jQuery.Deferred( function( newDefer ) { |
|
3466 jQuery.each( tuples, function( i, tuple ) { |
|
3467 |
|
3468 // Map tuples (progress, done, fail) to arguments (done, fail, progress) |
|
3469 var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; |
|
3470 |
|
3471 // deferred.progress(function() { bind to newDefer or newDefer.notify }) |
|
3472 // deferred.done(function() { bind to newDefer or newDefer.resolve }) |
|
3473 // deferred.fail(function() { bind to newDefer or newDefer.reject }) |
|
3474 deferred[ tuple[ 1 ] ]( function() { |
|
3475 var returned = fn && fn.apply( this, arguments ); |
|
3476 if ( returned && jQuery.isFunction( returned.promise ) ) { |
|
3477 returned.promise() |
|
3478 .progress( newDefer.notify ) |
|
3479 .done( newDefer.resolve ) |
|
3480 .fail( newDefer.reject ); |
|
3481 } else { |
|
3482 newDefer[ tuple[ 0 ] + "With" ]( |
|
3483 this, |
|
3484 fn ? [ returned ] : arguments |
|
3485 ); |
|
3486 } |
|
3487 } ); |
|
3488 } ); |
|
3489 fns = null; |
|
3490 } ).promise(); |
|
3491 }, |
|
3492 then: function( onFulfilled, onRejected, onProgress ) { |
|
3493 var maxDepth = 0; |
|
3494 function resolve( depth, deferred, handler, special ) { |
|
3495 return function() { |
|
3496 var that = this, |
|
3497 args = arguments, |
|
3498 mightThrow = function() { |
|
3499 var returned, then; |
|
3500 |
|
3501 // Support: Promises/A+ section 2.3.3.3.3 |
|
3502 // https://promisesaplus.com/#point-59 |
|
3503 // Ignore double-resolution attempts |
|
3504 if ( depth < maxDepth ) { |
|
3505 return; |
|
3506 } |
|
3507 |
|
3508 returned = handler.apply( that, args ); |
|
3509 |
|
3510 // Support: Promises/A+ section 2.3.1 |
|
3511 // https://promisesaplus.com/#point-48 |
|
3512 if ( returned === deferred.promise() ) { |
|
3513 throw new TypeError( "Thenable self-resolution" ); |
|
3514 } |
|
3515 |
|
3516 // Support: Promises/A+ sections 2.3.3.1, 3.5 |
|
3517 // https://promisesaplus.com/#point-54 |
|
3518 // https://promisesaplus.com/#point-75 |
|
3519 // Retrieve `then` only once |
|
3520 then = returned && |
|
3521 |
|
3522 // Support: Promises/A+ section 2.3.4 |
|
3523 // https://promisesaplus.com/#point-64 |
|
3524 // Only check objects and functions for thenability |
|
3525 ( typeof returned === "object" || |
|
3526 typeof returned === "function" ) && |
|
3527 returned.then; |
|
3528 |
|
3529 // Handle a returned thenable |
|
3530 if ( jQuery.isFunction( then ) ) { |
|
3531 |
|
3532 // Special processors (notify) just wait for resolution |
|
3533 if ( special ) { |
|
3534 then.call( |
|
3535 returned, |
|
3536 resolve( maxDepth, deferred, Identity, special ), |
|
3537 resolve( maxDepth, deferred, Thrower, special ) |
|
3538 ); |
|
3539 |
|
3540 // Normal processors (resolve) also hook into progress |
|
3541 } else { |
|
3542 |
|
3543 // ...and disregard older resolution values |
|
3544 maxDepth++; |
|
3545 |
|
3546 then.call( |
|
3547 returned, |
|
3548 resolve( maxDepth, deferred, Identity, special ), |
|
3549 resolve( maxDepth, deferred, Thrower, special ), |
|
3550 resolve( maxDepth, deferred, Identity, |
|
3551 deferred.notifyWith ) |
|
3552 ); |
|
3553 } |
|
3554 |
|
3555 // Handle all other returned values |
|
3556 } else { |
|
3557 |
|
3558 // Only substitute handlers pass on context |
|
3559 // and multiple values (non-spec behavior) |
|
3560 if ( handler !== Identity ) { |
|
3561 that = undefined; |
|
3562 args = [ returned ]; |
|
3563 } |
|
3564 |
|
3565 // Process the value(s) |
|
3566 // Default process is resolve |
|
3567 ( special || deferred.resolveWith )( that, args ); |
|
3568 } |
|
3569 }, |
|
3570 |
|
3571 // Only normal processors (resolve) catch and reject exceptions |
|
3572 process = special ? |
|
3573 mightThrow : |
|
3574 function() { |
|
3575 try { |
|
3576 mightThrow(); |
|
3577 } catch ( e ) { |
|
3578 |
|
3579 if ( jQuery.Deferred.exceptionHook ) { |
|
3580 jQuery.Deferred.exceptionHook( e, |
|
3581 process.stackTrace ); |
|
3582 } |
|
3583 |
|
3584 // Support: Promises/A+ section 2.3.3.3.4.1 |
|
3585 // https://promisesaplus.com/#point-61 |
|
3586 // Ignore post-resolution exceptions |
|
3587 if ( depth + 1 >= maxDepth ) { |
|
3588 |
|
3589 // Only substitute handlers pass on context |
|
3590 // and multiple values (non-spec behavior) |
|
3591 if ( handler !== Thrower ) { |
|
3592 that = undefined; |
|
3593 args = [ e ]; |
|
3594 } |
|
3595 |
|
3596 deferred.rejectWith( that, args ); |
|
3597 } |
|
3598 } |
|
3599 }; |
|
3600 |
|
3601 // Support: Promises/A+ section 2.3.3.3.1 |
|
3602 // https://promisesaplus.com/#point-57 |
|
3603 // Re-resolve promises immediately to dodge false rejection from |
|
3604 // subsequent errors |
|
3605 if ( depth ) { |
|
3606 process(); |
|
3607 } else { |
|
3608 |
|
3609 // Call an optional hook to record the stack, in case of exception |
|
3610 // since it's otherwise lost when execution goes async |
|
3611 if ( jQuery.Deferred.getStackHook ) { |
|
3612 process.stackTrace = jQuery.Deferred.getStackHook(); |
|
3613 } |
|
3614 window.setTimeout( process ); |
|
3615 } |
|
3616 }; |
|
3617 } |
|
3618 |
|
3619 return jQuery.Deferred( function( newDefer ) { |
|
3620 |
|
3621 // progress_handlers.add( ... ) |
|
3622 tuples[ 0 ][ 3 ].add( |
|
3623 resolve( |
|
3624 0, |
|
3625 newDefer, |
|
3626 jQuery.isFunction( onProgress ) ? |
|
3627 onProgress : |
|
3628 Identity, |
|
3629 newDefer.notifyWith |
|
3630 ) |
|
3631 ); |
|
3632 |
|
3633 // fulfilled_handlers.add( ... ) |
|
3634 tuples[ 1 ][ 3 ].add( |
|
3635 resolve( |
|
3636 0, |
|
3637 newDefer, |
|
3638 jQuery.isFunction( onFulfilled ) ? |
|
3639 onFulfilled : |
|
3640 Identity |
|
3641 ) |
|
3642 ); |
|
3643 |
|
3644 // rejected_handlers.add( ... ) |
|
3645 tuples[ 2 ][ 3 ].add( |
|
3646 resolve( |
|
3647 0, |
|
3648 newDefer, |
|
3649 jQuery.isFunction( onRejected ) ? |
|
3650 onRejected : |
|
3651 Thrower |
|
3652 ) |
|
3653 ); |
|
3654 } ).promise(); |
|
3655 }, |
|
3656 |
|
3657 // Get a promise for this deferred |
|
3658 // If obj is provided, the promise aspect is added to the object |
|
3659 promise: function( obj ) { |
|
3660 return obj != null ? jQuery.extend( obj, promise ) : promise; |
|
3661 } |
|
3662 }, |
|
3663 deferred = {}; |
|
3664 |
|
3665 // Add list-specific methods |
|
3666 jQuery.each( tuples, function( i, tuple ) { |
|
3667 var list = tuple[ 2 ], |
|
3668 stateString = tuple[ 5 ]; |
|
3669 |
|
3670 // promise.progress = list.add |
|
3671 // promise.done = list.add |
|
3672 // promise.fail = list.add |
|
3673 promise[ tuple[ 1 ] ] = list.add; |
|
3674 |
|
3675 // Handle state |
|
3676 if ( stateString ) { |
|
3677 list.add( |
|
3678 function() { |
|
3679 |
|
3680 // state = "resolved" (i.e., fulfilled) |
|
3681 // state = "rejected" |
|
3682 state = stateString; |
|
3683 }, |
|
3684 |
|
3685 // rejected_callbacks.disable |
|
3686 // fulfilled_callbacks.disable |
|
3687 tuples[ 3 - i ][ 2 ].disable, |
|
3688 |
|
3689 // progress_callbacks.lock |
|
3690 tuples[ 0 ][ 2 ].lock |
|
3691 ); |
|
3692 } |
|
3693 |
|
3694 // progress_handlers.fire |
|
3695 // fulfilled_handlers.fire |
|
3696 // rejected_handlers.fire |
|
3697 list.add( tuple[ 3 ].fire ); |
|
3698 |
|
3699 // deferred.notify = function() { deferred.notifyWith(...) } |
|
3700 // deferred.resolve = function() { deferred.resolveWith(...) } |
|
3701 // deferred.reject = function() { deferred.rejectWith(...) } |
|
3702 deferred[ tuple[ 0 ] ] = function() { |
|
3703 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); |
|
3704 return this; |
|
3705 }; |
|
3706 |
|
3707 // deferred.notifyWith = list.fireWith |
|
3708 // deferred.resolveWith = list.fireWith |
|
3709 // deferred.rejectWith = list.fireWith |
|
3710 deferred[ tuple[ 0 ] + "With" ] = list.fireWith; |
|
3711 } ); |
|
3712 |
|
3713 // Make the deferred a promise |
|
3714 promise.promise( deferred ); |
|
3715 |
|
3716 // Call given func if any |
|
3717 if ( func ) { |
|
3718 func.call( deferred, deferred ); |
|
3719 } |
|
3720 |
|
3721 // All done! |
|
3722 return deferred; |
|
3723 }, |
|
3724 |
|
3725 // Deferred helper |
|
3726 when: function( singleValue ) { |
|
3727 var |
|
3728 |
|
3729 // count of uncompleted subordinates |
|
3730 remaining = arguments.length, |
|
3731 |
|
3732 // count of unprocessed arguments |
|
3733 i = remaining, |
|
3734 |
|
3735 // subordinate fulfillment data |
|
3736 resolveContexts = Array( i ), |
|
3737 resolveValues = slice.call( arguments ), |
|
3738 |
|
3739 // the master Deferred |
|
3740 master = jQuery.Deferred(), |
|
3741 |
|
3742 // subordinate callback factory |
|
3743 updateFunc = function( i ) { |
|
3744 return function( value ) { |
|
3745 resolveContexts[ i ] = this; |
|
3746 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; |
|
3747 if ( !( --remaining ) ) { |
|
3748 master.resolveWith( resolveContexts, resolveValues ); |
|
3749 } |
|
3750 }; |
|
3751 }; |
|
3752 |
|
3753 // Single- and empty arguments are adopted like Promise.resolve |
|
3754 if ( remaining <= 1 ) { |
|
3755 adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject ); |
|
3756 |
|
3757 // Use .then() to unwrap secondary thenables (cf. gh-3000) |
|
3758 if ( master.state() === "pending" || |
|
3759 jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { |
|
3760 |
|
3761 return master.then(); |
|
3762 } |
|
3763 } |
|
3764 |
|
3765 // Multiple arguments are aggregated like Promise.all array elements |
|
3766 while ( i-- ) { |
|
3767 adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); |
|
3768 } |
|
3769 |
|
3770 return master.promise(); |
|
3771 } |
|
3772 } ); |
|
3773 |
|
3774 |
|
3775 // These usually indicate a programmer mistake during development, |
|
3776 // warn about them ASAP rather than swallowing them by default. |
|
3777 var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; |
|
3778 |
|
3779 jQuery.Deferred.exceptionHook = function( error, stack ) { |
|
3780 |
|
3781 // Support: IE 8 - 9 only |
|
3782 // Console exists when dev tools are open, which can happen at any time |
|
3783 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { |
|
3784 window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); |
|
3785 } |
|
3786 }; |
|
3787 |
|
3788 |
|
3789 |
|
3790 |
|
3791 jQuery.readyException = function( error ) { |
|
3792 window.setTimeout( function() { |
|
3793 throw error; |
|
3794 } ); |
|
3795 }; |
|
3796 |
|
3797 |
|
3798 |
|
3799 |
|
3800 // The deferred used on DOM ready |
|
3801 var readyList = jQuery.Deferred(); |
|
3802 |
|
3803 jQuery.fn.ready = function( fn ) { |
|
3804 |
|
3805 readyList |
|
3806 .then( fn ) |
|
3807 |
|
3808 // Wrap jQuery.readyException in a function so that the lookup |
|
3809 // happens at the time of error handling instead of callback |
|
3810 // registration. |
|
3811 .catch( function( error ) { |
|
3812 jQuery.readyException( error ); |
|
3813 } ); |
|
3814 |
|
3815 return this; |
|
3816 }; |
|
3817 |
|
3818 jQuery.extend( { |
|
3819 |
|
3820 // Is the DOM ready to be used? Set to true once it occurs. |
|
3821 isReady: false, |
|
3822 |
|
3823 // A counter to track how many items to wait for before |
|
3824 // the ready event fires. See #6781 |
|
3825 readyWait: 1, |
|
3826 |
|
3827 // Hold (or release) the ready event |
|
3828 holdReady: function( hold ) { |
|
3829 if ( hold ) { |
|
3830 jQuery.readyWait++; |
|
3831 } else { |
|
3832 jQuery.ready( true ); |
|
3833 } |
|
3834 }, |
|
3835 |
|
3836 // Handle when the DOM is ready |
|
3837 ready: function( wait ) { |
|
3838 |
|
3839 // Abort if there are pending holds or we're already ready |
|
3840 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { |
|
3841 return; |
|
3842 } |
|
3843 |
|
3844 // Remember that the DOM is ready |
|
3845 jQuery.isReady = true; |
|
3846 |
|
3847 // If a normal DOM Ready event fired, decrement, and wait if need be |
|
3848 if ( wait !== true && --jQuery.readyWait > 0 ) { |
|
3849 return; |
|
3850 } |
|
3851 |
|
3852 // If there are functions bound, to execute |
|
3853 readyList.resolveWith( document, [ jQuery ] ); |
|
3854 } |
|
3855 } ); |
|
3856 |
|
3857 jQuery.ready.then = readyList.then; |
|
3858 |
|
3859 // The ready event handler and self cleanup method |
|
3860 function completed() { |
|
3861 document.removeEventListener( "DOMContentLoaded", completed ); |
|
3862 window.removeEventListener( "load", completed ); |
|
3863 jQuery.ready(); |
|
3864 } |
|
3865 |
|
3866 // Catch cases where $(document).ready() is called |
|
3867 // after the browser event has already occurred. |
|
3868 // Support: IE <=9 - 10 only |
|
3869 // Older IE sometimes signals "interactive" too soon |
|
3870 if ( document.readyState === "complete" || |
|
3871 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { |
|
3872 |
|
3873 // Handle it asynchronously to allow scripts the opportunity to delay ready |
|
3874 window.setTimeout( jQuery.ready ); |
|
3875 |
|
3876 } else { |
|
3877 |
|
3878 // Use the handy event callback |
|
3879 document.addEventListener( "DOMContentLoaded", completed ); |
|
3880 |
|
3881 // A fallback to window.onload, that will always work |
|
3882 window.addEventListener( "load", completed ); |
|
3883 } |
|
3884 |
|
3885 |
|
3886 |
|
3887 |
|
3888 // Multifunctional method to get and set values of a collection |
|
3889 // The value/s can optionally be executed if it's a function |
|
3890 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { |
|
3891 var i = 0, |
|
3892 len = elems.length, |
|
3893 bulk = key == null; |
|
3894 |
|
3895 // Sets many values |
|
3896 if ( jQuery.type( key ) === "object" ) { |
|
3897 chainable = true; |
|
3898 for ( i in key ) { |
|
3899 access( elems, fn, i, key[ i ], true, emptyGet, raw ); |
|
3900 } |
|
3901 |
|
3902 // Sets one value |
|
3903 } else if ( value !== undefined ) { |
|
3904 chainable = true; |
|
3905 |
|
3906 if ( !jQuery.isFunction( value ) ) { |
|
3907 raw = true; |
|
3908 } |
|
3909 |
|
3910 if ( bulk ) { |
|
3911 |
|
3912 // Bulk operations run against the entire set |
|
3913 if ( raw ) { |
|
3914 fn.call( elems, value ); |
|
3915 fn = null; |
|
3916 |
|
3917 // ...except when executing function values |
|
3918 } else { |
|
3919 bulk = fn; |
|
3920 fn = function( elem, key, value ) { |
|
3921 return bulk.call( jQuery( elem ), value ); |
|
3922 }; |
|
3923 } |
|
3924 } |
|
3925 |
|
3926 if ( fn ) { |
|
3927 for ( ; i < len; i++ ) { |
|
3928 fn( |
|
3929 elems[ i ], key, raw ? |
|
3930 value : |
|
3931 value.call( elems[ i ], i, fn( elems[ i ], key ) ) |
|
3932 ); |
|
3933 } |
|
3934 } |
|
3935 } |
|
3936 |
|
3937 return chainable ? |
|
3938 elems : |
|
3939 |
|
3940 // Gets |
|
3941 bulk ? |
|
3942 fn.call( elems ) : |
|
3943 len ? fn( elems[ 0 ], key ) : emptyGet; |
|
3944 }; |
|
3945 var acceptData = function( owner ) { |
|
3946 |
|
3947 // Accepts only: |
|
3948 // - Node |
|
3949 // - Node.ELEMENT_NODE |
|
3950 // - Node.DOCUMENT_NODE |
|
3951 // - Object |
|
3952 // - Any |
|
3953 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); |
|
3954 }; |
|
3955 |
|
3956 |
|
3957 |
|
3958 |
|
3959 function Data() { |
|
3960 this.expando = jQuery.expando + Data.uid++; |
|
3961 } |
|
3962 |
|
3963 Data.uid = 1; |
|
3964 |
|
3965 Data.prototype = { |
|
3966 |
|
3967 cache: function( owner ) { |
|
3968 |
|
3969 // Check if the owner object already has a cache |
|
3970 var value = owner[ this.expando ]; |
|
3971 |
|
3972 // If not, create one |
|
3973 if ( !value ) { |
|
3974 value = {}; |
|
3975 |
|
3976 // We can accept data for non-element nodes in modern browsers, |
|
3977 // but we should not, see #8335. |
|
3978 // Always return an empty object. |
|
3979 if ( acceptData( owner ) ) { |
|
3980 |
|
3981 // If it is a node unlikely to be stringify-ed or looped over |
|
3982 // use plain assignment |
|
3983 if ( owner.nodeType ) { |
|
3984 owner[ this.expando ] = value; |
|
3985 |
|
3986 // Otherwise secure it in a non-enumerable property |
|
3987 // configurable must be true to allow the property to be |
|
3988 // deleted when data is removed |
|
3989 } else { |
|
3990 Object.defineProperty( owner, this.expando, { |
|
3991 value: value, |
|
3992 configurable: true |
|
3993 } ); |
|
3994 } |
|
3995 } |
|
3996 } |
|
3997 |
|
3998 return value; |
|
3999 }, |
|
4000 set: function( owner, data, value ) { |
|
4001 var prop, |
|
4002 cache = this.cache( owner ); |
|
4003 |
|
4004 // Handle: [ owner, key, value ] args |
|
4005 // Always use camelCase key (gh-2257) |
|
4006 if ( typeof data === "string" ) { |
|
4007 cache[ jQuery.camelCase( data ) ] = value; |
|
4008 |
|
4009 // Handle: [ owner, { properties } ] args |
|
4010 } else { |
|
4011 |
|
4012 // Copy the properties one-by-one to the cache object |
|
4013 for ( prop in data ) { |
|
4014 cache[ jQuery.camelCase( prop ) ] = data[ prop ]; |
|
4015 } |
|
4016 } |
|
4017 return cache; |
|
4018 }, |
|
4019 get: function( owner, key ) { |
|
4020 return key === undefined ? |
|
4021 this.cache( owner ) : |
|
4022 |
|
4023 // Always use camelCase key (gh-2257) |
|
4024 owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ]; |
|
4025 }, |
|
4026 access: function( owner, key, value ) { |
|
4027 |
|
4028 // In cases where either: |
|
4029 // |
|
4030 // 1. No key was specified |
|
4031 // 2. A string key was specified, but no value provided |
|
4032 // |
|
4033 // Take the "read" path and allow the get method to determine |
|
4034 // which value to return, respectively either: |
|
4035 // |
|
4036 // 1. The entire cache object |
|
4037 // 2. The data stored at the key |
|
4038 // |
|
4039 if ( key === undefined || |
|
4040 ( ( key && typeof key === "string" ) && value === undefined ) ) { |
|
4041 |
|
4042 return this.get( owner, key ); |
|
4043 } |
|
4044 |
|
4045 // When the key is not a string, or both a key and value |
|
4046 // are specified, set or extend (existing objects) with either: |
|
4047 // |
|
4048 // 1. An object of properties |
|
4049 // 2. A key and value |
|
4050 // |
|
4051 this.set( owner, key, value ); |
|
4052 |
|
4053 // Since the "set" path can have two possible entry points |
|
4054 // return the expected data based on which path was taken[*] |
|
4055 return value !== undefined ? value : key; |
|
4056 }, |
|
4057 remove: function( owner, key ) { |
|
4058 var i, |
|
4059 cache = owner[ this.expando ]; |
|
4060 |
|
4061 if ( cache === undefined ) { |
|
4062 return; |
|
4063 } |
|
4064 |
|
4065 if ( key !== undefined ) { |
|
4066 |
|
4067 // Support array or space separated string of keys |
|
4068 if ( jQuery.isArray( key ) ) { |
|
4069 |
|
4070 // If key is an array of keys... |
|
4071 // We always set camelCase keys, so remove that. |
|
4072 key = key.map( jQuery.camelCase ); |
|
4073 } else { |
|
4074 key = jQuery.camelCase( key ); |
|
4075 |
|
4076 // If a key with the spaces exists, use it. |
|
4077 // Otherwise, create an array by matching non-whitespace |
|
4078 key = key in cache ? |
|
4079 [ key ] : |
|
4080 ( key.match( rnotwhite ) || [] ); |
|
4081 } |
|
4082 |
|
4083 i = key.length; |
|
4084 |
|
4085 while ( i-- ) { |
|
4086 delete cache[ key[ i ] ]; |
|
4087 } |
|
4088 } |
|
4089 |
|
4090 // Remove the expando if there's no more data |
|
4091 if ( key === undefined || jQuery.isEmptyObject( cache ) ) { |
|
4092 |
|
4093 // Support: Chrome <=35 - 45 |
|
4094 // Webkit & Blink performance suffers when deleting properties |
|
4095 // from DOM nodes, so set to undefined instead |
|
4096 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) |
|
4097 if ( owner.nodeType ) { |
|
4098 owner[ this.expando ] = undefined; |
|
4099 } else { |
|
4100 delete owner[ this.expando ]; |
|
4101 } |
|
4102 } |
|
4103 }, |
|
4104 hasData: function( owner ) { |
|
4105 var cache = owner[ this.expando ]; |
|
4106 return cache !== undefined && !jQuery.isEmptyObject( cache ); |
|
4107 } |
|
4108 }; |
|
4109 var dataPriv = new Data(); |
|
4110 |
|
4111 var dataUser = new Data(); |
|
4112 |
|
4113 |
|
4114 |
|
4115 // Implementation Summary |
|
4116 // |
|
4117 // 1. Enforce API surface and semantic compatibility with 1.9.x branch |
|
4118 // 2. Improve the module's maintainability by reducing the storage |
|
4119 // paths to a single mechanism. |
|
4120 // 3. Use the same single mechanism to support "private" and "user" data. |
|
4121 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) |
|
4122 // 5. Avoid exposing implementation details on user objects (eg. expando properties) |
|
4123 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 |
|
4124 |
|
4125 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, |
|
4126 rmultiDash = /[A-Z]/g; |
|
4127 |
|
4128 function dataAttr( elem, key, data ) { |
|
4129 var name; |
|
4130 |
|
4131 // If nothing was found internally, try to fetch any |
|
4132 // data from the HTML5 data-* attribute |
|
4133 if ( data === undefined && elem.nodeType === 1 ) { |
|
4134 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); |
|
4135 data = elem.getAttribute( name ); |
|
4136 |
|
4137 if ( typeof data === "string" ) { |
|
4138 try { |
|
4139 data = data === "true" ? true : |
|
4140 data === "false" ? false : |
|
4141 data === "null" ? null : |
|
4142 |
|
4143 // Only convert to a number if it doesn't change the string |
|
4144 +data + "" === data ? +data : |
|
4145 rbrace.test( data ) ? JSON.parse( data ) : |
|
4146 data; |
|
4147 } catch ( e ) {} |
|
4148 |
|
4149 // Make sure we set the data so it isn't changed later |
|
4150 dataUser.set( elem, key, data ); |
|
4151 } else { |
|
4152 data = undefined; |
|
4153 } |
|
4154 } |
|
4155 return data; |
|
4156 } |
|
4157 |
|
4158 jQuery.extend( { |
|
4159 hasData: function( elem ) { |
|
4160 return dataUser.hasData( elem ) || dataPriv.hasData( elem ); |
|
4161 }, |
|
4162 |
|
4163 data: function( elem, name, data ) { |
|
4164 return dataUser.access( elem, name, data ); |
|
4165 }, |
|
4166 |
|
4167 removeData: function( elem, name ) { |
|
4168 dataUser.remove( elem, name ); |
|
4169 }, |
|
4170 |
|
4171 // TODO: Now that all calls to _data and _removeData have been replaced |
|
4172 // with direct calls to dataPriv methods, these can be deprecated. |
|
4173 _data: function( elem, name, data ) { |
|
4174 return dataPriv.access( elem, name, data ); |
|
4175 }, |
|
4176 |
|
4177 _removeData: function( elem, name ) { |
|
4178 dataPriv.remove( elem, name ); |
|
4179 } |
|
4180 } ); |
|
4181 |
|
4182 jQuery.fn.extend( { |
|
4183 data: function( key, value ) { |
|
4184 var i, name, data, |
|
4185 elem = this[ 0 ], |
|
4186 attrs = elem && elem.attributes; |
|
4187 |
|
4188 // Gets all values |
|
4189 if ( key === undefined ) { |
|
4190 if ( this.length ) { |
|
4191 data = dataUser.get( elem ); |
|
4192 |
|
4193 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { |
|
4194 i = attrs.length; |
|
4195 while ( i-- ) { |
|
4196 |
|
4197 // Support: IE 11 only |
|
4198 // The attrs elements can be null (#14894) |
|
4199 if ( attrs[ i ] ) { |
|
4200 name = attrs[ i ].name; |
|
4201 if ( name.indexOf( "data-" ) === 0 ) { |
|
4202 name = jQuery.camelCase( name.slice( 5 ) ); |
|
4203 dataAttr( elem, name, data[ name ] ); |
|
4204 } |
|
4205 } |
|
4206 } |
|
4207 dataPriv.set( elem, "hasDataAttrs", true ); |
|
4208 } |
|
4209 } |
|
4210 |
|
4211 return data; |
|
4212 } |
|
4213 |
|
4214 // Sets multiple values |
|
4215 if ( typeof key === "object" ) { |
|
4216 return this.each( function() { |
|
4217 dataUser.set( this, key ); |
|
4218 } ); |
|
4219 } |
|
4220 |
|
4221 return access( this, function( value ) { |
|
4222 var data; |
|
4223 |
|
4224 // The calling jQuery object (element matches) is not empty |
|
4225 // (and therefore has an element appears at this[ 0 ]) and the |
|
4226 // `value` parameter was not undefined. An empty jQuery object |
|
4227 // will result in `undefined` for elem = this[ 0 ] which will |
|
4228 // throw an exception if an attempt to read a data cache is made. |
|
4229 if ( elem && value === undefined ) { |
|
4230 |
|
4231 // Attempt to get data from the cache |
|
4232 // The key will always be camelCased in Data |
|
4233 data = dataUser.get( elem, key ); |
|
4234 if ( data !== undefined ) { |
|
4235 return data; |
|
4236 } |
|
4237 |
|
4238 // Attempt to "discover" the data in |
|
4239 // HTML5 custom data-* attrs |
|
4240 data = dataAttr( elem, key ); |
|
4241 if ( data !== undefined ) { |
|
4242 return data; |
|
4243 } |
|
4244 |
|
4245 // We tried really hard, but the data doesn't exist. |
|
4246 return; |
|
4247 } |
|
4248 |
|
4249 // Set the data... |
|
4250 this.each( function() { |
|
4251 |
|
4252 // We always store the camelCased key |
|
4253 dataUser.set( this, key, value ); |
|
4254 } ); |
|
4255 }, null, value, arguments.length > 1, null, true ); |
|
4256 }, |
|
4257 |
|
4258 removeData: function( key ) { |
|
4259 return this.each( function() { |
|
4260 dataUser.remove( this, key ); |
|
4261 } ); |
|
4262 } |
|
4263 } ); |
|
4264 |
|
4265 |
|
4266 jQuery.extend( { |
|
4267 queue: function( elem, type, data ) { |
|
4268 var queue; |
|
4269 |
|
4270 if ( elem ) { |
|
4271 type = ( type || "fx" ) + "queue"; |
|
4272 queue = dataPriv.get( elem, type ); |
|
4273 |
|
4274 // Speed up dequeue by getting out quickly if this is just a lookup |
|
4275 if ( data ) { |
|
4276 if ( !queue || jQuery.isArray( data ) ) { |
|
4277 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); |
|
4278 } else { |
|
4279 queue.push( data ); |
|
4280 } |
|
4281 } |
|
4282 return queue || []; |
|
4283 } |
|
4284 }, |
|
4285 |
|
4286 dequeue: function( elem, type ) { |
|
4287 type = type || "fx"; |
|
4288 |
|
4289 var queue = jQuery.queue( elem, type ), |
|
4290 startLength = queue.length, |
|
4291 fn = queue.shift(), |
|
4292 hooks = jQuery._queueHooks( elem, type ), |
|
4293 next = function() { |
|
4294 jQuery.dequeue( elem, type ); |
|
4295 }; |
|
4296 |
|
4297 // If the fx queue is dequeued, always remove the progress sentinel |
|
4298 if ( fn === "inprogress" ) { |
|
4299 fn = queue.shift(); |
|
4300 startLength--; |
|
4301 } |
|
4302 |
|
4303 if ( fn ) { |
|
4304 |
|
4305 // Add a progress sentinel to prevent the fx queue from being |
|
4306 // automatically dequeued |
|
4307 if ( type === "fx" ) { |
|
4308 queue.unshift( "inprogress" ); |
|
4309 } |
|
4310 |
|
4311 // Clear up the last queue stop function |
|
4312 delete hooks.stop; |
|
4313 fn.call( elem, next, hooks ); |
|
4314 } |
|
4315 |
|
4316 if ( !startLength && hooks ) { |
|
4317 hooks.empty.fire(); |
|
4318 } |
|
4319 }, |
|
4320 |
|
4321 // Not public - generate a queueHooks object, or return the current one |
|
4322 _queueHooks: function( elem, type ) { |
|
4323 var key = type + "queueHooks"; |
|
4324 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { |
|
4325 empty: jQuery.Callbacks( "once memory" ).add( function() { |
|
4326 dataPriv.remove( elem, [ type + "queue", key ] ); |
|
4327 } ) |
|
4328 } ); |
|
4329 } |
|
4330 } ); |
|
4331 |
|
4332 jQuery.fn.extend( { |
|
4333 queue: function( type, data ) { |
|
4334 var setter = 2; |
|
4335 |
|
4336 if ( typeof type !== "string" ) { |
|
4337 data = type; |
|
4338 type = "fx"; |
|
4339 setter--; |
|
4340 } |
|
4341 |
|
4342 if ( arguments.length < setter ) { |
|
4343 return jQuery.queue( this[ 0 ], type ); |
|
4344 } |
|
4345 |
|
4346 return data === undefined ? |
|
4347 this : |
|
4348 this.each( function() { |
|
4349 var queue = jQuery.queue( this, type, data ); |
|
4350 |
|
4351 // Ensure a hooks for this queue |
|
4352 jQuery._queueHooks( this, type ); |
|
4353 |
|
4354 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { |
|
4355 jQuery.dequeue( this, type ); |
|
4356 } |
|
4357 } ); |
|
4358 }, |
|
4359 dequeue: function( type ) { |
|
4360 return this.each( function() { |
|
4361 jQuery.dequeue( this, type ); |
|
4362 } ); |
|
4363 }, |
|
4364 clearQueue: function( type ) { |
|
4365 return this.queue( type || "fx", [] ); |
|
4366 }, |
|
4367 |
|
4368 // Get a promise resolved when queues of a certain type |
|
4369 // are emptied (fx is the type by default) |
|
4370 promise: function( type, obj ) { |
|
4371 var tmp, |
|
4372 count = 1, |
|
4373 defer = jQuery.Deferred(), |
|
4374 elements = this, |
|
4375 i = this.length, |
|
4376 resolve = function() { |
|
4377 if ( !( --count ) ) { |
|
4378 defer.resolveWith( elements, [ elements ] ); |
|
4379 } |
|
4380 }; |
|
4381 |
|
4382 if ( typeof type !== "string" ) { |
|
4383 obj = type; |
|
4384 type = undefined; |
|
4385 } |
|
4386 type = type || "fx"; |
|
4387 |
|
4388 while ( i-- ) { |
|
4389 tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); |
|
4390 if ( tmp && tmp.empty ) { |
|
4391 count++; |
|
4392 tmp.empty.add( resolve ); |
|
4393 } |
|
4394 } |
|
4395 resolve(); |
|
4396 return defer.promise( obj ); |
|
4397 } |
|
4398 } ); |
|
4399 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; |
|
4400 |
|
4401 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); |
|
4402 |
|
4403 |
|
4404 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; |
|
4405 |
|
4406 var isHiddenWithinTree = function( elem, el ) { |
|
4407 |
|
4408 // isHiddenWithinTree might be called from jQuery#filter function; |
|
4409 // in that case, element will be second argument |
|
4410 elem = el || elem; |
|
4411 |
|
4412 // Inline style trumps all |
|
4413 return elem.style.display === "none" || |
|
4414 elem.style.display === "" && |
|
4415 |
|
4416 // Otherwise, check computed style |
|
4417 // Support: Firefox <=43 - 45 |
|
4418 // Disconnected elements can have computed display: none, so first confirm that elem is |
|
4419 // in the document. |
|
4420 jQuery.contains( elem.ownerDocument, elem ) && |
|
4421 |
|
4422 jQuery.css( elem, "display" ) === "none"; |
|
4423 }; |
|
4424 |
|
4425 var swap = function( elem, options, callback, args ) { |
|
4426 var ret, name, |
|
4427 old = {}; |
|
4428 |
|
4429 // Remember the old values, and insert the new ones |
|
4430 for ( name in options ) { |
|
4431 old[ name ] = elem.style[ name ]; |
|
4432 elem.style[ name ] = options[ name ]; |
|
4433 } |
|
4434 |
|
4435 ret = callback.apply( elem, args || [] ); |
|
4436 |
|
4437 // Revert the old values |
|
4438 for ( name in options ) { |
|
4439 elem.style[ name ] = old[ name ]; |
|
4440 } |
|
4441 |
|
4442 return ret; |
|
4443 }; |
|
4444 |
|
4445 |
|
4446 |
|
4447 |
|
4448 function adjustCSS( elem, prop, valueParts, tween ) { |
|
4449 var adjusted, |
|
4450 scale = 1, |
|
4451 maxIterations = 20, |
|
4452 currentValue = tween ? |
|
4453 function() { |
|
4454 return tween.cur(); |
|
4455 } : |
|
4456 function() { |
|
4457 return jQuery.css( elem, prop, "" ); |
|
4458 }, |
|
4459 initial = currentValue(), |
|
4460 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
|
4461 |
|
4462 // Starting value computation is required for potential unit mismatches |
|
4463 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && |
|
4464 rcssNum.exec( jQuery.css( elem, prop ) ); |
|
4465 |
|
4466 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { |
|
4467 |
|
4468 // Trust units reported by jQuery.css |
|
4469 unit = unit || initialInUnit[ 3 ]; |
|
4470 |
|
4471 // Make sure we update the tween properties later on |
|
4472 valueParts = valueParts || []; |
|
4473 |
|
4474 // Iteratively approximate from a nonzero starting point |
|
4475 initialInUnit = +initial || 1; |
|
4476 |
|
4477 do { |
|
4478 |
|
4479 // If previous iteration zeroed out, double until we get *something*. |
|
4480 // Use string for doubling so we don't accidentally see scale as unchanged below |
|
4481 scale = scale || ".5"; |
|
4482 |
|
4483 // Adjust and apply |
|
4484 initialInUnit = initialInUnit / scale; |
|
4485 jQuery.style( elem, prop, initialInUnit + unit ); |
|
4486 |
|
4487 // Update scale, tolerating zero or NaN from tween.cur() |
|
4488 // Break the loop if scale is unchanged or perfect, or if we've just had enough. |
|
4489 } while ( |
|
4490 scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations |
|
4491 ); |
|
4492 } |
|
4493 |
|
4494 if ( valueParts ) { |
|
4495 initialInUnit = +initialInUnit || +initial || 0; |
|
4496 |
|
4497 // Apply relative offset (+=/-=) if specified |
|
4498 adjusted = valueParts[ 1 ] ? |
|
4499 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : |
|
4500 +valueParts[ 2 ]; |
|
4501 if ( tween ) { |
|
4502 tween.unit = unit; |
|
4503 tween.start = initialInUnit; |
|
4504 tween.end = adjusted; |
|
4505 } |
|
4506 } |
|
4507 return adjusted; |
|
4508 } |
|
4509 |
|
4510 |
|
4511 var defaultDisplayMap = {}; |
|
4512 |
|
4513 function getDefaultDisplay( elem ) { |
|
4514 var temp, |
|
4515 doc = elem.ownerDocument, |
|
4516 nodeName = elem.nodeName, |
|
4517 display = defaultDisplayMap[ nodeName ]; |
|
4518 |
|
4519 if ( display ) { |
|
4520 return display; |
|
4521 } |
|
4522 |
|
4523 temp = doc.body.appendChild( doc.createElement( nodeName ) ), |
|
4524 display = jQuery.css( temp, "display" ); |
|
4525 |
|
4526 temp.parentNode.removeChild( temp ); |
|
4527 |
|
4528 if ( display === "none" ) { |
|
4529 display = "block"; |
|
4530 } |
|
4531 defaultDisplayMap[ nodeName ] = display; |
|
4532 |
|
4533 return display; |
|
4534 } |
|
4535 |
|
4536 function showHide( elements, show ) { |
|
4537 var display, elem, |
|
4538 values = [], |
|
4539 index = 0, |
|
4540 length = elements.length; |
|
4541 |
|
4542 // Determine new display value for elements that need to change |
|
4543 for ( ; index < length; index++ ) { |
|
4544 elem = elements[ index ]; |
|
4545 if ( !elem.style ) { |
|
4546 continue; |
|
4547 } |
|
4548 |
|
4549 display = elem.style.display; |
|
4550 if ( show ) { |
|
4551 |
|
4552 // Since we force visibility upon cascade-hidden elements, an immediate (and slow) |
|
4553 // check is required in this first loop unless we have a nonempty display value (either |
|
4554 // inline or about-to-be-restored) |
|
4555 if ( display === "none" ) { |
|
4556 values[ index ] = dataPriv.get( elem, "display" ) || null; |
|
4557 if ( !values[ index ] ) { |
|
4558 elem.style.display = ""; |
|
4559 } |
|
4560 } |
|
4561 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { |
|
4562 values[ index ] = getDefaultDisplay( elem ); |
|
4563 } |
|
4564 } else { |
|
4565 if ( display !== "none" ) { |
|
4566 values[ index ] = "none"; |
|
4567 |
|
4568 // Remember what we're overwriting |
|
4569 dataPriv.set( elem, "display", display ); |
|
4570 } |
|
4571 } |
|
4572 } |
|
4573 |
|
4574 // Set the display of the elements in a second loop to avoid constant reflow |
|
4575 for ( index = 0; index < length; index++ ) { |
|
4576 if ( values[ index ] != null ) { |
|
4577 elements[ index ].style.display = values[ index ]; |
|
4578 } |
|
4579 } |
|
4580 |
|
4581 return elements; |
|
4582 } |
|
4583 |
|
4584 jQuery.fn.extend( { |
|
4585 show: function() { |
|
4586 return showHide( this, true ); |
|
4587 }, |
|
4588 hide: function() { |
|
4589 return showHide( this ); |
|
4590 }, |
|
4591 toggle: function( state ) { |
|
4592 if ( typeof state === "boolean" ) { |
|
4593 return state ? this.show() : this.hide(); |
|
4594 } |
|
4595 |
|
4596 return this.each( function() { |
|
4597 if ( isHiddenWithinTree( this ) ) { |
|
4598 jQuery( this ).show(); |
|
4599 } else { |
|
4600 jQuery( this ).hide(); |
|
4601 } |
|
4602 } ); |
|
4603 } |
|
4604 } ); |
|
4605 var rcheckableType = ( /^(?:checkbox|radio)$/i ); |
|
4606 |
|
4607 var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i ); |
|
4608 |
|
4609 var rscriptType = ( /^$|\/(?:java|ecma)script/i ); |
|
4610 |
|
4611 |
|
4612 |
|
4613 // We have to close these tags to support XHTML (#13200) |
|
4614 var wrapMap = { |
|
4615 |
|
4616 // Support: IE <=9 only |
|
4617 option: [ 1, "<select multiple='multiple'>", "</select>" ], |
|
4618 |
|
4619 // XHTML parsers do not magically insert elements in the |
|
4620 // same way that tag soup parsers do. So we cannot shorten |
|
4621 // this by omitting <tbody> or other required elements. |
|
4622 thead: [ 1, "<table>", "</table>" ], |
|
4623 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], |
|
4624 tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
|
4625 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
|
4626 |
|
4627 _default: [ 0, "", "" ] |
|
4628 }; |
|
4629 |
|
4630 // Support: IE <=9 only |
|
4631 wrapMap.optgroup = wrapMap.option; |
|
4632 |
|
4633 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
|
4634 wrapMap.th = wrapMap.td; |
|
4635 |
|
4636 |
|
4637 function getAll( context, tag ) { |
|
4638 |
|
4639 // Support: IE <=9 - 11 only |
|
4640 // Use typeof to avoid zero-argument method invocation on host objects (#15151) |
|
4641 var ret = typeof context.getElementsByTagName !== "undefined" ? |
|
4642 context.getElementsByTagName( tag || "*" ) : |
|
4643 typeof context.querySelectorAll !== "undefined" ? |
|
4644 context.querySelectorAll( tag || "*" ) : |
|
4645 []; |
|
4646 |
|
4647 return tag === undefined || tag && jQuery.nodeName( context, tag ) ? |
|
4648 jQuery.merge( [ context ], ret ) : |
|
4649 ret; |
|
4650 } |
|
4651 |
|
4652 |
|
4653 // Mark scripts as having already been evaluated |
|
4654 function setGlobalEval( elems, refElements ) { |
|
4655 var i = 0, |
|
4656 l = elems.length; |
|
4657 |
|
4658 for ( ; i < l; i++ ) { |
|
4659 dataPriv.set( |
|
4660 elems[ i ], |
|
4661 "globalEval", |
|
4662 !refElements || dataPriv.get( refElements[ i ], "globalEval" ) |
|
4663 ); |
|
4664 } |
|
4665 } |
|
4666 |
|
4667 |
|
4668 var rhtml = /<|&#?\w+;/; |
|
4669 |
|
4670 function buildFragment( elems, context, scripts, selection, ignored ) { |
|
4671 var elem, tmp, tag, wrap, contains, j, |
|
4672 fragment = context.createDocumentFragment(), |
|
4673 nodes = [], |
|
4674 i = 0, |
|
4675 l = elems.length; |
|
4676 |
|
4677 for ( ; i < l; i++ ) { |
|
4678 elem = elems[ i ]; |
|
4679 |
|
4680 if ( elem || elem === 0 ) { |
|
4681 |
|
4682 // Add nodes directly |
|
4683 if ( jQuery.type( elem ) === "object" ) { |
|
4684 |
|
4685 // Support: Android <=4.0 only, PhantomJS 1 only |
|
4686 // push.apply(_, arraylike) throws on ancient WebKit |
|
4687 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); |
|
4688 |
|
4689 // Convert non-html into a text node |
|
4690 } else if ( !rhtml.test( elem ) ) { |
|
4691 nodes.push( context.createTextNode( elem ) ); |
|
4692 |
|
4693 // Convert html into DOM nodes |
|
4694 } else { |
|
4695 tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); |
|
4696 |
|
4697 // Deserialize a standard representation |
|
4698 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); |
|
4699 wrap = wrapMap[ tag ] || wrapMap._default; |
|
4700 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; |
|
4701 |
|
4702 // Descend through wrappers to the right content |
|
4703 j = wrap[ 0 ]; |
|
4704 while ( j-- ) { |
|
4705 tmp = tmp.lastChild; |
|
4706 } |
|
4707 |
|
4708 // Support: Android <=4.0 only, PhantomJS 1 only |
|
4709 // push.apply(_, arraylike) throws on ancient WebKit |
|
4710 jQuery.merge( nodes, tmp.childNodes ); |
|
4711 |
|
4712 // Remember the top-level container |
|
4713 tmp = fragment.firstChild; |
|
4714 |
|
4715 // Ensure the created nodes are orphaned (#12392) |
|
4716 tmp.textContent = ""; |
|
4717 } |
|
4718 } |
|
4719 } |
|
4720 |
|
4721 // Remove wrapper from fragment |
|
4722 fragment.textContent = ""; |
|
4723 |
|
4724 i = 0; |
|
4725 while ( ( elem = nodes[ i++ ] ) ) { |
|
4726 |
|
4727 // Skip elements already in the context collection (trac-4087) |
|
4728 if ( selection && jQuery.inArray( elem, selection ) > -1 ) { |
|
4729 if ( ignored ) { |
|
4730 ignored.push( elem ); |
|
4731 } |
|
4732 continue; |
|
4733 } |
|
4734 |
|
4735 contains = jQuery.contains( elem.ownerDocument, elem ); |
|
4736 |
|
4737 // Append to fragment |
|
4738 tmp = getAll( fragment.appendChild( elem ), "script" ); |
|
4739 |
|
4740 // Preserve script evaluation history |
|
4741 if ( contains ) { |
|
4742 setGlobalEval( tmp ); |
|
4743 } |
|
4744 |
|
4745 // Capture executables |
|
4746 if ( scripts ) { |
|
4747 j = 0; |
|
4748 while ( ( elem = tmp[ j++ ] ) ) { |
|
4749 if ( rscriptType.test( elem.type || "" ) ) { |
|
4750 scripts.push( elem ); |
|
4751 } |
|
4752 } |
|
4753 } |
|
4754 } |
|
4755 |
|
4756 return fragment; |
|
4757 } |
|
4758 |
|
4759 |
|
4760 ( function() { |
|
4761 var fragment = document.createDocumentFragment(), |
|
4762 div = fragment.appendChild( document.createElement( "div" ) ), |
|
4763 input = document.createElement( "input" ); |
|
4764 |
|
4765 // Support: Android 4.0 - 4.3 only |
|
4766 // Check state lost if the name is set (#11217) |
|
4767 // Support: Windows Web Apps (WWA) |
|
4768 // `name` and `type` must use .setAttribute for WWA (#14901) |
|
4769 input.setAttribute( "type", "radio" ); |
|
4770 input.setAttribute( "checked", "checked" ); |
|
4771 input.setAttribute( "name", "t" ); |
|
4772 |
|
4773 div.appendChild( input ); |
|
4774 |
|
4775 // Support: Android <=4.1 only |
|
4776 // Older WebKit doesn't clone checked state correctly in fragments |
|
4777 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; |
|
4778 |
|
4779 // Support: IE <=11 only |
|
4780 // Make sure textarea (and checkbox) defaultValue is properly cloned |
|
4781 div.innerHTML = "<textarea>x</textarea>"; |
|
4782 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; |
|
4783 } )(); |
|
4784 var documentElement = document.documentElement; |
|
4785 |
|
4786 |
|
4787 |
|
4788 var |
|
4789 rkeyEvent = /^key/, |
|
4790 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, |
|
4791 rtypenamespace = /^([^.]*)(?:\.(.+)|)/; |
|
4792 |
|
4793 function returnTrue() { |
|
4794 return true; |
|
4795 } |
|
4796 |
|
4797 function returnFalse() { |
|
4798 return false; |
|
4799 } |
|
4800 |
|
4801 // Support: IE <=9 only |
|
4802 // See #13393 for more info |
|
4803 function safeActiveElement() { |
|
4804 try { |
|
4805 return document.activeElement; |
|
4806 } catch ( err ) { } |
|
4807 } |
|
4808 |
|
4809 function on( elem, types, selector, data, fn, one ) { |
|
4810 var origFn, type; |
|
4811 |
|
4812 // Types can be a map of types/handlers |
|
4813 if ( typeof types === "object" ) { |
|
4814 |
|
4815 // ( types-Object, selector, data ) |
|
4816 if ( typeof selector !== "string" ) { |
|
4817 |
|
4818 // ( types-Object, data ) |
|
4819 data = data || selector; |
|
4820 selector = undefined; |
|
4821 } |
|
4822 for ( type in types ) { |
|
4823 on( elem, type, selector, data, types[ type ], one ); |
|
4824 } |
|
4825 return elem; |
|
4826 } |
|
4827 |
|
4828 if ( data == null && fn == null ) { |
|
4829 |
|
4830 // ( types, fn ) |
|
4831 fn = selector; |
|
4832 data = selector = undefined; |
|
4833 } else if ( fn == null ) { |
|
4834 if ( typeof selector === "string" ) { |
|
4835 |
|
4836 // ( types, selector, fn ) |
|
4837 fn = data; |
|
4838 data = undefined; |
|
4839 } else { |
|
4840 |
|
4841 // ( types, data, fn ) |
|
4842 fn = data; |
|
4843 data = selector; |
|
4844 selector = undefined; |
|
4845 } |
|
4846 } |
|
4847 if ( fn === false ) { |
|
4848 fn = returnFalse; |
|
4849 } else if ( !fn ) { |
|
4850 return elem; |
|
4851 } |
|
4852 |
|
4853 if ( one === 1 ) { |
|
4854 origFn = fn; |
|
4855 fn = function( event ) { |
|
4856 |
|
4857 // Can use an empty set, since event contains the info |
|
4858 jQuery().off( event ); |
|
4859 return origFn.apply( this, arguments ); |
|
4860 }; |
|
4861 |
|
4862 // Use same guid so caller can remove using origFn |
|
4863 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); |
|
4864 } |
|
4865 return elem.each( function() { |
|
4866 jQuery.event.add( this, types, fn, data, selector ); |
|
4867 } ); |
|
4868 } |
|
4869 |
|
4870 /* |
|
4871 * Helper functions for managing events -- not part of the public interface. |
|
4872 * Props to Dean Edwards' addEvent library for many of the ideas. |
|
4873 */ |
|
4874 jQuery.event = { |
|
4875 |
|
4876 global: {}, |
|
4877 |
|
4878 add: function( elem, types, handler, data, selector ) { |
|
4879 |
|
4880 var handleObjIn, eventHandle, tmp, |
|
4881 events, t, handleObj, |
|
4882 special, handlers, type, namespaces, origType, |
|
4883 elemData = dataPriv.get( elem ); |
|
4884 |
|
4885 // Don't attach events to noData or text/comment nodes (but allow plain objects) |
|
4886 if ( !elemData ) { |
|
4887 return; |
|
4888 } |
|
4889 |
|
4890 // Caller can pass in an object of custom data in lieu of the handler |
|
4891 if ( handler.handler ) { |
|
4892 handleObjIn = handler; |
|
4893 handler = handleObjIn.handler; |
|
4894 selector = handleObjIn.selector; |
|
4895 } |
|
4896 |
|
4897 // Ensure that invalid selectors throw exceptions at attach time |
|
4898 // Evaluate against documentElement in case elem is a non-element node (e.g., document) |
|
4899 if ( selector ) { |
|
4900 jQuery.find.matchesSelector( documentElement, selector ); |
|
4901 } |
|
4902 |
|
4903 // Make sure that the handler has a unique ID, used to find/remove it later |
|
4904 if ( !handler.guid ) { |
|
4905 handler.guid = jQuery.guid++; |
|
4906 } |
|
4907 |
|
4908 // Init the element's event structure and main handler, if this is the first |
|
4909 if ( !( events = elemData.events ) ) { |
|
4910 events = elemData.events = {}; |
|
4911 } |
|
4912 if ( !( eventHandle = elemData.handle ) ) { |
|
4913 eventHandle = elemData.handle = function( e ) { |
|
4914 |
|
4915 // Discard the second event of a jQuery.event.trigger() and |
|
4916 // when an event is called after a page has unloaded |
|
4917 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? |
|
4918 jQuery.event.dispatch.apply( elem, arguments ) : undefined; |
|
4919 }; |
|
4920 } |
|
4921 |
|
4922 // Handle multiple events separated by a space |
|
4923 types = ( types || "" ).match( rnotwhite ) || [ "" ]; |
|
4924 t = types.length; |
|
4925 while ( t-- ) { |
|
4926 tmp = rtypenamespace.exec( types[ t ] ) || []; |
|
4927 type = origType = tmp[ 1 ]; |
|
4928 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); |
|
4929 |
|
4930 // There *must* be a type, no attaching namespace-only handlers |
|
4931 if ( !type ) { |
|
4932 continue; |
|
4933 } |
|
4934 |
|
4935 // If event changes its type, use the special event handlers for the changed type |
|
4936 special = jQuery.event.special[ type ] || {}; |
|
4937 |
|
4938 // If selector defined, determine special event api type, otherwise given type |
|
4939 type = ( selector ? special.delegateType : special.bindType ) || type; |
|
4940 |
|
4941 // Update special based on newly reset type |
|
4942 special = jQuery.event.special[ type ] || {}; |
|
4943 |
|
4944 // handleObj is passed to all event handlers |
|
4945 handleObj = jQuery.extend( { |
|
4946 type: type, |
|
4947 origType: origType, |
|
4948 data: data, |
|
4949 handler: handler, |
|
4950 guid: handler.guid, |
|
4951 selector: selector, |
|
4952 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), |
|
4953 namespace: namespaces.join( "." ) |
|
4954 }, handleObjIn ); |
|
4955 |
|
4956 // Init the event handler queue if we're the first |
|
4957 if ( !( handlers = events[ type ] ) ) { |
|
4958 handlers = events[ type ] = []; |
|
4959 handlers.delegateCount = 0; |
|
4960 |
|
4961 // Only use addEventListener if the special events handler returns false |
|
4962 if ( !special.setup || |
|
4963 special.setup.call( elem, data, namespaces, eventHandle ) === false ) { |
|
4964 |
|
4965 if ( elem.addEventListener ) { |
|
4966 elem.addEventListener( type, eventHandle ); |
|
4967 } |
|
4968 } |
|
4969 } |
|
4970 |
|
4971 if ( special.add ) { |
|
4972 special.add.call( elem, handleObj ); |
|
4973 |
|
4974 if ( !handleObj.handler.guid ) { |
|
4975 handleObj.handler.guid = handler.guid; |
|
4976 } |
|
4977 } |
|
4978 |
|
4979 // Add to the element's handler list, delegates in front |
|
4980 if ( selector ) { |
|
4981 handlers.splice( handlers.delegateCount++, 0, handleObj ); |
|
4982 } else { |
|
4983 handlers.push( handleObj ); |
|
4984 } |
|
4985 |
|
4986 // Keep track of which events have ever been used, for event optimization |
|
4987 jQuery.event.global[ type ] = true; |
|
4988 } |
|
4989 |
|
4990 }, |
|
4991 |
|
4992 // Detach an event or set of events from an element |
|
4993 remove: function( elem, types, handler, selector, mappedTypes ) { |
|
4994 |
|
4995 var j, origCount, tmp, |
|
4996 events, t, handleObj, |
|
4997 special, handlers, type, namespaces, origType, |
|
4998 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); |
|
4999 |
|
5000 if ( !elemData || !( events = elemData.events ) ) { |
|
5001 return; |
|
5002 } |
|
5003 |
|
5004 // Once for each type.namespace in types; type may be omitted |
|
5005 types = ( types || "" ).match( rnotwhite ) || [ "" ]; |
|
5006 t = types.length; |
|
5007 while ( t-- ) { |
|
5008 tmp = rtypenamespace.exec( types[ t ] ) || []; |
|
5009 type = origType = tmp[ 1 ]; |
|
5010 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); |
|
5011 |
|
5012 // Unbind all events (on this namespace, if provided) for the element |
|
5013 if ( !type ) { |
|
5014 for ( type in events ) { |
|
5015 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); |
|
5016 } |
|
5017 continue; |
|
5018 } |
|
5019 |
|
5020 special = jQuery.event.special[ type ] || {}; |
|
5021 type = ( selector ? special.delegateType : special.bindType ) || type; |
|
5022 handlers = events[ type ] || []; |
|
5023 tmp = tmp[ 2 ] && |
|
5024 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); |
|
5025 |
|
5026 // Remove matching events |
|
5027 origCount = j = handlers.length; |
|
5028 while ( j-- ) { |
|
5029 handleObj = handlers[ j ]; |
|
5030 |
|
5031 if ( ( mappedTypes || origType === handleObj.origType ) && |
|
5032 ( !handler || handler.guid === handleObj.guid ) && |
|
5033 ( !tmp || tmp.test( handleObj.namespace ) ) && |
|
5034 ( !selector || selector === handleObj.selector || |
|
5035 selector === "**" && handleObj.selector ) ) { |
|
5036 handlers.splice( j, 1 ); |
|
5037 |
|
5038 if ( handleObj.selector ) { |
|
5039 handlers.delegateCount--; |
|
5040 } |
|
5041 if ( special.remove ) { |
|
5042 special.remove.call( elem, handleObj ); |
|
5043 } |
|
5044 } |
|
5045 } |
|
5046 |
|
5047 // Remove generic event handler if we removed something and no more handlers exist |
|
5048 // (avoids potential for endless recursion during removal of special event handlers) |
|
5049 if ( origCount && !handlers.length ) { |
|
5050 if ( !special.teardown || |
|
5051 special.teardown.call( elem, namespaces, elemData.handle ) === false ) { |
|
5052 |
|
5053 jQuery.removeEvent( elem, type, elemData.handle ); |
|
5054 } |
|
5055 |
|
5056 delete events[ type ]; |
|
5057 } |
|
5058 } |
|
5059 |
|
5060 // Remove data and the expando if it's no longer used |
|
5061 if ( jQuery.isEmptyObject( events ) ) { |
|
5062 dataPriv.remove( elem, "handle events" ); |
|
5063 } |
|
5064 }, |
|
5065 |
|
5066 dispatch: function( nativeEvent ) { |
|
5067 |
|
5068 // Make a writable jQuery.Event from the native event object |
|
5069 var event = jQuery.event.fix( nativeEvent ); |
|
5070 |
|
5071 var i, j, ret, matched, handleObj, handlerQueue, |
|
5072 args = new Array( arguments.length ), |
|
5073 handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], |
|
5074 special = jQuery.event.special[ event.type ] || {}; |
|
5075 |
|
5076 // Use the fix-ed jQuery.Event rather than the (read-only) native event |
|
5077 args[ 0 ] = event; |
|
5078 |
|
5079 for ( i = 1; i < arguments.length; i++ ) { |
|
5080 args[ i ] = arguments[ i ]; |
|
5081 } |
|
5082 |
|
5083 event.delegateTarget = this; |
|
5084 |
|
5085 // Call the preDispatch hook for the mapped type, and let it bail if desired |
|
5086 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { |
|
5087 return; |
|
5088 } |
|
5089 |
|
5090 // Determine handlers |
|
5091 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); |
|
5092 |
|
5093 // Run delegates first; they may want to stop propagation beneath us |
|
5094 i = 0; |
|
5095 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { |
|
5096 event.currentTarget = matched.elem; |
|
5097 |
|
5098 j = 0; |
|
5099 while ( ( handleObj = matched.handlers[ j++ ] ) && |
|
5100 !event.isImmediatePropagationStopped() ) { |
|
5101 |
|
5102 // Triggered event must either 1) have no namespace, or 2) have namespace(s) |
|
5103 // a subset or equal to those in the bound event (both can have no namespace). |
|
5104 if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { |
|
5105 |
|
5106 event.handleObj = handleObj; |
|
5107 event.data = handleObj.data; |
|
5108 |
|
5109 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || |
|
5110 handleObj.handler ).apply( matched.elem, args ); |
|
5111 |
|
5112 if ( ret !== undefined ) { |
|
5113 if ( ( event.result = ret ) === false ) { |
|
5114 event.preventDefault(); |
|
5115 event.stopPropagation(); |
|
5116 } |
|
5117 } |
|
5118 } |
|
5119 } |
|
5120 } |
|
5121 |
|
5122 // Call the postDispatch hook for the mapped type |
|
5123 if ( special.postDispatch ) { |
|
5124 special.postDispatch.call( this, event ); |
|
5125 } |
|
5126 |
|
5127 return event.result; |
|
5128 }, |
|
5129 |
|
5130 handlers: function( event, handlers ) { |
|
5131 var i, matches, sel, handleObj, |
|
5132 handlerQueue = [], |
|
5133 delegateCount = handlers.delegateCount, |
|
5134 cur = event.target; |
|
5135 |
|
5136 // Support: IE <=9 |
|
5137 // Find delegate handlers |
|
5138 // Black-hole SVG <use> instance trees (#13180) |
|
5139 // |
|
5140 // Support: Firefox <=42 |
|
5141 // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343) |
|
5142 if ( delegateCount && cur.nodeType && |
|
5143 ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) { |
|
5144 |
|
5145 for ( ; cur !== this; cur = cur.parentNode || this ) { |
|
5146 |
|
5147 // Don't check non-elements (#13208) |
|
5148 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) |
|
5149 if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) { |
|
5150 matches = []; |
|
5151 for ( i = 0; i < delegateCount; i++ ) { |
|
5152 handleObj = handlers[ i ]; |
|
5153 |
|
5154 // Don't conflict with Object.prototype properties (#13203) |
|
5155 sel = handleObj.selector + " "; |
|
5156 |
|
5157 if ( matches[ sel ] === undefined ) { |
|
5158 matches[ sel ] = handleObj.needsContext ? |
|
5159 jQuery( sel, this ).index( cur ) > -1 : |
|
5160 jQuery.find( sel, this, null, [ cur ] ).length; |
|
5161 } |
|
5162 if ( matches[ sel ] ) { |
|
5163 matches.push( handleObj ); |
|
5164 } |
|
5165 } |
|
5166 if ( matches.length ) { |
|
5167 handlerQueue.push( { elem: cur, handlers: matches } ); |
|
5168 } |
|
5169 } |
|
5170 } |
|
5171 } |
|
5172 |
|
5173 // Add the remaining (directly-bound) handlers |
|
5174 if ( delegateCount < handlers.length ) { |
|
5175 handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } ); |
|
5176 } |
|
5177 |
|
5178 return handlerQueue; |
|
5179 }, |
|
5180 |
|
5181 addProp: function( name, hook ) { |
|
5182 Object.defineProperty( jQuery.Event.prototype, name, { |
|
5183 enumerable: true, |
|
5184 configurable: true, |
|
5185 |
|
5186 get: jQuery.isFunction( hook ) ? |
|
5187 function() { |
|
5188 if ( this.originalEvent ) { |
|
5189 return hook( this.originalEvent ); |
|
5190 } |
|
5191 } : |
|
5192 function() { |
|
5193 if ( this.originalEvent ) { |
|
5194 return this.originalEvent[ name ]; |
|
5195 } |
|
5196 }, |
|
5197 |
|
5198 set: function( value ) { |
|
5199 Object.defineProperty( this, name, { |
|
5200 enumerable: true, |
|
5201 configurable: true, |
|
5202 writable: true, |
|
5203 value: value |
|
5204 } ); |
|
5205 } |
|
5206 } ); |
|
5207 }, |
|
5208 |
|
5209 fix: function( originalEvent ) { |
|
5210 return originalEvent[ jQuery.expando ] ? |
|
5211 originalEvent : |
|
5212 new jQuery.Event( originalEvent ); |
|
5213 }, |
|
5214 |
|
5215 special: { |
|
5216 load: { |
|
5217 |
|
5218 // Prevent triggered image.load events from bubbling to window.load |
|
5219 noBubble: true |
|
5220 }, |
|
5221 focus: { |
|
5222 |
|
5223 // Fire native event if possible so blur/focus sequence is correct |
|
5224 trigger: function() { |
|
5225 if ( this !== safeActiveElement() && this.focus ) { |
|
5226 this.focus(); |
|
5227 return false; |
|
5228 } |
|
5229 }, |
|
5230 delegateType: "focusin" |
|
5231 }, |
|
5232 blur: { |
|
5233 trigger: function() { |
|
5234 if ( this === safeActiveElement() && this.blur ) { |
|
5235 this.blur(); |
|
5236 return false; |
|
5237 } |
|
5238 }, |
|
5239 delegateType: "focusout" |
|
5240 }, |
|
5241 click: { |
|
5242 |
|
5243 // For checkbox, fire native event so checked state will be right |
|
5244 trigger: function() { |
|
5245 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { |
|
5246 this.click(); |
|
5247 return false; |
|
5248 } |
|
5249 }, |
|
5250 |
|
5251 // For cross-browser consistency, don't fire native .click() on links |
|
5252 _default: function( event ) { |
|
5253 return jQuery.nodeName( event.target, "a" ); |
|
5254 } |
|
5255 }, |
|
5256 |
|
5257 beforeunload: { |
|
5258 postDispatch: function( event ) { |
|
5259 |
|
5260 // Support: Firefox 20+ |
|
5261 // Firefox doesn't alert if the returnValue field is not set. |
|
5262 if ( event.result !== undefined && event.originalEvent ) { |
|
5263 event.originalEvent.returnValue = event.result; |
|
5264 } |
|
5265 } |
|
5266 } |
|
5267 } |
|
5268 }; |
|
5269 |
|
5270 jQuery.removeEvent = function( elem, type, handle ) { |
|
5271 |
|
5272 // This "if" is needed for plain objects |
|
5273 if ( elem.removeEventListener ) { |
|
5274 elem.removeEventListener( type, handle ); |
|
5275 } |
|
5276 }; |
|
5277 |
|
5278 jQuery.Event = function( src, props ) { |
|
5279 |
|
5280 // Allow instantiation without the 'new' keyword |
|
5281 if ( !( this instanceof jQuery.Event ) ) { |
|
5282 return new jQuery.Event( src, props ); |
|
5283 } |
|
5284 |
|
5285 // Event object |
|
5286 if ( src && src.type ) { |
|
5287 this.originalEvent = src; |
|
5288 this.type = src.type; |
|
5289 |
|
5290 // Events bubbling up the document may have been marked as prevented |
|
5291 // by a handler lower down the tree; reflect the correct value. |
|
5292 this.isDefaultPrevented = src.defaultPrevented || |
|
5293 src.defaultPrevented === undefined && |
|
5294 |
|
5295 // Support: Android <=2.3 only |
|
5296 src.returnValue === false ? |
|
5297 returnTrue : |
|
5298 returnFalse; |
|
5299 |
|
5300 // Create target properties |
|
5301 // Support: Safari <=6 - 7 only |
|
5302 // Target should not be a text node (#504, #13143) |
|
5303 this.target = ( src.target && src.target.nodeType === 3 ) ? |
|
5304 src.target.parentNode : |
|
5305 src.target; |
|
5306 |
|
5307 this.currentTarget = src.currentTarget; |
|
5308 this.relatedTarget = src.relatedTarget; |
|
5309 |
|
5310 // Event type |
|
5311 } else { |
|
5312 this.type = src; |
|
5313 } |
|
5314 |
|
5315 // Put explicitly provided properties onto the event object |
|
5316 if ( props ) { |
|
5317 jQuery.extend( this, props ); |
|
5318 } |
|
5319 |
|
5320 // Create a timestamp if incoming event doesn't have one |
|
5321 this.timeStamp = src && src.timeStamp || jQuery.now(); |
|
5322 |
|
5323 // Mark it as fixed |
|
5324 this[ jQuery.expando ] = true; |
|
5325 }; |
|
5326 |
|
5327 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
|
5328 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
|
5329 jQuery.Event.prototype = { |
|
5330 constructor: jQuery.Event, |
|
5331 isDefaultPrevented: returnFalse, |
|
5332 isPropagationStopped: returnFalse, |
|
5333 isImmediatePropagationStopped: returnFalse, |
|
5334 isSimulated: false, |
|
5335 |
|
5336 preventDefault: function() { |
|
5337 var e = this.originalEvent; |
|
5338 |
|
5339 this.isDefaultPrevented = returnTrue; |
|
5340 |
|
5341 if ( e && !this.isSimulated ) { |
|
5342 e.preventDefault(); |
|
5343 } |
|
5344 }, |
|
5345 stopPropagation: function() { |
|
5346 var e = this.originalEvent; |
|
5347 |
|
5348 this.isPropagationStopped = returnTrue; |
|
5349 |
|
5350 if ( e && !this.isSimulated ) { |
|
5351 e.stopPropagation(); |
|
5352 } |
|
5353 }, |
|
5354 stopImmediatePropagation: function() { |
|
5355 var e = this.originalEvent; |
|
5356 |
|
5357 this.isImmediatePropagationStopped = returnTrue; |
|
5358 |
|
5359 if ( e && !this.isSimulated ) { |
|
5360 e.stopImmediatePropagation(); |
|
5361 } |
|
5362 |
|
5363 this.stopPropagation(); |
|
5364 } |
|
5365 }; |
|
5366 |
|
5367 // Includes all common event props including KeyEvent and MouseEvent specific props |
|
5368 jQuery.each( { |
|
5369 altKey: true, |
|
5370 bubbles: true, |
|
5371 cancelable: true, |
|
5372 changedTouches: true, |
|
5373 ctrlKey: true, |
|
5374 detail: true, |
|
5375 eventPhase: true, |
|
5376 metaKey: true, |
|
5377 pageX: true, |
|
5378 pageY: true, |
|
5379 shiftKey: true, |
|
5380 view: true, |
|
5381 "char": true, |
|
5382 charCode: true, |
|
5383 key: true, |
|
5384 keyCode: true, |
|
5385 button: true, |
|
5386 buttons: true, |
|
5387 clientX: true, |
|
5388 clientY: true, |
|
5389 offsetX: true, |
|
5390 offsetY: true, |
|
5391 pointerId: true, |
|
5392 pointerType: true, |
|
5393 screenX: true, |
|
5394 screenY: true, |
|
5395 targetTouches: true, |
|
5396 toElement: true, |
|
5397 touches: true, |
|
5398 |
|
5399 which: function( event ) { |
|
5400 var button = event.button; |
|
5401 |
|
5402 // Add which for key events |
|
5403 if ( event.which == null && rkeyEvent.test( event.type ) ) { |
|
5404 return event.charCode != null ? event.charCode : event.keyCode; |
|
5405 } |
|
5406 |
|
5407 // Add which for click: 1 === left; 2 === middle; 3 === right |
|
5408 if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) { |
|
5409 return ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); |
|
5410 } |
|
5411 |
|
5412 return event.which; |
|
5413 } |
|
5414 }, jQuery.event.addProp ); |
|
5415 |
|
5416 // Create mouseenter/leave events using mouseover/out and event-time checks |
|
5417 // so that event delegation works in jQuery. |
|
5418 // Do the same for pointerenter/pointerleave and pointerover/pointerout |
|
5419 // |
|
5420 // Support: Safari 7 only |
|
5421 // Safari sends mouseenter too often; see: |
|
5422 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258 |
|
5423 // for the description of the bug (it existed in older Chrome versions as well). |
|
5424 jQuery.each( { |
|
5425 mouseenter: "mouseover", |
|
5426 mouseleave: "mouseout", |
|
5427 pointerenter: "pointerover", |
|
5428 pointerleave: "pointerout" |
|
5429 }, function( orig, fix ) { |
|
5430 jQuery.event.special[ orig ] = { |
|
5431 delegateType: fix, |
|
5432 bindType: fix, |
|
5433 |
|
5434 handle: function( event ) { |
|
5435 var ret, |
|
5436 target = this, |
|
5437 related = event.relatedTarget, |
|
5438 handleObj = event.handleObj; |
|
5439 |
|
5440 // For mouseenter/leave call the handler if related is outside the target. |
|
5441 // NB: No relatedTarget if the mouse left/entered the browser window |
|
5442 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { |
|
5443 event.type = handleObj.origType; |
|
5444 ret = handleObj.handler.apply( this, arguments ); |
|
5445 event.type = fix; |
|
5446 } |
|
5447 return ret; |
|
5448 } |
|
5449 }; |
|
5450 } ); |
|
5451 |
|
5452 jQuery.fn.extend( { |
|
5453 |
|
5454 on: function( types, selector, data, fn ) { |
|
5455 return on( this, types, selector, data, fn ); |
|
5456 }, |
|
5457 one: function( types, selector, data, fn ) { |
|
5458 return on( this, types, selector, data, fn, 1 ); |
|
5459 }, |
|
5460 off: function( types, selector, fn ) { |
|
5461 var handleObj, type; |
|
5462 if ( types && types.preventDefault && types.handleObj ) { |
|
5463 |
|
5464 // ( event ) dispatched jQuery.Event |
|
5465 handleObj = types.handleObj; |
|
5466 jQuery( types.delegateTarget ).off( |
|
5467 handleObj.namespace ? |
|
5468 handleObj.origType + "." + handleObj.namespace : |
|
5469 handleObj.origType, |
|
5470 handleObj.selector, |
|
5471 handleObj.handler |
|
5472 ); |
|
5473 return this; |
|
5474 } |
|
5475 if ( typeof types === "object" ) { |
|
5476 |
|
5477 // ( types-object [, selector] ) |
|
5478 for ( type in types ) { |
|
5479 this.off( type, selector, types[ type ] ); |
|
5480 } |
|
5481 return this; |
|
5482 } |
|
5483 if ( selector === false || typeof selector === "function" ) { |
|
5484 |
|
5485 // ( types [, fn] ) |
|
5486 fn = selector; |
|
5487 selector = undefined; |
|
5488 } |
|
5489 if ( fn === false ) { |
|
5490 fn = returnFalse; |
|
5491 } |
|
5492 return this.each( function() { |
|
5493 jQuery.event.remove( this, types, fn, selector ); |
|
5494 } ); |
|
5495 } |
|
5496 } ); |
|
5497 |
|
5498 |
|
5499 var |
|
5500 |
|
5501 /* eslint-disable max-len */ |
|
5502 |
|
5503 // See https://github.com/eslint/eslint/issues/3229 |
|
5504 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi, |
|
5505 |
|
5506 /* eslint-enable */ |
|
5507 |
|
5508 // Support: IE <=10 - 11, Edge 12 - 13 |
|
5509 // In IE/Edge using regex groups here causes severe slowdowns. |
|
5510 // See https://connect.microsoft.com/IE/feedback/details/1736512/ |
|
5511 rnoInnerhtml = /<script|<style|<link/i, |
|
5512 |
|
5513 // checked="checked" or checked |
|
5514 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
|
5515 rscriptTypeMasked = /^true\/(.*)/, |
|
5516 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; |
|
5517 |
|
5518 function manipulationTarget( elem, content ) { |
|
5519 if ( jQuery.nodeName( elem, "table" ) && |
|
5520 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { |
|
5521 |
|
5522 return elem.getElementsByTagName( "tbody" )[ 0 ] || elem; |
|
5523 } |
|
5524 |
|
5525 return elem; |
|
5526 } |
|
5527 |
|
5528 // Replace/restore the type attribute of script elements for safe DOM manipulation |
|
5529 function disableScript( elem ) { |
|
5530 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; |
|
5531 return elem; |
|
5532 } |
|
5533 function restoreScript( elem ) { |
|
5534 var match = rscriptTypeMasked.exec( elem.type ); |
|
5535 |
|
5536 if ( match ) { |
|
5537 elem.type = match[ 1 ]; |
|
5538 } else { |
|
5539 elem.removeAttribute( "type" ); |
|
5540 } |
|
5541 |
|
5542 return elem; |
|
5543 } |
|
5544 |
|
5545 function cloneCopyEvent( src, dest ) { |
|
5546 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; |
|
5547 |
|
5548 if ( dest.nodeType !== 1 ) { |
|
5549 return; |
|
5550 } |
|
5551 |
|
5552 // 1. Copy private data: events, handlers, etc. |
|
5553 if ( dataPriv.hasData( src ) ) { |
|
5554 pdataOld = dataPriv.access( src ); |
|
5555 pdataCur = dataPriv.set( dest, pdataOld ); |
|
5556 events = pdataOld.events; |
|
5557 |
|
5558 if ( events ) { |
|
5559 delete pdataCur.handle; |
|
5560 pdataCur.events = {}; |
|
5561 |
|
5562 for ( type in events ) { |
|
5563 for ( i = 0, l = events[ type ].length; i < l; i++ ) { |
|
5564 jQuery.event.add( dest, type, events[ type ][ i ] ); |
|
5565 } |
|
5566 } |
|
5567 } |
|
5568 } |
|
5569 |
|
5570 // 2. Copy user data |
|
5571 if ( dataUser.hasData( src ) ) { |
|
5572 udataOld = dataUser.access( src ); |
|
5573 udataCur = jQuery.extend( {}, udataOld ); |
|
5574 |
|
5575 dataUser.set( dest, udataCur ); |
|
5576 } |
|
5577 } |
|
5578 |
|
5579 // Fix IE bugs, see support tests |
|
5580 function fixInput( src, dest ) { |
|
5581 var nodeName = dest.nodeName.toLowerCase(); |
|
5582 |
|
5583 // Fails to persist the checked state of a cloned checkbox or radio button. |
|
5584 if ( nodeName === "input" && rcheckableType.test( src.type ) ) { |
|
5585 dest.checked = src.checked; |
|
5586 |
|
5587 // Fails to return the selected option to the default selected state when cloning options |
|
5588 } else if ( nodeName === "input" || nodeName === "textarea" ) { |
|
5589 dest.defaultValue = src.defaultValue; |
|
5590 } |
|
5591 } |
|
5592 |
|
5593 function domManip( collection, args, callback, ignored ) { |
|
5594 |
|
5595 // Flatten any nested arrays |
|
5596 args = concat.apply( [], args ); |
|
5597 |
|
5598 var fragment, first, scripts, hasScripts, node, doc, |
|
5599 i = 0, |
|
5600 l = collection.length, |
|
5601 iNoClone = l - 1, |
|
5602 value = args[ 0 ], |
|
5603 isFunction = jQuery.isFunction( value ); |
|
5604 |
|
5605 // We can't cloneNode fragments that contain checked, in WebKit |
|
5606 if ( isFunction || |
|
5607 ( l > 1 && typeof value === "string" && |
|
5608 !support.checkClone && rchecked.test( value ) ) ) { |
|
5609 return collection.each( function( index ) { |
|
5610 var self = collection.eq( index ); |
|
5611 if ( isFunction ) { |
|
5612 args[ 0 ] = value.call( this, index, self.html() ); |
|
5613 } |
|
5614 domManip( self, args, callback, ignored ); |
|
5615 } ); |
|
5616 } |
|
5617 |
|
5618 if ( l ) { |
|
5619 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); |
|
5620 first = fragment.firstChild; |
|
5621 |
|
5622 if ( fragment.childNodes.length === 1 ) { |
|
5623 fragment = first; |
|
5624 } |
|
5625 |
|
5626 // Require either new content or an interest in ignored elements to invoke the callback |
|
5627 if ( first || ignored ) { |
|
5628 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); |
|
5629 hasScripts = scripts.length; |
|
5630 |
|
5631 // Use the original fragment for the last item |
|
5632 // instead of the first because it can end up |
|
5633 // being emptied incorrectly in certain situations (#8070). |
|
5634 for ( ; i < l; i++ ) { |
|
5635 node = fragment; |
|
5636 |
|
5637 if ( i !== iNoClone ) { |
|
5638 node = jQuery.clone( node, true, true ); |
|
5639 |
|
5640 // Keep references to cloned scripts for later restoration |
|
5641 if ( hasScripts ) { |
|
5642 |
|
5643 // Support: Android <=4.0 only, PhantomJS 1 only |
|
5644 // push.apply(_, arraylike) throws on ancient WebKit |
|
5645 jQuery.merge( scripts, getAll( node, "script" ) ); |
|
5646 } |
|
5647 } |
|
5648 |
|
5649 callback.call( collection[ i ], node, i ); |
|
5650 } |
|
5651 |
|
5652 if ( hasScripts ) { |
|
5653 doc = scripts[ scripts.length - 1 ].ownerDocument; |
|
5654 |
|
5655 // Reenable scripts |
|
5656 jQuery.map( scripts, restoreScript ); |
|
5657 |
|
5658 // Evaluate executable scripts on first document insertion |
|
5659 for ( i = 0; i < hasScripts; i++ ) { |
|
5660 node = scripts[ i ]; |
|
5661 if ( rscriptType.test( node.type || "" ) && |
|
5662 !dataPriv.access( node, "globalEval" ) && |
|
5663 jQuery.contains( doc, node ) ) { |
|
5664 |
|
5665 if ( node.src ) { |
|
5666 |
|
5667 // Optional AJAX dependency, but won't run scripts if not present |
|
5668 if ( jQuery._evalUrl ) { |
|
5669 jQuery._evalUrl( node.src ); |
|
5670 } |
|
5671 } else { |
|
5672 DOMEval( node.textContent.replace( rcleanScript, "" ), doc ); |
|
5673 } |
|
5674 } |
|
5675 } |
|
5676 } |
|
5677 } |
|
5678 } |
|
5679 |
|
5680 return collection; |
|
5681 } |
|
5682 |
|
5683 function remove( elem, selector, keepData ) { |
|
5684 var node, |
|
5685 nodes = selector ? jQuery.filter( selector, elem ) : elem, |
|
5686 i = 0; |
|
5687 |
|
5688 for ( ; ( node = nodes[ i ] ) != null; i++ ) { |
|
5689 if ( !keepData && node.nodeType === 1 ) { |
|
5690 jQuery.cleanData( getAll( node ) ); |
|
5691 } |
|
5692 |
|
5693 if ( node.parentNode ) { |
|
5694 if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { |
|
5695 setGlobalEval( getAll( node, "script" ) ); |
|
5696 } |
|
5697 node.parentNode.removeChild( node ); |
|
5698 } |
|
5699 } |
|
5700 |
|
5701 return elem; |
|
5702 } |
|
5703 |
|
5704 jQuery.extend( { |
|
5705 htmlPrefilter: function( html ) { |
|
5706 return html.replace( rxhtmlTag, "<$1></$2>" ); |
|
5707 }, |
|
5708 |
|
5709 clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
|
5710 var i, l, srcElements, destElements, |
|
5711 clone = elem.cloneNode( true ), |
|
5712 inPage = jQuery.contains( elem.ownerDocument, elem ); |
|
5713 |
|
5714 // Fix IE cloning issues |
|
5715 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && |
|
5716 !jQuery.isXMLDoc( elem ) ) { |
|
5717 |
|
5718 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 |
|
5719 destElements = getAll( clone ); |
|
5720 srcElements = getAll( elem ); |
|
5721 |
|
5722 for ( i = 0, l = srcElements.length; i < l; i++ ) { |
|
5723 fixInput( srcElements[ i ], destElements[ i ] ); |
|
5724 } |
|
5725 } |
|
5726 |
|
5727 // Copy the events from the original to the clone |
|
5728 if ( dataAndEvents ) { |
|
5729 if ( deepDataAndEvents ) { |
|
5730 srcElements = srcElements || getAll( elem ); |
|
5731 destElements = destElements || getAll( clone ); |
|
5732 |
|
5733 for ( i = 0, l = srcElements.length; i < l; i++ ) { |
|
5734 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); |
|
5735 } |
|
5736 } else { |
|
5737 cloneCopyEvent( elem, clone ); |
|
5738 } |
|
5739 } |
|
5740 |
|
5741 // Preserve script evaluation history |
|
5742 destElements = getAll( clone, "script" ); |
|
5743 if ( destElements.length > 0 ) { |
|
5744 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); |
|
5745 } |
|
5746 |
|
5747 // Return the cloned set |
|
5748 return clone; |
|
5749 }, |
|
5750 |
|
5751 cleanData: function( elems ) { |
|
5752 var data, elem, type, |
|
5753 special = jQuery.event.special, |
|
5754 i = 0; |
|
5755 |
|
5756 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { |
|
5757 if ( acceptData( elem ) ) { |
|
5758 if ( ( data = elem[ dataPriv.expando ] ) ) { |
|
5759 if ( data.events ) { |
|
5760 for ( type in data.events ) { |
|
5761 if ( special[ type ] ) { |
|
5762 jQuery.event.remove( elem, type ); |
|
5763 |
|
5764 // This is a shortcut to avoid jQuery.event.remove's overhead |
|
5765 } else { |
|
5766 jQuery.removeEvent( elem, type, data.handle ); |
|
5767 } |
|
5768 } |
|
5769 } |
|
5770 |
|
5771 // Support: Chrome <=35 - 45+ |
|
5772 // Assign undefined instead of using delete, see Data#remove |
|
5773 elem[ dataPriv.expando ] = undefined; |
|
5774 } |
|
5775 if ( elem[ dataUser.expando ] ) { |
|
5776 |
|
5777 // Support: Chrome <=35 - 45+ |
|
5778 // Assign undefined instead of using delete, see Data#remove |
|
5779 elem[ dataUser.expando ] = undefined; |
|
5780 } |
|
5781 } |
|
5782 } |
|
5783 } |
|
5784 } ); |
|
5785 |
|
5786 jQuery.fn.extend( { |
|
5787 detach: function( selector ) { |
|
5788 return remove( this, selector, true ); |
|
5789 }, |
|
5790 |
|
5791 remove: function( selector ) { |
|
5792 return remove( this, selector ); |
|
5793 }, |
|
5794 |
|
5795 text: function( value ) { |
|
5796 return access( this, function( value ) { |
|
5797 return value === undefined ? |
|
5798 jQuery.text( this ) : |
|
5799 this.empty().each( function() { |
|
5800 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
5801 this.textContent = value; |
|
5802 } |
|
5803 } ); |
|
5804 }, null, value, arguments.length ); |
|
5805 }, |
|
5806 |
|
5807 append: function() { |
|
5808 return domManip( this, arguments, function( elem ) { |
|
5809 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
5810 var target = manipulationTarget( this, elem ); |
|
5811 target.appendChild( elem ); |
|
5812 } |
|
5813 } ); |
|
5814 }, |
|
5815 |
|
5816 prepend: function() { |
|
5817 return domManip( this, arguments, function( elem ) { |
|
5818 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
5819 var target = manipulationTarget( this, elem ); |
|
5820 target.insertBefore( elem, target.firstChild ); |
|
5821 } |
|
5822 } ); |
|
5823 }, |
|
5824 |
|
5825 before: function() { |
|
5826 return domManip( this, arguments, function( elem ) { |
|
5827 if ( this.parentNode ) { |
|
5828 this.parentNode.insertBefore( elem, this ); |
|
5829 } |
|
5830 } ); |
|
5831 }, |
|
5832 |
|
5833 after: function() { |
|
5834 return domManip( this, arguments, function( elem ) { |
|
5835 if ( this.parentNode ) { |
|
5836 this.parentNode.insertBefore( elem, this.nextSibling ); |
|
5837 } |
|
5838 } ); |
|
5839 }, |
|
5840 |
|
5841 empty: function() { |
|
5842 var elem, |
|
5843 i = 0; |
|
5844 |
|
5845 for ( ; ( elem = this[ i ] ) != null; i++ ) { |
|
5846 if ( elem.nodeType === 1 ) { |
|
5847 |
|
5848 // Prevent memory leaks |
|
5849 jQuery.cleanData( getAll( elem, false ) ); |
|
5850 |
|
5851 // Remove any remaining nodes |
|
5852 elem.textContent = ""; |
|
5853 } |
|
5854 } |
|
5855 |
|
5856 return this; |
|
5857 }, |
|
5858 |
|
5859 clone: function( dataAndEvents, deepDataAndEvents ) { |
|
5860 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; |
|
5861 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; |
|
5862 |
|
5863 return this.map( function() { |
|
5864 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); |
|
5865 } ); |
|
5866 }, |
|
5867 |
|
5868 html: function( value ) { |
|
5869 return access( this, function( value ) { |
|
5870 var elem = this[ 0 ] || {}, |
|
5871 i = 0, |
|
5872 l = this.length; |
|
5873 |
|
5874 if ( value === undefined && elem.nodeType === 1 ) { |
|
5875 return elem.innerHTML; |
|
5876 } |
|
5877 |
|
5878 // See if we can take a shortcut and just use innerHTML |
|
5879 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && |
|
5880 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { |
|
5881 |
|
5882 value = jQuery.htmlPrefilter( value ); |
|
5883 |
|
5884 try { |
|
5885 for ( ; i < l; i++ ) { |
|
5886 elem = this[ i ] || {}; |
|
5887 |
|
5888 // Remove element nodes and prevent memory leaks |
|
5889 if ( elem.nodeType === 1 ) { |
|
5890 jQuery.cleanData( getAll( elem, false ) ); |
|
5891 elem.innerHTML = value; |
|
5892 } |
|
5893 } |
|
5894 |
|
5895 elem = 0; |
|
5896 |
|
5897 // If using innerHTML throws an exception, use the fallback method |
|
5898 } catch ( e ) {} |
|
5899 } |
|
5900 |
|
5901 if ( elem ) { |
|
5902 this.empty().append( value ); |
|
5903 } |
|
5904 }, null, value, arguments.length ); |
|
5905 }, |
|
5906 |
|
5907 replaceWith: function() { |
|
5908 var ignored = []; |
|
5909 |
|
5910 // Make the changes, replacing each non-ignored context element with the new content |
|
5911 return domManip( this, arguments, function( elem ) { |
|
5912 var parent = this.parentNode; |
|
5913 |
|
5914 if ( jQuery.inArray( this, ignored ) < 0 ) { |
|
5915 jQuery.cleanData( getAll( this ) ); |
|
5916 if ( parent ) { |
|
5917 parent.replaceChild( elem, this ); |
|
5918 } |
|
5919 } |
|
5920 |
|
5921 // Force callback invocation |
|
5922 }, ignored ); |
|
5923 } |
|
5924 } ); |
|
5925 |
|
5926 jQuery.each( { |
|
5927 appendTo: "append", |
|
5928 prependTo: "prepend", |
|
5929 insertBefore: "before", |
|
5930 insertAfter: "after", |
|
5931 replaceAll: "replaceWith" |
|
5932 }, function( name, original ) { |
|
5933 jQuery.fn[ name ] = function( selector ) { |
|
5934 var elems, |
|
5935 ret = [], |
|
5936 insert = jQuery( selector ), |
|
5937 last = insert.length - 1, |
|
5938 i = 0; |
|
5939 |
|
5940 for ( ; i <= last; i++ ) { |
|
5941 elems = i === last ? this : this.clone( true ); |
|
5942 jQuery( insert[ i ] )[ original ]( elems ); |
|
5943 |
|
5944 // Support: Android <=4.0 only, PhantomJS 1 only |
|
5945 // .get() because push.apply(_, arraylike) throws on ancient WebKit |
|
5946 push.apply( ret, elems.get() ); |
|
5947 } |
|
5948 |
|
5949 return this.pushStack( ret ); |
|
5950 }; |
|
5951 } ); |
|
5952 var rmargin = ( /^margin/ ); |
|
5953 |
|
5954 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); |
|
5955 |
|
5956 var getStyles = function( elem ) { |
|
5957 |
|
5958 // Support: IE <=11 only, Firefox <=30 (#15098, #14150) |
|
5959 // IE throws on elements created in popups |
|
5960 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" |
|
5961 var view = elem.ownerDocument.defaultView; |
|
5962 |
|
5963 if ( !view || !view.opener ) { |
|
5964 view = window; |
|
5965 } |
|
5966 |
|
5967 return view.getComputedStyle( elem ); |
|
5968 }; |
|
5969 |
|
5970 |
|
5971 |
|
5972 ( function() { |
|
5973 |
|
5974 // Executing both pixelPosition & boxSizingReliable tests require only one layout |
|
5975 // so they're executed at the same time to save the second computation. |
|
5976 function computeStyleTests() { |
|
5977 |
|
5978 // This is a singleton, we need to execute it only once |
|
5979 if ( !div ) { |
|
5980 return; |
|
5981 } |
|
5982 |
|
5983 div.style.cssText = |
|
5984 "box-sizing:border-box;" + |
|
5985 "position:relative;display:block;" + |
|
5986 "margin:auto;border:1px;padding:1px;" + |
|
5987 "top:1%;width:50%"; |
|
5988 div.innerHTML = ""; |
|
5989 documentElement.appendChild( container ); |
|
5990 |
|
5991 var divStyle = window.getComputedStyle( div ); |
|
5992 pixelPositionVal = divStyle.top !== "1%"; |
|
5993 |
|
5994 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 |
|
5995 reliableMarginLeftVal = divStyle.marginLeft === "2px"; |
|
5996 boxSizingReliableVal = divStyle.width === "4px"; |
|
5997 |
|
5998 // Support: Android 4.0 - 4.3 only |
|
5999 // Some styles come back with percentage values, even though they shouldn't |
|
6000 div.style.marginRight = "50%"; |
|
6001 pixelMarginRightVal = divStyle.marginRight === "4px"; |
|
6002 |
|
6003 documentElement.removeChild( container ); |
|
6004 |
|
6005 // Nullify the div so it wouldn't be stored in the memory and |
|
6006 // it will also be a sign that checks already performed |
|
6007 div = null; |
|
6008 } |
|
6009 |
|
6010 var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal, |
|
6011 container = document.createElement( "div" ), |
|
6012 div = document.createElement( "div" ); |
|
6013 |
|
6014 // Finish early in limited (non-browser) environments |
|
6015 if ( !div.style ) { |
|
6016 return; |
|
6017 } |
|
6018 |
|
6019 // Support: IE <=9 - 11 only |
|
6020 // Style of cloned element affects source element cloned (#8908) |
|
6021 div.style.backgroundClip = "content-box"; |
|
6022 div.cloneNode( true ).style.backgroundClip = ""; |
|
6023 support.clearCloneStyle = div.style.backgroundClip === "content-box"; |
|
6024 |
|
6025 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + |
|
6026 "padding:0;margin-top:1px;position:absolute"; |
|
6027 container.appendChild( div ); |
|
6028 |
|
6029 jQuery.extend( support, { |
|
6030 pixelPosition: function() { |
|
6031 computeStyleTests(); |
|
6032 return pixelPositionVal; |
|
6033 }, |
|
6034 boxSizingReliable: function() { |
|
6035 computeStyleTests(); |
|
6036 return boxSizingReliableVal; |
|
6037 }, |
|
6038 pixelMarginRight: function() { |
|
6039 computeStyleTests(); |
|
6040 return pixelMarginRightVal; |
|
6041 }, |
|
6042 reliableMarginLeft: function() { |
|
6043 computeStyleTests(); |
|
6044 return reliableMarginLeftVal; |
|
6045 } |
|
6046 } ); |
|
6047 } )(); |
|
6048 |
|
6049 |
|
6050 function curCSS( elem, name, computed ) { |
|
6051 var width, minWidth, maxWidth, ret, |
|
6052 style = elem.style; |
|
6053 |
|
6054 computed = computed || getStyles( elem ); |
|
6055 |
|
6056 // Support: IE <=9 only |
|
6057 // getPropertyValue is only needed for .css('filter') (#12537) |
|
6058 if ( computed ) { |
|
6059 ret = computed.getPropertyValue( name ) || computed[ name ]; |
|
6060 |
|
6061 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { |
|
6062 ret = jQuery.style( elem, name ); |
|
6063 } |
|
6064 |
|
6065 // A tribute to the "awesome hack by Dean Edwards" |
|
6066 // Android Browser returns percentage for some values, |
|
6067 // but width seems to be reliably pixels. |
|
6068 // This is against the CSSOM draft spec: |
|
6069 // https://drafts.csswg.org/cssom/#resolved-values |
|
6070 if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { |
|
6071 |
|
6072 // Remember the original values |
|
6073 width = style.width; |
|
6074 minWidth = style.minWidth; |
|
6075 maxWidth = style.maxWidth; |
|
6076 |
|
6077 // Put in the new values to get a computed value out |
|
6078 style.minWidth = style.maxWidth = style.width = ret; |
|
6079 ret = computed.width; |
|
6080 |
|
6081 // Revert the changed values |
|
6082 style.width = width; |
|
6083 style.minWidth = minWidth; |
|
6084 style.maxWidth = maxWidth; |
|
6085 } |
|
6086 } |
|
6087 |
|
6088 return ret !== undefined ? |
|
6089 |
|
6090 // Support: IE <=9 - 11 only |
|
6091 // IE returns zIndex value as an integer. |
|
6092 ret + "" : |
|
6093 ret; |
|
6094 } |
|
6095 |
|
6096 |
|
6097 function addGetHookIf( conditionFn, hookFn ) { |
|
6098 |
|
6099 // Define the hook, we'll check on the first run if it's really needed. |
|
6100 return { |
|
6101 get: function() { |
|
6102 if ( conditionFn() ) { |
|
6103 |
|
6104 // Hook not needed (or it's not possible to use it due |
|
6105 // to missing dependency), remove it. |
|
6106 delete this.get; |
|
6107 return; |
|
6108 } |
|
6109 |
|
6110 // Hook needed; redefine it so that the support test is not executed again. |
|
6111 return ( this.get = hookFn ).apply( this, arguments ); |
|
6112 } |
|
6113 }; |
|
6114 } |
|
6115 |
|
6116 |
|
6117 var |
|
6118 |
|
6119 // Swappable if display is none or starts with table |
|
6120 // except "table", "table-cell", or "table-caption" |
|
6121 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display |
|
6122 rdisplayswap = /^(none|table(?!-c[ea]).+)/, |
|
6123 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
|
6124 cssNormalTransform = { |
|
6125 letterSpacing: "0", |
|
6126 fontWeight: "400" |
|
6127 }, |
|
6128 |
|
6129 cssPrefixes = [ "Webkit", "Moz", "ms" ], |
|
6130 emptyStyle = document.createElement( "div" ).style; |
|
6131 |
|
6132 // Return a css property mapped to a potentially vendor prefixed property |
|
6133 function vendorPropName( name ) { |
|
6134 |
|
6135 // Shortcut for names that are not vendor prefixed |
|
6136 if ( name in emptyStyle ) { |
|
6137 return name; |
|
6138 } |
|
6139 |
|
6140 // Check for vendor prefixed names |
|
6141 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), |
|
6142 i = cssPrefixes.length; |
|
6143 |
|
6144 while ( i-- ) { |
|
6145 name = cssPrefixes[ i ] + capName; |
|
6146 if ( name in emptyStyle ) { |
|
6147 return name; |
|
6148 } |
|
6149 } |
|
6150 } |
|
6151 |
|
6152 function setPositiveNumber( elem, value, subtract ) { |
|
6153 |
|
6154 // Any relative (+/-) values have already been |
|
6155 // normalized at this point |
|
6156 var matches = rcssNum.exec( value ); |
|
6157 return matches ? |
|
6158 |
|
6159 // Guard against undefined "subtract", e.g., when used as in cssHooks |
|
6160 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : |
|
6161 value; |
|
6162 } |
|
6163 |
|
6164 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { |
|
6165 var i = extra === ( isBorderBox ? "border" : "content" ) ? |
|
6166 |
|
6167 // If we already have the right measurement, avoid augmentation |
|
6168 4 : |
|
6169 |
|
6170 // Otherwise initialize for horizontal or vertical properties |
|
6171 name === "width" ? 1 : 0, |
|
6172 |
|
6173 val = 0; |
|
6174 |
|
6175 for ( ; i < 4; i += 2 ) { |
|
6176 |
|
6177 // Both box models exclude margin, so add it if we want it |
|
6178 if ( extra === "margin" ) { |
|
6179 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); |
|
6180 } |
|
6181 |
|
6182 if ( isBorderBox ) { |
|
6183 |
|
6184 // border-box includes padding, so remove it if we want content |
|
6185 if ( extra === "content" ) { |
|
6186 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
|
6187 } |
|
6188 |
|
6189 // At this point, extra isn't border nor margin, so remove border |
|
6190 if ( extra !== "margin" ) { |
|
6191 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
6192 } |
|
6193 } else { |
|
6194 |
|
6195 // At this point, extra isn't content, so add padding |
|
6196 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
|
6197 |
|
6198 // At this point, extra isn't content nor padding, so add border |
|
6199 if ( extra !== "padding" ) { |
|
6200 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
|
6201 } |
|
6202 } |
|
6203 } |
|
6204 |
|
6205 return val; |
|
6206 } |
|
6207 |
|
6208 function getWidthOrHeight( elem, name, extra ) { |
|
6209 |
|
6210 // Start with offset property, which is equivalent to the border-box value |
|
6211 var val, |
|
6212 valueIsBorderBox = true, |
|
6213 styles = getStyles( elem ), |
|
6214 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; |
|
6215 |
|
6216 // Support: IE <=11 only |
|
6217 // Running getBoundingClientRect on a disconnected node |
|
6218 // in IE throws an error. |
|
6219 if ( elem.getClientRects().length ) { |
|
6220 val = elem.getBoundingClientRect()[ name ]; |
|
6221 } |
|
6222 |
|
6223 // Some non-html elements return undefined for offsetWidth, so check for null/undefined |
|
6224 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 |
|
6225 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 |
|
6226 if ( val <= 0 || val == null ) { |
|
6227 |
|
6228 // Fall back to computed then uncomputed css if necessary |
|
6229 val = curCSS( elem, name, styles ); |
|
6230 if ( val < 0 || val == null ) { |
|
6231 val = elem.style[ name ]; |
|
6232 } |
|
6233 |
|
6234 // Computed unit is not pixels. Stop here and return. |
|
6235 if ( rnumnonpx.test( val ) ) { |
|
6236 return val; |
|
6237 } |
|
6238 |
|
6239 // Check for style in case a browser which returns unreliable values |
|
6240 // for getComputedStyle silently falls back to the reliable elem.style |
|
6241 valueIsBorderBox = isBorderBox && |
|
6242 ( support.boxSizingReliable() || val === elem.style[ name ] ); |
|
6243 |
|
6244 // Normalize "", auto, and prepare for extra |
|
6245 val = parseFloat( val ) || 0; |
|
6246 } |
|
6247 |
|
6248 // Use the active box-sizing model to add/subtract irrelevant styles |
|
6249 return ( val + |
|
6250 augmentWidthOrHeight( |
|
6251 elem, |
|
6252 name, |
|
6253 extra || ( isBorderBox ? "border" : "content" ), |
|
6254 valueIsBorderBox, |
|
6255 styles |
|
6256 ) |
|
6257 ) + "px"; |
|
6258 } |
|
6259 |
|
6260 jQuery.extend( { |
|
6261 |
|
6262 // Add in style property hooks for overriding the default |
|
6263 // behavior of getting and setting a style property |
|
6264 cssHooks: { |
|
6265 opacity: { |
|
6266 get: function( elem, computed ) { |
|
6267 if ( computed ) { |
|
6268 |
|
6269 // We should always get a number back from opacity |
|
6270 var ret = curCSS( elem, "opacity" ); |
|
6271 return ret === "" ? "1" : ret; |
|
6272 } |
|
6273 } |
|
6274 } |
|
6275 }, |
|
6276 |
|
6277 // Don't automatically add "px" to these possibly-unitless properties |
|
6278 cssNumber: { |
|
6279 "animationIterationCount": true, |
|
6280 "columnCount": true, |
|
6281 "fillOpacity": true, |
|
6282 "flexGrow": true, |
|
6283 "flexShrink": true, |
|
6284 "fontWeight": true, |
|
6285 "lineHeight": true, |
|
6286 "opacity": true, |
|
6287 "order": true, |
|
6288 "orphans": true, |
|
6289 "widows": true, |
|
6290 "zIndex": true, |
|
6291 "zoom": true |
|
6292 }, |
|
6293 |
|
6294 // Add in properties whose names you wish to fix before |
|
6295 // setting or getting the value |
|
6296 cssProps: { |
|
6297 "float": "cssFloat" |
|
6298 }, |
|
6299 |
|
6300 // Get and set the style property on a DOM Node |
|
6301 style: function( elem, name, value, extra ) { |
|
6302 |
|
6303 // Don't set styles on text and comment nodes |
|
6304 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
|
6305 return; |
|
6306 } |
|
6307 |
|
6308 // Make sure that we're working with the right name |
|
6309 var ret, type, hooks, |
|
6310 origName = jQuery.camelCase( name ), |
|
6311 style = elem.style; |
|
6312 |
|
6313 name = jQuery.cssProps[ origName ] || |
|
6314 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); |
|
6315 |
|
6316 // Gets hook for the prefixed version, then unprefixed version |
|
6317 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
6318 |
|
6319 // Check if we're setting a value |
|
6320 if ( value !== undefined ) { |
|
6321 type = typeof value; |
|
6322 |
|
6323 // Convert "+=" or "-=" to relative numbers (#7345) |
|
6324 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { |
|
6325 value = adjustCSS( elem, name, ret ); |
|
6326 |
|
6327 // Fixes bug #9237 |
|
6328 type = "number"; |
|
6329 } |
|
6330 |
|
6331 // Make sure that null and NaN values aren't set (#7116) |
|
6332 if ( value == null || value !== value ) { |
|
6333 return; |
|
6334 } |
|
6335 |
|
6336 // If a number was passed in, add the unit (except for certain CSS properties) |
|
6337 if ( type === "number" ) { |
|
6338 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); |
|
6339 } |
|
6340 |
|
6341 // background-* props affect original clone's values |
|
6342 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { |
|
6343 style[ name ] = "inherit"; |
|
6344 } |
|
6345 |
|
6346 // If a hook was provided, use that value, otherwise just set the specified value |
|
6347 if ( !hooks || !( "set" in hooks ) || |
|
6348 ( value = hooks.set( elem, value, extra ) ) !== undefined ) { |
|
6349 |
|
6350 style[ name ] = value; |
|
6351 } |
|
6352 |
|
6353 } else { |
|
6354 |
|
6355 // If a hook was provided get the non-computed value from there |
|
6356 if ( hooks && "get" in hooks && |
|
6357 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { |
|
6358 |
|
6359 return ret; |
|
6360 } |
|
6361 |
|
6362 // Otherwise just get the value from the style object |
|
6363 return style[ name ]; |
|
6364 } |
|
6365 }, |
|
6366 |
|
6367 css: function( elem, name, extra, styles ) { |
|
6368 var val, num, hooks, |
|
6369 origName = jQuery.camelCase( name ); |
|
6370 |
|
6371 // Make sure that we're working with the right name |
|
6372 name = jQuery.cssProps[ origName ] || |
|
6373 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); |
|
6374 |
|
6375 // Try prefixed name followed by the unprefixed name |
|
6376 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
|
6377 |
|
6378 // If a hook was provided get the computed value from there |
|
6379 if ( hooks && "get" in hooks ) { |
|
6380 val = hooks.get( elem, true, extra ); |
|
6381 } |
|
6382 |
|
6383 // Otherwise, if a way to get the computed value exists, use that |
|
6384 if ( val === undefined ) { |
|
6385 val = curCSS( elem, name, styles ); |
|
6386 } |
|
6387 |
|
6388 // Convert "normal" to computed value |
|
6389 if ( val === "normal" && name in cssNormalTransform ) { |
|
6390 val = cssNormalTransform[ name ]; |
|
6391 } |
|
6392 |
|
6393 // Make numeric if forced or a qualifier was provided and val looks numeric |
|
6394 if ( extra === "" || extra ) { |
|
6395 num = parseFloat( val ); |
|
6396 return extra === true || isFinite( num ) ? num || 0 : val; |
|
6397 } |
|
6398 return val; |
|
6399 } |
|
6400 } ); |
|
6401 |
|
6402 jQuery.each( [ "height", "width" ], function( i, name ) { |
|
6403 jQuery.cssHooks[ name ] = { |
|
6404 get: function( elem, computed, extra ) { |
|
6405 if ( computed ) { |
|
6406 |
|
6407 // Certain elements can have dimension info if we invisibly show them |
|
6408 // but it must have a current display style that would benefit |
|
6409 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && |
|
6410 |
|
6411 // Support: Safari 8+ |
|
6412 // Table columns in Safari have non-zero offsetWidth & zero |
|
6413 // getBoundingClientRect().width unless display is changed. |
|
6414 // Support: IE <=11 only |
|
6415 // Running getBoundingClientRect on a disconnected node |
|
6416 // in IE throws an error. |
|
6417 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? |
|
6418 swap( elem, cssShow, function() { |
|
6419 return getWidthOrHeight( elem, name, extra ); |
|
6420 } ) : |
|
6421 getWidthOrHeight( elem, name, extra ); |
|
6422 } |
|
6423 }, |
|
6424 |
|
6425 set: function( elem, value, extra ) { |
|
6426 var matches, |
|
6427 styles = extra && getStyles( elem ), |
|
6428 subtract = extra && augmentWidthOrHeight( |
|
6429 elem, |
|
6430 name, |
|
6431 extra, |
|
6432 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", |
|
6433 styles |
|
6434 ); |
|
6435 |
|
6436 // Convert to pixels if value adjustment is needed |
|
6437 if ( subtract && ( matches = rcssNum.exec( value ) ) && |
|
6438 ( matches[ 3 ] || "px" ) !== "px" ) { |
|
6439 |
|
6440 elem.style[ name ] = value; |
|
6441 value = jQuery.css( elem, name ); |
|
6442 } |
|
6443 |
|
6444 return setPositiveNumber( elem, value, subtract ); |
|
6445 } |
|
6446 }; |
|
6447 } ); |
|
6448 |
|
6449 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, |
|
6450 function( elem, computed ) { |
|
6451 if ( computed ) { |
|
6452 return ( parseFloat( curCSS( elem, "marginLeft" ) ) || |
|
6453 elem.getBoundingClientRect().left - |
|
6454 swap( elem, { marginLeft: 0 }, function() { |
|
6455 return elem.getBoundingClientRect().left; |
|
6456 } ) |
|
6457 ) + "px"; |
|
6458 } |
|
6459 } |
|
6460 ); |
|
6461 |
|
6462 // These hooks are used by animate to expand properties |
|
6463 jQuery.each( { |
|
6464 margin: "", |
|
6465 padding: "", |
|
6466 border: "Width" |
|
6467 }, function( prefix, suffix ) { |
|
6468 jQuery.cssHooks[ prefix + suffix ] = { |
|
6469 expand: function( value ) { |
|
6470 var i = 0, |
|
6471 expanded = {}, |
|
6472 |
|
6473 // Assumes a single number if not a string |
|
6474 parts = typeof value === "string" ? value.split( " " ) : [ value ]; |
|
6475 |
|
6476 for ( ; i < 4; i++ ) { |
|
6477 expanded[ prefix + cssExpand[ i ] + suffix ] = |
|
6478 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; |
|
6479 } |
|
6480 |
|
6481 return expanded; |
|
6482 } |
|
6483 }; |
|
6484 |
|
6485 if ( !rmargin.test( prefix ) ) { |
|
6486 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; |
|
6487 } |
|
6488 } ); |
|
6489 |
|
6490 jQuery.fn.extend( { |
|
6491 css: function( name, value ) { |
|
6492 return access( this, function( elem, name, value ) { |
|
6493 var styles, len, |
|
6494 map = {}, |
|
6495 i = 0; |
|
6496 |
|
6497 if ( jQuery.isArray( name ) ) { |
|
6498 styles = getStyles( elem ); |
|
6499 len = name.length; |
|
6500 |
|
6501 for ( ; i < len; i++ ) { |
|
6502 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); |
|
6503 } |
|
6504 |
|
6505 return map; |
|
6506 } |
|
6507 |
|
6508 return value !== undefined ? |
|
6509 jQuery.style( elem, name, value ) : |
|
6510 jQuery.css( elem, name ); |
|
6511 }, name, value, arguments.length > 1 ); |
|
6512 } |
|
6513 } ); |
|
6514 |
|
6515 |
|
6516 function Tween( elem, options, prop, end, easing ) { |
|
6517 return new Tween.prototype.init( elem, options, prop, end, easing ); |
|
6518 } |
|
6519 jQuery.Tween = Tween; |
|
6520 |
|
6521 Tween.prototype = { |
|
6522 constructor: Tween, |
|
6523 init: function( elem, options, prop, end, easing, unit ) { |
|
6524 this.elem = elem; |
|
6525 this.prop = prop; |
|
6526 this.easing = easing || jQuery.easing._default; |
|
6527 this.options = options; |
|
6528 this.start = this.now = this.cur(); |
|
6529 this.end = end; |
|
6530 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); |
|
6531 }, |
|
6532 cur: function() { |
|
6533 var hooks = Tween.propHooks[ this.prop ]; |
|
6534 |
|
6535 return hooks && hooks.get ? |
|
6536 hooks.get( this ) : |
|
6537 Tween.propHooks._default.get( this ); |
|
6538 }, |
|
6539 run: function( percent ) { |
|
6540 var eased, |
|
6541 hooks = Tween.propHooks[ this.prop ]; |
|
6542 |
|
6543 if ( this.options.duration ) { |
|
6544 this.pos = eased = jQuery.easing[ this.easing ]( |
|
6545 percent, this.options.duration * percent, 0, 1, this.options.duration |
|
6546 ); |
|
6547 } else { |
|
6548 this.pos = eased = percent; |
|
6549 } |
|
6550 this.now = ( this.end - this.start ) * eased + this.start; |
|
6551 |
|
6552 if ( this.options.step ) { |
|
6553 this.options.step.call( this.elem, this.now, this ); |
|
6554 } |
|
6555 |
|
6556 if ( hooks && hooks.set ) { |
|
6557 hooks.set( this ); |
|
6558 } else { |
|
6559 Tween.propHooks._default.set( this ); |
|
6560 } |
|
6561 return this; |
|
6562 } |
|
6563 }; |
|
6564 |
|
6565 Tween.prototype.init.prototype = Tween.prototype; |
|
6566 |
|
6567 Tween.propHooks = { |
|
6568 _default: { |
|
6569 get: function( tween ) { |
|
6570 var result; |
|
6571 |
|
6572 // Use a property on the element directly when it is not a DOM element, |
|
6573 // or when there is no matching style property that exists. |
|
6574 if ( tween.elem.nodeType !== 1 || |
|
6575 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { |
|
6576 return tween.elem[ tween.prop ]; |
|
6577 } |
|
6578 |
|
6579 // Passing an empty string as a 3rd parameter to .css will automatically |
|
6580 // attempt a parseFloat and fallback to a string if the parse fails. |
|
6581 // Simple values such as "10px" are parsed to Float; |
|
6582 // complex values such as "rotate(1rad)" are returned as-is. |
|
6583 result = jQuery.css( tween.elem, tween.prop, "" ); |
|
6584 |
|
6585 // Empty strings, null, undefined and "auto" are converted to 0. |
|
6586 return !result || result === "auto" ? 0 : result; |
|
6587 }, |
|
6588 set: function( tween ) { |
|
6589 |
|
6590 // Use step hook for back compat. |
|
6591 // Use cssHook if its there. |
|
6592 // Use .style if available and use plain properties where available. |
|
6593 if ( jQuery.fx.step[ tween.prop ] ) { |
|
6594 jQuery.fx.step[ tween.prop ]( tween ); |
|
6595 } else if ( tween.elem.nodeType === 1 && |
|
6596 ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || |
|
6597 jQuery.cssHooks[ tween.prop ] ) ) { |
|
6598 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); |
|
6599 } else { |
|
6600 tween.elem[ tween.prop ] = tween.now; |
|
6601 } |
|
6602 } |
|
6603 } |
|
6604 }; |
|
6605 |
|
6606 // Support: IE <=9 only |
|
6607 // Panic based approach to setting things on disconnected nodes |
|
6608 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { |
|
6609 set: function( tween ) { |
|
6610 if ( tween.elem.nodeType && tween.elem.parentNode ) { |
|
6611 tween.elem[ tween.prop ] = tween.now; |
|
6612 } |
|
6613 } |
|
6614 }; |
|
6615 |
|
6616 jQuery.easing = { |
|
6617 linear: function( p ) { |
|
6618 return p; |
|
6619 }, |
|
6620 swing: function( p ) { |
|
6621 return 0.5 - Math.cos( p * Math.PI ) / 2; |
|
6622 }, |
|
6623 _default: "swing" |
|
6624 }; |
|
6625 |
|
6626 jQuery.fx = Tween.prototype.init; |
|
6627 |
|
6628 // Back compat <1.8 extension point |
|
6629 jQuery.fx.step = {}; |
|
6630 |
|
6631 |
|
6632 |
|
6633 |
|
6634 var |
|
6635 fxNow, timerId, |
|
6636 rfxtypes = /^(?:toggle|show|hide)$/, |
|
6637 rrun = /queueHooks$/; |
|
6638 |
|
6639 function raf() { |
|
6640 if ( timerId ) { |
|
6641 window.requestAnimationFrame( raf ); |
|
6642 jQuery.fx.tick(); |
|
6643 } |
|
6644 } |
|
6645 |
|
6646 // Animations created synchronously will run synchronously |
|
6647 function createFxNow() { |
|
6648 window.setTimeout( function() { |
|
6649 fxNow = undefined; |
|
6650 } ); |
|
6651 return ( fxNow = jQuery.now() ); |
|
6652 } |
|
6653 |
|
6654 // Generate parameters to create a standard animation |
|
6655 function genFx( type, includeWidth ) { |
|
6656 var which, |
|
6657 i = 0, |
|
6658 attrs = { height: type }; |
|
6659 |
|
6660 // If we include width, step value is 1 to do all cssExpand values, |
|
6661 // otherwise step value is 2 to skip over Left and Right |
|
6662 includeWidth = includeWidth ? 1 : 0; |
|
6663 for ( ; i < 4; i += 2 - includeWidth ) { |
|
6664 which = cssExpand[ i ]; |
|
6665 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; |
|
6666 } |
|
6667 |
|
6668 if ( includeWidth ) { |
|
6669 attrs.opacity = attrs.width = type; |
|
6670 } |
|
6671 |
|
6672 return attrs; |
|
6673 } |
|
6674 |
|
6675 function createTween( value, prop, animation ) { |
|
6676 var tween, |
|
6677 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), |
|
6678 index = 0, |
|
6679 length = collection.length; |
|
6680 for ( ; index < length; index++ ) { |
|
6681 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { |
|
6682 |
|
6683 // We're done with this property |
|
6684 return tween; |
|
6685 } |
|
6686 } |
|
6687 } |
|
6688 |
|
6689 function defaultPrefilter( elem, props, opts ) { |
|
6690 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, |
|
6691 isBox = "width" in props || "height" in props, |
|
6692 anim = this, |
|
6693 orig = {}, |
|
6694 style = elem.style, |
|
6695 hidden = elem.nodeType && isHiddenWithinTree( elem ), |
|
6696 dataShow = dataPriv.get( elem, "fxshow" ); |
|
6697 |
|
6698 // Queue-skipping animations hijack the fx hooks |
|
6699 if ( !opts.queue ) { |
|
6700 hooks = jQuery._queueHooks( elem, "fx" ); |
|
6701 if ( hooks.unqueued == null ) { |
|
6702 hooks.unqueued = 0; |
|
6703 oldfire = hooks.empty.fire; |
|
6704 hooks.empty.fire = function() { |
|
6705 if ( !hooks.unqueued ) { |
|
6706 oldfire(); |
|
6707 } |
|
6708 }; |
|
6709 } |
|
6710 hooks.unqueued++; |
|
6711 |
|
6712 anim.always( function() { |
|
6713 |
|
6714 // Ensure the complete handler is called before this completes |
|
6715 anim.always( function() { |
|
6716 hooks.unqueued--; |
|
6717 if ( !jQuery.queue( elem, "fx" ).length ) { |
|
6718 hooks.empty.fire(); |
|
6719 } |
|
6720 } ); |
|
6721 } ); |
|
6722 } |
|
6723 |
|
6724 // Detect show/hide animations |
|
6725 for ( prop in props ) { |
|
6726 value = props[ prop ]; |
|
6727 if ( rfxtypes.test( value ) ) { |
|
6728 delete props[ prop ]; |
|
6729 toggle = toggle || value === "toggle"; |
|
6730 if ( value === ( hidden ? "hide" : "show" ) ) { |
|
6731 |
|
6732 // Pretend to be hidden if this is a "show" and |
|
6733 // there is still data from a stopped show/hide |
|
6734 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { |
|
6735 hidden = true; |
|
6736 |
|
6737 // Ignore all other no-op show/hide data |
|
6738 } else { |
|
6739 continue; |
|
6740 } |
|
6741 } |
|
6742 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); |
|
6743 } |
|
6744 } |
|
6745 |
|
6746 // Bail out if this is a no-op like .hide().hide() |
|
6747 propTween = !jQuery.isEmptyObject( props ); |
|
6748 if ( !propTween && jQuery.isEmptyObject( orig ) ) { |
|
6749 return; |
|
6750 } |
|
6751 |
|
6752 // Restrict "overflow" and "display" styles during box animations |
|
6753 if ( isBox && elem.nodeType === 1 ) { |
|
6754 |
|
6755 // Support: IE <=9 - 11, Edge 12 - 13 |
|
6756 // Record all 3 overflow attributes because IE does not infer the shorthand |
|
6757 // from identically-valued overflowX and overflowY |
|
6758 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; |
|
6759 |
|
6760 // Identify a display type, preferring old show/hide data over the CSS cascade |
|
6761 restoreDisplay = dataShow && dataShow.display; |
|
6762 if ( restoreDisplay == null ) { |
|
6763 restoreDisplay = dataPriv.get( elem, "display" ); |
|
6764 } |
|
6765 display = jQuery.css( elem, "display" ); |
|
6766 if ( display === "none" ) { |
|
6767 if ( restoreDisplay ) { |
|
6768 display = restoreDisplay; |
|
6769 } else { |
|
6770 |
|
6771 // Get nonempty value(s) by temporarily forcing visibility |
|
6772 showHide( [ elem ], true ); |
|
6773 restoreDisplay = elem.style.display || restoreDisplay; |
|
6774 display = jQuery.css( elem, "display" ); |
|
6775 showHide( [ elem ] ); |
|
6776 } |
|
6777 } |
|
6778 |
|
6779 // Animate inline elements as inline-block |
|
6780 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { |
|
6781 if ( jQuery.css( elem, "float" ) === "none" ) { |
|
6782 |
|
6783 // Restore the original display value at the end of pure show/hide animations |
|
6784 if ( !propTween ) { |
|
6785 anim.done( function() { |
|
6786 style.display = restoreDisplay; |
|
6787 } ); |
|
6788 if ( restoreDisplay == null ) { |
|
6789 display = style.display; |
|
6790 restoreDisplay = display === "none" ? "" : display; |
|
6791 } |
|
6792 } |
|
6793 style.display = "inline-block"; |
|
6794 } |
|
6795 } |
|
6796 } |
|
6797 |
|
6798 if ( opts.overflow ) { |
|
6799 style.overflow = "hidden"; |
|
6800 anim.always( function() { |
|
6801 style.overflow = opts.overflow[ 0 ]; |
|
6802 style.overflowX = opts.overflow[ 1 ]; |
|
6803 style.overflowY = opts.overflow[ 2 ]; |
|
6804 } ); |
|
6805 } |
|
6806 |
|
6807 // Implement show/hide animations |
|
6808 propTween = false; |
|
6809 for ( prop in orig ) { |
|
6810 |
|
6811 // General show/hide setup for this element animation |
|
6812 if ( !propTween ) { |
|
6813 if ( dataShow ) { |
|
6814 if ( "hidden" in dataShow ) { |
|
6815 hidden = dataShow.hidden; |
|
6816 } |
|
6817 } else { |
|
6818 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); |
|
6819 } |
|
6820 |
|
6821 // Store hidden/visible for toggle so `.stop().toggle()` "reverses" |
|
6822 if ( toggle ) { |
|
6823 dataShow.hidden = !hidden; |
|
6824 } |
|
6825 |
|
6826 // Show elements before animating them |
|
6827 if ( hidden ) { |
|
6828 showHide( [ elem ], true ); |
|
6829 } |
|
6830 |
|
6831 /* eslint-disable no-loop-func */ |
|
6832 |
|
6833 anim.done( function() { |
|
6834 |
|
6835 /* eslint-enable no-loop-func */ |
|
6836 |
|
6837 // The final step of a "hide" animation is actually hiding the element |
|
6838 if ( !hidden ) { |
|
6839 showHide( [ elem ] ); |
|
6840 } |
|
6841 dataPriv.remove( elem, "fxshow" ); |
|
6842 for ( prop in orig ) { |
|
6843 jQuery.style( elem, prop, orig[ prop ] ); |
|
6844 } |
|
6845 } ); |
|
6846 } |
|
6847 |
|
6848 // Per-property setup |
|
6849 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); |
|
6850 if ( !( prop in dataShow ) ) { |
|
6851 dataShow[ prop ] = propTween.start; |
|
6852 if ( hidden ) { |
|
6853 propTween.end = propTween.start; |
|
6854 propTween.start = 0; |
|
6855 } |
|
6856 } |
|
6857 } |
|
6858 } |
|
6859 |
|
6860 function propFilter( props, specialEasing ) { |
|
6861 var index, name, easing, value, hooks; |
|
6862 |
|
6863 // camelCase, specialEasing and expand cssHook pass |
|
6864 for ( index in props ) { |
|
6865 name = jQuery.camelCase( index ); |
|
6866 easing = specialEasing[ name ]; |
|
6867 value = props[ index ]; |
|
6868 if ( jQuery.isArray( value ) ) { |
|
6869 easing = value[ 1 ]; |
|
6870 value = props[ index ] = value[ 0 ]; |
|
6871 } |
|
6872 |
|
6873 if ( index !== name ) { |
|
6874 props[ name ] = value; |
|
6875 delete props[ index ]; |
|
6876 } |
|
6877 |
|
6878 hooks = jQuery.cssHooks[ name ]; |
|
6879 if ( hooks && "expand" in hooks ) { |
|
6880 value = hooks.expand( value ); |
|
6881 delete props[ name ]; |
|
6882 |
|
6883 // Not quite $.extend, this won't overwrite existing keys. |
|
6884 // Reusing 'index' because we have the correct "name" |
|
6885 for ( index in value ) { |
|
6886 if ( !( index in props ) ) { |
|
6887 props[ index ] = value[ index ]; |
|
6888 specialEasing[ index ] = easing; |
|
6889 } |
|
6890 } |
|
6891 } else { |
|
6892 specialEasing[ name ] = easing; |
|
6893 } |
|
6894 } |
|
6895 } |
|
6896 |
|
6897 function Animation( elem, properties, options ) { |
|
6898 var result, |
|
6899 stopped, |
|
6900 index = 0, |
|
6901 length = Animation.prefilters.length, |
|
6902 deferred = jQuery.Deferred().always( function() { |
|
6903 |
|
6904 // Don't match elem in the :animated selector |
|
6905 delete tick.elem; |
|
6906 } ), |
|
6907 tick = function() { |
|
6908 if ( stopped ) { |
|
6909 return false; |
|
6910 } |
|
6911 var currentTime = fxNow || createFxNow(), |
|
6912 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), |
|
6913 |
|
6914 // Support: Android 2.3 only |
|
6915 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) |
|
6916 temp = remaining / animation.duration || 0, |
|
6917 percent = 1 - temp, |
|
6918 index = 0, |
|
6919 length = animation.tweens.length; |
|
6920 |
|
6921 for ( ; index < length; index++ ) { |
|
6922 animation.tweens[ index ].run( percent ); |
|
6923 } |
|
6924 |
|
6925 deferred.notifyWith( elem, [ animation, percent, remaining ] ); |
|
6926 |
|
6927 if ( percent < 1 && length ) { |
|
6928 return remaining; |
|
6929 } else { |
|
6930 deferred.resolveWith( elem, [ animation ] ); |
|
6931 return false; |
|
6932 } |
|
6933 }, |
|
6934 animation = deferred.promise( { |
|
6935 elem: elem, |
|
6936 props: jQuery.extend( {}, properties ), |
|
6937 opts: jQuery.extend( true, { |
|
6938 specialEasing: {}, |
|
6939 easing: jQuery.easing._default |
|
6940 }, options ), |
|
6941 originalProperties: properties, |
|
6942 originalOptions: options, |
|
6943 startTime: fxNow || createFxNow(), |
|
6944 duration: options.duration, |
|
6945 tweens: [], |
|
6946 createTween: function( prop, end ) { |
|
6947 var tween = jQuery.Tween( elem, animation.opts, prop, end, |
|
6948 animation.opts.specialEasing[ prop ] || animation.opts.easing ); |
|
6949 animation.tweens.push( tween ); |
|
6950 return tween; |
|
6951 }, |
|
6952 stop: function( gotoEnd ) { |
|
6953 var index = 0, |
|
6954 |
|
6955 // If we are going to the end, we want to run all the tweens |
|
6956 // otherwise we skip this part |
|
6957 length = gotoEnd ? animation.tweens.length : 0; |
|
6958 if ( stopped ) { |
|
6959 return this; |
|
6960 } |
|
6961 stopped = true; |
|
6962 for ( ; index < length; index++ ) { |
|
6963 animation.tweens[ index ].run( 1 ); |
|
6964 } |
|
6965 |
|
6966 // Resolve when we played the last frame; otherwise, reject |
|
6967 if ( gotoEnd ) { |
|
6968 deferred.notifyWith( elem, [ animation, 1, 0 ] ); |
|
6969 deferred.resolveWith( elem, [ animation, gotoEnd ] ); |
|
6970 } else { |
|
6971 deferred.rejectWith( elem, [ animation, gotoEnd ] ); |
|
6972 } |
|
6973 return this; |
|
6974 } |
|
6975 } ), |
|
6976 props = animation.props; |
|
6977 |
|
6978 propFilter( props, animation.opts.specialEasing ); |
|
6979 |
|
6980 for ( ; index < length; index++ ) { |
|
6981 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); |
|
6982 if ( result ) { |
|
6983 if ( jQuery.isFunction( result.stop ) ) { |
|
6984 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = |
|
6985 jQuery.proxy( result.stop, result ); |
|
6986 } |
|
6987 return result; |
|
6988 } |
|
6989 } |
|
6990 |
|
6991 jQuery.map( props, createTween, animation ); |
|
6992 |
|
6993 if ( jQuery.isFunction( animation.opts.start ) ) { |
|
6994 animation.opts.start.call( elem, animation ); |
|
6995 } |
|
6996 |
|
6997 jQuery.fx.timer( |
|
6998 jQuery.extend( tick, { |
|
6999 elem: elem, |
|
7000 anim: animation, |
|
7001 queue: animation.opts.queue |
|
7002 } ) |
|
7003 ); |
|
7004 |
|
7005 // attach callbacks from options |
|
7006 return animation.progress( animation.opts.progress ) |
|
7007 .done( animation.opts.done, animation.opts.complete ) |
|
7008 .fail( animation.opts.fail ) |
|
7009 .always( animation.opts.always ); |
|
7010 } |
|
7011 |
|
7012 jQuery.Animation = jQuery.extend( Animation, { |
|
7013 |
|
7014 tweeners: { |
|
7015 "*": [ function( prop, value ) { |
|
7016 var tween = this.createTween( prop, value ); |
|
7017 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); |
|
7018 return tween; |
|
7019 } ] |
|
7020 }, |
|
7021 |
|
7022 tweener: function( props, callback ) { |
|
7023 if ( jQuery.isFunction( props ) ) { |
|
7024 callback = props; |
|
7025 props = [ "*" ]; |
|
7026 } else { |
|
7027 props = props.match( rnotwhite ); |
|
7028 } |
|
7029 |
|
7030 var prop, |
|
7031 index = 0, |
|
7032 length = props.length; |
|
7033 |
|
7034 for ( ; index < length; index++ ) { |
|
7035 prop = props[ index ]; |
|
7036 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; |
|
7037 Animation.tweeners[ prop ].unshift( callback ); |
|
7038 } |
|
7039 }, |
|
7040 |
|
7041 prefilters: [ defaultPrefilter ], |
|
7042 |
|
7043 prefilter: function( callback, prepend ) { |
|
7044 if ( prepend ) { |
|
7045 Animation.prefilters.unshift( callback ); |
|
7046 } else { |
|
7047 Animation.prefilters.push( callback ); |
|
7048 } |
|
7049 } |
|
7050 } ); |
|
7051 |
|
7052 jQuery.speed = function( speed, easing, fn ) { |
|
7053 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { |
|
7054 complete: fn || !fn && easing || |
|
7055 jQuery.isFunction( speed ) && speed, |
|
7056 duration: speed, |
|
7057 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing |
|
7058 }; |
|
7059 |
|
7060 // Go to the end state if fx are off or if document is hidden |
|
7061 if ( jQuery.fx.off || document.hidden ) { |
|
7062 opt.duration = 0; |
|
7063 |
|
7064 } else { |
|
7065 opt.duration = typeof opt.duration === "number" ? |
|
7066 opt.duration : opt.duration in jQuery.fx.speeds ? |
|
7067 jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; |
|
7068 } |
|
7069 |
|
7070 // Normalize opt.queue - true/undefined/null -> "fx" |
|
7071 if ( opt.queue == null || opt.queue === true ) { |
|
7072 opt.queue = "fx"; |
|
7073 } |
|
7074 |
|
7075 // Queueing |
|
7076 opt.old = opt.complete; |
|
7077 |
|
7078 opt.complete = function() { |
|
7079 if ( jQuery.isFunction( opt.old ) ) { |
|
7080 opt.old.call( this ); |
|
7081 } |
|
7082 |
|
7083 if ( opt.queue ) { |
|
7084 jQuery.dequeue( this, opt.queue ); |
|
7085 } |
|
7086 }; |
|
7087 |
|
7088 return opt; |
|
7089 }; |
|
7090 |
|
7091 jQuery.fn.extend( { |
|
7092 fadeTo: function( speed, to, easing, callback ) { |
|
7093 |
|
7094 // Show any hidden elements after setting opacity to 0 |
|
7095 return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() |
|
7096 |
|
7097 // Animate to the value specified |
|
7098 .end().animate( { opacity: to }, speed, easing, callback ); |
|
7099 }, |
|
7100 animate: function( prop, speed, easing, callback ) { |
|
7101 var empty = jQuery.isEmptyObject( prop ), |
|
7102 optall = jQuery.speed( speed, easing, callback ), |
|
7103 doAnimation = function() { |
|
7104 |
|
7105 // Operate on a copy of prop so per-property easing won't be lost |
|
7106 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); |
|
7107 |
|
7108 // Empty animations, or finishing resolves immediately |
|
7109 if ( empty || dataPriv.get( this, "finish" ) ) { |
|
7110 anim.stop( true ); |
|
7111 } |
|
7112 }; |
|
7113 doAnimation.finish = doAnimation; |
|
7114 |
|
7115 return empty || optall.queue === false ? |
|
7116 this.each( doAnimation ) : |
|
7117 this.queue( optall.queue, doAnimation ); |
|
7118 }, |
|
7119 stop: function( type, clearQueue, gotoEnd ) { |
|
7120 var stopQueue = function( hooks ) { |
|
7121 var stop = hooks.stop; |
|
7122 delete hooks.stop; |
|
7123 stop( gotoEnd ); |
|
7124 }; |
|
7125 |
|
7126 if ( typeof type !== "string" ) { |
|
7127 gotoEnd = clearQueue; |
|
7128 clearQueue = type; |
|
7129 type = undefined; |
|
7130 } |
|
7131 if ( clearQueue && type !== false ) { |
|
7132 this.queue( type || "fx", [] ); |
|
7133 } |
|
7134 |
|
7135 return this.each( function() { |
|
7136 var dequeue = true, |
|
7137 index = type != null && type + "queueHooks", |
|
7138 timers = jQuery.timers, |
|
7139 data = dataPriv.get( this ); |
|
7140 |
|
7141 if ( index ) { |
|
7142 if ( data[ index ] && data[ index ].stop ) { |
|
7143 stopQueue( data[ index ] ); |
|
7144 } |
|
7145 } else { |
|
7146 for ( index in data ) { |
|
7147 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { |
|
7148 stopQueue( data[ index ] ); |
|
7149 } |
|
7150 } |
|
7151 } |
|
7152 |
|
7153 for ( index = timers.length; index--; ) { |
|
7154 if ( timers[ index ].elem === this && |
|
7155 ( type == null || timers[ index ].queue === type ) ) { |
|
7156 |
|
7157 timers[ index ].anim.stop( gotoEnd ); |
|
7158 dequeue = false; |
|
7159 timers.splice( index, 1 ); |
|
7160 } |
|
7161 } |
|
7162 |
|
7163 // Start the next in the queue if the last step wasn't forced. |
|
7164 // Timers currently will call their complete callbacks, which |
|
7165 // will dequeue but only if they were gotoEnd. |
|
7166 if ( dequeue || !gotoEnd ) { |
|
7167 jQuery.dequeue( this, type ); |
|
7168 } |
|
7169 } ); |
|
7170 }, |
|
7171 finish: function( type ) { |
|
7172 if ( type !== false ) { |
|
7173 type = type || "fx"; |
|
7174 } |
|
7175 return this.each( function() { |
|
7176 var index, |
|
7177 data = dataPriv.get( this ), |
|
7178 queue = data[ type + "queue" ], |
|
7179 hooks = data[ type + "queueHooks" ], |
|
7180 timers = jQuery.timers, |
|
7181 length = queue ? queue.length : 0; |
|
7182 |
|
7183 // Enable finishing flag on private data |
|
7184 data.finish = true; |
|
7185 |
|
7186 // Empty the queue first |
|
7187 jQuery.queue( this, type, [] ); |
|
7188 |
|
7189 if ( hooks && hooks.stop ) { |
|
7190 hooks.stop.call( this, true ); |
|
7191 } |
|
7192 |
|
7193 // Look for any active animations, and finish them |
|
7194 for ( index = timers.length; index--; ) { |
|
7195 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { |
|
7196 timers[ index ].anim.stop( true ); |
|
7197 timers.splice( index, 1 ); |
|
7198 } |
|
7199 } |
|
7200 |
|
7201 // Look for any animations in the old queue and finish them |
|
7202 for ( index = 0; index < length; index++ ) { |
|
7203 if ( queue[ index ] && queue[ index ].finish ) { |
|
7204 queue[ index ].finish.call( this ); |
|
7205 } |
|
7206 } |
|
7207 |
|
7208 // Turn off finishing flag |
|
7209 delete data.finish; |
|
7210 } ); |
|
7211 } |
|
7212 } ); |
|
7213 |
|
7214 jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) { |
|
7215 var cssFn = jQuery.fn[ name ]; |
|
7216 jQuery.fn[ name ] = function( speed, easing, callback ) { |
|
7217 return speed == null || typeof speed === "boolean" ? |
|
7218 cssFn.apply( this, arguments ) : |
|
7219 this.animate( genFx( name, true ), speed, easing, callback ); |
|
7220 }; |
|
7221 } ); |
|
7222 |
|
7223 // Generate shortcuts for custom animations |
|
7224 jQuery.each( { |
|
7225 slideDown: genFx( "show" ), |
|
7226 slideUp: genFx( "hide" ), |
|
7227 slideToggle: genFx( "toggle" ), |
|
7228 fadeIn: { opacity: "show" }, |
|
7229 fadeOut: { opacity: "hide" }, |
|
7230 fadeToggle: { opacity: "toggle" } |
|
7231 }, function( name, props ) { |
|
7232 jQuery.fn[ name ] = function( speed, easing, callback ) { |
|
7233 return this.animate( props, speed, easing, callback ); |
|
7234 }; |
|
7235 } ); |
|
7236 |
|
7237 jQuery.timers = []; |
|
7238 jQuery.fx.tick = function() { |
|
7239 var timer, |
|
7240 i = 0, |
|
7241 timers = jQuery.timers; |
|
7242 |
|
7243 fxNow = jQuery.now(); |
|
7244 |
|
7245 for ( ; i < timers.length; i++ ) { |
|
7246 timer = timers[ i ]; |
|
7247 |
|
7248 // Checks the timer has not already been removed |
|
7249 if ( !timer() && timers[ i ] === timer ) { |
|
7250 timers.splice( i--, 1 ); |
|
7251 } |
|
7252 } |
|
7253 |
|
7254 if ( !timers.length ) { |
|
7255 jQuery.fx.stop(); |
|
7256 } |
|
7257 fxNow = undefined; |
|
7258 }; |
|
7259 |
|
7260 jQuery.fx.timer = function( timer ) { |
|
7261 jQuery.timers.push( timer ); |
|
7262 if ( timer() ) { |
|
7263 jQuery.fx.start(); |
|
7264 } else { |
|
7265 jQuery.timers.pop(); |
|
7266 } |
|
7267 }; |
|
7268 |
|
7269 jQuery.fx.interval = 13; |
|
7270 jQuery.fx.start = function() { |
|
7271 if ( !timerId ) { |
|
7272 timerId = window.requestAnimationFrame ? |
|
7273 window.requestAnimationFrame( raf ) : |
|
7274 window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); |
|
7275 } |
|
7276 }; |
|
7277 |
|
7278 jQuery.fx.stop = function() { |
|
7279 if ( window.cancelAnimationFrame ) { |
|
7280 window.cancelAnimationFrame( timerId ); |
|
7281 } else { |
|
7282 window.clearInterval( timerId ); |
|
7283 } |
|
7284 |
|
7285 timerId = null; |
|
7286 }; |
|
7287 |
|
7288 jQuery.fx.speeds = { |
|
7289 slow: 600, |
|
7290 fast: 200, |
|
7291 |
|
7292 // Default speed |
|
7293 _default: 400 |
|
7294 }; |
|
7295 |
|
7296 |
|
7297 // Based off of the plugin by Clint Helfers, with permission. |
|
7298 // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ |
|
7299 jQuery.fn.delay = function( time, type ) { |
|
7300 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; |
|
7301 type = type || "fx"; |
|
7302 |
|
7303 return this.queue( type, function( next, hooks ) { |
|
7304 var timeout = window.setTimeout( next, time ); |
|
7305 hooks.stop = function() { |
|
7306 window.clearTimeout( timeout ); |
|
7307 }; |
|
7308 } ); |
|
7309 }; |
|
7310 |
|
7311 |
|
7312 ( function() { |
|
7313 var input = document.createElement( "input" ), |
|
7314 select = document.createElement( "select" ), |
|
7315 opt = select.appendChild( document.createElement( "option" ) ); |
|
7316 |
|
7317 input.type = "checkbox"; |
|
7318 |
|
7319 // Support: Android <=4.3 only |
|
7320 // Default value for a checkbox should be "on" |
|
7321 support.checkOn = input.value !== ""; |
|
7322 |
|
7323 // Support: IE <=11 only |
|
7324 // Must access selectedIndex to make default options select |
|
7325 support.optSelected = opt.selected; |
|
7326 |
|
7327 // Support: IE <=11 only |
|
7328 // An input loses its value after becoming a radio |
|
7329 input = document.createElement( "input" ); |
|
7330 input.value = "t"; |
|
7331 input.type = "radio"; |
|
7332 support.radioValue = input.value === "t"; |
|
7333 } )(); |
|
7334 |
|
7335 |
|
7336 var boolHook, |
|
7337 attrHandle = jQuery.expr.attrHandle; |
|
7338 |
|
7339 jQuery.fn.extend( { |
|
7340 attr: function( name, value ) { |
|
7341 return access( this, jQuery.attr, name, value, arguments.length > 1 ); |
|
7342 }, |
|
7343 |
|
7344 removeAttr: function( name ) { |
|
7345 return this.each( function() { |
|
7346 jQuery.removeAttr( this, name ); |
|
7347 } ); |
|
7348 } |
|
7349 } ); |
|
7350 |
|
7351 jQuery.extend( { |
|
7352 attr: function( elem, name, value ) { |
|
7353 var ret, hooks, |
|
7354 nType = elem.nodeType; |
|
7355 |
|
7356 // Don't get/set attributes on text, comment and attribute nodes |
|
7357 if ( nType === 3 || nType === 8 || nType === 2 ) { |
|
7358 return; |
|
7359 } |
|
7360 |
|
7361 // Fallback to prop when attributes are not supported |
|
7362 if ( typeof elem.getAttribute === "undefined" ) { |
|
7363 return jQuery.prop( elem, name, value ); |
|
7364 } |
|
7365 |
|
7366 // Attribute hooks are determined by the lowercase version |
|
7367 // Grab necessary hook if one is defined |
|
7368 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { |
|
7369 hooks = jQuery.attrHooks[ name.toLowerCase() ] || |
|
7370 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); |
|
7371 } |
|
7372 |
|
7373 if ( value !== undefined ) { |
|
7374 if ( value === null ) { |
|
7375 jQuery.removeAttr( elem, name ); |
|
7376 return; |
|
7377 } |
|
7378 |
|
7379 if ( hooks && "set" in hooks && |
|
7380 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { |
|
7381 return ret; |
|
7382 } |
|
7383 |
|
7384 elem.setAttribute( name, value + "" ); |
|
7385 return value; |
|
7386 } |
|
7387 |
|
7388 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { |
|
7389 return ret; |
|
7390 } |
|
7391 |
|
7392 ret = jQuery.find.attr( elem, name ); |
|
7393 |
|
7394 // Non-existent attributes return null, we normalize to undefined |
|
7395 return ret == null ? undefined : ret; |
|
7396 }, |
|
7397 |
|
7398 attrHooks: { |
|
7399 type: { |
|
7400 set: function( elem, value ) { |
|
7401 if ( !support.radioValue && value === "radio" && |
|
7402 jQuery.nodeName( elem, "input" ) ) { |
|
7403 var val = elem.value; |
|
7404 elem.setAttribute( "type", value ); |
|
7405 if ( val ) { |
|
7406 elem.value = val; |
|
7407 } |
|
7408 return value; |
|
7409 } |
|
7410 } |
|
7411 } |
|
7412 }, |
|
7413 |
|
7414 removeAttr: function( elem, value ) { |
|
7415 var name, |
|
7416 i = 0, |
|
7417 attrNames = value && value.match( rnotwhite ); |
|
7418 |
|
7419 if ( attrNames && elem.nodeType === 1 ) { |
|
7420 while ( ( name = attrNames[ i++ ] ) ) { |
|
7421 elem.removeAttribute( name ); |
|
7422 } |
|
7423 } |
|
7424 } |
|
7425 } ); |
|
7426 |
|
7427 // Hooks for boolean attributes |
|
7428 boolHook = { |
|
7429 set: function( elem, value, name ) { |
|
7430 if ( value === false ) { |
|
7431 |
|
7432 // Remove boolean attributes when set to false |
|
7433 jQuery.removeAttr( elem, name ); |
|
7434 } else { |
|
7435 elem.setAttribute( name, name ); |
|
7436 } |
|
7437 return name; |
|
7438 } |
|
7439 }; |
|
7440 |
|
7441 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { |
|
7442 var getter = attrHandle[ name ] || jQuery.find.attr; |
|
7443 |
|
7444 attrHandle[ name ] = function( elem, name, isXML ) { |
|
7445 var ret, handle, |
|
7446 lowercaseName = name.toLowerCase(); |
|
7447 |
|
7448 if ( !isXML ) { |
|
7449 |
|
7450 // Avoid an infinite loop by temporarily removing this function from the getter |
|
7451 handle = attrHandle[ lowercaseName ]; |
|
7452 attrHandle[ lowercaseName ] = ret; |
|
7453 ret = getter( elem, name, isXML ) != null ? |
|
7454 lowercaseName : |
|
7455 null; |
|
7456 attrHandle[ lowercaseName ] = handle; |
|
7457 } |
|
7458 return ret; |
|
7459 }; |
|
7460 } ); |
|
7461 |
|
7462 |
|
7463 |
|
7464 |
|
7465 var rfocusable = /^(?:input|select|textarea|button)$/i, |
|
7466 rclickable = /^(?:a|area)$/i; |
|
7467 |
|
7468 jQuery.fn.extend( { |
|
7469 prop: function( name, value ) { |
|
7470 return access( this, jQuery.prop, name, value, arguments.length > 1 ); |
|
7471 }, |
|
7472 |
|
7473 removeProp: function( name ) { |
|
7474 return this.each( function() { |
|
7475 delete this[ jQuery.propFix[ name ] || name ]; |
|
7476 } ); |
|
7477 } |
|
7478 } ); |
|
7479 |
|
7480 jQuery.extend( { |
|
7481 prop: function( elem, name, value ) { |
|
7482 var ret, hooks, |
|
7483 nType = elem.nodeType; |
|
7484 |
|
7485 // Don't get/set properties on text, comment and attribute nodes |
|
7486 if ( nType === 3 || nType === 8 || nType === 2 ) { |
|
7487 return; |
|
7488 } |
|
7489 |
|
7490 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { |
|
7491 |
|
7492 // Fix name and attach hooks |
|
7493 name = jQuery.propFix[ name ] || name; |
|
7494 hooks = jQuery.propHooks[ name ]; |
|
7495 } |
|
7496 |
|
7497 if ( value !== undefined ) { |
|
7498 if ( hooks && "set" in hooks && |
|
7499 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { |
|
7500 return ret; |
|
7501 } |
|
7502 |
|
7503 return ( elem[ name ] = value ); |
|
7504 } |
|
7505 |
|
7506 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { |
|
7507 return ret; |
|
7508 } |
|
7509 |
|
7510 return elem[ name ]; |
|
7511 }, |
|
7512 |
|
7513 propHooks: { |
|
7514 tabIndex: { |
|
7515 get: function( elem ) { |
|
7516 |
|
7517 // Support: IE <=9 - 11 only |
|
7518 // elem.tabIndex doesn't always return the |
|
7519 // correct value when it hasn't been explicitly set |
|
7520 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
|
7521 // Use proper attribute retrieval(#12072) |
|
7522 var tabindex = jQuery.find.attr( elem, "tabindex" ); |
|
7523 |
|
7524 return tabindex ? |
|
7525 parseInt( tabindex, 10 ) : |
|
7526 rfocusable.test( elem.nodeName ) || |
|
7527 rclickable.test( elem.nodeName ) && elem.href ? |
|
7528 0 : |
|
7529 -1; |
|
7530 } |
|
7531 } |
|
7532 }, |
|
7533 |
|
7534 propFix: { |
|
7535 "for": "htmlFor", |
|
7536 "class": "className" |
|
7537 } |
|
7538 } ); |
|
7539 |
|
7540 // Support: IE <=11 only |
|
7541 // Accessing the selectedIndex property |
|
7542 // forces the browser to respect setting selected |
|
7543 // on the option |
|
7544 // The getter ensures a default option is selected |
|
7545 // when in an optgroup |
|
7546 if ( !support.optSelected ) { |
|
7547 jQuery.propHooks.selected = { |
|
7548 get: function( elem ) { |
|
7549 var parent = elem.parentNode; |
|
7550 if ( parent && parent.parentNode ) { |
|
7551 parent.parentNode.selectedIndex; |
|
7552 } |
|
7553 return null; |
|
7554 }, |
|
7555 set: function( elem ) { |
|
7556 var parent = elem.parentNode; |
|
7557 if ( parent ) { |
|
7558 parent.selectedIndex; |
|
7559 |
|
7560 if ( parent.parentNode ) { |
|
7561 parent.parentNode.selectedIndex; |
|
7562 } |
|
7563 } |
|
7564 } |
|
7565 }; |
|
7566 } |
|
7567 |
|
7568 jQuery.each( [ |
|
7569 "tabIndex", |
|
7570 "readOnly", |
|
7571 "maxLength", |
|
7572 "cellSpacing", |
|
7573 "cellPadding", |
|
7574 "rowSpan", |
|
7575 "colSpan", |
|
7576 "useMap", |
|
7577 "frameBorder", |
|
7578 "contentEditable" |
|
7579 ], function() { |
|
7580 jQuery.propFix[ this.toLowerCase() ] = this; |
|
7581 } ); |
|
7582 |
|
7583 |
|
7584 |
|
7585 |
|
7586 var rclass = /[\t\r\n\f]/g; |
|
7587 |
|
7588 function getClass( elem ) { |
|
7589 return elem.getAttribute && elem.getAttribute( "class" ) || ""; |
|
7590 } |
|
7591 |
|
7592 jQuery.fn.extend( { |
|
7593 addClass: function( value ) { |
|
7594 var classes, elem, cur, curValue, clazz, j, finalValue, |
|
7595 i = 0; |
|
7596 |
|
7597 if ( jQuery.isFunction( value ) ) { |
|
7598 return this.each( function( j ) { |
|
7599 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); |
|
7600 } ); |
|
7601 } |
|
7602 |
|
7603 if ( typeof value === "string" && value ) { |
|
7604 classes = value.match( rnotwhite ) || []; |
|
7605 |
|
7606 while ( ( elem = this[ i++ ] ) ) { |
|
7607 curValue = getClass( elem ); |
|
7608 cur = elem.nodeType === 1 && |
|
7609 ( " " + curValue + " " ).replace( rclass, " " ); |
|
7610 |
|
7611 if ( cur ) { |
|
7612 j = 0; |
|
7613 while ( ( clazz = classes[ j++ ] ) ) { |
|
7614 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { |
|
7615 cur += clazz + " "; |
|
7616 } |
|
7617 } |
|
7618 |
|
7619 // Only assign if different to avoid unneeded rendering. |
|
7620 finalValue = jQuery.trim( cur ); |
|
7621 if ( curValue !== finalValue ) { |
|
7622 elem.setAttribute( "class", finalValue ); |
|
7623 } |
|
7624 } |
|
7625 } |
|
7626 } |
|
7627 |
|
7628 return this; |
|
7629 }, |
|
7630 |
|
7631 removeClass: function( value ) { |
|
7632 var classes, elem, cur, curValue, clazz, j, finalValue, |
|
7633 i = 0; |
|
7634 |
|
7635 if ( jQuery.isFunction( value ) ) { |
|
7636 return this.each( function( j ) { |
|
7637 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); |
|
7638 } ); |
|
7639 } |
|
7640 |
|
7641 if ( !arguments.length ) { |
|
7642 return this.attr( "class", "" ); |
|
7643 } |
|
7644 |
|
7645 if ( typeof value === "string" && value ) { |
|
7646 classes = value.match( rnotwhite ) || []; |
|
7647 |
|
7648 while ( ( elem = this[ i++ ] ) ) { |
|
7649 curValue = getClass( elem ); |
|
7650 |
|
7651 // This expression is here for better compressibility (see addClass) |
|
7652 cur = elem.nodeType === 1 && |
|
7653 ( " " + curValue + " " ).replace( rclass, " " ); |
|
7654 |
|
7655 if ( cur ) { |
|
7656 j = 0; |
|
7657 while ( ( clazz = classes[ j++ ] ) ) { |
|
7658 |
|
7659 // Remove *all* instances |
|
7660 while ( cur.indexOf( " " + clazz + " " ) > -1 ) { |
|
7661 cur = cur.replace( " " + clazz + " ", " " ); |
|
7662 } |
|
7663 } |
|
7664 |
|
7665 // Only assign if different to avoid unneeded rendering. |
|
7666 finalValue = jQuery.trim( cur ); |
|
7667 if ( curValue !== finalValue ) { |
|
7668 elem.setAttribute( "class", finalValue ); |
|
7669 } |
|
7670 } |
|
7671 } |
|
7672 } |
|
7673 |
|
7674 return this; |
|
7675 }, |
|
7676 |
|
7677 toggleClass: function( value, stateVal ) { |
|
7678 var type = typeof value; |
|
7679 |
|
7680 if ( typeof stateVal === "boolean" && type === "string" ) { |
|
7681 return stateVal ? this.addClass( value ) : this.removeClass( value ); |
|
7682 } |
|
7683 |
|
7684 if ( jQuery.isFunction( value ) ) { |
|
7685 return this.each( function( i ) { |
|
7686 jQuery( this ).toggleClass( |
|
7687 value.call( this, i, getClass( this ), stateVal ), |
|
7688 stateVal |
|
7689 ); |
|
7690 } ); |
|
7691 } |
|
7692 |
|
7693 return this.each( function() { |
|
7694 var className, i, self, classNames; |
|
7695 |
|
7696 if ( type === "string" ) { |
|
7697 |
|
7698 // Toggle individual class names |
|
7699 i = 0; |
|
7700 self = jQuery( this ); |
|
7701 classNames = value.match( rnotwhite ) || []; |
|
7702 |
|
7703 while ( ( className = classNames[ i++ ] ) ) { |
|
7704 |
|
7705 // Check each className given, space separated list |
|
7706 if ( self.hasClass( className ) ) { |
|
7707 self.removeClass( className ); |
|
7708 } else { |
|
7709 self.addClass( className ); |
|
7710 } |
|
7711 } |
|
7712 |
|
7713 // Toggle whole class name |
|
7714 } else if ( value === undefined || type === "boolean" ) { |
|
7715 className = getClass( this ); |
|
7716 if ( className ) { |
|
7717 |
|
7718 // Store className if set |
|
7719 dataPriv.set( this, "__className__", className ); |
|
7720 } |
|
7721 |
|
7722 // If the element has a class name or if we're passed `false`, |
|
7723 // then remove the whole classname (if there was one, the above saved it). |
|
7724 // Otherwise bring back whatever was previously saved (if anything), |
|
7725 // falling back to the empty string if nothing was stored. |
|
7726 if ( this.setAttribute ) { |
|
7727 this.setAttribute( "class", |
|
7728 className || value === false ? |
|
7729 "" : |
|
7730 dataPriv.get( this, "__className__" ) || "" |
|
7731 ); |
|
7732 } |
|
7733 } |
|
7734 } ); |
|
7735 }, |
|
7736 |
|
7737 hasClass: function( selector ) { |
|
7738 var className, elem, |
|
7739 i = 0; |
|
7740 |
|
7741 className = " " + selector + " "; |
|
7742 while ( ( elem = this[ i++ ] ) ) { |
|
7743 if ( elem.nodeType === 1 && |
|
7744 ( " " + getClass( elem ) + " " ).replace( rclass, " " ) |
|
7745 .indexOf( className ) > -1 |
|
7746 ) { |
|
7747 return true; |
|
7748 } |
|
7749 } |
|
7750 |
|
7751 return false; |
|
7752 } |
|
7753 } ); |
|
7754 |
|
7755 |
|
7756 |
|
7757 |
|
7758 var rreturn = /\r/g, |
|
7759 rspaces = /[\x20\t\r\n\f]+/g; |
|
7760 |
|
7761 jQuery.fn.extend( { |
|
7762 val: function( value ) { |
|
7763 var hooks, ret, isFunction, |
|
7764 elem = this[ 0 ]; |
|
7765 |
|
7766 if ( !arguments.length ) { |
|
7767 if ( elem ) { |
|
7768 hooks = jQuery.valHooks[ elem.type ] || |
|
7769 jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
|
7770 |
|
7771 if ( hooks && |
|
7772 "get" in hooks && |
|
7773 ( ret = hooks.get( elem, "value" ) ) !== undefined |
|
7774 ) { |
|
7775 return ret; |
|
7776 } |
|
7777 |
|
7778 ret = elem.value; |
|
7779 |
|
7780 return typeof ret === "string" ? |
|
7781 |
|
7782 // Handle most common string cases |
|
7783 ret.replace( rreturn, "" ) : |
|
7784 |
|
7785 // Handle cases where value is null/undef or number |
|
7786 ret == null ? "" : ret; |
|
7787 } |
|
7788 |
|
7789 return; |
|
7790 } |
|
7791 |
|
7792 isFunction = jQuery.isFunction( value ); |
|
7793 |
|
7794 return this.each( function( i ) { |
|
7795 var val; |
|
7796 |
|
7797 if ( this.nodeType !== 1 ) { |
|
7798 return; |
|
7799 } |
|
7800 |
|
7801 if ( isFunction ) { |
|
7802 val = value.call( this, i, jQuery( this ).val() ); |
|
7803 } else { |
|
7804 val = value; |
|
7805 } |
|
7806 |
|
7807 // Treat null/undefined as ""; convert numbers to string |
|
7808 if ( val == null ) { |
|
7809 val = ""; |
|
7810 |
|
7811 } else if ( typeof val === "number" ) { |
|
7812 val += ""; |
|
7813 |
|
7814 } else if ( jQuery.isArray( val ) ) { |
|
7815 val = jQuery.map( val, function( value ) { |
|
7816 return value == null ? "" : value + ""; |
|
7817 } ); |
|
7818 } |
|
7819 |
|
7820 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; |
|
7821 |
|
7822 // If set returns undefined, fall back to normal setting |
|
7823 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { |
|
7824 this.value = val; |
|
7825 } |
|
7826 } ); |
|
7827 } |
|
7828 } ); |
|
7829 |
|
7830 jQuery.extend( { |
|
7831 valHooks: { |
|
7832 option: { |
|
7833 get: function( elem ) { |
|
7834 |
|
7835 var val = jQuery.find.attr( elem, "value" ); |
|
7836 return val != null ? |
|
7837 val : |
|
7838 |
|
7839 // Support: IE <=10 - 11 only |
|
7840 // option.text throws exceptions (#14686, #14858) |
|
7841 // Strip and collapse whitespace |
|
7842 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace |
|
7843 jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " ); |
|
7844 } |
|
7845 }, |
|
7846 select: { |
|
7847 get: function( elem ) { |
|
7848 var value, option, |
|
7849 options = elem.options, |
|
7850 index = elem.selectedIndex, |
|
7851 one = elem.type === "select-one", |
|
7852 values = one ? null : [], |
|
7853 max = one ? index + 1 : options.length, |
|
7854 i = index < 0 ? |
|
7855 max : |
|
7856 one ? index : 0; |
|
7857 |
|
7858 // Loop through all the selected options |
|
7859 for ( ; i < max; i++ ) { |
|
7860 option = options[ i ]; |
|
7861 |
|
7862 // Support: IE <=9 only |
|
7863 // IE8-9 doesn't update selected after form reset (#2551) |
|
7864 if ( ( option.selected || i === index ) && |
|
7865 |
|
7866 // Don't return options that are disabled or in a disabled optgroup |
|
7867 !option.disabled && |
|
7868 ( !option.parentNode.disabled || |
|
7869 !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { |
|
7870 |
|
7871 // Get the specific value for the option |
|
7872 value = jQuery( option ).val(); |
|
7873 |
|
7874 // We don't need an array for one selects |
|
7875 if ( one ) { |
|
7876 return value; |
|
7877 } |
|
7878 |
|
7879 // Multi-Selects return an array |
|
7880 values.push( value ); |
|
7881 } |
|
7882 } |
|
7883 |
|
7884 return values; |
|
7885 }, |
|
7886 |
|
7887 set: function( elem, value ) { |
|
7888 var optionSet, option, |
|
7889 options = elem.options, |
|
7890 values = jQuery.makeArray( value ), |
|
7891 i = options.length; |
|
7892 |
|
7893 while ( i-- ) { |
|
7894 option = options[ i ]; |
|
7895 |
|
7896 /* eslint-disable no-cond-assign */ |
|
7897 |
|
7898 if ( option.selected = |
|
7899 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 |
|
7900 ) { |
|
7901 optionSet = true; |
|
7902 } |
|
7903 |
|
7904 /* eslint-enable no-cond-assign */ |
|
7905 } |
|
7906 |
|
7907 // Force browsers to behave consistently when non-matching value is set |
|
7908 if ( !optionSet ) { |
|
7909 elem.selectedIndex = -1; |
|
7910 } |
|
7911 return values; |
|
7912 } |
|
7913 } |
|
7914 } |
|
7915 } ); |
|
7916 |
|
7917 // Radios and checkboxes getter/setter |
|
7918 jQuery.each( [ "radio", "checkbox" ], function() { |
|
7919 jQuery.valHooks[ this ] = { |
|
7920 set: function( elem, value ) { |
|
7921 if ( jQuery.isArray( value ) ) { |
|
7922 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); |
|
7923 } |
|
7924 } |
|
7925 }; |
|
7926 if ( !support.checkOn ) { |
|
7927 jQuery.valHooks[ this ].get = function( elem ) { |
|
7928 return elem.getAttribute( "value" ) === null ? "on" : elem.value; |
|
7929 }; |
|
7930 } |
|
7931 } ); |
|
7932 |
|
7933 |
|
7934 |
|
7935 |
|
7936 // Return jQuery for attributes-only inclusion |
|
7937 |
|
7938 |
|
7939 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/; |
|
7940 |
|
7941 jQuery.extend( jQuery.event, { |
|
7942 |
|
7943 trigger: function( event, data, elem, onlyHandlers ) { |
|
7944 |
|
7945 var i, cur, tmp, bubbleType, ontype, handle, special, |
|
7946 eventPath = [ elem || document ], |
|
7947 type = hasOwn.call( event, "type" ) ? event.type : event, |
|
7948 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; |
|
7949 |
|
7950 cur = tmp = elem = elem || document; |
|
7951 |
|
7952 // Don't do events on text and comment nodes |
|
7953 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
|
7954 return; |
|
7955 } |
|
7956 |
|
7957 // focus/blur morphs to focusin/out; ensure we're not firing them right now |
|
7958 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { |
|
7959 return; |
|
7960 } |
|
7961 |
|
7962 if ( type.indexOf( "." ) > -1 ) { |
|
7963 |
|
7964 // Namespaced trigger; create a regexp to match event type in handle() |
|
7965 namespaces = type.split( "." ); |
|
7966 type = namespaces.shift(); |
|
7967 namespaces.sort(); |
|
7968 } |
|
7969 ontype = type.indexOf( ":" ) < 0 && "on" + type; |
|
7970 |
|
7971 // Caller can pass in a jQuery.Event object, Object, or just an event type string |
|
7972 event = event[ jQuery.expando ] ? |
|
7973 event : |
|
7974 new jQuery.Event( type, typeof event === "object" && event ); |
|
7975 |
|
7976 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) |
|
7977 event.isTrigger = onlyHandlers ? 2 : 3; |
|
7978 event.namespace = namespaces.join( "." ); |
|
7979 event.rnamespace = event.namespace ? |
|
7980 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : |
|
7981 null; |
|
7982 |
|
7983 // Clean up the event in case it is being reused |
|
7984 event.result = undefined; |
|
7985 if ( !event.target ) { |
|
7986 event.target = elem; |
|
7987 } |
|
7988 |
|
7989 // Clone any incoming data and prepend the event, creating the handler arg list |
|
7990 data = data == null ? |
|
7991 [ event ] : |
|
7992 jQuery.makeArray( data, [ event ] ); |
|
7993 |
|
7994 // Allow special events to draw outside the lines |
|
7995 special = jQuery.event.special[ type ] || {}; |
|
7996 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { |
|
7997 return; |
|
7998 } |
|
7999 |
|
8000 // Determine event propagation path in advance, per W3C events spec (#9951) |
|
8001 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) |
|
8002 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { |
|
8003 |
|
8004 bubbleType = special.delegateType || type; |
|
8005 if ( !rfocusMorph.test( bubbleType + type ) ) { |
|
8006 cur = cur.parentNode; |
|
8007 } |
|
8008 for ( ; cur; cur = cur.parentNode ) { |
|
8009 eventPath.push( cur ); |
|
8010 tmp = cur; |
|
8011 } |
|
8012 |
|
8013 // Only add window if we got to document (e.g., not plain obj or detached DOM) |
|
8014 if ( tmp === ( elem.ownerDocument || document ) ) { |
|
8015 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); |
|
8016 } |
|
8017 } |
|
8018 |
|
8019 // Fire handlers on the event path |
|
8020 i = 0; |
|
8021 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { |
|
8022 |
|
8023 event.type = i > 1 ? |
|
8024 bubbleType : |
|
8025 special.bindType || type; |
|
8026 |
|
8027 // jQuery handler |
|
8028 handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && |
|
8029 dataPriv.get( cur, "handle" ); |
|
8030 if ( handle ) { |
|
8031 handle.apply( cur, data ); |
|
8032 } |
|
8033 |
|
8034 // Native handler |
|
8035 handle = ontype && cur[ ontype ]; |
|
8036 if ( handle && handle.apply && acceptData( cur ) ) { |
|
8037 event.result = handle.apply( cur, data ); |
|
8038 if ( event.result === false ) { |
|
8039 event.preventDefault(); |
|
8040 } |
|
8041 } |
|
8042 } |
|
8043 event.type = type; |
|
8044 |
|
8045 // If nobody prevented the default action, do it now |
|
8046 if ( !onlyHandlers && !event.isDefaultPrevented() ) { |
|
8047 |
|
8048 if ( ( !special._default || |
|
8049 special._default.apply( eventPath.pop(), data ) === false ) && |
|
8050 acceptData( elem ) ) { |
|
8051 |
|
8052 // Call a native DOM method on the target with the same name as the event. |
|
8053 // Don't do default actions on window, that's where global variables be (#6170) |
|
8054 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { |
|
8055 |
|
8056 // Don't re-trigger an onFOO event when we call its FOO() method |
|
8057 tmp = elem[ ontype ]; |
|
8058 |
|
8059 if ( tmp ) { |
|
8060 elem[ ontype ] = null; |
|
8061 } |
|
8062 |
|
8063 // Prevent re-triggering of the same event, since we already bubbled it above |
|
8064 jQuery.event.triggered = type; |
|
8065 elem[ type ](); |
|
8066 jQuery.event.triggered = undefined; |
|
8067 |
|
8068 if ( tmp ) { |
|
8069 elem[ ontype ] = tmp; |
|
8070 } |
|
8071 } |
|
8072 } |
|
8073 } |
|
8074 |
|
8075 return event.result; |
|
8076 }, |
|
8077 |
|
8078 // Piggyback on a donor event to simulate a different one |
|
8079 // Used only for `focus(in | out)` events |
|
8080 simulate: function( type, elem, event ) { |
|
8081 var e = jQuery.extend( |
|
8082 new jQuery.Event(), |
|
8083 event, |
|
8084 { |
|
8085 type: type, |
|
8086 isSimulated: true |
|
8087 } |
|
8088 ); |
|
8089 |
|
8090 jQuery.event.trigger( e, null, elem ); |
|
8091 } |
|
8092 |
|
8093 } ); |
|
8094 |
|
8095 jQuery.fn.extend( { |
|
8096 |
|
8097 trigger: function( type, data ) { |
|
8098 return this.each( function() { |
|
8099 jQuery.event.trigger( type, data, this ); |
|
8100 } ); |
|
8101 }, |
|
8102 triggerHandler: function( type, data ) { |
|
8103 var elem = this[ 0 ]; |
|
8104 if ( elem ) { |
|
8105 return jQuery.event.trigger( type, data, elem, true ); |
|
8106 } |
|
8107 } |
|
8108 } ); |
|
8109 |
|
8110 |
|
8111 jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + |
|
8112 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
|
8113 "change select submit keydown keypress keyup contextmenu" ).split( " " ), |
|
8114 function( i, name ) { |
|
8115 |
|
8116 // Handle event binding |
|
8117 jQuery.fn[ name ] = function( data, fn ) { |
|
8118 return arguments.length > 0 ? |
|
8119 this.on( name, null, data, fn ) : |
|
8120 this.trigger( name ); |
|
8121 }; |
|
8122 } ); |
|
8123 |
|
8124 jQuery.fn.extend( { |
|
8125 hover: function( fnOver, fnOut ) { |
|
8126 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
|
8127 } |
|
8128 } ); |
|
8129 |
|
8130 |
|
8131 |
|
8132 |
|
8133 support.focusin = "onfocusin" in window; |
|
8134 |
|
8135 |
|
8136 // Support: Firefox <=44 |
|
8137 // Firefox doesn't have focus(in | out) events |
|
8138 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 |
|
8139 // |
|
8140 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 |
|
8141 // focus(in | out) events fire after focus & blur events, |
|
8142 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order |
|
8143 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 |
|
8144 if ( !support.focusin ) { |
|
8145 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
|
8146 |
|
8147 // Attach a single capturing handler on the document while someone wants focusin/focusout |
|
8148 var handler = function( event ) { |
|
8149 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); |
|
8150 }; |
|
8151 |
|
8152 jQuery.event.special[ fix ] = { |
|
8153 setup: function() { |
|
8154 var doc = this.ownerDocument || this, |
|
8155 attaches = dataPriv.access( doc, fix ); |
|
8156 |
|
8157 if ( !attaches ) { |
|
8158 doc.addEventListener( orig, handler, true ); |
|
8159 } |
|
8160 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); |
|
8161 }, |
|
8162 teardown: function() { |
|
8163 var doc = this.ownerDocument || this, |
|
8164 attaches = dataPriv.access( doc, fix ) - 1; |
|
8165 |
|
8166 if ( !attaches ) { |
|
8167 doc.removeEventListener( orig, handler, true ); |
|
8168 dataPriv.remove( doc, fix ); |
|
8169 |
|
8170 } else { |
|
8171 dataPriv.access( doc, fix, attaches ); |
|
8172 } |
|
8173 } |
|
8174 }; |
|
8175 } ); |
|
8176 } |
|
8177 var location = window.location; |
|
8178 |
|
8179 var nonce = jQuery.now(); |
|
8180 |
|
8181 var rquery = ( /\?/ ); |
|
8182 |
|
8183 |
|
8184 |
|
8185 // Cross-browser xml parsing |
|
8186 jQuery.parseXML = function( data ) { |
|
8187 var xml; |
|
8188 if ( !data || typeof data !== "string" ) { |
|
8189 return null; |
|
8190 } |
|
8191 |
|
8192 // Support: IE 9 - 11 only |
|
8193 // IE throws on parseFromString with invalid input. |
|
8194 try { |
|
8195 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); |
|
8196 } catch ( e ) { |
|
8197 xml = undefined; |
|
8198 } |
|
8199 |
|
8200 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { |
|
8201 jQuery.error( "Invalid XML: " + data ); |
|
8202 } |
|
8203 return xml; |
|
8204 }; |
|
8205 |
|
8206 |
|
8207 var |
|
8208 rbracket = /\[\]$/, |
|
8209 rCRLF = /\r?\n/g, |
|
8210 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, |
|
8211 rsubmittable = /^(?:input|select|textarea|keygen)/i; |
|
8212 |
|
8213 function buildParams( prefix, obj, traditional, add ) { |
|
8214 var name; |
|
8215 |
|
8216 if ( jQuery.isArray( obj ) ) { |
|
8217 |
|
8218 // Serialize array item. |
|
8219 jQuery.each( obj, function( i, v ) { |
|
8220 if ( traditional || rbracket.test( prefix ) ) { |
|
8221 |
|
8222 // Treat each array item as a scalar. |
|
8223 add( prefix, v ); |
|
8224 |
|
8225 } else { |
|
8226 |
|
8227 // Item is non-scalar (array or object), encode its numeric index. |
|
8228 buildParams( |
|
8229 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", |
|
8230 v, |
|
8231 traditional, |
|
8232 add |
|
8233 ); |
|
8234 } |
|
8235 } ); |
|
8236 |
|
8237 } else if ( !traditional && jQuery.type( obj ) === "object" ) { |
|
8238 |
|
8239 // Serialize object item. |
|
8240 for ( name in obj ) { |
|
8241 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
|
8242 } |
|
8243 |
|
8244 } else { |
|
8245 |
|
8246 // Serialize scalar item. |
|
8247 add( prefix, obj ); |
|
8248 } |
|
8249 } |
|
8250 |
|
8251 // Serialize an array of form elements or a set of |
|
8252 // key/values into a query string |
|
8253 jQuery.param = function( a, traditional ) { |
|
8254 var prefix, |
|
8255 s = [], |
|
8256 add = function( key, valueOrFunction ) { |
|
8257 |
|
8258 // If value is a function, invoke it and use its return value |
|
8259 var value = jQuery.isFunction( valueOrFunction ) ? |
|
8260 valueOrFunction() : |
|
8261 valueOrFunction; |
|
8262 |
|
8263 s[ s.length ] = encodeURIComponent( key ) + "=" + |
|
8264 encodeURIComponent( value == null ? "" : value ); |
|
8265 }; |
|
8266 |
|
8267 // If an array was passed in, assume that it is an array of form elements. |
|
8268 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
|
8269 |
|
8270 // Serialize the form elements |
|
8271 jQuery.each( a, function() { |
|
8272 add( this.name, this.value ); |
|
8273 } ); |
|
8274 |
|
8275 } else { |
|
8276 |
|
8277 // If traditional, encode the "old" way (the way 1.3.2 or older |
|
8278 // did it), otherwise encode params recursively. |
|
8279 for ( prefix in a ) { |
|
8280 buildParams( prefix, a[ prefix ], traditional, add ); |
|
8281 } |
|
8282 } |
|
8283 |
|
8284 // Return the resulting serialization |
|
8285 return s.join( "&" ); |
|
8286 }; |
|
8287 |
|
8288 jQuery.fn.extend( { |
|
8289 serialize: function() { |
|
8290 return jQuery.param( this.serializeArray() ); |
|
8291 }, |
|
8292 serializeArray: function() { |
|
8293 return this.map( function() { |
|
8294 |
|
8295 // Can add propHook for "elements" to filter or add form elements |
|
8296 var elements = jQuery.prop( this, "elements" ); |
|
8297 return elements ? jQuery.makeArray( elements ) : this; |
|
8298 } ) |
|
8299 .filter( function() { |
|
8300 var type = this.type; |
|
8301 |
|
8302 // Use .is( ":disabled" ) so that fieldset[disabled] works |
|
8303 return this.name && !jQuery( this ).is( ":disabled" ) && |
|
8304 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && |
|
8305 ( this.checked || !rcheckableType.test( type ) ); |
|
8306 } ) |
|
8307 .map( function( i, elem ) { |
|
8308 var val = jQuery( this ).val(); |
|
8309 |
|
8310 return val == null ? |
|
8311 null : |
|
8312 jQuery.isArray( val ) ? |
|
8313 jQuery.map( val, function( val ) { |
|
8314 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
|
8315 } ) : |
|
8316 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
|
8317 } ).get(); |
|
8318 } |
|
8319 } ); |
|
8320 |
|
8321 |
|
8322 var |
|
8323 r20 = /%20/g, |
|
8324 rhash = /#.*$/, |
|
8325 rts = /([?&])_=[^&]*/, |
|
8326 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, |
|
8327 |
|
8328 // #7653, #8125, #8152: local protocol detection |
|
8329 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, |
|
8330 rnoContent = /^(?:GET|HEAD)$/, |
|
8331 rprotocol = /^\/\//, |
|
8332 |
|
8333 /* Prefilters |
|
8334 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) |
|
8335 * 2) These are called: |
|
8336 * - BEFORE asking for a transport |
|
8337 * - AFTER param serialization (s.data is a string if s.processData is true) |
|
8338 * 3) key is the dataType |
|
8339 * 4) the catchall symbol "*" can be used |
|
8340 * 5) execution will start with transport dataType and THEN continue down to "*" if needed |
|
8341 */ |
|
8342 prefilters = {}, |
|
8343 |
|
8344 /* Transports bindings |
|
8345 * 1) key is the dataType |
|
8346 * 2) the catchall symbol "*" can be used |
|
8347 * 3) selection will start with transport dataType and THEN go to "*" if needed |
|
8348 */ |
|
8349 transports = {}, |
|
8350 |
|
8351 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression |
|
8352 allTypes = "*/".concat( "*" ), |
|
8353 |
|
8354 // Anchor tag for parsing the document origin |
|
8355 originAnchor = document.createElement( "a" ); |
|
8356 originAnchor.href = location.href; |
|
8357 |
|
8358 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport |
|
8359 function addToPrefiltersOrTransports( structure ) { |
|
8360 |
|
8361 // dataTypeExpression is optional and defaults to "*" |
|
8362 return function( dataTypeExpression, func ) { |
|
8363 |
|
8364 if ( typeof dataTypeExpression !== "string" ) { |
|
8365 func = dataTypeExpression; |
|
8366 dataTypeExpression = "*"; |
|
8367 } |
|
8368 |
|
8369 var dataType, |
|
8370 i = 0, |
|
8371 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; |
|
8372 |
|
8373 if ( jQuery.isFunction( func ) ) { |
|
8374 |
|
8375 // For each dataType in the dataTypeExpression |
|
8376 while ( ( dataType = dataTypes[ i++ ] ) ) { |
|
8377 |
|
8378 // Prepend if requested |
|
8379 if ( dataType[ 0 ] === "+" ) { |
|
8380 dataType = dataType.slice( 1 ) || "*"; |
|
8381 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); |
|
8382 |
|
8383 // Otherwise append |
|
8384 } else { |
|
8385 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); |
|
8386 } |
|
8387 } |
|
8388 } |
|
8389 }; |
|
8390 } |
|
8391 |
|
8392 // Base inspection function for prefilters and transports |
|
8393 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { |
|
8394 |
|
8395 var inspected = {}, |
|
8396 seekingTransport = ( structure === transports ); |
|
8397 |
|
8398 function inspect( dataType ) { |
|
8399 var selected; |
|
8400 inspected[ dataType ] = true; |
|
8401 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { |
|
8402 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); |
|
8403 if ( typeof dataTypeOrTransport === "string" && |
|
8404 !seekingTransport && !inspected[ dataTypeOrTransport ] ) { |
|
8405 |
|
8406 options.dataTypes.unshift( dataTypeOrTransport ); |
|
8407 inspect( dataTypeOrTransport ); |
|
8408 return false; |
|
8409 } else if ( seekingTransport ) { |
|
8410 return !( selected = dataTypeOrTransport ); |
|
8411 } |
|
8412 } ); |
|
8413 return selected; |
|
8414 } |
|
8415 |
|
8416 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); |
|
8417 } |
|
8418 |
|
8419 // A special extend for ajax options |
|
8420 // that takes "flat" options (not to be deep extended) |
|
8421 // Fixes #9887 |
|
8422 function ajaxExtend( target, src ) { |
|
8423 var key, deep, |
|
8424 flatOptions = jQuery.ajaxSettings.flatOptions || {}; |
|
8425 |
|
8426 for ( key in src ) { |
|
8427 if ( src[ key ] !== undefined ) { |
|
8428 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; |
|
8429 } |
|
8430 } |
|
8431 if ( deep ) { |
|
8432 jQuery.extend( true, target, deep ); |
|
8433 } |
|
8434 |
|
8435 return target; |
|
8436 } |
|
8437 |
|
8438 /* Handles responses to an ajax request: |
|
8439 * - finds the right dataType (mediates between content-type and expected dataType) |
|
8440 * - returns the corresponding response |
|
8441 */ |
|
8442 function ajaxHandleResponses( s, jqXHR, responses ) { |
|
8443 |
|
8444 var ct, type, finalDataType, firstDataType, |
|
8445 contents = s.contents, |
|
8446 dataTypes = s.dataTypes; |
|
8447 |
|
8448 // Remove auto dataType and get content-type in the process |
|
8449 while ( dataTypes[ 0 ] === "*" ) { |
|
8450 dataTypes.shift(); |
|
8451 if ( ct === undefined ) { |
|
8452 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); |
|
8453 } |
|
8454 } |
|
8455 |
|
8456 // Check if we're dealing with a known content-type |
|
8457 if ( ct ) { |
|
8458 for ( type in contents ) { |
|
8459 if ( contents[ type ] && contents[ type ].test( ct ) ) { |
|
8460 dataTypes.unshift( type ); |
|
8461 break; |
|
8462 } |
|
8463 } |
|
8464 } |
|
8465 |
|
8466 // Check to see if we have a response for the expected dataType |
|
8467 if ( dataTypes[ 0 ] in responses ) { |
|
8468 finalDataType = dataTypes[ 0 ]; |
|
8469 } else { |
|
8470 |
|
8471 // Try convertible dataTypes |
|
8472 for ( type in responses ) { |
|
8473 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { |
|
8474 finalDataType = type; |
|
8475 break; |
|
8476 } |
|
8477 if ( !firstDataType ) { |
|
8478 firstDataType = type; |
|
8479 } |
|
8480 } |
|
8481 |
|
8482 // Or just use first one |
|
8483 finalDataType = finalDataType || firstDataType; |
|
8484 } |
|
8485 |
|
8486 // If we found a dataType |
|
8487 // We add the dataType to the list if needed |
|
8488 // and return the corresponding response |
|
8489 if ( finalDataType ) { |
|
8490 if ( finalDataType !== dataTypes[ 0 ] ) { |
|
8491 dataTypes.unshift( finalDataType ); |
|
8492 } |
|
8493 return responses[ finalDataType ]; |
|
8494 } |
|
8495 } |
|
8496 |
|
8497 /* Chain conversions given the request and the original response |
|
8498 * Also sets the responseXXX fields on the jqXHR instance |
|
8499 */ |
|
8500 function ajaxConvert( s, response, jqXHR, isSuccess ) { |
|
8501 var conv2, current, conv, tmp, prev, |
|
8502 converters = {}, |
|
8503 |
|
8504 // Work with a copy of dataTypes in case we need to modify it for conversion |
|
8505 dataTypes = s.dataTypes.slice(); |
|
8506 |
|
8507 // Create converters map with lowercased keys |
|
8508 if ( dataTypes[ 1 ] ) { |
|
8509 for ( conv in s.converters ) { |
|
8510 converters[ conv.toLowerCase() ] = s.converters[ conv ]; |
|
8511 } |
|
8512 } |
|
8513 |
|
8514 current = dataTypes.shift(); |
|
8515 |
|
8516 // Convert to each sequential dataType |
|
8517 while ( current ) { |
|
8518 |
|
8519 if ( s.responseFields[ current ] ) { |
|
8520 jqXHR[ s.responseFields[ current ] ] = response; |
|
8521 } |
|
8522 |
|
8523 // Apply the dataFilter if provided |
|
8524 if ( !prev && isSuccess && s.dataFilter ) { |
|
8525 response = s.dataFilter( response, s.dataType ); |
|
8526 } |
|
8527 |
|
8528 prev = current; |
|
8529 current = dataTypes.shift(); |
|
8530 |
|
8531 if ( current ) { |
|
8532 |
|
8533 // There's only work to do if current dataType is non-auto |
|
8534 if ( current === "*" ) { |
|
8535 |
|
8536 current = prev; |
|
8537 |
|
8538 // Convert response if prev dataType is non-auto and differs from current |
|
8539 } else if ( prev !== "*" && prev !== current ) { |
|
8540 |
|
8541 // Seek a direct converter |
|
8542 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; |
|
8543 |
|
8544 // If none found, seek a pair |
|
8545 if ( !conv ) { |
|
8546 for ( conv2 in converters ) { |
|
8547 |
|
8548 // If conv2 outputs current |
|
8549 tmp = conv2.split( " " ); |
|
8550 if ( tmp[ 1 ] === current ) { |
|
8551 |
|
8552 // If prev can be converted to accepted input |
|
8553 conv = converters[ prev + " " + tmp[ 0 ] ] || |
|
8554 converters[ "* " + tmp[ 0 ] ]; |
|
8555 if ( conv ) { |
|
8556 |
|
8557 // Condense equivalence converters |
|
8558 if ( conv === true ) { |
|
8559 conv = converters[ conv2 ]; |
|
8560 |
|
8561 // Otherwise, insert the intermediate dataType |
|
8562 } else if ( converters[ conv2 ] !== true ) { |
|
8563 current = tmp[ 0 ]; |
|
8564 dataTypes.unshift( tmp[ 1 ] ); |
|
8565 } |
|
8566 break; |
|
8567 } |
|
8568 } |
|
8569 } |
|
8570 } |
|
8571 |
|
8572 // Apply converter (if not an equivalence) |
|
8573 if ( conv !== true ) { |
|
8574 |
|
8575 // Unless errors are allowed to bubble, catch and return them |
|
8576 if ( conv && s.throws ) { |
|
8577 response = conv( response ); |
|
8578 } else { |
|
8579 try { |
|
8580 response = conv( response ); |
|
8581 } catch ( e ) { |
|
8582 return { |
|
8583 state: "parsererror", |
|
8584 error: conv ? e : "No conversion from " + prev + " to " + current |
|
8585 }; |
|
8586 } |
|
8587 } |
|
8588 } |
|
8589 } |
|
8590 } |
|
8591 } |
|
8592 |
|
8593 return { state: "success", data: response }; |
|
8594 } |
|
8595 |
|
8596 jQuery.extend( { |
|
8597 |
|
8598 // Counter for holding the number of active queries |
|
8599 active: 0, |
|
8600 |
|
8601 // Last-Modified header cache for next request |
|
8602 lastModified: {}, |
|
8603 etag: {}, |
|
8604 |
|
8605 ajaxSettings: { |
|
8606 url: location.href, |
|
8607 type: "GET", |
|
8608 isLocal: rlocalProtocol.test( location.protocol ), |
|
8609 global: true, |
|
8610 processData: true, |
|
8611 async: true, |
|
8612 contentType: "application/x-www-form-urlencoded; charset=UTF-8", |
|
8613 |
|
8614 /* |
|
8615 timeout: 0, |
|
8616 data: null, |
|
8617 dataType: null, |
|
8618 username: null, |
|
8619 password: null, |
|
8620 cache: null, |
|
8621 throws: false, |
|
8622 traditional: false, |
|
8623 headers: {}, |
|
8624 */ |
|
8625 |
|
8626 accepts: { |
|
8627 "*": allTypes, |
|
8628 text: "text/plain", |
|
8629 html: "text/html", |
|
8630 xml: "application/xml, text/xml", |
|
8631 json: "application/json, text/javascript" |
|
8632 }, |
|
8633 |
|
8634 contents: { |
|
8635 xml: /\bxml\b/, |
|
8636 html: /\bhtml/, |
|
8637 json: /\bjson\b/ |
|
8638 }, |
|
8639 |
|
8640 responseFields: { |
|
8641 xml: "responseXML", |
|
8642 text: "responseText", |
|
8643 json: "responseJSON" |
|
8644 }, |
|
8645 |
|
8646 // Data converters |
|
8647 // Keys separate source (or catchall "*") and destination types with a single space |
|
8648 converters: { |
|
8649 |
|
8650 // Convert anything to text |
|
8651 "* text": String, |
|
8652 |
|
8653 // Text to html (true = no transformation) |
|
8654 "text html": true, |
|
8655 |
|
8656 // Evaluate text as a json expression |
|
8657 "text json": JSON.parse, |
|
8658 |
|
8659 // Parse text as xml |
|
8660 "text xml": jQuery.parseXML |
|
8661 }, |
|
8662 |
|
8663 // For options that shouldn't be deep extended: |
|
8664 // you can add your own custom options here if |
|
8665 // and when you create one that shouldn't be |
|
8666 // deep extended (see ajaxExtend) |
|
8667 flatOptions: { |
|
8668 url: true, |
|
8669 context: true |
|
8670 } |
|
8671 }, |
|
8672 |
|
8673 // Creates a full fledged settings object into target |
|
8674 // with both ajaxSettings and settings fields. |
|
8675 // If target is omitted, writes into ajaxSettings. |
|
8676 ajaxSetup: function( target, settings ) { |
|
8677 return settings ? |
|
8678 |
|
8679 // Building a settings object |
|
8680 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : |
|
8681 |
|
8682 // Extending ajaxSettings |
|
8683 ajaxExtend( jQuery.ajaxSettings, target ); |
|
8684 }, |
|
8685 |
|
8686 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), |
|
8687 ajaxTransport: addToPrefiltersOrTransports( transports ), |
|
8688 |
|
8689 // Main method |
|
8690 ajax: function( url, options ) { |
|
8691 |
|
8692 // If url is an object, simulate pre-1.5 signature |
|
8693 if ( typeof url === "object" ) { |
|
8694 options = url; |
|
8695 url = undefined; |
|
8696 } |
|
8697 |
|
8698 // Force options to be an object |
|
8699 options = options || {}; |
|
8700 |
|
8701 var transport, |
|
8702 |
|
8703 // URL without anti-cache param |
|
8704 cacheURL, |
|
8705 |
|
8706 // Response headers |
|
8707 responseHeadersString, |
|
8708 responseHeaders, |
|
8709 |
|
8710 // timeout handle |
|
8711 timeoutTimer, |
|
8712 |
|
8713 // Url cleanup var |
|
8714 urlAnchor, |
|
8715 |
|
8716 // Request state (becomes false upon send and true upon completion) |
|
8717 completed, |
|
8718 |
|
8719 // To know if global events are to be dispatched |
|
8720 fireGlobals, |
|
8721 |
|
8722 // Loop variable |
|
8723 i, |
|
8724 |
|
8725 // uncached part of the url |
|
8726 uncached, |
|
8727 |
|
8728 // Create the final options object |
|
8729 s = jQuery.ajaxSetup( {}, options ), |
|
8730 |
|
8731 // Callbacks context |
|
8732 callbackContext = s.context || s, |
|
8733 |
|
8734 // Context for global events is callbackContext if it is a DOM node or jQuery collection |
|
8735 globalEventContext = s.context && |
|
8736 ( callbackContext.nodeType || callbackContext.jquery ) ? |
|
8737 jQuery( callbackContext ) : |
|
8738 jQuery.event, |
|
8739 |
|
8740 // Deferreds |
|
8741 deferred = jQuery.Deferred(), |
|
8742 completeDeferred = jQuery.Callbacks( "once memory" ), |
|
8743 |
|
8744 // Status-dependent callbacks |
|
8745 statusCode = s.statusCode || {}, |
|
8746 |
|
8747 // Headers (they are sent all at once) |
|
8748 requestHeaders = {}, |
|
8749 requestHeadersNames = {}, |
|
8750 |
|
8751 // Default abort message |
|
8752 strAbort = "canceled", |
|
8753 |
|
8754 // Fake xhr |
|
8755 jqXHR = { |
|
8756 readyState: 0, |
|
8757 |
|
8758 // Builds headers hashtable if needed |
|
8759 getResponseHeader: function( key ) { |
|
8760 var match; |
|
8761 if ( completed ) { |
|
8762 if ( !responseHeaders ) { |
|
8763 responseHeaders = {}; |
|
8764 while ( ( match = rheaders.exec( responseHeadersString ) ) ) { |
|
8765 responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ]; |
|
8766 } |
|
8767 } |
|
8768 match = responseHeaders[ key.toLowerCase() ]; |
|
8769 } |
|
8770 return match == null ? null : match; |
|
8771 }, |
|
8772 |
|
8773 // Raw string |
|
8774 getAllResponseHeaders: function() { |
|
8775 return completed ? responseHeadersString : null; |
|
8776 }, |
|
8777 |
|
8778 // Caches the header |
|
8779 setRequestHeader: function( name, value ) { |
|
8780 if ( completed == null ) { |
|
8781 name = requestHeadersNames[ name.toLowerCase() ] = |
|
8782 requestHeadersNames[ name.toLowerCase() ] || name; |
|
8783 requestHeaders[ name ] = value; |
|
8784 } |
|
8785 return this; |
|
8786 }, |
|
8787 |
|
8788 // Overrides response content-type header |
|
8789 overrideMimeType: function( type ) { |
|
8790 if ( completed == null ) { |
|
8791 s.mimeType = type; |
|
8792 } |
|
8793 return this; |
|
8794 }, |
|
8795 |
|
8796 // Status-dependent callbacks |
|
8797 statusCode: function( map ) { |
|
8798 var code; |
|
8799 if ( map ) { |
|
8800 if ( completed ) { |
|
8801 |
|
8802 // Execute the appropriate callbacks |
|
8803 jqXHR.always( map[ jqXHR.status ] ); |
|
8804 } else { |
|
8805 |
|
8806 // Lazy-add the new callbacks in a way that preserves old ones |
|
8807 for ( code in map ) { |
|
8808 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; |
|
8809 } |
|
8810 } |
|
8811 } |
|
8812 return this; |
|
8813 }, |
|
8814 |
|
8815 // Cancel the request |
|
8816 abort: function( statusText ) { |
|
8817 var finalText = statusText || strAbort; |
|
8818 if ( transport ) { |
|
8819 transport.abort( finalText ); |
|
8820 } |
|
8821 done( 0, finalText ); |
|
8822 return this; |
|
8823 } |
|
8824 }; |
|
8825 |
|
8826 // Attach deferreds |
|
8827 deferred.promise( jqXHR ); |
|
8828 |
|
8829 // Add protocol if not provided (prefilters might expect it) |
|
8830 // Handle falsy url in the settings object (#10093: consistency with old signature) |
|
8831 // We also use the url parameter if available |
|
8832 s.url = ( ( url || s.url || location.href ) + "" ) |
|
8833 .replace( rprotocol, location.protocol + "//" ); |
|
8834 |
|
8835 // Alias method option to type as per ticket #12004 |
|
8836 s.type = options.method || options.type || s.method || s.type; |
|
8837 |
|
8838 // Extract dataTypes list |
|
8839 s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; |
|
8840 |
|
8841 // A cross-domain request is in order when the origin doesn't match the current origin. |
|
8842 if ( s.crossDomain == null ) { |
|
8843 urlAnchor = document.createElement( "a" ); |
|
8844 |
|
8845 // Support: IE <=8 - 11, Edge 12 - 13 |
|
8846 // IE throws exception on accessing the href property if url is malformed, |
|
8847 // e.g. http://example.com:80x/ |
|
8848 try { |
|
8849 urlAnchor.href = s.url; |
|
8850 |
|
8851 // Support: IE <=8 - 11 only |
|
8852 // Anchor's host property isn't correctly set when s.url is relative |
|
8853 urlAnchor.href = urlAnchor.href; |
|
8854 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== |
|
8855 urlAnchor.protocol + "//" + urlAnchor.host; |
|
8856 } catch ( e ) { |
|
8857 |
|
8858 // If there is an error parsing the URL, assume it is crossDomain, |
|
8859 // it can be rejected by the transport if it is invalid |
|
8860 s.crossDomain = true; |
|
8861 } |
|
8862 } |
|
8863 |
|
8864 // Convert data if not already a string |
|
8865 if ( s.data && s.processData && typeof s.data !== "string" ) { |
|
8866 s.data = jQuery.param( s.data, s.traditional ); |
|
8867 } |
|
8868 |
|
8869 // Apply prefilters |
|
8870 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); |
|
8871 |
|
8872 // If request was aborted inside a prefilter, stop there |
|
8873 if ( completed ) { |
|
8874 return jqXHR; |
|
8875 } |
|
8876 |
|
8877 // We can fire global events as of now if asked to |
|
8878 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) |
|
8879 fireGlobals = jQuery.event && s.global; |
|
8880 |
|
8881 // Watch for a new set of requests |
|
8882 if ( fireGlobals && jQuery.active++ === 0 ) { |
|
8883 jQuery.event.trigger( "ajaxStart" ); |
|
8884 } |
|
8885 |
|
8886 // Uppercase the type |
|
8887 s.type = s.type.toUpperCase(); |
|
8888 |
|
8889 // Determine if request has content |
|
8890 s.hasContent = !rnoContent.test( s.type ); |
|
8891 |
|
8892 // Save the URL in case we're toying with the If-Modified-Since |
|
8893 // and/or If-None-Match header later on |
|
8894 // Remove hash to simplify url manipulation |
|
8895 cacheURL = s.url.replace( rhash, "" ); |
|
8896 |
|
8897 // More options handling for requests with no content |
|
8898 if ( !s.hasContent ) { |
|
8899 |
|
8900 // Remember the hash so we can put it back |
|
8901 uncached = s.url.slice( cacheURL.length ); |
|
8902 |
|
8903 // If data is available, append data to url |
|
8904 if ( s.data ) { |
|
8905 cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; |
|
8906 |
|
8907 // #9682: remove data so that it's not used in an eventual retry |
|
8908 delete s.data; |
|
8909 } |
|
8910 |
|
8911 // Add anti-cache in uncached url if needed |
|
8912 if ( s.cache === false ) { |
|
8913 cacheURL = cacheURL.replace( rts, "" ); |
|
8914 uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached; |
|
8915 } |
|
8916 |
|
8917 // Put hash and anti-cache on the URL that will be requested (gh-1732) |
|
8918 s.url = cacheURL + uncached; |
|
8919 |
|
8920 // Change '%20' to '+' if this is encoded form body content (gh-2658) |
|
8921 } else if ( s.data && s.processData && |
|
8922 ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { |
|
8923 s.data = s.data.replace( r20, "+" ); |
|
8924 } |
|
8925 |
|
8926 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
|
8927 if ( s.ifModified ) { |
|
8928 if ( jQuery.lastModified[ cacheURL ] ) { |
|
8929 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); |
|
8930 } |
|
8931 if ( jQuery.etag[ cacheURL ] ) { |
|
8932 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); |
|
8933 } |
|
8934 } |
|
8935 |
|
8936 // Set the correct header, if data is being sent |
|
8937 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { |
|
8938 jqXHR.setRequestHeader( "Content-Type", s.contentType ); |
|
8939 } |
|
8940 |
|
8941 // Set the Accepts header for the server, depending on the dataType |
|
8942 jqXHR.setRequestHeader( |
|
8943 "Accept", |
|
8944 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? |
|
8945 s.accepts[ s.dataTypes[ 0 ] ] + |
|
8946 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : |
|
8947 s.accepts[ "*" ] |
|
8948 ); |
|
8949 |
|
8950 // Check for headers option |
|
8951 for ( i in s.headers ) { |
|
8952 jqXHR.setRequestHeader( i, s.headers[ i ] ); |
|
8953 } |
|
8954 |
|
8955 // Allow custom headers/mimetypes and early abort |
|
8956 if ( s.beforeSend && |
|
8957 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { |
|
8958 |
|
8959 // Abort if not done already and return |
|
8960 return jqXHR.abort(); |
|
8961 } |
|
8962 |
|
8963 // Aborting is no longer a cancellation |
|
8964 strAbort = "abort"; |
|
8965 |
|
8966 // Install callbacks on deferreds |
|
8967 completeDeferred.add( s.complete ); |
|
8968 jqXHR.done( s.success ); |
|
8969 jqXHR.fail( s.error ); |
|
8970 |
|
8971 // Get transport |
|
8972 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); |
|
8973 |
|
8974 // If no transport, we auto-abort |
|
8975 if ( !transport ) { |
|
8976 done( -1, "No Transport" ); |
|
8977 } else { |
|
8978 jqXHR.readyState = 1; |
|
8979 |
|
8980 // Send global event |
|
8981 if ( fireGlobals ) { |
|
8982 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); |
|
8983 } |
|
8984 |
|
8985 // If request was aborted inside ajaxSend, stop there |
|
8986 if ( completed ) { |
|
8987 return jqXHR; |
|
8988 } |
|
8989 |
|
8990 // Timeout |
|
8991 if ( s.async && s.timeout > 0 ) { |
|
8992 timeoutTimer = window.setTimeout( function() { |
|
8993 jqXHR.abort( "timeout" ); |
|
8994 }, s.timeout ); |
|
8995 } |
|
8996 |
|
8997 try { |
|
8998 completed = false; |
|
8999 transport.send( requestHeaders, done ); |
|
9000 } catch ( e ) { |
|
9001 |
|
9002 // Rethrow post-completion exceptions |
|
9003 if ( completed ) { |
|
9004 throw e; |
|
9005 } |
|
9006 |
|
9007 // Propagate others as results |
|
9008 done( -1, e ); |
|
9009 } |
|
9010 } |
|
9011 |
|
9012 // Callback for when everything is done |
|
9013 function done( status, nativeStatusText, responses, headers ) { |
|
9014 var isSuccess, success, error, response, modified, |
|
9015 statusText = nativeStatusText; |
|
9016 |
|
9017 // Ignore repeat invocations |
|
9018 if ( completed ) { |
|
9019 return; |
|
9020 } |
|
9021 |
|
9022 completed = true; |
|
9023 |
|
9024 // Clear timeout if it exists |
|
9025 if ( timeoutTimer ) { |
|
9026 window.clearTimeout( timeoutTimer ); |
|
9027 } |
|
9028 |
|
9029 // Dereference transport for early garbage collection |
|
9030 // (no matter how long the jqXHR object will be used) |
|
9031 transport = undefined; |
|
9032 |
|
9033 // Cache response headers |
|
9034 responseHeadersString = headers || ""; |
|
9035 |
|
9036 // Set readyState |
|
9037 jqXHR.readyState = status > 0 ? 4 : 0; |
|
9038 |
|
9039 // Determine if successful |
|
9040 isSuccess = status >= 200 && status < 300 || status === 304; |
|
9041 |
|
9042 // Get response data |
|
9043 if ( responses ) { |
|
9044 response = ajaxHandleResponses( s, jqXHR, responses ); |
|
9045 } |
|
9046 |
|
9047 // Convert no matter what (that way responseXXX fields are always set) |
|
9048 response = ajaxConvert( s, response, jqXHR, isSuccess ); |
|
9049 |
|
9050 // If successful, handle type chaining |
|
9051 if ( isSuccess ) { |
|
9052 |
|
9053 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
|
9054 if ( s.ifModified ) { |
|
9055 modified = jqXHR.getResponseHeader( "Last-Modified" ); |
|
9056 if ( modified ) { |
|
9057 jQuery.lastModified[ cacheURL ] = modified; |
|
9058 } |
|
9059 modified = jqXHR.getResponseHeader( "etag" ); |
|
9060 if ( modified ) { |
|
9061 jQuery.etag[ cacheURL ] = modified; |
|
9062 } |
|
9063 } |
|
9064 |
|
9065 // if no content |
|
9066 if ( status === 204 || s.type === "HEAD" ) { |
|
9067 statusText = "nocontent"; |
|
9068 |
|
9069 // if not modified |
|
9070 } else if ( status === 304 ) { |
|
9071 statusText = "notmodified"; |
|
9072 |
|
9073 // If we have data, let's convert it |
|
9074 } else { |
|
9075 statusText = response.state; |
|
9076 success = response.data; |
|
9077 error = response.error; |
|
9078 isSuccess = !error; |
|
9079 } |
|
9080 } else { |
|
9081 |
|
9082 // Extract error from statusText and normalize for non-aborts |
|
9083 error = statusText; |
|
9084 if ( status || !statusText ) { |
|
9085 statusText = "error"; |
|
9086 if ( status < 0 ) { |
|
9087 status = 0; |
|
9088 } |
|
9089 } |
|
9090 } |
|
9091 |
|
9092 // Set data for the fake xhr object |
|
9093 jqXHR.status = status; |
|
9094 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; |
|
9095 |
|
9096 // Success/Error |
|
9097 if ( isSuccess ) { |
|
9098 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); |
|
9099 } else { |
|
9100 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); |
|
9101 } |
|
9102 |
|
9103 // Status-dependent callbacks |
|
9104 jqXHR.statusCode( statusCode ); |
|
9105 statusCode = undefined; |
|
9106 |
|
9107 if ( fireGlobals ) { |
|
9108 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", |
|
9109 [ jqXHR, s, isSuccess ? success : error ] ); |
|
9110 } |
|
9111 |
|
9112 // Complete |
|
9113 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); |
|
9114 |
|
9115 if ( fireGlobals ) { |
|
9116 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); |
|
9117 |
|
9118 // Handle the global AJAX counter |
|
9119 if ( !( --jQuery.active ) ) { |
|
9120 jQuery.event.trigger( "ajaxStop" ); |
|
9121 } |
|
9122 } |
|
9123 } |
|
9124 |
|
9125 return jqXHR; |
|
9126 }, |
|
9127 |
|
9128 getJSON: function( url, data, callback ) { |
|
9129 return jQuery.get( url, data, callback, "json" ); |
|
9130 }, |
|
9131 |
|
9132 getScript: function( url, callback ) { |
|
9133 return jQuery.get( url, undefined, callback, "script" ); |
|
9134 } |
|
9135 } ); |
|
9136 |
|
9137 jQuery.each( [ "get", "post" ], function( i, method ) { |
|
9138 jQuery[ method ] = function( url, data, callback, type ) { |
|
9139 |
|
9140 // Shift arguments if data argument was omitted |
|
9141 if ( jQuery.isFunction( data ) ) { |
|
9142 type = type || callback; |
|
9143 callback = data; |
|
9144 data = undefined; |
|
9145 } |
|
9146 |
|
9147 // The url can be an options object (which then must have .url) |
|
9148 return jQuery.ajax( jQuery.extend( { |
|
9149 url: url, |
|
9150 type: method, |
|
9151 dataType: type, |
|
9152 data: data, |
|
9153 success: callback |
|
9154 }, jQuery.isPlainObject( url ) && url ) ); |
|
9155 }; |
|
9156 } ); |
|
9157 |
|
9158 |
|
9159 jQuery._evalUrl = function( url ) { |
|
9160 return jQuery.ajax( { |
|
9161 url: url, |
|
9162 |
|
9163 // Make this explicit, since user can override this through ajaxSetup (#11264) |
|
9164 type: "GET", |
|
9165 dataType: "script", |
|
9166 cache: true, |
|
9167 async: false, |
|
9168 global: false, |
|
9169 "throws": true |
|
9170 } ); |
|
9171 }; |
|
9172 |
|
9173 |
|
9174 jQuery.fn.extend( { |
|
9175 wrapAll: function( html ) { |
|
9176 var wrap; |
|
9177 |
|
9178 if ( this[ 0 ] ) { |
|
9179 if ( jQuery.isFunction( html ) ) { |
|
9180 html = html.call( this[ 0 ] ); |
|
9181 } |
|
9182 |
|
9183 // The elements to wrap the target around |
|
9184 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); |
|
9185 |
|
9186 if ( this[ 0 ].parentNode ) { |
|
9187 wrap.insertBefore( this[ 0 ] ); |
|
9188 } |
|
9189 |
|
9190 wrap.map( function() { |
|
9191 var elem = this; |
|
9192 |
|
9193 while ( elem.firstElementChild ) { |
|
9194 elem = elem.firstElementChild; |
|
9195 } |
|
9196 |
|
9197 return elem; |
|
9198 } ).append( this ); |
|
9199 } |
|
9200 |
|
9201 return this; |
|
9202 }, |
|
9203 |
|
9204 wrapInner: function( html ) { |
|
9205 if ( jQuery.isFunction( html ) ) { |
|
9206 return this.each( function( i ) { |
|
9207 jQuery( this ).wrapInner( html.call( this, i ) ); |
|
9208 } ); |
|
9209 } |
|
9210 |
|
9211 return this.each( function() { |
|
9212 var self = jQuery( this ), |
|
9213 contents = self.contents(); |
|
9214 |
|
9215 if ( contents.length ) { |
|
9216 contents.wrapAll( html ); |
|
9217 |
|
9218 } else { |
|
9219 self.append( html ); |
|
9220 } |
|
9221 } ); |
|
9222 }, |
|
9223 |
|
9224 wrap: function( html ) { |
|
9225 var isFunction = jQuery.isFunction( html ); |
|
9226 |
|
9227 return this.each( function( i ) { |
|
9228 jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html ); |
|
9229 } ); |
|
9230 }, |
|
9231 |
|
9232 unwrap: function( selector ) { |
|
9233 this.parent( selector ).not( "body" ).each( function() { |
|
9234 jQuery( this ).replaceWith( this.childNodes ); |
|
9235 } ); |
|
9236 return this; |
|
9237 } |
|
9238 } ); |
|
9239 |
|
9240 |
|
9241 jQuery.expr.pseudos.hidden = function( elem ) { |
|
9242 return !jQuery.expr.pseudos.visible( elem ); |
|
9243 }; |
|
9244 jQuery.expr.pseudos.visible = function( elem ) { |
|
9245 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); |
|
9246 }; |
|
9247 |
|
9248 |
|
9249 |
|
9250 |
|
9251 jQuery.ajaxSettings.xhr = function() { |
|
9252 try { |
|
9253 return new window.XMLHttpRequest(); |
|
9254 } catch ( e ) {} |
|
9255 }; |
|
9256 |
|
9257 var xhrSuccessStatus = { |
|
9258 |
|
9259 // File protocol always yields status code 0, assume 200 |
|
9260 0: 200, |
|
9261 |
|
9262 // Support: IE <=9 only |
|
9263 // #1450: sometimes IE returns 1223 when it should be 204 |
|
9264 1223: 204 |
|
9265 }, |
|
9266 xhrSupported = jQuery.ajaxSettings.xhr(); |
|
9267 |
|
9268 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); |
|
9269 support.ajax = xhrSupported = !!xhrSupported; |
|
9270 |
|
9271 jQuery.ajaxTransport( function( options ) { |
|
9272 var callback, errorCallback; |
|
9273 |
|
9274 // Cross domain only allowed if supported through XMLHttpRequest |
|
9275 if ( support.cors || xhrSupported && !options.crossDomain ) { |
|
9276 return { |
|
9277 send: function( headers, complete ) { |
|
9278 var i, |
|
9279 xhr = options.xhr(); |
|
9280 |
|
9281 xhr.open( |
|
9282 options.type, |
|
9283 options.url, |
|
9284 options.async, |
|
9285 options.username, |
|
9286 options.password |
|
9287 ); |
|
9288 |
|
9289 // Apply custom fields if provided |
|
9290 if ( options.xhrFields ) { |
|
9291 for ( i in options.xhrFields ) { |
|
9292 xhr[ i ] = options.xhrFields[ i ]; |
|
9293 } |
|
9294 } |
|
9295 |
|
9296 // Override mime type if needed |
|
9297 if ( options.mimeType && xhr.overrideMimeType ) { |
|
9298 xhr.overrideMimeType( options.mimeType ); |
|
9299 } |
|
9300 |
|
9301 // X-Requested-With header |
|
9302 // For cross-domain requests, seeing as conditions for a preflight are |
|
9303 // akin to a jigsaw puzzle, we simply never set it to be sure. |
|
9304 // (it can always be set on a per-request basis or even using ajaxSetup) |
|
9305 // For same-domain requests, won't change header if already provided. |
|
9306 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { |
|
9307 headers[ "X-Requested-With" ] = "XMLHttpRequest"; |
|
9308 } |
|
9309 |
|
9310 // Set headers |
|
9311 for ( i in headers ) { |
|
9312 xhr.setRequestHeader( i, headers[ i ] ); |
|
9313 } |
|
9314 |
|
9315 // Callback |
|
9316 callback = function( type ) { |
|
9317 return function() { |
|
9318 if ( callback ) { |
|
9319 callback = errorCallback = xhr.onload = |
|
9320 xhr.onerror = xhr.onabort = xhr.onreadystatechange = null; |
|
9321 |
|
9322 if ( type === "abort" ) { |
|
9323 xhr.abort(); |
|
9324 } else if ( type === "error" ) { |
|
9325 |
|
9326 // Support: IE <=9 only |
|
9327 // On a manual native abort, IE9 throws |
|
9328 // errors on any property access that is not readyState |
|
9329 if ( typeof xhr.status !== "number" ) { |
|
9330 complete( 0, "error" ); |
|
9331 } else { |
|
9332 complete( |
|
9333 |
|
9334 // File: protocol always yields status 0; see #8605, #14207 |
|
9335 xhr.status, |
|
9336 xhr.statusText |
|
9337 ); |
|
9338 } |
|
9339 } else { |
|
9340 complete( |
|
9341 xhrSuccessStatus[ xhr.status ] || xhr.status, |
|
9342 xhr.statusText, |
|
9343 |
|
9344 // Support: IE <=9 only |
|
9345 // IE9 has no XHR2 but throws on binary (trac-11426) |
|
9346 // For XHR2 non-text, let the caller handle it (gh-2498) |
|
9347 ( xhr.responseType || "text" ) !== "text" || |
|
9348 typeof xhr.responseText !== "string" ? |
|
9349 { binary: xhr.response } : |
|
9350 { text: xhr.responseText }, |
|
9351 xhr.getAllResponseHeaders() |
|
9352 ); |
|
9353 } |
|
9354 } |
|
9355 }; |
|
9356 }; |
|
9357 |
|
9358 // Listen to events |
|
9359 xhr.onload = callback(); |
|
9360 errorCallback = xhr.onerror = callback( "error" ); |
|
9361 |
|
9362 // Support: IE 9 only |
|
9363 // Use onreadystatechange to replace onabort |
|
9364 // to handle uncaught aborts |
|
9365 if ( xhr.onabort !== undefined ) { |
|
9366 xhr.onabort = errorCallback; |
|
9367 } else { |
|
9368 xhr.onreadystatechange = function() { |
|
9369 |
|
9370 // Check readyState before timeout as it changes |
|
9371 if ( xhr.readyState === 4 ) { |
|
9372 |
|
9373 // Allow onerror to be called first, |
|
9374 // but that will not handle a native abort |
|
9375 // Also, save errorCallback to a variable |
|
9376 // as xhr.onerror cannot be accessed |
|
9377 window.setTimeout( function() { |
|
9378 if ( callback ) { |
|
9379 errorCallback(); |
|
9380 } |
|
9381 } ); |
|
9382 } |
|
9383 }; |
|
9384 } |
|
9385 |
|
9386 // Create the abort callback |
|
9387 callback = callback( "abort" ); |
|
9388 |
|
9389 try { |
|
9390 |
|
9391 // Do send the request (this may raise an exception) |
|
9392 xhr.send( options.hasContent && options.data || null ); |
|
9393 } catch ( e ) { |
|
9394 |
|
9395 // #14683: Only rethrow if this hasn't been notified as an error yet |
|
9396 if ( callback ) { |
|
9397 throw e; |
|
9398 } |
|
9399 } |
|
9400 }, |
|
9401 |
|
9402 abort: function() { |
|
9403 if ( callback ) { |
|
9404 callback(); |
|
9405 } |
|
9406 } |
|
9407 }; |
|
9408 } |
|
9409 } ); |
|
9410 |
|
9411 |
|
9412 |
|
9413 |
|
9414 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) |
|
9415 jQuery.ajaxPrefilter( function( s ) { |
|
9416 if ( s.crossDomain ) { |
|
9417 s.contents.script = false; |
|
9418 } |
|
9419 } ); |
|
9420 |
|
9421 // Install script dataType |
|
9422 jQuery.ajaxSetup( { |
|
9423 accepts: { |
|
9424 script: "text/javascript, application/javascript, " + |
|
9425 "application/ecmascript, application/x-ecmascript" |
|
9426 }, |
|
9427 contents: { |
|
9428 script: /\b(?:java|ecma)script\b/ |
|
9429 }, |
|
9430 converters: { |
|
9431 "text script": function( text ) { |
|
9432 jQuery.globalEval( text ); |
|
9433 return text; |
|
9434 } |
|
9435 } |
|
9436 } ); |
|
9437 |
|
9438 // Handle cache's special case and crossDomain |
|
9439 jQuery.ajaxPrefilter( "script", function( s ) { |
|
9440 if ( s.cache === undefined ) { |
|
9441 s.cache = false; |
|
9442 } |
|
9443 if ( s.crossDomain ) { |
|
9444 s.type = "GET"; |
|
9445 } |
|
9446 } ); |
|
9447 |
|
9448 // Bind script tag hack transport |
|
9449 jQuery.ajaxTransport( "script", function( s ) { |
|
9450 |
|
9451 // This transport only deals with cross domain requests |
|
9452 if ( s.crossDomain ) { |
|
9453 var script, callback; |
|
9454 return { |
|
9455 send: function( _, complete ) { |
|
9456 script = jQuery( "<script>" ).prop( { |
|
9457 charset: s.scriptCharset, |
|
9458 src: s.url |
|
9459 } ).on( |
|
9460 "load error", |
|
9461 callback = function( evt ) { |
|
9462 script.remove(); |
|
9463 callback = null; |
|
9464 if ( evt ) { |
|
9465 complete( evt.type === "error" ? 404 : 200, evt.type ); |
|
9466 } |
|
9467 } |
|
9468 ); |
|
9469 |
|
9470 // Use native DOM manipulation to avoid our domManip AJAX trickery |
|
9471 document.head.appendChild( script[ 0 ] ); |
|
9472 }, |
|
9473 abort: function() { |
|
9474 if ( callback ) { |
|
9475 callback(); |
|
9476 } |
|
9477 } |
|
9478 }; |
|
9479 } |
|
9480 } ); |
|
9481 |
|
9482 |
|
9483 |
|
9484 |
|
9485 var oldCallbacks = [], |
|
9486 rjsonp = /(=)\?(?=&|$)|\?\?/; |
|
9487 |
|
9488 // Default jsonp settings |
|
9489 jQuery.ajaxSetup( { |
|
9490 jsonp: "callback", |
|
9491 jsonpCallback: function() { |
|
9492 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); |
|
9493 this[ callback ] = true; |
|
9494 return callback; |
|
9495 } |
|
9496 } ); |
|
9497 |
|
9498 // Detect, normalize options and install callbacks for jsonp requests |
|
9499 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
|
9500 |
|
9501 var callbackName, overwritten, responseContainer, |
|
9502 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? |
|
9503 "url" : |
|
9504 typeof s.data === "string" && |
|
9505 ( s.contentType || "" ) |
|
9506 .indexOf( "application/x-www-form-urlencoded" ) === 0 && |
|
9507 rjsonp.test( s.data ) && "data" |
|
9508 ); |
|
9509 |
|
9510 // Handle iff the expected data type is "jsonp" or we have a parameter to set |
|
9511 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { |
|
9512 |
|
9513 // Get callback name, remembering preexisting value associated with it |
|
9514 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? |
|
9515 s.jsonpCallback() : |
|
9516 s.jsonpCallback; |
|
9517 |
|
9518 // Insert callback into url or form data |
|
9519 if ( jsonProp ) { |
|
9520 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); |
|
9521 } else if ( s.jsonp !== false ) { |
|
9522 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; |
|
9523 } |
|
9524 |
|
9525 // Use data converter to retrieve json after script execution |
|
9526 s.converters[ "script json" ] = function() { |
|
9527 if ( !responseContainer ) { |
|
9528 jQuery.error( callbackName + " was not called" ); |
|
9529 } |
|
9530 return responseContainer[ 0 ]; |
|
9531 }; |
|
9532 |
|
9533 // Force json dataType |
|
9534 s.dataTypes[ 0 ] = "json"; |
|
9535 |
|
9536 // Install callback |
|
9537 overwritten = window[ callbackName ]; |
|
9538 window[ callbackName ] = function() { |
|
9539 responseContainer = arguments; |
|
9540 }; |
|
9541 |
|
9542 // Clean-up function (fires after converters) |
|
9543 jqXHR.always( function() { |
|
9544 |
|
9545 // If previous value didn't exist - remove it |
|
9546 if ( overwritten === undefined ) { |
|
9547 jQuery( window ).removeProp( callbackName ); |
|
9548 |
|
9549 // Otherwise restore preexisting value |
|
9550 } else { |
|
9551 window[ callbackName ] = overwritten; |
|
9552 } |
|
9553 |
|
9554 // Save back as free |
|
9555 if ( s[ callbackName ] ) { |
|
9556 |
|
9557 // Make sure that re-using the options doesn't screw things around |
|
9558 s.jsonpCallback = originalSettings.jsonpCallback; |
|
9559 |
|
9560 // Save the callback name for future use |
|
9561 oldCallbacks.push( callbackName ); |
|
9562 } |
|
9563 |
|
9564 // Call if it was a function and we have a response |
|
9565 if ( responseContainer && jQuery.isFunction( overwritten ) ) { |
|
9566 overwritten( responseContainer[ 0 ] ); |
|
9567 } |
|
9568 |
|
9569 responseContainer = overwritten = undefined; |
|
9570 } ); |
|
9571 |
|
9572 // Delegate to script |
|
9573 return "script"; |
|
9574 } |
|
9575 } ); |
|
9576 |
|
9577 |
|
9578 |
|
9579 |
|
9580 // Support: Safari 8 only |
|
9581 // In Safari 8 documents created via document.implementation.createHTMLDocument |
|
9582 // collapse sibling forms: the second one becomes a child of the first one. |
|
9583 // Because of that, this security measure has to be disabled in Safari 8. |
|
9584 // https://bugs.webkit.org/show_bug.cgi?id=137337 |
|
9585 support.createHTMLDocument = ( function() { |
|
9586 var body = document.implementation.createHTMLDocument( "" ).body; |
|
9587 body.innerHTML = "<form></form><form></form>"; |
|
9588 return body.childNodes.length === 2; |
|
9589 } )(); |
|
9590 |
|
9591 |
|
9592 // Argument "data" should be string of html |
|
9593 // context (optional): If specified, the fragment will be created in this context, |
|
9594 // defaults to document |
|
9595 // keepScripts (optional): If true, will include scripts passed in the html string |
|
9596 jQuery.parseHTML = function( data, context, keepScripts ) { |
|
9597 if ( typeof data !== "string" ) { |
|
9598 return []; |
|
9599 } |
|
9600 if ( typeof context === "boolean" ) { |
|
9601 keepScripts = context; |
|
9602 context = false; |
|
9603 } |
|
9604 |
|
9605 var base, parsed, scripts; |
|
9606 |
|
9607 if ( !context ) { |
|
9608 |
|
9609 // Stop scripts or inline event handlers from being executed immediately |
|
9610 // by using document.implementation |
|
9611 if ( support.createHTMLDocument ) { |
|
9612 context = document.implementation.createHTMLDocument( "" ); |
|
9613 |
|
9614 // Set the base href for the created document |
|
9615 // so any parsed elements with URLs |
|
9616 // are based on the document's URL (gh-2965) |
|
9617 base = context.createElement( "base" ); |
|
9618 base.href = document.location.href; |
|
9619 context.head.appendChild( base ); |
|
9620 } else { |
|
9621 context = document; |
|
9622 } |
|
9623 } |
|
9624 |
|
9625 parsed = rsingleTag.exec( data ); |
|
9626 scripts = !keepScripts && []; |
|
9627 |
|
9628 // Single tag |
|
9629 if ( parsed ) { |
|
9630 return [ context.createElement( parsed[ 1 ] ) ]; |
|
9631 } |
|
9632 |
|
9633 parsed = buildFragment( [ data ], context, scripts ); |
|
9634 |
|
9635 if ( scripts && scripts.length ) { |
|
9636 jQuery( scripts ).remove(); |
|
9637 } |
|
9638 |
|
9639 return jQuery.merge( [], parsed.childNodes ); |
|
9640 }; |
|
9641 |
|
9642 |
|
9643 /** |
|
9644 * Load a url into a page |
|
9645 */ |
|
9646 jQuery.fn.load = function( url, params, callback ) { |
|
9647 var selector, type, response, |
|
9648 self = this, |
|
9649 off = url.indexOf( " " ); |
|
9650 |
|
9651 if ( off > -1 ) { |
|
9652 selector = jQuery.trim( url.slice( off ) ); |
|
9653 url = url.slice( 0, off ); |
|
9654 } |
|
9655 |
|
9656 // If it's a function |
|
9657 if ( jQuery.isFunction( params ) ) { |
|
9658 |
|
9659 // We assume that it's the callback |
|
9660 callback = params; |
|
9661 params = undefined; |
|
9662 |
|
9663 // Otherwise, build a param string |
|
9664 } else if ( params && typeof params === "object" ) { |
|
9665 type = "POST"; |
|
9666 } |
|
9667 |
|
9668 // If we have elements to modify, make the request |
|
9669 if ( self.length > 0 ) { |
|
9670 jQuery.ajax( { |
|
9671 url: url, |
|
9672 |
|
9673 // If "type" variable is undefined, then "GET" method will be used. |
|
9674 // Make value of this field explicit since |
|
9675 // user can override it through ajaxSetup method |
|
9676 type: type || "GET", |
|
9677 dataType: "html", |
|
9678 data: params |
|
9679 } ).done( function( responseText ) { |
|
9680 |
|
9681 // Save response for use in complete callback |
|
9682 response = arguments; |
|
9683 |
|
9684 self.html( selector ? |
|
9685 |
|
9686 // If a selector was specified, locate the right elements in a dummy div |
|
9687 // Exclude scripts to avoid IE 'Permission Denied' errors |
|
9688 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : |
|
9689 |
|
9690 // Otherwise use the full result |
|
9691 responseText ); |
|
9692 |
|
9693 // If the request succeeds, this function gets "data", "status", "jqXHR" |
|
9694 // but they are ignored because response was set above. |
|
9695 // If it fails, this function gets "jqXHR", "status", "error" |
|
9696 } ).always( callback && function( jqXHR, status ) { |
|
9697 self.each( function() { |
|
9698 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); |
|
9699 } ); |
|
9700 } ); |
|
9701 } |
|
9702 |
|
9703 return this; |
|
9704 }; |
|
9705 |
|
9706 |
|
9707 |
|
9708 |
|
9709 // Attach a bunch of functions for handling common AJAX events |
|
9710 jQuery.each( [ |
|
9711 "ajaxStart", |
|
9712 "ajaxStop", |
|
9713 "ajaxComplete", |
|
9714 "ajaxError", |
|
9715 "ajaxSuccess", |
|
9716 "ajaxSend" |
|
9717 ], function( i, type ) { |
|
9718 jQuery.fn[ type ] = function( fn ) { |
|
9719 return this.on( type, fn ); |
|
9720 }; |
|
9721 } ); |
|
9722 |
|
9723 |
|
9724 |
|
9725 |
|
9726 jQuery.expr.pseudos.animated = function( elem ) { |
|
9727 return jQuery.grep( jQuery.timers, function( fn ) { |
|
9728 return elem === fn.elem; |
|
9729 } ).length; |
|
9730 }; |
|
9731 |
|
9732 |
|
9733 |
|
9734 |
|
9735 /** |
|
9736 * Gets a window from an element |
|
9737 */ |
|
9738 function getWindow( elem ) { |
|
9739 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView; |
|
9740 } |
|
9741 |
|
9742 jQuery.offset = { |
|
9743 setOffset: function( elem, options, i ) { |
|
9744 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, |
|
9745 position = jQuery.css( elem, "position" ), |
|
9746 curElem = jQuery( elem ), |
|
9747 props = {}; |
|
9748 |
|
9749 // Set position first, in-case top/left are set even on static elem |
|
9750 if ( position === "static" ) { |
|
9751 elem.style.position = "relative"; |
|
9752 } |
|
9753 |
|
9754 curOffset = curElem.offset(); |
|
9755 curCSSTop = jQuery.css( elem, "top" ); |
|
9756 curCSSLeft = jQuery.css( elem, "left" ); |
|
9757 calculatePosition = ( position === "absolute" || position === "fixed" ) && |
|
9758 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; |
|
9759 |
|
9760 // Need to be able to calculate position if either |
|
9761 // top or left is auto and position is either absolute or fixed |
|
9762 if ( calculatePosition ) { |
|
9763 curPosition = curElem.position(); |
|
9764 curTop = curPosition.top; |
|
9765 curLeft = curPosition.left; |
|
9766 |
|
9767 } else { |
|
9768 curTop = parseFloat( curCSSTop ) || 0; |
|
9769 curLeft = parseFloat( curCSSLeft ) || 0; |
|
9770 } |
|
9771 |
|
9772 if ( jQuery.isFunction( options ) ) { |
|
9773 |
|
9774 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) |
|
9775 options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); |
|
9776 } |
|
9777 |
|
9778 if ( options.top != null ) { |
|
9779 props.top = ( options.top - curOffset.top ) + curTop; |
|
9780 } |
|
9781 if ( options.left != null ) { |
|
9782 props.left = ( options.left - curOffset.left ) + curLeft; |
|
9783 } |
|
9784 |
|
9785 if ( "using" in options ) { |
|
9786 options.using.call( elem, props ); |
|
9787 |
|
9788 } else { |
|
9789 curElem.css( props ); |
|
9790 } |
|
9791 } |
|
9792 }; |
|
9793 |
|
9794 jQuery.fn.extend( { |
|
9795 offset: function( options ) { |
|
9796 |
|
9797 // Preserve chaining for setter |
|
9798 if ( arguments.length ) { |
|
9799 return options === undefined ? |
|
9800 this : |
|
9801 this.each( function( i ) { |
|
9802 jQuery.offset.setOffset( this, options, i ); |
|
9803 } ); |
|
9804 } |
|
9805 |
|
9806 var docElem, win, rect, doc, |
|
9807 elem = this[ 0 ]; |
|
9808 |
|
9809 if ( !elem ) { |
|
9810 return; |
|
9811 } |
|
9812 |
|
9813 // Support: IE <=11 only |
|
9814 // Running getBoundingClientRect on a |
|
9815 // disconnected node in IE throws an error |
|
9816 if ( !elem.getClientRects().length ) { |
|
9817 return { top: 0, left: 0 }; |
|
9818 } |
|
9819 |
|
9820 rect = elem.getBoundingClientRect(); |
|
9821 |
|
9822 // Make sure element is not hidden (display: none) |
|
9823 if ( rect.width || rect.height ) { |
|
9824 doc = elem.ownerDocument; |
|
9825 win = getWindow( doc ); |
|
9826 docElem = doc.documentElement; |
|
9827 |
|
9828 return { |
|
9829 top: rect.top + win.pageYOffset - docElem.clientTop, |
|
9830 left: rect.left + win.pageXOffset - docElem.clientLeft |
|
9831 }; |
|
9832 } |
|
9833 |
|
9834 // Return zeros for disconnected and hidden elements (gh-2310) |
|
9835 return rect; |
|
9836 }, |
|
9837 |
|
9838 position: function() { |
|
9839 if ( !this[ 0 ] ) { |
|
9840 return; |
|
9841 } |
|
9842 |
|
9843 var offsetParent, offset, |
|
9844 elem = this[ 0 ], |
|
9845 parentOffset = { top: 0, left: 0 }; |
|
9846 |
|
9847 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, |
|
9848 // because it is its only offset parent |
|
9849 if ( jQuery.css( elem, "position" ) === "fixed" ) { |
|
9850 |
|
9851 // Assume getBoundingClientRect is there when computed position is fixed |
|
9852 offset = elem.getBoundingClientRect(); |
|
9853 |
|
9854 } else { |
|
9855 |
|
9856 // Get *real* offsetParent |
|
9857 offsetParent = this.offsetParent(); |
|
9858 |
|
9859 // Get correct offsets |
|
9860 offset = this.offset(); |
|
9861 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { |
|
9862 parentOffset = offsetParent.offset(); |
|
9863 } |
|
9864 |
|
9865 // Add offsetParent borders |
|
9866 parentOffset = { |
|
9867 top: parentOffset.top + jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ), |
|
9868 left: parentOffset.left + jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ) |
|
9869 }; |
|
9870 } |
|
9871 |
|
9872 // Subtract parent offsets and element margins |
|
9873 return { |
|
9874 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), |
|
9875 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) |
|
9876 }; |
|
9877 }, |
|
9878 |
|
9879 // This method will return documentElement in the following cases: |
|
9880 // 1) For the element inside the iframe without offsetParent, this method will return |
|
9881 // documentElement of the parent window |
|
9882 // 2) For the hidden or detached element |
|
9883 // 3) For body or html element, i.e. in case of the html node - it will return itself |
|
9884 // |
|
9885 // but those exceptions were never presented as a real life use-cases |
|
9886 // and might be considered as more preferable results. |
|
9887 // |
|
9888 // This logic, however, is not guaranteed and can change at any point in the future |
|
9889 offsetParent: function() { |
|
9890 return this.map( function() { |
|
9891 var offsetParent = this.offsetParent; |
|
9892 |
|
9893 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { |
|
9894 offsetParent = offsetParent.offsetParent; |
|
9895 } |
|
9896 |
|
9897 return offsetParent || documentElement; |
|
9898 } ); |
|
9899 } |
|
9900 } ); |
|
9901 |
|
9902 // Create scrollLeft and scrollTop methods |
|
9903 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { |
|
9904 var top = "pageYOffset" === prop; |
|
9905 |
|
9906 jQuery.fn[ method ] = function( val ) { |
|
9907 return access( this, function( elem, method, val ) { |
|
9908 var win = getWindow( elem ); |
|
9909 |
|
9910 if ( val === undefined ) { |
|
9911 return win ? win[ prop ] : elem[ method ]; |
|
9912 } |
|
9913 |
|
9914 if ( win ) { |
|
9915 win.scrollTo( |
|
9916 !top ? val : win.pageXOffset, |
|
9917 top ? val : win.pageYOffset |
|
9918 ); |
|
9919 |
|
9920 } else { |
|
9921 elem[ method ] = val; |
|
9922 } |
|
9923 }, method, val, arguments.length ); |
|
9924 }; |
|
9925 } ); |
|
9926 |
|
9927 // Support: Safari <=7 - 9.1, Chrome <=37 - 49 |
|
9928 // Add the top/left cssHooks using jQuery.fn.position |
|
9929 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 |
|
9930 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347 |
|
9931 // getComputedStyle returns percent when specified for top/left/bottom/right; |
|
9932 // rather than make the css module depend on the offset module, just check for it here |
|
9933 jQuery.each( [ "top", "left" ], function( i, prop ) { |
|
9934 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, |
|
9935 function( elem, computed ) { |
|
9936 if ( computed ) { |
|
9937 computed = curCSS( elem, prop ); |
|
9938 |
|
9939 // If curCSS returns percentage, fallback to offset |
|
9940 return rnumnonpx.test( computed ) ? |
|
9941 jQuery( elem ).position()[ prop ] + "px" : |
|
9942 computed; |
|
9943 } |
|
9944 } |
|
9945 ); |
|
9946 } ); |
|
9947 |
|
9948 |
|
9949 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods |
|
9950 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { |
|
9951 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, |
|
9952 function( defaultExtra, funcName ) { |
|
9953 |
|
9954 // Margin is only for outerHeight, outerWidth |
|
9955 jQuery.fn[ funcName ] = function( margin, value ) { |
|
9956 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), |
|
9957 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); |
|
9958 |
|
9959 return access( this, function( elem, type, value ) { |
|
9960 var doc; |
|
9961 |
|
9962 if ( jQuery.isWindow( elem ) ) { |
|
9963 |
|
9964 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) |
|
9965 return funcName.indexOf( "outer" ) === 0 ? |
|
9966 elem[ "inner" + name ] : |
|
9967 elem.document.documentElement[ "client" + name ]; |
|
9968 } |
|
9969 |
|
9970 // Get document width or height |
|
9971 if ( elem.nodeType === 9 ) { |
|
9972 doc = elem.documentElement; |
|
9973 |
|
9974 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], |
|
9975 // whichever is greatest |
|
9976 return Math.max( |
|
9977 elem.body[ "scroll" + name ], doc[ "scroll" + name ], |
|
9978 elem.body[ "offset" + name ], doc[ "offset" + name ], |
|
9979 doc[ "client" + name ] |
|
9980 ); |
|
9981 } |
|
9982 |
|
9983 return value === undefined ? |
|
9984 |
|
9985 // Get width or height on the element, requesting but not forcing parseFloat |
|
9986 jQuery.css( elem, type, extra ) : |
|
9987 |
|
9988 // Set width or height on the element |
|
9989 jQuery.style( elem, type, value, extra ); |
|
9990 }, type, chainable ? margin : undefined, chainable ); |
|
9991 }; |
|
9992 } ); |
|
9993 } ); |
|
9994 |
|
9995 |
|
9996 jQuery.fn.extend( { |
|
9997 |
|
9998 bind: function( types, data, fn ) { |
|
9999 return this.on( types, null, data, fn ); |
|
10000 }, |
|
10001 unbind: function( types, fn ) { |
|
10002 return this.off( types, null, fn ); |
|
10003 }, |
|
10004 |
|
10005 delegate: function( selector, types, data, fn ) { |
|
10006 return this.on( types, selector, data, fn ); |
|
10007 }, |
|
10008 undelegate: function( selector, types, fn ) { |
|
10009 |
|
10010 // ( namespace ) or ( selector, types [, fn] ) |
|
10011 return arguments.length === 1 ? |
|
10012 this.off( selector, "**" ) : |
|
10013 this.off( types, selector || "**", fn ); |
|
10014 } |
|
10015 } ); |
|
10016 |
|
10017 jQuery.parseJSON = JSON.parse; |
|
10018 |
|
10019 |
|
10020 |
|
10021 |
|
10022 // Register as a named AMD module, since jQuery can be concatenated with other |
|
10023 // files that may use define, but not via a proper concatenation script that |
|
10024 // understands anonymous AMD modules. A named AMD is safest and most robust |
|
10025 // way to register. Lowercase jquery is used because AMD module names are |
|
10026 // derived from file names, and jQuery is normally delivered in a lowercase |
|
10027 // file name. Do this after creating the global so that if an AMD module wants |
|
10028 // to call noConflict to hide this version of jQuery, it will work. |
|
10029 |
|
10030 // Note that for maximum portability, libraries that are not jQuery should |
|
10031 // declare themselves as anonymous modules, and avoid setting a global if an |
|
10032 // AMD loader is present. jQuery is a special case. For more information, see |
|
10033 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon |
|
10034 |
|
10035 if ( typeof define === "function" && define.amd ) { |
|
10036 define( "jquery", [], function() { |
|
10037 return jQuery; |
|
10038 } ); |
|
10039 } |
|
10040 |
|
10041 |
|
10042 |
|
10043 |
|
10044 |
|
10045 var |
|
10046 |
|
10047 // Map over jQuery in case of overwrite |
|
10048 _jQuery = window.jQuery, |
|
10049 |
|
10050 // Map over the $ in case of overwrite |
|
10051 _$ = window.$; |
|
10052 |
|
10053 jQuery.noConflict = function( deep ) { |
|
10054 if ( window.$ === jQuery ) { |
|
10055 window.$ = _$; |
|
10056 } |
|
10057 |
|
10058 if ( deep && window.jQuery === jQuery ) { |
|
10059 window.jQuery = _jQuery; |
|
10060 } |
|
10061 |
|
10062 return jQuery; |
|
10063 }; |
|
10064 |
|
10065 // Expose jQuery and $ identifiers, even in AMD |
|
10066 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557) |
|
10067 // and CommonJS for browser emulators (#13566) |
|
10068 if ( !noGlobal ) { |
|
10069 window.jQuery = window.$ = jQuery; |
|
10070 } |
|
10071 |
|
10072 |
|
10073 return jQuery; |
|
10074 } ); |