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