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