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