MDL-47303 libraries: import latest jQuery library and friends
[moodle.git] / lib / jquery / jquery-1.11.1.js
1 /*!
2  * jQuery JavaScript Library v1.11.1
3  * http://jquery.com/
4  *
5  * Includes Sizzle.js
6  * http://sizzlejs.com/
7  *
8  * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9  * Released under the MIT license
10  * http://jquery.org/license
11  *
12  * Date: 2014-05-01T17:42Z
13  */
15 (function( global, factory ) {
17         if ( typeof module === "object" && typeof module.exports === "object" ) {
18                 // For CommonJS and CommonJS-like environments where a proper window is present,
19                 // execute the factory and get jQuery
20                 // For environments that do not inherently posses a window with a document
21                 // (such as Node.js), expose a jQuery-making factory as module.exports
22                 // This accentuates the need for the creation of a real window
23                 // e.g. var jQuery = require("jquery")(window);
24                 // See ticket #14549 for more info
25                 module.exports = global.document ?
26                         factory( global, true ) :
27                         function( w ) {
28                                 if ( !w.document ) {
29                                         throw new Error( "jQuery requires a window with a document" );
30                                 }
31                                 return factory( w );
32                         };
33         } else {
34                 factory( global );
35         }
37 // Pass this if window is not defined yet
38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
40 // Can't do this because several apps including ASP.NET trace
41 // the stack via arguments.caller.callee and Firefox dies if
42 // you try to trace through "use strict" call chains. (#13335)
43 // Support: Firefox 18+
44 //
46 var deletedIds = [];
48 var slice = deletedIds.slice;
50 var concat = deletedIds.concat;
52 var push = deletedIds.push;
54 var indexOf = deletedIds.indexOf;
56 var class2type = {};
58 var toString = class2type.toString;
60 var hasOwn = class2type.hasOwnProperty;
62 var support = {};
66 var
67         version = "1.11.1",
69         // Define a local copy of jQuery
70         jQuery = function( selector, context ) {
71                 // The jQuery object is actually just the init constructor 'enhanced'
72                 // Need init if jQuery is called (just allow error to be thrown if not included)
73                 return new jQuery.fn.init( selector, context );
74         },
76         // Support: Android<4.1, IE<9
77         // Make sure we trim BOM and NBSP
78         rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
80         // Matches dashed string for camelizing
81         rmsPrefix = /^-ms-/,
82         rdashAlpha = /-([\da-z])/gi,
84         // Used by jQuery.camelCase as callback to replace()
85         fcamelCase = function( all, letter ) {
86                 return letter.toUpperCase();
87         };
89 jQuery.fn = jQuery.prototype = {
90         // The current version of jQuery being used
91         jquery: version,
93         constructor: jQuery,
95         // Start with an empty selector
96         selector: "",
98         // The default length of a jQuery object is 0
99         length: 0,
101         toArray: function() {
102                 return slice.call( this );
103         },
105         // Get the Nth element in the matched element set OR
106         // Get the whole matched element set as a clean array
107         get: function( num ) {
108                 return num != null ?
110                         // Return just the one element from the set
111                         ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
113                         // Return all the elements in a clean array
114                         slice.call( this );
115         },
117         // Take an array of elements and push it onto the stack
118         // (returning the new matched element set)
119         pushStack: function( elems ) {
121                 // Build a new jQuery matched element set
122                 var ret = jQuery.merge( this.constructor(), elems );
124                 // Add the old object onto the stack (as a reference)
125                 ret.prevObject = this;
126                 ret.context = this.context;
128                 // Return the newly-formed element set
129                 return ret;
130         },
132         // Execute a callback for every element in the matched set.
133         // (You can seed the arguments with an array of args, but this is
134         // only used internally.)
135         each: function( callback, args ) {
136                 return jQuery.each( this, callback, args );
137         },
139         map: function( callback ) {
140                 return this.pushStack( jQuery.map(this, function( elem, i ) {
141                         return callback.call( elem, i, elem );
142                 }));
143         },
145         slice: function() {
146                 return this.pushStack( slice.apply( this, arguments ) );
147         },
149         first: function() {
150                 return this.eq( 0 );
151         },
153         last: function() {
154                 return this.eq( -1 );
155         },
157         eq: function( i ) {
158                 var len = this.length,
159                         j = +i + ( i < 0 ? len : 0 );
160                 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
161         },
163         end: function() {
164                 return this.prevObject || this.constructor(null);
165         },
167         // For internal use only.
168         // Behaves like an Array's method, not like a jQuery method.
169         push: push,
170         sort: deletedIds.sort,
171         splice: deletedIds.splice
172 };
174 jQuery.extend = jQuery.fn.extend = function() {
175         var src, copyIsArray, copy, name, options, clone,
176                 target = arguments[0] || {},
177                 i = 1,
178                 length = arguments.length,
179                 deep = false;
181         // Handle a deep copy situation
182         if ( typeof target === "boolean" ) {
183                 deep = target;
185                 // skip the boolean and the target
186                 target = arguments[ i ] || {};
187                 i++;
188         }
190         // Handle case when target is a string or something (possible in deep copy)
191         if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
192                 target = {};
193         }
195         // extend jQuery itself if only one argument is passed
196         if ( i === length ) {
197                 target = this;
198                 i--;
199         }
201         for ( ; i < length; i++ ) {
202                 // Only deal with non-null/undefined values
203                 if ( (options = arguments[ i ]) != null ) {
204                         // Extend the base object
205                         for ( name in options ) {
206                                 src = target[ name ];
207                                 copy = options[ name ];
209                                 // Prevent never-ending loop
210                                 if ( target === copy ) {
211                                         continue;
212                                 }
214                                 // Recurse if we're merging plain objects or arrays
215                                 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
216                                         if ( copyIsArray ) {
217                                                 copyIsArray = false;
218                                                 clone = src && jQuery.isArray(src) ? src : [];
220                                         } else {
221                                                 clone = src && jQuery.isPlainObject(src) ? src : {};
222                                         }
224                                         // Never move original objects, clone them
225                                         target[ name ] = jQuery.extend( deep, clone, copy );
227                                 // Don't bring in undefined values
228                                 } else if ( copy !== undefined ) {
229                                         target[ name ] = copy;
230                                 }
231                         }
232                 }
233         }
235         // Return the modified object
236         return target;
237 };
239 jQuery.extend({
240         // Unique for each copy of jQuery on the page
241         expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
243         // Assume jQuery is ready without the ready module
244         isReady: true,
246         error: function( msg ) {
247                 throw new Error( msg );
248         },
250         noop: function() {},
252         // See test/unit/core.js for details concerning isFunction.
253         // Since version 1.3, DOM methods and functions like alert
254         // aren't supported. They return false on IE (#2968).
255         isFunction: function( obj ) {
256                 return jQuery.type(obj) === "function";
257         },
259         isArray: Array.isArray || function( obj ) {
260                 return jQuery.type(obj) === "array";
261         },
263         isWindow: function( obj ) {
264                 /* jshint eqeqeq: false */
265                 return obj != null && obj == obj.window;
266         },
268         isNumeric: function( obj ) {
269                 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
270                 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
271                 // subtraction forces infinities to NaN
272                 return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
273         },
275         isEmptyObject: function( obj ) {
276                 var name;
277                 for ( name in obj ) {
278                         return false;
279                 }
280                 return true;
281         },
283         isPlainObject: function( obj ) {
284                 var key;
286                 // Must be an Object.
287                 // Because of IE, we also have to check the presence of the constructor property.
288                 // Make sure that DOM nodes and window objects don't pass through, as well
289                 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
290                         return false;
291                 }
293                 try {
294                         // Not own constructor property must be Object
295                         if ( obj.constructor &&
296                                 !hasOwn.call(obj, "constructor") &&
297                                 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
298                                 return false;
299                         }
300                 } catch ( e ) {
301                         // IE8,9 Will throw exceptions on certain host objects #9897
302                         return false;
303                 }
305                 // Support: IE<9
306                 // Handle iteration over inherited properties before own properties.
307                 if ( support.ownLast ) {
308                         for ( key in obj ) {
309                                 return hasOwn.call( obj, key );
310                         }
311                 }
313                 // Own properties are enumerated firstly, so to speed up,
314                 // if last one is own, then all properties are own.
315                 for ( key in obj ) {}
317                 return key === undefined || hasOwn.call( obj, key );
318         },
320         type: function( obj ) {
321                 if ( obj == null ) {
322                         return obj + "";
323                 }
324                 return typeof obj === "object" || typeof obj === "function" ?
325                         class2type[ toString.call(obj) ] || "object" :
326                         typeof obj;
327         },
329         // Evaluates a script in a global context
330         // Workarounds based on findings by Jim Driscoll
331         // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
332         globalEval: function( data ) {
333                 if ( data && jQuery.trim( data ) ) {
334                         // We use execScript on Internet Explorer
335                         // We use an anonymous function so that context is window
336                         // rather than jQuery in Firefox
337                         ( window.execScript || function( data ) {
338                                 window[ "eval" ].call( window, data );
339                         } )( data );
340                 }
341         },
343         // Convert dashed to camelCase; used by the css and data modules
344         // Microsoft forgot to hump their vendor prefix (#9572)
345         camelCase: function( string ) {
346                 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
347         },
349         nodeName: function( elem, name ) {
350                 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
351         },
353         // args is for internal usage only
354         each: function( obj, callback, args ) {
355                 var value,
356                         i = 0,
357                         length = obj.length,
358                         isArray = isArraylike( obj );
360                 if ( args ) {
361                         if ( isArray ) {
362                                 for ( ; i < length; i++ ) {
363                                         value = callback.apply( obj[ i ], args );
365                                         if ( value === false ) {
366                                                 break;
367                                         }
368                                 }
369                         } else {
370                                 for ( i in obj ) {
371                                         value = callback.apply( obj[ i ], args );
373                                         if ( value === false ) {
374                                                 break;
375                                         }
376                                 }
377                         }
379                 // A special, fast, case for the most common use of each
380                 } else {
381                         if ( isArray ) {
382                                 for ( ; i < length; i++ ) {
383                                         value = callback.call( obj[ i ], i, obj[ i ] );
385                                         if ( value === false ) {
386                                                 break;
387                                         }
388                                 }
389                         } else {
390                                 for ( i in obj ) {
391                                         value = callback.call( obj[ i ], i, obj[ i ] );
393                                         if ( value === false ) {
394                                                 break;
395                                         }
396                                 }
397                         }
398                 }
400                 return obj;
401         },
403         // Support: Android<4.1, IE<9
404         trim: function( text ) {
405                 return text == null ?
406                         "" :
407                         ( text + "" ).replace( rtrim, "" );
408         },
410         // results is for internal usage only
411         makeArray: function( arr, results ) {
412                 var ret = results || [];
414                 if ( arr != null ) {
415                         if ( isArraylike( Object(arr) ) ) {
416                                 jQuery.merge( ret,
417                                         typeof arr === "string" ?
418                                         [ arr ] : arr
419                                 );
420                         } else {
421                                 push.call( ret, arr );
422                         }
423                 }
425                 return ret;
426         },
428         inArray: function( elem, arr, i ) {
429                 var len;
431                 if ( arr ) {
432                         if ( indexOf ) {
433                                 return indexOf.call( arr, elem, i );
434                         }
436                         len = arr.length;
437                         i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
439                         for ( ; i < len; i++ ) {
440                                 // Skip accessing in sparse arrays
441                                 if ( i in arr && arr[ i ] === elem ) {
442                                         return i;
443                                 }
444                         }
445                 }
447                 return -1;
448         },
450         merge: function( first, second ) {
451                 var len = +second.length,
452                         j = 0,
453                         i = first.length;
455                 while ( j < len ) {
456                         first[ i++ ] = second[ j++ ];
457                 }
459                 // Support: IE<9
460                 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
461                 if ( len !== len ) {
462                         while ( second[j] !== undefined ) {
463                                 first[ i++ ] = second[ j++ ];
464                         }
465                 }
467                 first.length = i;
469                 return first;
470         },
472         grep: function( elems, callback, invert ) {
473                 var callbackInverse,
474                         matches = [],
475                         i = 0,
476                         length = elems.length,
477                         callbackExpect = !invert;
479                 // Go through the array, only saving the items
480                 // that pass the validator function
481                 for ( ; i < length; i++ ) {
482                         callbackInverse = !callback( elems[ i ], i );
483                         if ( callbackInverse !== callbackExpect ) {
484                                 matches.push( elems[ i ] );
485                         }
486                 }
488                 return matches;
489         },
491         // arg is for internal usage only
492         map: function( elems, callback, arg ) {
493                 var value,
494                         i = 0,
495                         length = elems.length,
496                         isArray = isArraylike( elems ),
497                         ret = [];
499                 // Go through the array, translating each of the items to their new values
500                 if ( isArray ) {
501                         for ( ; i < length; i++ ) {
502                                 value = callback( elems[ i ], i, arg );
504                                 if ( value != null ) {
505                                         ret.push( value );
506                                 }
507                         }
509                 // Go through every key on the object,
510                 } else {
511                         for ( i in elems ) {
512                                 value = callback( elems[ i ], i, arg );
514                                 if ( value != null ) {
515                                         ret.push( value );
516                                 }
517                         }
518                 }
520                 // Flatten any nested arrays
521                 return concat.apply( [], ret );
522         },
524         // A global GUID counter for objects
525         guid: 1,
527         // Bind a function to a context, optionally partially applying any
528         // arguments.
529         proxy: function( fn, context ) {
530                 var args, proxy, tmp;
532                 if ( typeof context === "string" ) {
533                         tmp = fn[ context ];
534                         context = fn;
535                         fn = tmp;
536                 }
538                 // Quick check to determine if target is callable, in the spec
539                 // this throws a TypeError, but we will just return undefined.
540                 if ( !jQuery.isFunction( fn ) ) {
541                         return undefined;
542                 }
544                 // Simulated bind
545                 args = slice.call( arguments, 2 );
546                 proxy = function() {
547                         return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
548                 };
550                 // Set the guid of unique handler to the same of original handler, so it can be removed
551                 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
553                 return proxy;
554         },
556         now: function() {
557                 return +( new Date() );
558         },
560         // jQuery.support is not used in Core but other projects attach their
561         // properties to it so it needs to exist.
562         support: support
563 });
565 // Populate the class2type map
566 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
567         class2type[ "[object " + name + "]" ] = name.toLowerCase();
568 });
570 function isArraylike( obj ) {
571         var length = obj.length,
572                 type = jQuery.type( obj );
574         if ( type === "function" || jQuery.isWindow( obj ) ) {
575                 return false;
576         }
578         if ( obj.nodeType === 1 && length ) {
579                 return true;
580         }
582         return type === "array" || length === 0 ||
583                 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
585 var Sizzle =
586 /*!
587  * Sizzle CSS Selector Engine v1.10.19
588  * http://sizzlejs.com/
589  *
590  * Copyright 2013 jQuery Foundation, Inc. and other contributors
591  * Released under the MIT license
592  * http://jquery.org/license
593  *
594  * Date: 2014-04-18
595  */
596 (function( window ) {
598 var i,
599         support,
600         Expr,
601         getText,
602         isXML,
603         tokenize,
604         compile,
605         select,
606         outermostContext,
607         sortInput,
608         hasDuplicate,
610         // Local document vars
611         setDocument,
612         document,
613         docElem,
614         documentIsHTML,
615         rbuggyQSA,
616         rbuggyMatches,
617         matches,
618         contains,
620         // Instance-specific data
621         expando = "sizzle" + -(new Date()),
622         preferredDoc = window.document,
623         dirruns = 0,
624         done = 0,
625         classCache = createCache(),
626         tokenCache = createCache(),
627         compilerCache = createCache(),
628         sortOrder = function( a, b ) {
629                 if ( a === b ) {
630                         hasDuplicate = true;
631                 }
632                 return 0;
633         },
635         // General-purpose constants
636         strundefined = typeof undefined,
637         MAX_NEGATIVE = 1 << 31,
639         // Instance methods
640         hasOwn = ({}).hasOwnProperty,
641         arr = [],
642         pop = arr.pop,
643         push_native = arr.push,
644         push = arr.push,
645         slice = arr.slice,
646         // Use a stripped-down indexOf if we can't use a native one
647         indexOf = arr.indexOf || function( elem ) {
648                 var i = 0,
649                         len = this.length;
650                 for ( ; i < len; i++ ) {
651                         if ( this[i] === elem ) {
652                                 return i;
653                         }
654                 }
655                 return -1;
656         },
658         booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
660         // Regular expressions
662         // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
663         whitespace = "[\\x20\\t\\r\\n\\f]",
664         // http://www.w3.org/TR/css3-syntax/#characters
665         characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
667         // Loosely modeled on CSS identifier characters
668         // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
669         // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
670         identifier = characterEncoding.replace( "w", "w#" ),
672         // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
673         attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
674                 // Operator (capture 2)
675                 "*([*^$|!~]?=)" + whitespace +
676                 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
677                 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
678                 "*\\]",
680         pseudos = ":(" + characterEncoding + ")(?:\\((" +
681                 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
682                 // 1. quoted (capture 3; capture 4 or capture 5)
683                 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
684                 // 2. simple (capture 6)
685                 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
686                 // 3. anything else (capture 2)
687                 ".*" +
688                 ")\\)|)",
690         // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
691         rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
693         rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
694         rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
696         rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
698         rpseudo = new RegExp( pseudos ),
699         ridentifier = new RegExp( "^" + identifier + "$" ),
701         matchExpr = {
702                 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
703                 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
704                 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
705                 "ATTR": new RegExp( "^" + attributes ),
706                 "PSEUDO": new RegExp( "^" + pseudos ),
707                 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
708                         "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
709                         "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
710                 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
711                 // For use in libraries implementing .is()
712                 // We use this for POS matching in `select`
713                 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
714                         whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
715         },
717         rinputs = /^(?:input|select|textarea|button)$/i,
718         rheader = /^h\d$/i,
720         rnative = /^[^{]+\{\s*\[native \w/,
722         // Easily-parseable/retrievable ID or TAG or CLASS selectors
723         rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
725         rsibling = /[+~]/,
726         rescape = /'|\\/g,
728         // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
729         runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
730         funescape = function( _, escaped, escapedWhitespace ) {
731                 var high = "0x" + escaped - 0x10000;
732                 // NaN means non-codepoint
733                 // Support: Firefox<24
734                 // Workaround erroneous numeric interpretation of +"0x"
735                 return high !== high || escapedWhitespace ?
736                         escaped :
737                         high < 0 ?
738                                 // BMP codepoint
739                                 String.fromCharCode( high + 0x10000 ) :
740                                 // Supplemental Plane codepoint (surrogate pair)
741                                 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
742         };
744 // Optimize for push.apply( _, NodeList )
745 try {
746         push.apply(
747                 (arr = slice.call( preferredDoc.childNodes )),
748                 preferredDoc.childNodes
749         );
750         // Support: Android<4.0
751         // Detect silently failing push.apply
752         arr[ preferredDoc.childNodes.length ].nodeType;
753 } catch ( e ) {
754         push = { apply: arr.length ?
756                 // Leverage slice if possible
757                 function( target, els ) {
758                         push_native.apply( target, slice.call(els) );
759                 } :
761                 // Support: IE<9
762                 // Otherwise append directly
763                 function( target, els ) {
764                         var j = target.length,
765                                 i = 0;
766                         // Can't trust NodeList.length
767                         while ( (target[j++] = els[i++]) ) {}
768                         target.length = j - 1;
769                 }
770         };
773 function Sizzle( selector, context, results, seed ) {
774         var match, elem, m, nodeType,
775                 // QSA vars
776                 i, groups, old, nid, newContext, newSelector;
778         if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
779                 setDocument( context );
780         }
782         context = context || document;
783         results = results || [];
785         if ( !selector || typeof selector !== "string" ) {
786                 return results;
787         }
789         if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
790                 return [];
791         }
793         if ( documentIsHTML && !seed ) {
795                 // Shortcuts
796                 if ( (match = rquickExpr.exec( selector )) ) {
797                         // Speed-up: Sizzle("#ID")
798                         if ( (m = match[1]) ) {
799                                 if ( nodeType === 9 ) {
800                                         elem = context.getElementById( m );
801                                         // Check parentNode to catch when Blackberry 4.6 returns
802                                         // nodes that are no longer in the document (jQuery #6963)
803                                         if ( elem && elem.parentNode ) {
804                                                 // Handle the case where IE, Opera, and Webkit return items
805                                                 // by name instead of ID
806                                                 if ( elem.id === m ) {
807                                                         results.push( elem );
808                                                         return results;
809                                                 }
810                                         } else {
811                                                 return results;
812                                         }
813                                 } else {
814                                         // Context is not a document
815                                         if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
816                                                 contains( context, elem ) && elem.id === m ) {
817                                                 results.push( elem );
818                                                 return results;
819                                         }
820                                 }
822                         // Speed-up: Sizzle("TAG")
823                         } else if ( match[2] ) {
824                                 push.apply( results, context.getElementsByTagName( selector ) );
825                                 return results;
827                         // Speed-up: Sizzle(".CLASS")
828                         } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
829                                 push.apply( results, context.getElementsByClassName( m ) );
830                                 return results;
831                         }
832                 }
834                 // QSA path
835                 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
836                         nid = old = expando;
837                         newContext = context;
838                         newSelector = nodeType === 9 && selector;
840                         // qSA works strangely on Element-rooted queries
841                         // We can work around this by specifying an extra ID on the root
842                         // and working up from there (Thanks to Andrew Dupont for the technique)
843                         // IE 8 doesn't work on object elements
844                         if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
845                                 groups = tokenize( selector );
847                                 if ( (old = context.getAttribute("id")) ) {
848                                         nid = old.replace( rescape, "\\$&" );
849                                 } else {
850                                         context.setAttribute( "id", nid );
851                                 }
852                                 nid = "[id='" + nid + "'] ";
854                                 i = groups.length;
855                                 while ( i-- ) {
856                                         groups[i] = nid + toSelector( groups[i] );
857                                 }
858                                 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
859                                 newSelector = groups.join(",");
860                         }
862                         if ( newSelector ) {
863                                 try {
864                                         push.apply( results,
865                                                 newContext.querySelectorAll( newSelector )
866                                         );
867                                         return results;
868                                 } catch(qsaError) {
869                                 } finally {
870                                         if ( !old ) {
871                                                 context.removeAttribute("id");
872                                         }
873                                 }
874                         }
875                 }
876         }
878         // All others
879         return select( selector.replace( rtrim, "$1" ), context, results, seed );
882 /**
883  * Create key-value caches of limited size
884  * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
885  *      property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
886  *      deleting the oldest entry
887  */
888 function createCache() {
889         var keys = [];
891         function cache( key, value ) {
892                 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
893                 if ( keys.push( key + " " ) > Expr.cacheLength ) {
894                         // Only keep the most recent entries
895                         delete cache[ keys.shift() ];
896                 }
897                 return (cache[ key + " " ] = value);
898         }
899         return cache;
902 /**
903  * Mark a function for special use by Sizzle
904  * @param {Function} fn The function to mark
905  */
906 function markFunction( fn ) {
907         fn[ expando ] = true;
908         return fn;
911 /**
912  * Support testing using an element
913  * @param {Function} fn Passed the created div and expects a boolean result
914  */
915 function assert( fn ) {
916         var div = document.createElement("div");
918         try {
919                 return !!fn( div );
920         } catch (e) {
921                 return false;
922         } finally {
923                 // Remove from its parent by default
924                 if ( div.parentNode ) {
925                         div.parentNode.removeChild( div );
926                 }
927                 // release memory in IE
928                 div = null;
929         }
932 /**
933  * Adds the same handler for all of the specified attrs
934  * @param {String} attrs Pipe-separated list of attributes
935  * @param {Function} handler The method that will be applied
936  */
937 function addHandle( attrs, handler ) {
938         var arr = attrs.split("|"),
939                 i = attrs.length;
941         while ( i-- ) {
942                 Expr.attrHandle[ arr[i] ] = handler;
943         }
946 /**
947  * Checks document order of two siblings
948  * @param {Element} a
949  * @param {Element} b
950  * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
951  */
952 function siblingCheck( a, b ) {
953         var cur = b && a,
954                 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
955                         ( ~b.sourceIndex || MAX_NEGATIVE ) -
956                         ( ~a.sourceIndex || MAX_NEGATIVE );
958         // Use IE sourceIndex if available on both nodes
959         if ( diff ) {
960                 return diff;
961         }
963         // Check if b follows a
964         if ( cur ) {
965                 while ( (cur = cur.nextSibling) ) {
966                         if ( cur === b ) {
967                                 return -1;
968                         }
969                 }
970         }
972         return a ? 1 : -1;
975 /**
976  * Returns a function to use in pseudos for input types
977  * @param {String} type
978  */
979 function createInputPseudo( type ) {
980         return function( elem ) {
981                 var name = elem.nodeName.toLowerCase();
982                 return name === "input" && elem.type === type;
983         };
986 /**
987  * Returns a function to use in pseudos for buttons
988  * @param {String} type
989  */
990 function createButtonPseudo( type ) {
991         return function( elem ) {
992                 var name = elem.nodeName.toLowerCase();
993                 return (name === "input" || name === "button") && elem.type === type;
994         };
997 /**
998  * Returns a function to use in pseudos for positionals
999  * @param {Function} fn
1000  */
1001 function createPositionalPseudo( fn ) {
1002         return markFunction(function( argument ) {
1003                 argument = +argument;
1004                 return markFunction(function( seed, matches ) {
1005                         var j,
1006                                 matchIndexes = fn( [], seed.length, argument ),
1007                                 i = matchIndexes.length;
1009                         // Match elements found at the specified indexes
1010                         while ( i-- ) {
1011                                 if ( seed[ (j = matchIndexes[i]) ] ) {
1012                                         seed[j] = !(matches[j] = seed[j]);
1013                                 }
1014                         }
1015                 });
1016         });
1019 /**
1020  * Checks a node for validity as a Sizzle context
1021  * @param {Element|Object=} context
1022  * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1023  */
1024 function testContext( context ) {
1025         return context && typeof context.getElementsByTagName !== strundefined && context;
1028 // Expose support vars for convenience
1029 support = Sizzle.support = {};
1031 /**
1032  * Detects XML nodes
1033  * @param {Element|Object} elem An element or a document
1034  * @returns {Boolean} True iff elem is a non-HTML XML node
1035  */
1036 isXML = Sizzle.isXML = function( elem ) {
1037         // documentElement is verified for cases where it doesn't yet exist
1038         // (such as loading iframes in IE - #4833)
1039         var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1040         return documentElement ? documentElement.nodeName !== "HTML" : false;
1041 };
1043 /**
1044  * Sets document-related variables once based on the current document
1045  * @param {Element|Object} [doc] An element or document object to use to set the document
1046  * @returns {Object} Returns the current document
1047  */
1048 setDocument = Sizzle.setDocument = function( node ) {
1049         var hasCompare,
1050                 doc = node ? node.ownerDocument || node : preferredDoc,
1051                 parent = doc.defaultView;
1053         // If no document and documentElement is available, return
1054         if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1055                 return document;
1056         }
1058         // Set our document
1059         document = doc;
1060         docElem = doc.documentElement;
1062         // Support tests
1063         documentIsHTML = !isXML( doc );
1065         // Support: IE>8
1066         // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1067         // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1068         // IE6-8 do not support the defaultView property so parent will be undefined
1069         if ( parent && parent !== parent.top ) {
1070                 // IE11 does not have attachEvent, so all must suffer
1071                 if ( parent.addEventListener ) {
1072                         parent.addEventListener( "unload", function() {
1073                                 setDocument();
1074                         }, false );
1075                 } else if ( parent.attachEvent ) {
1076                         parent.attachEvent( "onunload", function() {
1077                                 setDocument();
1078                         });
1079                 }
1080         }
1082         /* Attributes
1083         ---------------------------------------------------------------------- */
1085         // Support: IE<8
1086         // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1087         support.attributes = assert(function( div ) {
1088                 div.className = "i";
1089                 return !div.getAttribute("className");
1090         });
1092         /* getElement(s)By*
1093         ---------------------------------------------------------------------- */
1095         // Check if getElementsByTagName("*") returns only elements
1096         support.getElementsByTagName = assert(function( div ) {
1097                 div.appendChild( doc.createComment("") );
1098                 return !div.getElementsByTagName("*").length;
1099         });
1101         // Check if getElementsByClassName can be trusted
1102         support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
1103                 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
1105                 // Support: Safari<4
1106                 // Catch class over-caching
1107                 div.firstChild.className = "i";
1108                 // Support: Opera<10
1109                 // Catch gEBCN failure to find non-leading classes
1110                 return div.getElementsByClassName("i").length === 2;
1111         });
1113         // Support: IE<10
1114         // Check if getElementById returns elements by name
1115         // The broken getElementById methods don't pick up programatically-set names,
1116         // so use a roundabout getElementsByName test
1117         support.getById = assert(function( div ) {
1118                 docElem.appendChild( div ).id = expando;
1119                 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
1120         });
1122         // ID find and filter
1123         if ( support.getById ) {
1124                 Expr.find["ID"] = function( id, context ) {
1125                         if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
1126                                 var m = context.getElementById( id );
1127                                 // Check parentNode to catch when Blackberry 4.6 returns
1128                                 // nodes that are no longer in the document #6963
1129                                 return m && m.parentNode ? [ m ] : [];
1130                         }
1131                 };
1132                 Expr.filter["ID"] = function( id ) {
1133                         var attrId = id.replace( runescape, funescape );
1134                         return function( elem ) {
1135                                 return elem.getAttribute("id") === attrId;
1136                         };
1137                 };
1138         } else {
1139                 // Support: IE6/7
1140                 // getElementById is not reliable as a find shortcut
1141                 delete Expr.find["ID"];
1143                 Expr.filter["ID"] =  function( id ) {
1144                         var attrId = id.replace( runescape, funescape );
1145                         return function( elem ) {
1146                                 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
1147                                 return node && node.value === attrId;
1148                         };
1149                 };
1150         }
1152         // Tag
1153         Expr.find["TAG"] = support.getElementsByTagName ?
1154                 function( tag, context ) {
1155                         if ( typeof context.getElementsByTagName !== strundefined ) {
1156                                 return context.getElementsByTagName( tag );
1157                         }
1158                 } :
1159                 function( tag, context ) {
1160                         var elem,
1161                                 tmp = [],
1162                                 i = 0,
1163                                 results = context.getElementsByTagName( tag );
1165                         // Filter out possible comments
1166                         if ( tag === "*" ) {
1167                                 while ( (elem = results[i++]) ) {
1168                                         if ( elem.nodeType === 1 ) {
1169                                                 tmp.push( elem );
1170                                         }
1171                                 }
1173                                 return tmp;
1174                         }
1175                         return results;
1176                 };
1178         // Class
1179         Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1180                 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
1181                         return context.getElementsByClassName( className );
1182                 }
1183         };
1185         /* QSA/matchesSelector
1186         ---------------------------------------------------------------------- */
1188         // QSA and matchesSelector support
1190         // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1191         rbuggyMatches = [];
1193         // qSa(:focus) reports false when true (Chrome 21)
1194         // We allow this because of a bug in IE8/9 that throws an error
1195         // whenever `document.activeElement` is accessed on an iframe
1196         // So, we allow :focus to pass through QSA all the time to avoid the IE error
1197         // See http://bugs.jquery.com/ticket/13378
1198         rbuggyQSA = [];
1200         if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1201                 // Build QSA regex
1202                 // Regex strategy adopted from Diego Perini
1203                 assert(function( div ) {
1204                         // Select is set to empty string on purpose
1205                         // This is to test IE's treatment of not explicitly
1206                         // setting a boolean content attribute,
1207                         // since its presence should be enough
1208                         // http://bugs.jquery.com/ticket/12359
1209                         div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
1211                         // Support: IE8, Opera 11-12.16
1212                         // Nothing should be selected when empty strings follow ^= or $= or *=
1213                         // The test attribute must be unknown in Opera but "safe" for WinRT
1214                         // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1215                         if ( div.querySelectorAll("[msallowclip^='']").length ) {
1216                                 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1217                         }
1219                         // Support: IE8
1220                         // Boolean attributes and "value" are not treated correctly
1221                         if ( !div.querySelectorAll("[selected]").length ) {
1222                                 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1223                         }
1225                         // Webkit/Opera - :checked should return selected option elements
1226                         // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1227                         // IE8 throws error here and will not see later tests
1228                         if ( !div.querySelectorAll(":checked").length ) {
1229                                 rbuggyQSA.push(":checked");
1230                         }
1231                 });
1233                 assert(function( div ) {
1234                         // Support: Windows 8 Native Apps
1235                         // The type and name attributes are restricted during .innerHTML assignment
1236                         var input = doc.createElement("input");
1237                         input.setAttribute( "type", "hidden" );
1238                         div.appendChild( input ).setAttribute( "name", "D" );
1240                         // Support: IE8
1241                         // Enforce case-sensitivity of name attribute
1242                         if ( div.querySelectorAll("[name=d]").length ) {
1243                                 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1244                         }
1246                         // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1247                         // IE8 throws error here and will not see later tests
1248                         if ( !div.querySelectorAll(":enabled").length ) {
1249                                 rbuggyQSA.push( ":enabled", ":disabled" );
1250                         }
1252                         // Opera 10-11 does not throw on post-comma invalid pseudos
1253                         div.querySelectorAll("*,:x");
1254                         rbuggyQSA.push(",.*:");
1255                 });
1256         }
1258         if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1259                 docElem.webkitMatchesSelector ||
1260                 docElem.mozMatchesSelector ||
1261                 docElem.oMatchesSelector ||
1262                 docElem.msMatchesSelector) )) ) {
1264                 assert(function( div ) {
1265                         // Check to see if it's possible to do matchesSelector
1266                         // on a disconnected node (IE 9)
1267                         support.disconnectedMatch = matches.call( div, "div" );
1269                         // This should fail with an exception
1270                         // Gecko does not error, returns false instead
1271                         matches.call( div, "[s!='']:x" );
1272                         rbuggyMatches.push( "!=", pseudos );
1273                 });
1274         }
1276         rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1277         rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1279         /* Contains
1280         ---------------------------------------------------------------------- */
1281         hasCompare = rnative.test( docElem.compareDocumentPosition );
1283         // Element contains another
1284         // Purposefully does not implement inclusive descendent
1285         // As in, an element does not contain itself
1286         contains = hasCompare || rnative.test( docElem.contains ) ?
1287                 function( a, b ) {
1288                         var adown = a.nodeType === 9 ? a.documentElement : a,
1289                                 bup = b && b.parentNode;
1290                         return a === bup || !!( bup && bup.nodeType === 1 && (
1291                                 adown.contains ?
1292                                         adown.contains( bup ) :
1293                                         a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1294                         ));
1295                 } :
1296                 function( a, b ) {
1297                         if ( b ) {
1298                                 while ( (b = b.parentNode) ) {
1299                                         if ( b === a ) {
1300                                                 return true;
1301                                         }
1302                                 }
1303                         }
1304                         return false;
1305                 };
1307         /* Sorting
1308         ---------------------------------------------------------------------- */
1310         // Document order sorting
1311         sortOrder = hasCompare ?
1312         function( a, b ) {
1314                 // Flag for duplicate removal
1315                 if ( a === b ) {
1316                         hasDuplicate = true;
1317                         return 0;
1318                 }
1320                 // Sort on method existence if only one input has compareDocumentPosition
1321                 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1322                 if ( compare ) {
1323                         return compare;
1324                 }
1326                 // Calculate position if both inputs belong to the same document
1327                 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1328                         a.compareDocumentPosition( b ) :
1330                         // Otherwise we know they are disconnected
1331                         1;
1333                 // Disconnected nodes
1334                 if ( compare & 1 ||
1335                         (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1337                         // Choose the first element that is related to our preferred document
1338                         if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1339                                 return -1;
1340                         }
1341                         if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1342                                 return 1;
1343                         }
1345                         // Maintain original order
1346                         return sortInput ?
1347                                 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1348                                 0;
1349                 }
1351                 return compare & 4 ? -1 : 1;
1352         } :
1353         function( a, b ) {
1354                 // Exit early if the nodes are identical
1355                 if ( a === b ) {
1356                         hasDuplicate = true;
1357                         return 0;
1358                 }
1360                 var cur,
1361                         i = 0,
1362                         aup = a.parentNode,
1363                         bup = b.parentNode,
1364                         ap = [ a ],
1365                         bp = [ b ];
1367                 // Parentless nodes are either documents or disconnected
1368                 if ( !aup || !bup ) {
1369                         return a === doc ? -1 :
1370                                 b === doc ? 1 :
1371                                 aup ? -1 :
1372                                 bup ? 1 :
1373                                 sortInput ?
1374                                 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1375                                 0;
1377                 // If the nodes are siblings, we can do a quick check
1378                 } else if ( aup === bup ) {
1379                         return siblingCheck( a, b );
1380                 }
1382                 // Otherwise we need full lists of their ancestors for comparison
1383                 cur = a;
1384                 while ( (cur = cur.parentNode) ) {
1385                         ap.unshift( cur );
1386                 }
1387                 cur = b;
1388                 while ( (cur = cur.parentNode) ) {
1389                         bp.unshift( cur );
1390                 }
1392                 // Walk down the tree looking for a discrepancy
1393                 while ( ap[i] === bp[i] ) {
1394                         i++;
1395                 }
1397                 return i ?
1398                         // Do a sibling check if the nodes have a common ancestor
1399                         siblingCheck( ap[i], bp[i] ) :
1401                         // Otherwise nodes in our document sort first
1402                         ap[i] === preferredDoc ? -1 :
1403                         bp[i] === preferredDoc ? 1 :
1404                         0;
1405         };
1407         return doc;
1408 };
1410 Sizzle.matches = function( expr, elements ) {
1411         return Sizzle( expr, null, null, elements );
1412 };
1414 Sizzle.matchesSelector = function( elem, expr ) {
1415         // Set document vars if needed
1416         if ( ( elem.ownerDocument || elem ) !== document ) {
1417                 setDocument( elem );
1418         }
1420         // Make sure that attribute selectors are quoted
1421         expr = expr.replace( rattributeQuotes, "='$1']" );
1423         if ( support.matchesSelector && documentIsHTML &&
1424                 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1425                 ( !rbuggyQSA     || !rbuggyQSA.test( expr ) ) ) {
1427                 try {
1428                         var ret = matches.call( elem, expr );
1430                         // IE 9's matchesSelector returns false on disconnected nodes
1431                         if ( ret || support.disconnectedMatch ||
1432                                         // As well, disconnected nodes are said to be in a document
1433                                         // fragment in IE 9
1434                                         elem.document && elem.document.nodeType !== 11 ) {
1435                                 return ret;
1436                         }
1437                 } catch(e) {}
1438         }
1440         return Sizzle( expr, document, null, [ elem ] ).length > 0;
1441 };
1443 Sizzle.contains = function( context, elem ) {
1444         // Set document vars if needed
1445         if ( ( context.ownerDocument || context ) !== document ) {
1446                 setDocument( context );
1447         }
1448         return contains( context, elem );
1449 };
1451 Sizzle.attr = function( elem, name ) {
1452         // Set document vars if needed
1453         if ( ( elem.ownerDocument || elem ) !== document ) {
1454                 setDocument( elem );
1455         }
1457         var fn = Expr.attrHandle[ name.toLowerCase() ],
1458                 // Don't get fooled by Object.prototype properties (jQuery #13807)
1459                 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1460                         fn( elem, name, !documentIsHTML ) :
1461                         undefined;
1463         return val !== undefined ?
1464                 val :
1465                 support.attributes || !documentIsHTML ?
1466                         elem.getAttribute( name ) :
1467                         (val = elem.getAttributeNode(name)) && val.specified ?
1468                                 val.value :
1469                                 null;
1470 };
1472 Sizzle.error = function( msg ) {
1473         throw new Error( "Syntax error, unrecognized expression: " + msg );
1474 };
1476 /**
1477  * Document sorting and removing duplicates
1478  * @param {ArrayLike} results
1479  */
1480 Sizzle.uniqueSort = function( results ) {
1481         var elem,
1482                 duplicates = [],
1483                 j = 0,
1484                 i = 0;
1486         // Unless we *know* we can detect duplicates, assume their presence
1487         hasDuplicate = !support.detectDuplicates;
1488         sortInput = !support.sortStable && results.slice( 0 );
1489         results.sort( sortOrder );
1491         if ( hasDuplicate ) {
1492                 while ( (elem = results[i++]) ) {
1493                         if ( elem === results[ i ] ) {
1494                                 j = duplicates.push( i );
1495                         }
1496                 }
1497                 while ( j-- ) {
1498                         results.splice( duplicates[ j ], 1 );
1499                 }
1500         }
1502         // Clear input after sorting to release objects
1503         // See https://github.com/jquery/sizzle/pull/225
1504         sortInput = null;
1506         return results;
1507 };
1509 /**
1510  * Utility function for retrieving the text value of an array of DOM nodes
1511  * @param {Array|Element} elem
1512  */
1513 getText = Sizzle.getText = function( elem ) {
1514         var node,
1515                 ret = "",
1516                 i = 0,
1517                 nodeType = elem.nodeType;
1519         if ( !nodeType ) {
1520                 // If no nodeType, this is expected to be an array
1521                 while ( (node = elem[i++]) ) {
1522                         // Do not traverse comment nodes
1523                         ret += getText( node );
1524                 }
1525         } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1526                 // Use textContent for elements
1527                 // innerText usage removed for consistency of new lines (jQuery #11153)
1528                 if ( typeof elem.textContent === "string" ) {
1529                         return elem.textContent;
1530                 } else {
1531                         // Traverse its children
1532                         for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1533                                 ret += getText( elem );
1534                         }
1535                 }
1536         } else if ( nodeType === 3 || nodeType === 4 ) {
1537                 return elem.nodeValue;
1538         }
1539         // Do not include comment or processing instruction nodes
1541         return ret;
1542 };
1544 Expr = Sizzle.selectors = {
1546         // Can be adjusted by the user
1547         cacheLength: 50,
1549         createPseudo: markFunction,
1551         match: matchExpr,
1553         attrHandle: {},
1555         find: {},
1557         relative: {
1558                 ">": { dir: "parentNode", first: true },
1559                 " ": { dir: "parentNode" },
1560                 "+": { dir: "previousSibling", first: true },
1561                 "~": { dir: "previousSibling" }
1562         },
1564         preFilter: {
1565                 "ATTR": function( match ) {
1566                         match[1] = match[1].replace( runescape, funescape );
1568                         // Move the given value to match[3] whether quoted or unquoted
1569                         match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1571                         if ( match[2] === "~=" ) {
1572                                 match[3] = " " + match[3] + " ";
1573                         }
1575                         return match.slice( 0, 4 );
1576                 },
1578                 "CHILD": function( match ) {
1579                         /* matches from matchExpr["CHILD"]
1580                                 1 type (only|nth|...)
1581                                 2 what (child|of-type)
1582                                 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1583                                 4 xn-component of xn+y argument ([+-]?\d*n|)
1584                                 5 sign of xn-component
1585                                 6 x of xn-component
1586                                 7 sign of y-component
1587                                 8 y of y-component
1588                         */
1589                         match[1] = match[1].toLowerCase();
1591                         if ( match[1].slice( 0, 3 ) === "nth" ) {
1592                                 // nth-* requires argument
1593                                 if ( !match[3] ) {
1594                                         Sizzle.error( match[0] );
1595                                 }
1597                                 // numeric x and y parameters for Expr.filter.CHILD
1598                                 // remember that false/true cast respectively to 0/1
1599                                 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1600                                 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1602                         // other types prohibit arguments
1603                         } else if ( match[3] ) {
1604                                 Sizzle.error( match[0] );
1605                         }
1607                         return match;
1608                 },
1610                 "PSEUDO": function( match ) {
1611                         var excess,
1612                                 unquoted = !match[6] && match[2];
1614                         if ( matchExpr["CHILD"].test( match[0] ) ) {
1615                                 return null;
1616                         }
1618                         // Accept quoted arguments as-is
1619                         if ( match[3] ) {
1620                                 match[2] = match[4] || match[5] || "";
1622                         // Strip excess characters from unquoted arguments
1623                         } else if ( unquoted && rpseudo.test( unquoted ) &&
1624                                 // Get excess from tokenize (recursively)
1625                                 (excess = tokenize( unquoted, true )) &&
1626                                 // advance to the next closing parenthesis
1627                                 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1629                                 // excess is a negative index
1630                                 match[0] = match[0].slice( 0, excess );
1631                                 match[2] = unquoted.slice( 0, excess );
1632                         }
1634                         // Return only captures needed by the pseudo filter method (type and argument)
1635                         return match.slice( 0, 3 );
1636                 }
1637         },
1639         filter: {
1641                 "TAG": function( nodeNameSelector ) {
1642                         var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1643                         return nodeNameSelector === "*" ?
1644                                 function() { return true; } :
1645                                 function( elem ) {
1646                                         return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1647                                 };
1648                 },
1650                 "CLASS": function( className ) {
1651                         var pattern = classCache[ className + " " ];
1653                         return pattern ||
1654                                 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1655                                 classCache( className, function( elem ) {
1656                                         return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
1657                                 });
1658                 },
1660                 "ATTR": function( name, operator, check ) {
1661                         return function( elem ) {
1662                                 var result = Sizzle.attr( elem, name );
1664                                 if ( result == null ) {
1665                                         return operator === "!=";
1666                                 }
1667                                 if ( !operator ) {
1668                                         return true;
1669                                 }
1671                                 result += "";
1673                                 return operator === "=" ? result === check :
1674                                         operator === "!=" ? result !== check :
1675                                         operator === "^=" ? check && result.indexOf( check ) === 0 :
1676                                         operator === "*=" ? check && result.indexOf( check ) > -1 :
1677                                         operator === "$=" ? check && result.slice( -check.length ) === check :
1678                                         operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
1679                                         operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1680                                         false;
1681                         };
1682                 },
1684                 "CHILD": function( type, what, argument, first, last ) {
1685                         var simple = type.slice( 0, 3 ) !== "nth",
1686                                 forward = type.slice( -4 ) !== "last",
1687                                 ofType = what === "of-type";
1689                         return first === 1 && last === 0 ?
1691                                 // Shortcut for :nth-*(n)
1692                                 function( elem ) {
1693                                         return !!elem.parentNode;
1694                                 } :
1696                                 function( elem, context, xml ) {
1697                                         var cache, outerCache, node, diff, nodeIndex, start,
1698                                                 dir = simple !== forward ? "nextSibling" : "previousSibling",
1699                                                 parent = elem.parentNode,
1700                                                 name = ofType && elem.nodeName.toLowerCase(),
1701                                                 useCache = !xml && !ofType;
1703                                         if ( parent ) {
1705                                                 // :(first|last|only)-(child|of-type)
1706                                                 if ( simple ) {
1707                                                         while ( dir ) {
1708                                                                 node = elem;
1709                                                                 while ( (node = node[ dir ]) ) {
1710                                                                         if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1711                                                                                 return false;
1712                                                                         }
1713                                                                 }
1714                                                                 // Reverse direction for :only-* (if we haven't yet done so)
1715                                                                 start = dir = type === "only" && !start && "nextSibling";
1716                                                         }
1717                                                         return true;
1718                                                 }
1720                                                 start = [ forward ? parent.firstChild : parent.lastChild ];
1722                                                 // non-xml :nth-child(...) stores cache data on `parent`
1723                                                 if ( forward && useCache ) {
1724                                                         // Seek `elem` from a previously-cached index
1725                                                         outerCache = parent[ expando ] || (parent[ expando ] = {});
1726                                                         cache = outerCache[ type ] || [];
1727                                                         nodeIndex = cache[0] === dirruns && cache[1];
1728                                                         diff = cache[0] === dirruns && cache[2];
1729                                                         node = nodeIndex && parent.childNodes[ nodeIndex ];
1731                                                         while ( (node = ++nodeIndex && node && node[ dir ] ||
1733                                                                 // Fallback to seeking `elem` from the start
1734                                                                 (diff = nodeIndex = 0) || start.pop()) ) {
1736                                                                 // When found, cache indexes on `parent` and break
1737                                                                 if ( node.nodeType === 1 && ++diff && node === elem ) {
1738                                                                         outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1739                                                                         break;
1740                                                                 }
1741                                                         }
1743                                                 // Use previously-cached element index if available
1744                                                 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1745                                                         diff = cache[1];
1747                                                 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1748                                                 } else {
1749                                                         // Use the same loop as above to seek `elem` from the start
1750                                                         while ( (node = ++nodeIndex && node && node[ dir ] ||
1751                                                                 (diff = nodeIndex = 0) || start.pop()) ) {
1753                                                                 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1754                                                                         // Cache the index of each encountered element
1755                                                                         if ( useCache ) {
1756                                                                                 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1757                                                                         }
1759                                                                         if ( node === elem ) {
1760                                                                                 break;
1761                                                                         }
1762                                                                 }
1763                                                         }
1764                                                 }
1766                                                 // Incorporate the offset, then check against cycle size
1767                                                 diff -= last;
1768                                                 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1769                                         }
1770                                 };
1771                 },
1773                 "PSEUDO": function( pseudo, argument ) {
1774                         // pseudo-class names are case-insensitive
1775                         // http://www.w3.org/TR/selectors/#pseudo-classes
1776                         // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1777                         // Remember that setFilters inherits from pseudos
1778                         var args,
1779                                 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1780                                         Sizzle.error( "unsupported pseudo: " + pseudo );
1782                         // The user may use createPseudo to indicate that
1783                         // arguments are needed to create the filter function
1784                         // just as Sizzle does
1785                         if ( fn[ expando ] ) {
1786                                 return fn( argument );
1787                         }
1789                         // But maintain support for old signatures
1790                         if ( fn.length > 1 ) {
1791                                 args = [ pseudo, pseudo, "", argument ];
1792                                 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1793                                         markFunction(function( seed, matches ) {
1794                                                 var idx,
1795                                                         matched = fn( seed, argument ),
1796                                                         i = matched.length;
1797                                                 while ( i-- ) {
1798                                                         idx = indexOf.call( seed, matched[i] );
1799                                                         seed[ idx ] = !( matches[ idx ] = matched[i] );
1800                                                 }
1801                                         }) :
1802                                         function( elem ) {
1803                                                 return fn( elem, 0, args );
1804                                         };
1805                         }
1807                         return fn;
1808                 }
1809         },
1811         pseudos: {
1812                 // Potentially complex pseudos
1813                 "not": markFunction(function( selector ) {
1814                         // Trim the selector passed to compile
1815                         // to avoid treating leading and trailing
1816                         // spaces as combinators
1817                         var input = [],
1818                                 results = [],
1819                                 matcher = compile( selector.replace( rtrim, "$1" ) );
1821                         return matcher[ expando ] ?
1822                                 markFunction(function( seed, matches, context, xml ) {
1823                                         var elem,
1824                                                 unmatched = matcher( seed, null, xml, [] ),
1825                                                 i = seed.length;
1827                                         // Match elements unmatched by `matcher`
1828                                         while ( i-- ) {
1829                                                 if ( (elem = unmatched[i]) ) {
1830                                                         seed[i] = !(matches[i] = elem);
1831                                                 }
1832                                         }
1833                                 }) :
1834                                 function( elem, context, xml ) {
1835                                         input[0] = elem;
1836                                         matcher( input, null, xml, results );
1837                                         return !results.pop();
1838                                 };
1839                 }),
1841                 "has": markFunction(function( selector ) {
1842                         return function( elem ) {
1843                                 return Sizzle( selector, elem ).length > 0;
1844                         };
1845                 }),
1847                 "contains": markFunction(function( text ) {
1848                         return function( elem ) {
1849                                 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1850                         };
1851                 }),
1853                 // "Whether an element is represented by a :lang() selector
1854                 // is based solely on the element's language value
1855                 // being equal to the identifier C,
1856                 // or beginning with the identifier C immediately followed by "-".
1857                 // The matching of C against the element's language value is performed case-insensitively.
1858                 // The identifier C does not have to be a valid language name."
1859                 // http://www.w3.org/TR/selectors/#lang-pseudo
1860                 "lang": markFunction( function( lang ) {
1861                         // lang value must be a valid identifier
1862                         if ( !ridentifier.test(lang || "") ) {
1863                                 Sizzle.error( "unsupported lang: " + lang );
1864                         }
1865                         lang = lang.replace( runescape, funescape ).toLowerCase();
1866                         return function( elem ) {
1867                                 var elemLang;
1868                                 do {
1869                                         if ( (elemLang = documentIsHTML ?
1870                                                 elem.lang :
1871                                                 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1873                                                 elemLang = elemLang.toLowerCase();
1874                                                 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1875                                         }
1876                                 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1877                                 return false;
1878                         };
1879                 }),
1881                 // Miscellaneous
1882                 "target": function( elem ) {
1883                         var hash = window.location && window.location.hash;
1884                         return hash && hash.slice( 1 ) === elem.id;
1885                 },
1887                 "root": function( elem ) {
1888                         return elem === docElem;
1889                 },
1891                 "focus": function( elem ) {
1892                         return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1893                 },
1895                 // Boolean properties
1896                 "enabled": function( elem ) {
1897                         return elem.disabled === false;
1898                 },
1900                 "disabled": function( elem ) {
1901                         return elem.disabled === true;
1902                 },
1904                 "checked": function( elem ) {
1905                         // In CSS3, :checked should return both checked and selected elements
1906                         // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1907                         var nodeName = elem.nodeName.toLowerCase();
1908                         return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1909                 },
1911                 "selected": function( elem ) {
1912                         // Accessing this property makes selected-by-default
1913                         // options in Safari work properly
1914                         if ( elem.parentNode ) {
1915                                 elem.parentNode.selectedIndex;
1916                         }
1918                         return elem.selected === true;
1919                 },
1921                 // Contents
1922                 "empty": function( elem ) {
1923                         // http://www.w3.org/TR/selectors/#empty-pseudo
1924                         // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1925                         //   but not by others (comment: 8; processing instruction: 7; etc.)
1926                         // nodeType < 6 works because attributes (2) do not appear as children
1927                         for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1928                                 if ( elem.nodeType < 6 ) {
1929                                         return false;
1930                                 }
1931                         }
1932                         return true;
1933                 },
1935                 "parent": function( elem ) {
1936                         return !Expr.pseudos["empty"]( elem );
1937                 },
1939                 // Element/input types
1940                 "header": function( elem ) {
1941                         return rheader.test( elem.nodeName );
1942                 },
1944                 "input": function( elem ) {
1945                         return rinputs.test( elem.nodeName );
1946                 },
1948                 "button": function( elem ) {
1949                         var name = elem.nodeName.toLowerCase();
1950                         return name === "input" && elem.type === "button" || name === "button";
1951                 },
1953                 "text": function( elem ) {
1954                         var attr;
1955                         return elem.nodeName.toLowerCase() === "input" &&
1956                                 elem.type === "text" &&
1958                                 // Support: IE<8
1959                                 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1960                                 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1961                 },
1963                 // Position-in-collection
1964                 "first": createPositionalPseudo(function() {
1965                         return [ 0 ];
1966                 }),
1968                 "last": createPositionalPseudo(function( matchIndexes, length ) {
1969                         return [ length - 1 ];
1970                 }),
1972                 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1973                         return [ argument < 0 ? argument + length : argument ];
1974                 }),
1976                 "even": createPositionalPseudo(function( matchIndexes, length ) {
1977                         var i = 0;
1978                         for ( ; i < length; i += 2 ) {
1979                                 matchIndexes.push( i );
1980                         }
1981                         return matchIndexes;
1982                 }),
1984                 "odd": createPositionalPseudo(function( matchIndexes, length ) {
1985                         var i = 1;
1986                         for ( ; i < length; i += 2 ) {
1987                                 matchIndexes.push( i );
1988                         }
1989                         return matchIndexes;
1990                 }),
1992                 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1993                         var i = argument < 0 ? argument + length : argument;
1994                         for ( ; --i >= 0; ) {
1995                                 matchIndexes.push( i );
1996                         }
1997                         return matchIndexes;
1998                 }),
2000                 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2001                         var i = argument < 0 ? argument + length : argument;
2002                         for ( ; ++i < length; ) {
2003                                 matchIndexes.push( i );
2004                         }
2005                         return matchIndexes;
2006                 })
2007         }
2008 };
2010 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2012 // Add button/input type pseudos
2013 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2014         Expr.pseudos[ i ] = createInputPseudo( i );
2016 for ( i in { submit: true, reset: true } ) {
2017         Expr.pseudos[ i ] = createButtonPseudo( i );
2020 // Easy API for creating new setFilters
2021 function setFilters() {}
2022 setFilters.prototype = Expr.filters = Expr.pseudos;
2023 Expr.setFilters = new setFilters();
2025 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2026         var matched, match, tokens, type,
2027                 soFar, groups, preFilters,
2028                 cached = tokenCache[ selector + " " ];
2030         if ( cached ) {
2031                 return parseOnly ? 0 : cached.slice( 0 );
2032         }
2034         soFar = selector;
2035         groups = [];
2036         preFilters = Expr.preFilter;
2038         while ( soFar ) {
2040                 // Comma and first run
2041                 if ( !matched || (match = rcomma.exec( soFar )) ) {
2042                         if ( match ) {
2043                                 // Don't consume trailing commas as valid
2044                                 soFar = soFar.slice( match[0].length ) || soFar;
2045                         }
2046                         groups.push( (tokens = []) );
2047                 }
2049                 matched = false;
2051                 // Combinators
2052                 if ( (match = rcombinators.exec( soFar )) ) {
2053                         matched = match.shift();
2054                         tokens.push({
2055                                 value: matched,
2056                                 // Cast descendant combinators to space
2057                                 type: match[0].replace( rtrim, " " )
2058                         });
2059                         soFar = soFar.slice( matched.length );
2060                 }
2062                 // Filters
2063                 for ( type in Expr.filter ) {
2064                         if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2065                                 (match = preFilters[ type ]( match ))) ) {
2066                                 matched = match.shift();
2067                                 tokens.push({
2068                                         value: matched,
2069                                         type: type,
2070                                         matches: match
2071                                 });
2072                                 soFar = soFar.slice( matched.length );
2073                         }
2074                 }
2076                 if ( !matched ) {
2077                         break;
2078                 }
2079         }
2081         // Return the length of the invalid excess
2082         // if we're just parsing
2083         // Otherwise, throw an error or return tokens
2084         return parseOnly ?
2085                 soFar.length :
2086                 soFar ?
2087                         Sizzle.error( selector ) :
2088                         // Cache the tokens
2089                         tokenCache( selector, groups ).slice( 0 );
2090 };
2092 function toSelector( tokens ) {
2093         var i = 0,
2094                 len = tokens.length,
2095                 selector = "";
2096         for ( ; i < len; i++ ) {
2097                 selector += tokens[i].value;
2098         }
2099         return selector;
2102 function addCombinator( matcher, combinator, base ) {
2103         var dir = combinator.dir,
2104                 checkNonElements = base && dir === "parentNode",
2105                 doneName = done++;
2107         return combinator.first ?
2108                 // Check against closest ancestor/preceding element
2109                 function( elem, context, xml ) {
2110                         while ( (elem = elem[ dir ]) ) {
2111                                 if ( elem.nodeType === 1 || checkNonElements ) {
2112                                         return matcher( elem, context, xml );
2113                                 }
2114                         }
2115                 } :
2117                 // Check against all ancestor/preceding elements
2118                 function( elem, context, xml ) {
2119                         var oldCache, outerCache,
2120                                 newCache = [ dirruns, doneName ];
2122                         // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2123                         if ( xml ) {
2124                                 while ( (elem = elem[ dir ]) ) {
2125                                         if ( elem.nodeType === 1 || checkNonElements ) {
2126                                                 if ( matcher( elem, context, xml ) ) {
2127                                                         return true;
2128                                                 }
2129                                         }
2130                                 }
2131                         } else {
2132                                 while ( (elem = elem[ dir ]) ) {
2133                                         if ( elem.nodeType === 1 || checkNonElements ) {
2134                                                 outerCache = elem[ expando ] || (elem[ expando ] = {});
2135                                                 if ( (oldCache = outerCache[ dir ]) &&
2136                                                         oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2138                                                         // Assign to newCache so results back-propagate to previous elements
2139                                                         return (newCache[ 2 ] = oldCache[ 2 ]);
2140                                                 } else {
2141                                                         // Reuse newcache so results back-propagate to previous elements
2142                                                         outerCache[ dir ] = newCache;
2144                                                         // A match means we're done; a fail means we have to keep checking
2145                                                         if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2146                                                                 return true;
2147                                                         }
2148                                                 }
2149                                         }
2150                                 }
2151                         }
2152                 };
2155 function elementMatcher( matchers ) {
2156         return matchers.length > 1 ?
2157                 function( elem, context, xml ) {
2158                         var i = matchers.length;
2159                         while ( i-- ) {
2160                                 if ( !matchers[i]( elem, context, xml ) ) {
2161                                         return false;
2162                                 }
2163                         }
2164                         return true;
2165                 } :
2166                 matchers[0];
2169 function multipleContexts( selector, contexts, results ) {
2170         var i = 0,
2171                 len = contexts.length;
2172         for ( ; i < len; i++ ) {
2173                 Sizzle( selector, contexts[i], results );
2174         }
2175         return results;
2178 function condense( unmatched, map, filter, context, xml ) {
2179         var elem,
2180                 newUnmatched = [],
2181                 i = 0,
2182                 len = unmatched.length,
2183                 mapped = map != null;
2185         for ( ; i < len; i++ ) {
2186                 if ( (elem = unmatched[i]) ) {
2187                         if ( !filter || filter( elem, context, xml ) ) {
2188                                 newUnmatched.push( elem );
2189                                 if ( mapped ) {
2190                                         map.push( i );
2191                                 }
2192                         }
2193                 }
2194         }
2196         return newUnmatched;
2199 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2200         if ( postFilter && !postFilter[ expando ] ) {
2201                 postFilter = setMatcher( postFilter );
2202         }
2203         if ( postFinder && !postFinder[ expando ] ) {
2204                 postFinder = setMatcher( postFinder, postSelector );
2205         }
2206         return markFunction(function( seed, results, context, xml ) {
2207                 var temp, i, elem,
2208                         preMap = [],
2209                         postMap = [],
2210                         preexisting = results.length,
2212                         // Get initial elements from seed or context
2213                         elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2215                         // Prefilter to get matcher input, preserving a map for seed-results synchronization
2216                         matcherIn = preFilter && ( seed || !selector ) ?
2217                                 condense( elems, preMap, preFilter, context, xml ) :
2218                                 elems,
2220                         matcherOut = matcher ?
2221                                 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2222                                 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2224                                         // ...intermediate processing is necessary
2225                                         [] :
2227                                         // ...otherwise use results directly
2228                                         results :
2229                                 matcherIn;
2231                 // Find primary matches
2232                 if ( matcher ) {
2233                         matcher( matcherIn, matcherOut, context, xml );
2234                 }
2236                 // Apply postFilter
2237                 if ( postFilter ) {
2238                         temp = condense( matcherOut, postMap );
2239                         postFilter( temp, [], context, xml );
2241                         // Un-match failing elements by moving them back to matcherIn
2242                         i = temp.length;
2243                         while ( i-- ) {
2244                                 if ( (elem = temp[i]) ) {
2245                                         matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2246                                 }
2247                         }
2248                 }
2250                 if ( seed ) {
2251                         if ( postFinder || preFilter ) {
2252                                 if ( postFinder ) {
2253                                         // Get the final matcherOut by condensing this intermediate into postFinder contexts
2254                                         temp = [];
2255                                         i = matcherOut.length;
2256                                         while ( i-- ) {
2257                                                 if ( (elem = matcherOut[i]) ) {
2258                                                         // Restore matcherIn since elem is not yet a final match
2259                                                         temp.push( (matcherIn[i] = elem) );
2260                                                 }
2261                                         }
2262                                         postFinder( null, (matcherOut = []), temp, xml );
2263                                 }
2265                                 // Move matched elements from seed to results to keep them synchronized
2266                                 i = matcherOut.length;
2267                                 while ( i-- ) {
2268                                         if ( (elem = matcherOut[i]) &&
2269                                                 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
2271                                                 seed[temp] = !(results[temp] = elem);
2272                                         }
2273                                 }
2274                         }
2276                 // Add elements to results, through postFinder if defined
2277                 } else {
2278                         matcherOut = condense(
2279                                 matcherOut === results ?
2280                                         matcherOut.splice( preexisting, matcherOut.length ) :
2281                                         matcherOut
2282                         );
2283                         if ( postFinder ) {
2284                                 postFinder( null, results, matcherOut, xml );
2285                         } else {
2286                                 push.apply( results, matcherOut );
2287                         }
2288                 }
2289         });
2292 function matcherFromTokens( tokens ) {
2293         var checkContext, matcher, j,
2294                 len = tokens.length,
2295                 leadingRelative = Expr.relative[ tokens[0].type ],
2296                 implicitRelative = leadingRelative || Expr.relative[" "],
2297                 i = leadingRelative ? 1 : 0,
2299                 // The foundational matcher ensures that elements are reachable from top-level context(s)
2300                 matchContext = addCombinator( function( elem ) {
2301                         return elem === checkContext;
2302                 }, implicitRelative, true ),
2303                 matchAnyContext = addCombinator( function( elem ) {
2304                         return indexOf.call( checkContext, elem ) > -1;
2305                 }, implicitRelative, true ),
2306                 matchers = [ function( elem, context, xml ) {
2307                         return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2308                                 (checkContext = context).nodeType ?
2309                                         matchContext( elem, context, xml ) :
2310                                         matchAnyContext( elem, context, xml ) );
2311                 } ];
2313         for ( ; i < len; i++ ) {
2314                 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2315                         matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2316                 } else {
2317                         matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2319                         // Return special upon seeing a positional matcher
2320                         if ( matcher[ expando ] ) {
2321                                 // Find the next relative operator (if any) for proper handling
2322                                 j = ++i;
2323                                 for ( ; j < len; j++ ) {
2324                                         if ( Expr.relative[ tokens[j].type ] ) {
2325                                                 break;
2326                                         }
2327                                 }
2328                                 return setMatcher(
2329                                         i > 1 && elementMatcher( matchers ),
2330                                         i > 1 && toSelector(
2331                                                 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2332                                                 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2333                                         ).replace( rtrim, "$1" ),
2334                                         matcher,
2335                                         i < j && matcherFromTokens( tokens.slice( i, j ) ),
2336                                         j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2337                                         j < len && toSelector( tokens )
2338                                 );
2339                         }
2340                         matchers.push( matcher );
2341                 }
2342         }
2344         return elementMatcher( matchers );
2347 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2348         var bySet = setMatchers.length > 0,
2349                 byElement = elementMatchers.length > 0,
2350                 superMatcher = function( seed, context, xml, results, outermost ) {
2351                         var elem, j, matcher,
2352                                 matchedCount = 0,
2353                                 i = "0",
2354                                 unmatched = seed && [],
2355                                 setMatched = [],
2356                                 contextBackup = outermostContext,
2357                                 // We must always have either seed elements or outermost context
2358                                 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2359                                 // Use integer dirruns iff this is the outermost matcher
2360                                 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2361                                 len = elems.length;
2363                         if ( outermost ) {
2364                                 outermostContext = context !== document && context;
2365                         }
2367                         // Add elements passing elementMatchers directly to results
2368                         // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2369                         // Support: IE<9, Safari
2370                         // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2371                         for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2372                                 if ( byElement && elem ) {
2373                                         j = 0;
2374                                         while ( (matcher = elementMatchers[j++]) ) {
2375                                                 if ( matcher( elem, context, xml ) ) {
2376                                                         results.push( elem );
2377                                                         break;
2378                                                 }
2379                                         }
2380                                         if ( outermost ) {
2381                                                 dirruns = dirrunsUnique;
2382                                         }
2383                                 }
2385                                 // Track unmatched elements for set filters
2386                                 if ( bySet ) {
2387                                         // They will have gone through all possible matchers
2388                                         if ( (elem = !matcher && elem) ) {
2389                                                 matchedCount--;
2390                                         }
2392                                         // Lengthen the array for every element, matched or not
2393                                         if ( seed ) {
2394                                                 unmatched.push( elem );
2395                                         }
2396                                 }
2397                         }
2399                         // Apply set filters to unmatched elements
2400                         matchedCount += i;
2401                         if ( bySet && i !== matchedCount ) {
2402                                 j = 0;
2403                                 while ( (matcher = setMatchers[j++]) ) {
2404                                         matcher( unmatched, setMatched, context, xml );
2405                                 }
2407                                 if ( seed ) {
2408                                         // Reintegrate element matches to eliminate the need for sorting
2409                                         if ( matchedCount > 0 ) {
2410                                                 while ( i-- ) {
2411                                                         if ( !(unmatched[i] || setMatched[i]) ) {
2412                                                                 setMatched[i] = pop.call( results );
2413                                                         }
2414                                                 }
2415                                         }
2417                                         // Discard index placeholder values to get only actual matches
2418                                         setMatched = condense( setMatched );
2419                                 }
2421                                 // Add matches to results
2422                                 push.apply( results, setMatched );
2424                                 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2425                                 if ( outermost && !seed && setMatched.length > 0 &&
2426                                         ( matchedCount + setMatchers.length ) > 1 ) {
2428                                         Sizzle.uniqueSort( results );
2429                                 }
2430                         }
2432                         // Override manipulation of globals by nested matchers
2433                         if ( outermost ) {
2434                                 dirruns = dirrunsUnique;
2435                                 outermostContext = contextBackup;
2436                         }
2438                         return unmatched;
2439                 };
2441         return bySet ?
2442                 markFunction( superMatcher ) :
2443                 superMatcher;
2446 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2447         var i,
2448                 setMatchers = [],
2449                 elementMatchers = [],
2450                 cached = compilerCache[ selector + " " ];
2452         if ( !cached ) {
2453                 // Generate a function of recursive functions that can be used to check each element
2454                 if ( !match ) {
2455                         match = tokenize( selector );
2456                 }
2457                 i = match.length;
2458                 while ( i-- ) {
2459                         cached = matcherFromTokens( match[i] );
2460                         if ( cached[ expando ] ) {
2461                                 setMatchers.push( cached );
2462                         } else {
2463                                 elementMatchers.push( cached );
2464                         }
2465                 }
2467                 // Cache the compiled function
2468                 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2470                 // Save selector and tokenization
2471                 cached.selector = selector;
2472         }
2473         return cached;
2474 };
2476 /**
2477  * A low-level selection function that works with Sizzle's compiled
2478  *  selector functions
2479  * @param {String|Function} selector A selector or a pre-compiled
2480  *  selector function built with Sizzle.compile
2481  * @param {Element} context
2482  * @param {Array} [results]
2483  * @param {Array} [seed] A set of elements to match against
2484  */
2485 select = Sizzle.select = function( selector, context, results, seed ) {
2486         var i, tokens, token, type, find,
2487                 compiled = typeof selector === "function" && selector,
2488                 match = !seed && tokenize( (selector = compiled.selector || selector) );
2490         results = results || [];
2492         // Try to minimize operations if there is no seed and only one group
2493         if ( match.length === 1 ) {
2495                 // Take a shortcut and set the context if the root selector is an ID
2496                 tokens = match[0] = match[0].slice( 0 );
2497                 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2498                                 support.getById && context.nodeType === 9 && documentIsHTML &&
2499                                 Expr.relative[ tokens[1].type ] ) {
2501                         context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2502                         if ( !context ) {
2503                                 return results;
2505                         // Precompiled matchers will still verify ancestry, so step up a level
2506                         } else if ( compiled ) {
2507                                 context = context.parentNode;
2508                         }
2510                         selector = selector.slice( tokens.shift().value.length );
2511                 }
2513                 // Fetch a seed set for right-to-left matching
2514                 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2515                 while ( i-- ) {
2516                         token = tokens[i];
2518                         // Abort if we hit a combinator
2519                         if ( Expr.relative[ (type = token.type) ] ) {
2520                                 break;
2521                         }
2522                         if ( (find = Expr.find[ type ]) ) {
2523                                 // Search, expanding context for leading sibling combinators
2524                                 if ( (seed = find(
2525                                         token.matches[0].replace( runescape, funescape ),
2526                                         rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2527                                 )) ) {
2529                                         // If seed is empty or no tokens remain, we can return early
2530                                         tokens.splice( i, 1 );
2531                                         selector = seed.length && toSelector( tokens );
2532                                         if ( !selector ) {
2533                                                 push.apply( results, seed );
2534                                                 return results;
2535                                         }
2537                                         break;
2538                                 }
2539                         }
2540                 }
2541         }
2543         // Compile and execute a filtering function if one is not provided
2544         // Provide `match` to avoid retokenization if we modified the selector above
2545         ( compiled || compile( selector, match ) )(
2546                 seed,
2547                 context,
2548                 !documentIsHTML,
2549                 results,
2550                 rsibling.test( selector ) && testContext( context.parentNode ) || context
2551         );
2552         return results;
2553 };
2555 // One-time assignments
2557 // Sort stability
2558 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2560 // Support: Chrome<14
2561 // Always assume duplicates if they aren't passed to the comparison function
2562 support.detectDuplicates = !!hasDuplicate;
2564 // Initialize against the default document
2565 setDocument();
2567 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2568 // Detached nodes confoundingly follow *each other*
2569 support.sortDetached = assert(function( div1 ) {
2570         // Should return 1, but returns 4 (following)
2571         return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2572 });
2574 // Support: IE<8
2575 // Prevent attribute/property "interpolation"
2576 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2577 if ( !assert(function( div ) {
2578         div.innerHTML = "<a href='#'></a>";
2579         return div.firstChild.getAttribute("href") === "#" ;
2580 }) ) {
2581         addHandle( "type|href|height|width", function( elem, name, isXML ) {
2582                 if ( !isXML ) {
2583                         return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2584                 }
2585         });
2588 // Support: IE<9
2589 // Use defaultValue in place of getAttribute("value")
2590 if ( !support.attributes || !assert(function( div ) {
2591         div.innerHTML = "<input/>";
2592         div.firstChild.setAttribute( "value", "" );
2593         return div.firstChild.getAttribute( "value" ) === "";
2594 }) ) {
2595         addHandle( "value", function( elem, name, isXML ) {
2596                 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2597                         return elem.defaultValue;
2598                 }
2599         });
2602 // Support: IE<9
2603 // Use getAttributeNode to fetch booleans when getAttribute lies
2604 if ( !assert(function( div ) {
2605         return div.getAttribute("disabled") == null;
2606 }) ) {
2607         addHandle( booleans, function( elem, name, isXML ) {
2608                 var val;
2609                 if ( !isXML ) {
2610                         return elem[ name ] === true ? name.toLowerCase() :
2611                                         (val = elem.getAttributeNode( name )) && val.specified ?
2612                                         val.value :
2613                                 null;
2614                 }
2615         });
2618 return Sizzle;
2620 })( window );
2624 jQuery.find = Sizzle;
2625 jQuery.expr = Sizzle.selectors;
2626 jQuery.expr[":"] = jQuery.expr.pseudos;
2627 jQuery.unique = Sizzle.uniqueSort;
2628 jQuery.text = Sizzle.getText;
2629 jQuery.isXMLDoc = Sizzle.isXML;
2630 jQuery.contains = Sizzle.contains;
2634 var rneedsContext = jQuery.expr.match.needsContext;
2636 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2640 var risSimple = /^.[^:#\[\.,]*$/;
2642 // Implement the identical functionality for filter and not
2643 function winnow( elements, qualifier, not ) {
2644         if ( jQuery.isFunction( qualifier ) ) {
2645                 return jQuery.grep( elements, function( elem, i ) {
2646                         /* jshint -W018 */
2647                         return !!qualifier.call( elem, i, elem ) !== not;
2648                 });
2650         }
2652         if ( qualifier.nodeType ) {
2653                 return jQuery.grep( elements, function( elem ) {
2654                         return ( elem === qualifier ) !== not;
2655                 });
2657         }
2659         if ( typeof qualifier === "string" ) {
2660                 if ( risSimple.test( qualifier ) ) {
2661                         return jQuery.filter( qualifier, elements, not );
2662                 }
2664                 qualifier = jQuery.filter( qualifier, elements );
2665         }
2667         return jQuery.grep( elements, function( elem ) {
2668                 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
2669         });
2672 jQuery.filter = function( expr, elems, not ) {
2673         var elem = elems[ 0 ];
2675         if ( not ) {
2676                 expr = ":not(" + expr + ")";
2677         }
2679         return elems.length === 1 && elem.nodeType === 1 ?
2680                 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2681                 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2682                         return elem.nodeType === 1;
2683                 }));
2684 };
2686 jQuery.fn.extend({
2687         find: function( selector ) {
2688                 var i,
2689                         ret = [],
2690                         self = this,
2691                         len = self.length;
2693                 if ( typeof selector !== "string" ) {
2694                         return this.pushStack( jQuery( selector ).filter(function() {
2695                                 for ( i = 0; i < len; i++ ) {
2696                                         if ( jQuery.contains( self[ i ], this ) ) {
2697                                                 return true;
2698                                         }
2699                                 }
2700                         }) );
2701                 }
2703                 for ( i = 0; i < len; i++ ) {
2704                         jQuery.find( selector, self[ i ], ret );
2705                 }
2707                 // Needed because $( selector, context ) becomes $( context ).find( selector )
2708                 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2709                 ret.selector = this.selector ? this.selector + " " + selector : selector;
2710                 return ret;
2711         },
2712         filter: function( selector ) {
2713                 return this.pushStack( winnow(this, selector || [], false) );
2714         },
2715         not: function( selector ) {
2716                 return this.pushStack( winnow(this, selector || [], true) );
2717         },
2718         is: function( selector ) {
2719                 return !!winnow(
2720                         this,
2722                         // If this is a positional/relative selector, check membership in the returned set
2723                         // so $("p:first").is("p:last") won't return true for a doc with two "p".
2724                         typeof selector === "string" && rneedsContext.test( selector ) ?
2725                                 jQuery( selector ) :
2726                                 selector || [],
2727                         false
2728                 ).length;
2729         }
2730 });
2733 // Initialize a jQuery object
2736 // A central reference to the root jQuery(document)
2737 var rootjQuery,
2739         // Use the correct document accordingly with window argument (sandbox)
2740         document = window.document,
2742         // A simple way to check for HTML strings
2743         // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2744         // Strict HTML recognition (#11290: must start with <)
2745         rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2747         init = jQuery.fn.init = function( selector, context ) {
2748                 var match, elem;
2750                 // HANDLE: $(""), $(null), $(undefined), $(false)
2751                 if ( !selector ) {
2752                         return this;
2753                 }
2755                 // Handle HTML strings
2756                 if ( typeof selector === "string" ) {
2757                         if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
2758                                 // Assume that strings that start and end with <> are HTML and skip the regex check
2759                                 match = [ null, selector, null ];
2761                         } else {
2762                                 match = rquickExpr.exec( selector );
2763                         }
2765                         // Match html or make sure no context is specified for #id
2766                         if ( match && (match[1] || !context) ) {
2768                                 // HANDLE: $(html) -> $(array)
2769                                 if ( match[1] ) {
2770                                         context = context instanceof jQuery ? context[0] : context;
2772                                         // scripts is true for back-compat
2773                                         // Intentionally let the error be thrown if parseHTML is not present
2774                                         jQuery.merge( this, jQuery.parseHTML(
2775                                                 match[1],
2776                                                 context && context.nodeType ? context.ownerDocument || context : document,
2777                                                 true
2778                                         ) );
2780                                         // HANDLE: $(html, props)
2781                                         if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
2782                                                 for ( match in context ) {
2783                                                         // Properties of context are called as methods if possible
2784                                                         if ( jQuery.isFunction( this[ match ] ) ) {
2785                                                                 this[ match ]( context[ match ] );
2787                                                         // ...and otherwise set as attributes
2788                                                         } else {
2789                                                                 this.attr( match, context[ match ] );
2790                                                         }
2791                                                 }
2792                                         }
2794                                         return this;
2796                                 // HANDLE: $(#id)
2797                                 } else {
2798                                         elem = document.getElementById( match[2] );
2800                                         // Check parentNode to catch when Blackberry 4.6 returns
2801                                         // nodes that are no longer in the document #6963
2802                                         if ( elem && elem.parentNode ) {
2803                                                 // Handle the case where IE and Opera return items
2804                                                 // by name instead of ID
2805                                                 if ( elem.id !== match[2] ) {
2806                                                         return rootjQuery.find( selector );
2807                                                 }
2809                                                 // Otherwise, we inject the element directly into the jQuery object
2810                                                 this.length = 1;
2811                                                 this[0] = elem;
2812                                         }
2814                                         this.context = document;
2815                                         this.selector = selector;
2816                                         return this;
2817                                 }
2819                         // HANDLE: $(expr, $(...))
2820                         } else if ( !context || context.jquery ) {
2821                                 return ( context || rootjQuery ).find( selector );
2823                         // HANDLE: $(expr, context)
2824                         // (which is just equivalent to: $(context).find(expr)
2825                         } else {
2826                                 return this.constructor( context ).find( selector );
2827                         }
2829                 // HANDLE: $(DOMElement)
2830                 } else if ( selector.nodeType ) {
2831                         this.context = this[0] = selector;
2832                         this.length = 1;
2833                         return this;
2835                 // HANDLE: $(function)
2836                 // Shortcut for document ready
2837                 } else if ( jQuery.isFunction( selector ) ) {
2838                         return typeof rootjQuery.ready !== "undefined" ?
2839                                 rootjQuery.ready( selector ) :
2840                                 // Execute immediately if ready is not present
2841                                 selector( jQuery );
2842                 }
2844                 if ( selector.selector !== undefined ) {
2845                         this.selector = selector.selector;
2846                         this.context = selector.context;
2847                 }
2849                 return jQuery.makeArray( selector, this );
2850         };
2852 // Give the init function the jQuery prototype for later instantiation
2853 init.prototype = jQuery.fn;
2855 // Initialize central reference
2856 rootjQuery = jQuery( document );
2859 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2860         // methods guaranteed to produce a unique set when starting from a unique set
2861         guaranteedUnique = {
2862                 children: true,
2863                 contents: true,
2864                 next: true,
2865                 prev: true
2866         };
2868 jQuery.extend({
2869         dir: function( elem, dir, until ) {
2870                 var matched = [],
2871                         cur = elem[ dir ];
2873                 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
2874                         if ( cur.nodeType === 1 ) {
2875                                 matched.push( cur );
2876                         }
2877                         cur = cur[dir];
2878                 }
2879                 return matched;
2880         },
2882         sibling: function( n, elem ) {
2883                 var r = [];
2885                 for ( ; n; n = n.nextSibling ) {
2886                         if ( n.nodeType === 1 && n !== elem ) {
2887                                 r.push( n );
2888                         }
2889                 }
2891                 return r;
2892         }
2893 });
2895 jQuery.fn.extend({
2896         has: function( target ) {