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