2 * jQuery JavaScript Library v1.11.0
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2014-01-23T21:02Z
15 // modified by Bob Hanson for local MSIE 11 reading remote files
17 (function( global, factory ) {
19 if ( typeof module === "object" && typeof module.exports === "object" ) {
20 // For CommonJS and CommonJS-like environments where a proper window is present,
21 // execute the factory and get jQuery
22 // For environments that do not inherently posses a window with a document
23 // (such as Node.js), expose a jQuery-making factory as module.exports
24 // This accentuates the need for the creation of a real window
25 // e.g. var jQuery = require("jquery")(window);
26 // See ticket #14549 for more info
27 module.exports = global.document ?
28 factory( global, true ) :
31 throw new Error( "jQuery requires a window with a document" );
39 // Pass this if window is not defined yet
40 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
42 // Can't do this because several apps including ASP.NET trace
43 // the stack via arguments.caller.callee and Firefox dies if
44 // you try to trace through "use strict" call chains. (#13335)
45 // Support: Firefox 18+
50 var slice = deletedIds.slice;
52 var concat = deletedIds.concat;
54 var push = deletedIds.push;
56 var indexOf = deletedIds.indexOf;
60 var toString = class2type.toString;
62 var hasOwn = class2type.hasOwnProperty;
73 // Define a local copy of jQuery
74 jQuery = function( selector, context ) {
75 // The jQuery object is actually just the init constructor 'enhanced'
76 // Need init if jQuery is called (just allow error to be thrown if not included)
77 return new jQuery.fn.init( selector, context );
80 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
81 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
83 // Matches dashed string for camelizing
85 rdashAlpha = /-([\da-z])/gi,
87 // Used by jQuery.camelCase as callback to replace()
88 fcamelCase = function( all, letter ) {
89 return letter.toUpperCase();
92 jQuery.fn = jQuery.prototype = {
93 // The current version of jQuery being used
98 // Start with an empty selector
101 // The default length of a jQuery object is 0
104 toArray: function() {
105 return slice.call( this );
108 // Get the Nth element in the matched element set OR
109 // Get the whole matched element set as a clean array
110 get: function( num ) {
113 // Return a 'clean' array
114 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
116 // Return just the object
120 // Take an array of elements and push it onto the stack
121 // (returning the new matched element set)
122 pushStack: function( elems ) {
124 // Build a new jQuery matched element set
125 var ret = jQuery.merge( this.constructor(), elems );
127 // Add the old object onto the stack (as a reference)
128 ret.prevObject = this;
129 ret.context = this.context;
131 // Return the newly-formed element set
135 // Execute a callback for every element in the matched set.
136 // (You can seed the arguments with an array of args, but this is
137 // only used internally.)
138 each: function( callback, args ) {
139 return jQuery.each( this, callback, args );
142 map: function( callback ) {
143 return this.pushStack( jQuery.map(this, function( elem, i ) {
144 return callback.call( elem, i, elem );
149 return this.pushStack( slice.apply( this, arguments ) );
157 return this.eq( -1 );
161 var len = this.length,
162 j = +i + ( i < 0 ? len : 0 );
163 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
167 return this.prevObject || this.constructor(null);
170 // For internal use only.
171 // Behaves like an Array's method, not like a jQuery method.
173 sort: deletedIds.sort,
174 splice: deletedIds.splice
177 jQuery.extend = jQuery.fn.extend = function() {
178 var src, copyIsArray, copy, name, options, clone,
179 target = arguments[0] || {},
181 length = arguments.length,
184 // Handle a deep copy situation
185 if ( typeof target === "boolean" ) {
188 // skip the boolean and the target
189 target = arguments[ i ] || {};
193 // Handle case when target is a string or something (possible in deep copy)
194 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
198 // extend jQuery itself if only one argument is passed
199 if ( i === length ) {
204 for ( ; i < length; i++ ) {
205 // Only deal with non-null/undefined values
206 if ( (options = arguments[ i ]) != null ) {
207 // Extend the base object
208 for ( name in options ) {
209 src = target[ name ];
210 copy = options[ name ];
212 // Prevent never-ending loop
213 if ( target === copy ) {
217 // Recurse if we're merging plain objects or arrays
218 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
221 clone = src && jQuery.isArray(src) ? src : [];
224 clone = src && jQuery.isPlainObject(src) ? src : {};
227 // Never move original objects, clone them
228 target[ name ] = jQuery.extend( deep, clone, copy );
230 // Don't bring in undefined values
231 } else if ( copy !== undefined ) {
232 target[ name ] = copy;
238 // Return the modified object
243 // Unique for each copy of jQuery on the page
244 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
246 // Assume jQuery is ready without the ready module
249 error: function( msg ) {
250 throw new Error( msg );
255 // See test/unit/core.js for details concerning isFunction.
256 // Since version 1.3, DOM methods and functions like alert
257 // aren't supported. They return false on IE (#2968).
258 isFunction: function( obj ) {
259 return jQuery.type(obj) === "function";
262 isArray: Array.isArray || function( obj ) {
263 return jQuery.type(obj) === "array";
266 isWindow: function( obj ) {
267 /* jshint eqeqeq: false */
268 return obj != null && obj == obj.window;
271 isNumeric: function( obj ) {
272 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
273 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
274 // subtraction forces infinities to NaN
275 return obj - parseFloat( obj ) >= 0;
278 isEmptyObject: function( obj ) {
280 for ( name in obj ) {
286 isPlainObject: function( obj ) {
289 // Must be an Object.
290 // Because of IE, we also have to check the presence of the constructor property.
291 // Make sure that DOM nodes and window objects don't pass through, as well
292 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
297 // Not own constructor property must be Object
298 if ( obj.constructor &&
299 !hasOwn.call(obj, "constructor") &&
300 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
304 // IE8,9 Will throw exceptions on certain host objects #9897
309 // Handle iteration over inherited properties before own properties.
310 if ( support.ownLast ) {
312 return hasOwn.call( obj, key );
316 // Own properties are enumerated firstly, so to speed up,
317 // if last one is own, then all properties are own.
318 for ( key in obj ) {}
320 return key === undefined || hasOwn.call( obj, key );
323 type: function( obj ) {
327 return typeof obj === "object" || typeof obj === "function" ?
328 class2type[ toString.call(obj) ] || "object" :
332 // Evaluates a script in a global context
333 // Workarounds based on findings by Jim Driscoll
334 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
335 globalEval: function( data ) {
336 if ( data && jQuery.trim( data ) ) {
337 // We use execScript on Internet Explorer
338 // We use an anonymous function so that context is window
339 // rather than jQuery in Firefox
340 ( window.execScript || function( data ) {
341 window[ "eval" ].call( window, data );
346 // Convert dashed to camelCase; used by the css and data modules
347 // Microsoft forgot to hump their vendor prefix (#9572)
348 camelCase: function( string ) {
349 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
352 nodeName: function( elem, name ) {
353 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
356 // args is for internal usage only
357 each: function( obj, callback, args ) {
361 isArray = isArraylike( obj );
365 for ( ; i < length; i++ ) {
366 value = callback.apply( obj[ i ], args );
368 if ( value === false ) {
374 value = callback.apply( obj[ i ], args );
376 if ( value === false ) {
382 // A special, fast, case for the most common use of each
385 for ( ; i < length; i++ ) {
386 value = callback.call( obj[ i ], i, obj[ i ] );
388 if ( value === false ) {
394 value = callback.call( obj[ i ], i, obj[ i ] );
396 if ( value === false ) {
406 // Use native String.trim function wherever possible
407 trim: trim && !trim.call("\uFEFF\xA0") ?
409 return text == null ?
414 // Otherwise use our own trimming functionality
416 return text == null ?
418 ( text + "" ).replace( rtrim, "" );
421 // results is for internal usage only
422 makeArray: function( arr, results ) {
423 var ret = results || [];
426 if ( isArraylike( Object(arr) ) ) {
428 typeof arr === "string" ?
432 push.call( ret, arr );
439 inArray: function( elem, arr, i ) {
444 return indexOf.call( arr, elem, i );
448 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
450 for ( ; i < len; i++ ) {
451 // Skip accessing in sparse arrays
452 if ( i in arr && arr[ i ] === elem ) {
461 merge: function( first, second ) {
462 var len = +second.length,
467 first[ i++ ] = second[ j++ ];
471 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
473 while ( second[j] !== undefined ) {
474 first[ i++ ] = second[ j++ ];
483 grep: function( elems, callback, invert ) {
487 length = elems.length,
488 callbackExpect = !invert;
490 // Go through the array, only saving the items
491 // that pass the validator function
492 for ( ; i < length; i++ ) {
493 callbackInverse = !callback( elems[ i ], i );
494 if ( callbackInverse !== callbackExpect ) {
495 matches.push( elems[ i ] );
502 // arg is for internal usage only
503 map: function( elems, callback, arg ) {
506 length = elems.length,
507 isArray = isArraylike( elems ),
510 // Go through the array, translating each of the items to their new values
512 for ( ; i < length; i++ ) {
513 value = callback( elems[ i ], i, arg );
515 if ( value != null ) {
520 // Go through every key on the object,
523 value = callback( elems[ i ], i, arg );
525 if ( value != null ) {
531 // Flatten any nested arrays
532 return concat.apply( [], ret );
535 // A global GUID counter for objects
538 // Bind a function to a context, optionally partially applying any
540 proxy: function( fn, context ) {
541 var args, proxy, tmp;
543 if ( typeof context === "string" ) {
549 // Quick check to determine if target is callable, in the spec
550 // this throws a TypeError, but we will just return undefined.
551 if ( !jQuery.isFunction( fn ) ) {
556 args = slice.call( arguments, 2 );
558 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
561 // Set the guid of unique handler to the same of original handler, so it can be removed
562 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
568 return +( new Date() );
571 // jQuery.support is not used in Core but other projects attach their
572 // properties to it so it needs to exist.
576 // Populate the class2type map
577 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
578 class2type[ "[object " + name + "]" ] = name.toLowerCase();
581 function isArraylike( obj ) {
582 var length = obj.length,
583 type = jQuery.type( obj );
585 if ( type === "function" || jQuery.isWindow( obj ) ) {
589 if ( obj.nodeType === 1 && length ) {
593 return type === "array" || length === 0 ||
594 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
598 * Sizzle CSS Selector Engine v1.10.16
599 * http://sizzlejs.com/
601 * Copyright 2013 jQuery Foundation, Inc. and other contributors
602 * Released under the MIT license
603 * http://jquery.org/license
607 (function( window ) {
619 // Local document vars
629 // Instance-specific data
630 expando = "sizzle" + -(new Date()),
631 preferredDoc = window.document,
634 classCache = createCache(),
635 tokenCache = createCache(),
636 compilerCache = createCache(),
637 sortOrder = function( a, b ) {
644 // General-purpose constants
645 strundefined = typeof undefined,
646 MAX_NEGATIVE = 1 << 31,
649 hasOwn = ({}).hasOwnProperty,
652 push_native = arr.push,
655 // Use a stripped-down indexOf if we can't use a native one
656 indexOf = arr.indexOf || function( elem ) {
659 for ( ; i < len; i++ ) {
660 if ( this[i] === elem ) {
667 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
669 // Regular expressions
671 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
672 whitespace = "[\\x20\\t\\r\\n\\f]",
673 // http://www.w3.org/TR/css3-syntax/#characters
674 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
676 // Loosely modeled on CSS identifier characters
677 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
678 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
679 identifier = characterEncoding.replace( "w", "w#" ),
681 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
682 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
683 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
685 // Prefer arguments quoted,
686 // then not containing pseudos/brackets,
687 // then attribute selectors/non-parenthetical expressions,
688 // then anything else
689 // These preferences are here to reduce the number of selectors
690 // needing tokenize in the PSEUDO preFilter
691 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
693 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
694 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
696 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
697 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
699 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
701 rpseudo = new RegExp( pseudos ),
702 ridentifier = new RegExp( "^" + identifier + "$" ),
705 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
706 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
707 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
708 "ATTR": new RegExp( "^" + attributes ),
709 "PSEUDO": new RegExp( "^" + pseudos ),
710 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
711 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
712 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
713 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
714 // For use in libraries implementing .is()
715 // We use this for POS matching in `select`
716 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
717 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
720 rinputs = /^(?:input|select|textarea|button)$/i,
723 rnative = /^[^{]+\{\s*\[native \w/,
725 // Easily-parseable/retrievable ID or TAG or CLASS selectors
726 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
731 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
732 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
733 funescape = function( _, escaped, escapedWhitespace ) {
734 var high = "0x" + escaped - 0x10000;
735 // NaN means non-codepoint
737 // Workaround erroneous numeric interpretation of +"0x"
738 return high !== high || escapedWhitespace ?
742 String.fromCharCode( high + 0x10000 ) :
743 // Supplemental Plane codepoint (surrogate pair)
744 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
747 // Optimize for push.apply( _, NodeList )
750 (arr = slice.call( preferredDoc.childNodes )),
751 preferredDoc.childNodes
753 // Support: Android<4.0
754 // Detect silently failing push.apply
755 arr[ preferredDoc.childNodes.length ].nodeType;
757 push = { apply: arr.length ?
759 // Leverage slice if possible
760 function( target, els ) {
761 push_native.apply( target, slice.call(els) );
765 // Otherwise append directly
766 function( target, els ) {
767 var j = target.length,
769 // Can't trust NodeList.length
770 while ( (target[j++] = els[i++]) ) {}
771 target.length = j - 1;
776 function Sizzle( selector, context, results, seed ) {
777 var match, elem, m, nodeType,
779 i, groups, old, nid, newContext, newSelector;
781 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
782 setDocument( context );
785 context = context || document;
786 results = results || [];
788 if ( !selector || typeof selector !== "string" ) {
792 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
796 if ( documentIsHTML && !seed ) {
799 if ( (match = rquickExpr.exec( selector )) ) {
800 // Speed-up: Sizzle("#ID")
801 if ( (m = match[1]) ) {
802 if ( nodeType === 9 ) {
803 elem = context.getElementById( m );
804 // Check parentNode to catch when Blackberry 4.6 returns
805 // nodes that are no longer in the document (jQuery #6963)
806 if ( elem && elem.parentNode ) {
807 // Handle the case where IE, Opera, and Webkit return items
808 // by name instead of ID
809 if ( elem.id === m ) {
810 results.push( elem );
817 // Context is not a document
818 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
819 contains( context, elem ) && elem.id === m ) {
820 results.push( elem );
825 // Speed-up: Sizzle("TAG")
826 } else if ( match[2] ) {
827 push.apply( results, context.getElementsByTagName( selector ) );
830 // Speed-up: Sizzle(".CLASS")
831 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
832 push.apply( results, context.getElementsByClassName( m ) );
838 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
840 newContext = context;
841 newSelector = nodeType === 9 && selector;
843 // qSA works strangely on Element-rooted queries
844 // We can work around this by specifying an extra ID on the root
845 // and working up from there (Thanks to Andrew Dupont for the technique)
846 // IE 8 doesn't work on object elements
847 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
848 groups = tokenize( selector );
850 if ( (old = context.getAttribute("id")) ) {
851 nid = old.replace( rescape, "\\$&" );
853 context.setAttribute( "id", nid );
855 nid = "[id='" + nid + "'] ";
859 groups[i] = nid + toSelector( groups[i] );
861 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
862 newSelector = groups.join(",");
868 newContext.querySelectorAll( newSelector )
874 context.removeAttribute("id");
882 return select( selector.replace( rtrim, "$1" ), context, results, seed );
886 * Create key-value caches of limited size
887 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
888 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
889 * deleting the oldest entry
891 function createCache() {
894 function cache( key, value ) {
895 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
896 if ( keys.push( key + " " ) > Expr.cacheLength ) {
897 // Only keep the most recent entries
898 delete cache[ keys.shift() ];
900 return (cache[ key + " " ] = value);
906 * Mark a function for special use by Sizzle
907 * @param {Function} fn The function to mark
909 function markFunction( fn ) {
910 fn[ expando ] = true;
915 * Support testing using an element
916 * @param {Function} fn Passed the created div and expects a boolean result
918 function assert( fn ) {
919 var div = document.createElement("div");
926 // Remove from its parent by default
927 if ( div.parentNode ) {
928 div.parentNode.removeChild( div );
930 // release memory in IE
936 * Adds the same handler for all of the specified attrs
937 * @param {String} attrs Pipe-separated list of attributes
938 * @param {Function} handler The method that will be applied
940 function addHandle( attrs, handler ) {
941 var arr = attrs.split("|"),
945 Expr.attrHandle[ arr[i] ] = handler;
950 * Checks document order of two siblings
953 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
955 function siblingCheck( a, b ) {
957 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
958 ( ~b.sourceIndex || MAX_NEGATIVE ) -
959 ( ~a.sourceIndex || MAX_NEGATIVE );
961 // Use IE sourceIndex if available on both nodes
966 // Check if b follows a
968 while ( (cur = cur.nextSibling) ) {
979 * Returns a function to use in pseudos for input types
980 * @param {String} type
982 function createInputPseudo( type ) {
983 return function( elem ) {
984 var name = elem.nodeName.toLowerCase();
985 return name === "input" && elem.type === type;
990 * Returns a function to use in pseudos for buttons
991 * @param {String} type
993 function createButtonPseudo( type ) {
994 return function( elem ) {
995 var name = elem.nodeName.toLowerCase();
996 return (name === "input" || name === "button") && elem.type === type;
1001 * Returns a function to use in pseudos for positionals
1002 * @param {Function} fn
1004 function createPositionalPseudo( fn ) {
1005 return markFunction(function( argument ) {
1006 argument = +argument;
1007 return markFunction(function( seed, matches ) {
1009 matchIndexes = fn( [], seed.length, argument ),
1010 i = matchIndexes.length;
1012 // Match elements found at the specified indexes
1014 if ( seed[ (j = matchIndexes[i]) ] ) {
1015 seed[j] = !(matches[j] = seed[j]);
1023 * Checks a node for validity as a Sizzle context
1024 * @param {Element|Object=} context
1025 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1027 function testContext( context ) {
1028 return context && typeof context.getElementsByTagName !== strundefined && context;
1031 // Expose support vars for convenience
1032 support = Sizzle.support = {};
1036 * @param {Element|Object} elem An element or a document
1037 * @returns {Boolean} True iff elem is a non-HTML XML node
1039 isXML = Sizzle.isXML = function( elem ) {
1040 // documentElement is verified for cases where it doesn't yet exist
1041 // (such as loading iframes in IE - #4833)
1042 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1043 return documentElement ? documentElement.nodeName !== "HTML" : false;
1047 * Sets document-related variables once based on the current document
1048 * @param {Element|Object} [doc] An element or document object to use to set the document
1049 * @returns {Object} Returns the current document
1051 setDocument = Sizzle.setDocument = function( node ) {
1053 doc = node ? node.ownerDocument || node : preferredDoc,
1054 parent = doc.defaultView;
1056 // If no document and documentElement is available, return
1057 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1063 docElem = doc.documentElement;
1066 documentIsHTML = !isXML( doc );
1069 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1070 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1071 // IE6-8 do not support the defaultView property so parent will be undefined
1072 if ( parent && parent !== parent.top ) {
1073 // IE11 does not have attachEvent, so all must suffer
1074 if ( parent.addEventListener ) {
1075 parent.addEventListener( "unload", function() {
1078 } else if ( parent.attachEvent ) {
1079 parent.attachEvent( "onunload", function() {
1086 ---------------------------------------------------------------------- */
1089 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1090 support.attributes = assert(function( div ) {
1091 div.className = "i";
1092 return !div.getAttribute("className");
1096 ---------------------------------------------------------------------- */
1098 // Check if getElementsByTagName("*") returns only elements
1099 support.getElementsByTagName = assert(function( div ) {
1100 div.appendChild( doc.createComment("") );
1101 return !div.getElementsByTagName("*").length;
1104 // Check if getElementsByClassName can be trusted
1105 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
1106 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
1108 // Support: Safari<4
1109 // Catch class over-caching
1110 div.firstChild.className = "i";
1111 // Support: Opera<10
1112 // Catch gEBCN failure to find non-leading classes
1113 return div.getElementsByClassName("i").length === 2;
1117 // Check if getElementById returns elements by name
1118 // The broken getElementById methods don't pick up programatically-set names,
1119 // so use a roundabout getElementsByName test
1120 support.getById = assert(function( div ) {
1121 docElem.appendChild( div ).id = expando;
1122 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
1125 // ID find and filter
1126 if ( support.getById ) {
1127 Expr.find["ID"] = function( id, context ) {
1128 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
1129 var m = context.getElementById( id );
1130 // Check parentNode to catch when Blackberry 4.6 returns
1131 // nodes that are no longer in the document #6963
1132 return m && m.parentNode ? [m] : [];
1135 Expr.filter["ID"] = function( id ) {
1136 var attrId = id.replace( runescape, funescape );
1137 return function( elem ) {
1138 return elem.getAttribute("id") === attrId;
1143 // getElementById is not reliable as a find shortcut
1144 delete Expr.find["ID"];
1146 Expr.filter["ID"] = function( id ) {
1147 var attrId = id.replace( runescape, funescape );
1148 return function( elem ) {
1149 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
1150 return node && node.value === attrId;
1156 Expr.find["TAG"] = support.getElementsByTagName ?
1157 function( tag, context ) {
1158 if ( typeof context.getElementsByTagName !== strundefined ) {
1159 return context.getElementsByTagName( tag );
1162 function( tag, context ) {
1166 results = context.getElementsByTagName( tag );
1168 // Filter out possible comments
1169 if ( tag === "*" ) {
1170 while ( (elem = results[i++]) ) {
1171 if ( elem.nodeType === 1 ) {
1182 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1183 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
1184 return context.getElementsByClassName( className );
1188 /* QSA/matchesSelector
1189 ---------------------------------------------------------------------- */
1191 // QSA and matchesSelector support
1193 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1196 // qSa(:focus) reports false when true (Chrome 21)
1197 // We allow this because of a bug in IE8/9 that throws an error
1198 // whenever `document.activeElement` is accessed on an iframe
1199 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1200 // See http://bugs.jquery.com/ticket/13378
1203 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1205 // Regex strategy adopted from Diego Perini
1206 assert(function( div ) {
1207 // Select is set to empty string on purpose
1208 // This is to test IE's treatment of not explicitly
1209 // setting a boolean content attribute,
1210 // since its presence should be enough
1211 // http://bugs.jquery.com/ticket/12359
1212 div.innerHTML = "<select t=''><option selected=''></option></select>";
1214 // Support: IE8, Opera 10-12
1215 // Nothing should be selected when empty strings follow ^= or $= or *=
1216 if ( div.querySelectorAll("[t^='']").length ) {
1217 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1221 // Boolean attributes and "value" are not treated correctly
1222 if ( !div.querySelectorAll("[selected]").length ) {
1223 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1226 // Webkit/Opera - :checked should return selected option elements
1227 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1228 // IE8 throws error here and will not see later tests
1229 if ( !div.querySelectorAll(":checked").length ) {
1230 rbuggyQSA.push(":checked");
1234 assert(function( div ) {
1235 // Support: Windows 8 Native Apps
1236 // The type and name attributes are restricted during .innerHTML assignment
1237 var input = doc.createElement("input");
1238 input.setAttribute( "type", "hidden" );
1239 div.appendChild( input ).setAttribute( "name", "D" );
1242 // Enforce case-sensitivity of name attribute
1243 if ( div.querySelectorAll("[name=d]").length ) {
1244 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1247 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1248 // IE8 throws error here and will not see later tests
1249 if ( !div.querySelectorAll(":enabled").length ) {
1250 rbuggyQSA.push( ":enabled", ":disabled" );
1253 // Opera 10-11 does not throw on post-comma invalid pseudos
1254 div.querySelectorAll("*,:x");
1255 rbuggyQSA.push(",.*:");
1259 if ( (support.matchesSelector = rnative.test( (matches = 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 );
1276 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1277 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
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 ) ?
1288 var adown = a.nodeType === 9 ? a.documentElement : a,
1289 bup = b && b.parentNode;
1290 return a === bup || !!( bup && bup.nodeType === 1 && (
1292 adown.contains( bup ) :
1293 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1298 while ( (b = b.parentNode) ) {
1308 ---------------------------------------------------------------------- */
1310 // Document order sorting
1311 sortOrder = hasCompare ?
1314 // Flag for duplicate removal
1316 hasDuplicate = true;
1320 // Sort on method existence if only one input has compareDocumentPosition
1321 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
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
1333 // Disconnected nodes
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) ) {
1341 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1345 // Maintain original order
1347 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1351 return compare & 4 ? -1 : 1;
1354 // Exit early if the nodes are identical
1356 hasDuplicate = true;
1367 // Parentless nodes are either documents or disconnected
1368 if ( !aup || !bup ) {
1369 return a === doc ? -1 :
1374 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1377 // If the nodes are siblings, we can do a quick check
1378 } else if ( aup === bup ) {
1379 return siblingCheck( a, b );
1382 // Otherwise we need full lists of their ancestors for comparison
1384 while ( (cur = cur.parentNode) ) {
1388 while ( (cur = cur.parentNode) ) {
1392 // Walk down the tree looking for a discrepancy
1393 while ( ap[i] === bp[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 :
1410 Sizzle.matches = function( expr, elements ) {
1411 return Sizzle( expr, null, null, elements );
1414 Sizzle.matchesSelector = function( elem, expr ) {
1415 // Set document vars if needed
1416 if ( ( elem.ownerDocument || elem ) !== document ) {
1417 setDocument( elem );
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 ) ) ) {
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
1434 elem.document && elem.document.nodeType !== 11 ) {
1440 return Sizzle( expr, document, null, [elem] ).length > 0;
1443 Sizzle.contains = function( context, elem ) {
1444 // Set document vars if needed
1445 if ( ( context.ownerDocument || context ) !== document ) {
1446 setDocument( context );
1448 return contains( context, elem );
1451 Sizzle.attr = function( elem, name ) {
1452 // Set document vars if needed
1453 if ( ( elem.ownerDocument || elem ) !== document ) {
1454 setDocument( elem );
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 ) :
1463 return val !== undefined ?
1465 support.attributes || !documentIsHTML ?
1466 elem.getAttribute( name ) :
1467 (val = elem.getAttributeNode(name)) && val.specified ?
1472 Sizzle.error = function( msg ) {
1473 throw new Error( "Syntax error, unrecognized expression: " + msg );
1477 * Document sorting and removing duplicates
1478 * @param {ArrayLike} results
1480 Sizzle.uniqueSort = function( results ) {
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 );
1498 results.splice( duplicates[ j ], 1 );
1502 // Clear input after sorting to release objects
1503 // See https://github.com/jquery/sizzle/pull/225
1510 * Utility function for retrieving the text value of an array of DOM nodes
1511 * @param {Array|Element} elem
1513 getText = Sizzle.getText = function( elem ) {
1517 nodeType = elem.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 );
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;
1531 // Traverse its children
1532 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1533 ret += getText( elem );
1536 } else if ( nodeType === 3 || nodeType === 4 ) {
1537 return elem.nodeValue;
1539 // Do not include comment or processing instruction nodes
1544 Expr = Sizzle.selectors = {
1546 // Can be adjusted by the user
1549 createPseudo: markFunction,
1558 ">": { dir: "parentNode", first: true },
1559 " ": { dir: "parentNode" },
1560 "+": { dir: "previousSibling", first: true },
1561 "~": { dir: "previousSibling" }
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[4] || match[5] || "" ).replace( runescape, funescape );
1571 if ( match[2] === "~=" ) {
1572 match[3] = " " + match[3] + " ";
1575 return match.slice( 0, 4 );
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
1586 7 sign of y-component
1589 match[1] = match[1].toLowerCase();
1591 if ( match[1].slice( 0, 3 ) === "nth" ) {
1592 // nth-* requires argument
1594 Sizzle.error( match[0] );
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] );
1610 "PSEUDO": function( match ) {
1612 unquoted = !match[5] && match[2];
1614 if ( matchExpr["CHILD"].test( match[0] ) ) {
1618 // Accept quoted arguments as-is
1619 if ( match[3] && match[4] !== undefined ) {
1620 match[2] = match[4];
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 );
1634 // Return only captures needed by the pseudo filter method (type and argument)
1635 return match.slice( 0, 3 );
1641 "TAG": function( nodeNameSelector ) {
1642 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1643 return nodeNameSelector === "*" ?
1644 function() { return true; } :
1646 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1650 "CLASS": function( className ) {
1651 var pattern = classCache[ className + " " ];
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") || "" );
1660 "ATTR": function( name, operator, check ) {
1661 return function( elem ) {
1662 var result = Sizzle.attr( elem, name );
1664 if ( result == null ) {
1665 return operator === "!=";
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 + "-" :
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)
1693 return !!elem.parentNode;
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;
1705 // :(first|last|only)-(child|of-type)
1709 while ( (node = node[ dir ]) ) {
1710 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1714 // Reverse direction for :only-* (if we haven't yet done so)
1715 start = dir = type === "only" && !start && "nextSibling";
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 ];
1743 // Use previously-cached element index if available
1744 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1747 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
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
1756 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1759 if ( node === elem ) {
1766 // Incorporate the offset, then check against cycle size
1768 return diff === first || ( diff % first === 0 && diff / first >= 0 );
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
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 );
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 ) {
1795 matched = fn( seed, argument ),
1798 idx = indexOf.call( seed, matched[i] );
1799 seed[ idx ] = !( matches[ idx ] = matched[i] );
1803 return fn( elem, 0, args );
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
1819 matcher = compile( selector.replace( rtrim, "$1" ) );
1821 return matcher[ expando ] ?
1822 markFunction(function( seed, matches, context, xml ) {
1824 unmatched = matcher( seed, null, xml, [] ),
1827 // Match elements unmatched by `matcher`
1829 if ( (elem = unmatched[i]) ) {
1830 seed[i] = !(matches[i] = elem);
1834 function( elem, context, xml ) {
1836 matcher( input, null, xml, results );
1837 return !results.pop();
1841 "has": markFunction(function( selector ) {
1842 return function( elem ) {
1843 return Sizzle( selector, elem ).length > 0;
1847 "contains": markFunction(function( text ) {
1848 return function( elem ) {
1849 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
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 );
1865 lang = lang.replace( runescape, funescape ).toLowerCase();
1866 return function( elem ) {
1869 if ( (elemLang = documentIsHTML ?
1871 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1873 elemLang = elemLang.toLowerCase();
1874 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1876 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1882 "target": function( elem ) {
1883 var hash = window.location && window.location.hash;
1884 return hash && hash.slice( 1 ) === elem.id;
1887 "root": function( elem ) {
1888 return elem === docElem;
1891 "focus": function( elem ) {
1892 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1895 // Boolean properties
1896 "enabled": function( elem ) {
1897 return elem.disabled === false;
1900 "disabled": function( elem ) {
1901 return elem.disabled === true;
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);
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;
1918 return elem.selected === true;
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 ) {
1935 "parent": function( elem ) {
1936 return !Expr.pseudos["empty"]( elem );
1939 // Element/input types
1940 "header": function( elem ) {
1941 return rheader.test( elem.nodeName );
1944 "input": function( elem ) {
1945 return rinputs.test( elem.nodeName );
1948 "button": function( elem ) {
1949 var name = elem.nodeName.toLowerCase();
1950 return name === "input" && elem.type === "button" || name === "button";
1953 "text": function( elem ) {
1955 return elem.nodeName.toLowerCase() === "input" &&
1956 elem.type === "text" &&
1959 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1960 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1963 // Position-in-collection
1964 "first": createPositionalPseudo(function() {
1968 "last": createPositionalPseudo(function( matchIndexes, length ) {
1969 return [ length - 1 ];
1972 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1973 return [ argument < 0 ? argument + length : argument ];
1976 "even": createPositionalPseudo(function( matchIndexes, length ) {
1978 for ( ; i < length; i += 2 ) {
1979 matchIndexes.push( i );
1981 return matchIndexes;
1984 "odd": createPositionalPseudo(function( matchIndexes, length ) {
1986 for ( ; i < length; i += 2 ) {
1987 matchIndexes.push( i );
1989 return matchIndexes;
1992 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1993 var i = argument < 0 ? argument + length : argument;
1994 for ( ; --i >= 0; ) {
1995 matchIndexes.push( i );
1997 return matchIndexes;
2000 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2001 var i = argument < 0 ? argument + length : argument;
2002 for ( ; ++i < length; ) {
2003 matchIndexes.push( i );
2005 return matchIndexes;
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 function tokenize( selector, parseOnly ) {
2026 var matched, match, tokens, type,
2027 soFar, groups, preFilters,
2028 cached = tokenCache[ selector + " " ];
2031 return parseOnly ? 0 : cached.slice( 0 );
2036 preFilters = Expr.preFilter;
2040 // Comma and first run
2041 if ( !matched || (match = rcomma.exec( soFar )) ) {
2043 // Don't consume trailing commas as valid
2044 soFar = soFar.slice( match[0].length ) || soFar;
2046 groups.push( (tokens = []) );
2052 if ( (match = rcombinators.exec( soFar )) ) {
2053 matched = match.shift();
2056 // Cast descendant combinators to space
2057 type: match[0].replace( rtrim, " " )
2059 soFar = soFar.slice( matched.length );
2063 for ( type in Expr.filter ) {
2064 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2065 (match = preFilters[ type ]( match ))) ) {
2066 matched = match.shift();
2072 soFar = soFar.slice( matched.length );
2081 // Return the length of the invalid excess
2082 // if we're just parsing
2083 // Otherwise, throw an error or return tokens
2087 Sizzle.error( selector ) :
2089 tokenCache( selector, groups ).slice( 0 );
2092 function toSelector( tokens ) {
2094 len = tokens.length,
2096 for ( ; i < len; i++ ) {
2097 selector += tokens[i].value;
2102 function addCombinator( matcher, combinator, base ) {
2103 var dir = combinator.dir,
2104 checkNonElements = base && dir === "parentNode",
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 );
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
2124 while ( (elem = elem[ dir ]) ) {
2125 if ( elem.nodeType === 1 || checkNonElements ) {
2126 if ( matcher( elem, context, xml ) ) {
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 ]);
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 )) ) {
2155 function elementMatcher( matchers ) {
2156 return matchers.length > 1 ?
2157 function( elem, context, xml ) {
2158 var i = matchers.length;
2160 if ( !matchers[i]( elem, context, xml ) ) {
2169 function condense( unmatched, map, filter, context, xml ) {
2173 len = unmatched.length,
2174 mapped = map != null;
2176 for ( ; i < len; i++ ) {
2177 if ( (elem = unmatched[i]) ) {
2178 if ( !filter || filter( elem, context, xml ) ) {
2179 newUnmatched.push( elem );
2187 return newUnmatched;
2190 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2191 if ( postFilter && !postFilter[ expando ] ) {
2192 postFilter = setMatcher( postFilter );
2194 if ( postFinder && !postFinder[ expando ] ) {
2195 postFinder = setMatcher( postFinder, postSelector );
2197 return markFunction(function( seed, results, context, xml ) {
2201 preexisting = results.length,
2203 // Get initial elements from seed or context
2204 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2206 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2207 matcherIn = preFilter && ( seed || !selector ) ?
2208 condense( elems, preMap, preFilter, context, xml ) :
2211 matcherOut = matcher ?
2212 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2213 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2215 // ...intermediate processing is necessary
2218 // ...otherwise use results directly
2222 // Find primary matches
2224 matcher( matcherIn, matcherOut, context, xml );
2229 temp = condense( matcherOut, postMap );
2230 postFilter( temp, [], context, xml );
2232 // Un-match failing elements by moving them back to matcherIn
2235 if ( (elem = temp[i]) ) {
2236 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2242 if ( postFinder || preFilter ) {
2244 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2246 i = matcherOut.length;
2248 if ( (elem = matcherOut[i]) ) {
2249 // Restore matcherIn since elem is not yet a final match
2250 temp.push( (matcherIn[i] = elem) );
2253 postFinder( null, (matcherOut = []), temp, xml );
2256 // Move matched elements from seed to results to keep them synchronized
2257 i = matcherOut.length;
2259 if ( (elem = matcherOut[i]) &&
2260 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
2262 seed[temp] = !(results[temp] = elem);
2267 // Add elements to results, through postFinder if defined
2269 matcherOut = condense(
2270 matcherOut === results ?
2271 matcherOut.splice( preexisting, matcherOut.length ) :
2275 postFinder( null, results, matcherOut, xml );
2277 push.apply( results, matcherOut );
2283 function matcherFromTokens( tokens ) {
2284 var checkContext, matcher, j,
2285 len = tokens.length,
2286 leadingRelative = Expr.relative[ tokens[0].type ],
2287 implicitRelative = leadingRelative || Expr.relative[" "],
2288 i = leadingRelative ? 1 : 0,
2290 // The foundational matcher ensures that elements are reachable from top-level context(s)
2291 matchContext = addCombinator( function( elem ) {
2292 return elem === checkContext;
2293 }, implicitRelative, true ),
2294 matchAnyContext = addCombinator( function( elem ) {
2295 return indexOf.call( checkContext, elem ) > -1;
2296 }, implicitRelative, true ),
2297 matchers = [ function( elem, context, xml ) {
2298 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2299 (checkContext = context).nodeType ?
2300 matchContext( elem, context, xml ) :
2301 matchAnyContext( elem, context, xml ) );
2304 for ( ; i < len; i++ ) {
2305 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2306 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2308 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2310 // Return special upon seeing a positional matcher
2311 if ( matcher[ expando ] ) {
2312 // Find the next relative operator (if any) for proper handling
2314 for ( ; j < len; j++ ) {
2315 if ( Expr.relative[ tokens[j].type ] ) {
2320 i > 1 && elementMatcher( matchers ),
2321 i > 1 && toSelector(
2322 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2323 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2324 ).replace( rtrim, "$1" ),
2326 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2327 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2328 j < len && toSelector( tokens )
2331 matchers.push( matcher );
2335 return elementMatcher( matchers );
2338 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2339 var bySet = setMatchers.length > 0,
2340 byElement = elementMatchers.length > 0,
2341 superMatcher = function( seed, context, xml, results, outermost ) {
2342 var elem, j, matcher,
2345 unmatched = seed && [],
2347 contextBackup = outermostContext,
2348 // We must always have either seed elements or outermost context
2349 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2350 // Use integer dirruns iff this is the outermost matcher
2351 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2355 outermostContext = context !== document && context;
2358 // Add elements passing elementMatchers directly to results
2359 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2360 // Support: IE<9, Safari
2361 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2362 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2363 if ( byElement && elem ) {
2365 while ( (matcher = elementMatchers[j++]) ) {
2366 if ( matcher( elem, context, xml ) ) {
2367 results.push( elem );
2372 dirruns = dirrunsUnique;
2376 // Track unmatched elements for set filters
2378 // They will have gone through all possible matchers
2379 if ( (elem = !matcher && elem) ) {
2383 // Lengthen the array for every element, matched or not
2385 unmatched.push( elem );
2390 // Apply set filters to unmatched elements
2392 if ( bySet && i !== matchedCount ) {
2394 while ( (matcher = setMatchers[j++]) ) {
2395 matcher( unmatched, setMatched, context, xml );
2399 // Reintegrate element matches to eliminate the need for sorting
2400 if ( matchedCount > 0 ) {
2402 if ( !(unmatched[i] || setMatched[i]) ) {
2403 setMatched[i] = pop.call( results );
2408 // Discard index placeholder values to get only actual matches
2409 setMatched = condense( setMatched );
2412 // Add matches to results
2413 push.apply( results, setMatched );
2415 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2416 if ( outermost && !seed && setMatched.length > 0 &&
2417 ( matchedCount + setMatchers.length ) > 1 ) {
2419 Sizzle.uniqueSort( results );
2423 // Override manipulation of globals by nested matchers
2425 dirruns = dirrunsUnique;
2426 outermostContext = contextBackup;
2433 markFunction( superMatcher ) :
2437 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
2440 elementMatchers = [],
2441 cached = compilerCache[ selector + " " ];
2444 // Generate a function of recursive functions that can be used to check each element
2446 group = tokenize( selector );
2450 cached = matcherFromTokens( group[i] );
2451 if ( cached[ expando ] ) {
2452 setMatchers.push( cached );
2454 elementMatchers.push( cached );
2458 // Cache the compiled function
2459 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2464 function multipleContexts( selector, contexts, results ) {
2466 len = contexts.length;
2467 for ( ; i < len; i++ ) {
2468 Sizzle( selector, contexts[i], results );
2473 function select( selector, context, results, seed ) {
2474 var i, tokens, token, type, find,
2475 match = tokenize( selector );
2478 // Try to minimize operations if there is only one group
2479 if ( match.length === 1 ) {
2481 // Take a shortcut and set the context if the root selector is an ID
2482 tokens = match[0] = match[0].slice( 0 );
2483 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2484 support.getById && context.nodeType === 9 && documentIsHTML &&
2485 Expr.relative[ tokens[1].type ] ) {
2487 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2491 selector = selector.slice( tokens.shift().value.length );
2494 // Fetch a seed set for right-to-left matching
2495 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2499 // Abort if we hit a combinator
2500 if ( Expr.relative[ (type = token.type) ] ) {
2503 if ( (find = Expr.find[ type ]) ) {
2504 // Search, expanding context for leading sibling combinators
2506 token.matches[0].replace( runescape, funescape ),
2507 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2510 // If seed is empty or no tokens remain, we can return early
2511 tokens.splice( i, 1 );
2512 selector = seed.length && toSelector( tokens );
2514 push.apply( results, seed );
2525 // Compile and execute a filtering function
2526 // Provide `match` to avoid retokenization if we modified the selector above
2527 compile( selector, match )(
2532 rsibling.test( selector ) && testContext( context.parentNode ) || context
2537 // One-time assignments
2540 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2542 // Support: Chrome<14
2543 // Always assume duplicates if they aren't passed to the comparison function
2544 support.detectDuplicates = !!hasDuplicate;
2546 // Initialize against the default document
2549 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2550 // Detached nodes confoundingly follow *each other*
2551 support.sortDetached = assert(function( div1 ) {
2552 // Should return 1, but returns 4 (following)
2553 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2557 // Prevent attribute/property "interpolation"
2558 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2559 if ( !assert(function( div ) {
2560 div.innerHTML = "<a href='#'></a>";
2561 return div.firstChild.getAttribute("href") === "#" ;
2563 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2565 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2571 // Use defaultValue in place of getAttribute("value")
2572 if ( !support.attributes || !assert(function( div ) {
2573 div.innerHTML = "<input/>";
2574 div.firstChild.setAttribute( "value", "" );
2575 return div.firstChild.getAttribute( "value" ) === "";
2577 addHandle( "value", function( elem, name, isXML ) {
2578 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2579 return elem.defaultValue;
2585 // Use getAttributeNode to fetch booleans when getAttribute lies
2586 if ( !assert(function( div ) {
2587 return div.getAttribute("disabled") == null;
2589 addHandle( booleans, function( elem, name, isXML ) {
2592 return elem[ name ] === true ? name.toLowerCase() :
2593 (val = elem.getAttributeNode( name )) && val.specified ?
2606 jQuery.find = Sizzle;
2607 jQuery.expr = Sizzle.selectors;
2608 jQuery.expr[":"] = jQuery.expr.pseudos;
2609 jQuery.unique = Sizzle.uniqueSort;
2610 jQuery.text = Sizzle.getText;
2611 jQuery.isXMLDoc = Sizzle.isXML;
2612 jQuery.contains = Sizzle.contains;
2616 var rneedsContext = jQuery.expr.match.needsContext;
2618 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2622 var risSimple = /^.[^:#\[\.,]*$/;
2624 // Implement the identical functionality for filter and not
2625 function winnow( elements, qualifier, not ) {
2626 if ( jQuery.isFunction( qualifier ) ) {
2627 return jQuery.grep( elements, function( elem, i ) {
2629 return !!qualifier.call( elem, i, elem ) !== not;
2634 if ( qualifier.nodeType ) {
2635 return jQuery.grep( elements, function( elem ) {
2636 return ( elem === qualifier ) !== not;
2641 if ( typeof qualifier === "string" ) {
2642 if ( risSimple.test( qualifier ) ) {
2643 return jQuery.filter( qualifier, elements, not );
2646 qualifier = jQuery.filter( qualifier, elements );
2649 return jQuery.grep( elements, function( elem ) {
2650 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
2654 jQuery.filter = function( expr, elems, not ) {
2655 var elem = elems[ 0 ];
2658 expr = ":not(" + expr + ")";
2661 return elems.length === 1 && elem.nodeType === 1 ?
2662 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2663 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2664 return elem.nodeType === 1;
2669 find: function( selector ) {
2675 if ( typeof selector !== "string" ) {
2676 return this.pushStack( jQuery( selector ).filter(function() {
2677 for ( i = 0; i < len; i++ ) {
2678 if ( jQuery.contains( self[ i ], this ) ) {
2685 for ( i = 0; i < len; i++ ) {
2686 jQuery.find( selector, self[ i ], ret );
2689 // Needed because $( selector, context ) becomes $( context ).find( selector )
2690 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2691 ret.selector = this.selector ? this.selector + " " + selector : selector;
2694 filter: function( selector ) {
2695 return this.pushStack( winnow(this, selector || [], false) );
2697 not: function( selector ) {
2698 return this.pushStack( winnow(this, selector || [], true) );
2700 is: function( selector ) {
2704 // If this is a positional/relative selector, check membership in the returned set
2705 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2706 typeof selector === "string" && rneedsContext.test( selector ) ?
2707 jQuery( selector ) :
2715 // Initialize a jQuery object
2718 // A central reference to the root jQuery(document)
2721 // Use the correct document accordingly with window argument (sandbox)
2722 document = window.document,
2724 // A simple way to check for HTML strings
2725 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2726 // Strict HTML recognition (#11290: must start with <)
2727 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2729 init = jQuery.fn.init = function( selector, context ) {
2732 // HANDLE: $(""), $(null), $(undefined), $(false)
2737 // Handle HTML strings
2738 if ( typeof selector === "string" ) {
2739 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
2740 // Assume that strings that start and end with <> are HTML and skip the regex check
2741 match = [ null, selector, null ];
2744 match = rquickExpr.exec( selector );
2747 // Match html or make sure no context is specified for #id
2748 if ( match && (match[1] || !context) ) {
2750 // HANDLE: $(html) -> $(array)
2752 context = context instanceof jQuery ? context[0] : context;
2754 // scripts is true for back-compat
2755 // Intentionally let the error be thrown if parseHTML is not present
2756 jQuery.merge( this, jQuery.parseHTML(
2758 context && context.nodeType ? context.ownerDocument || context : document,
2762 // HANDLE: $(html, props)
2763 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
2764 for ( match in context ) {
2765 // Properties of context are called as methods if possible
2766 if ( jQuery.isFunction( this[ match ] ) ) {
2767 this[ match ]( context[ match ] );
2769 // ...and otherwise set as attributes
2771 this.attr( match, context[ match ] );
2780 elem = document.getElementById( match[2] );
2782 // Check parentNode to catch when Blackberry 4.6 returns
2783 // nodes that are no longer in the document #6963
2784 if ( elem && elem.parentNode ) {
2785 // Handle the case where IE and Opera return items
2786 // by name instead of ID
2787 if ( elem.id !== match[2] ) {
2788 return rootjQuery.find( selector );
2791 // Otherwise, we inject the element directly into the jQuery object
2796 this.context = document;
2797 this.selector = selector;
2801 // HANDLE: $(expr, $(...))
2802 } else if ( !context || context.jquery ) {
2803 return ( context || rootjQuery ).find( selector );
2805 // HANDLE: $(expr, context)
2806 // (which is just equivalent to: $(context).find(expr)
2808 return this.constructor( context ).find( selector );
2811 // HANDLE: $(DOMElement)
2812 } else if ( selector.nodeType ) {
2813 this.context = this[0] = selector;
2817 // HANDLE: $(function)
2818 // Shortcut for document ready
2819 } else if ( jQuery.isFunction( selector ) ) {
2820 return typeof rootjQuery.ready !== "undefined" ?
2821 rootjQuery.ready( selector ) :
2822 // Execute immediately if ready is not present
2826 if ( selector.selector !== undefined ) {
2827 this.selector = selector.selector;
2828 this.context = selector.context;
2831 return jQuery.makeArray( selector, this );
2834 // Give the init function the jQuery prototype for later instantiation
2835 init.prototype = jQuery.fn;
2837 // Initialize central reference
2838 rootjQuery = jQuery( document );
2841 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2842 // methods guaranteed to produce a unique set when starting from a unique set
2843 guaranteedUnique = {
2851 dir: function( elem, dir, until ) {
2855 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
2856 if ( cur.nodeType === 1 ) {
2857 matched.push( cur );
2864 sibling: function( n, elem ) {
2867 for ( ; n; n = n.nextSibling ) {
2868 if ( n.nodeType === 1 && n !== elem ) {
2878 has: function( target ) {
2880 targets = jQuery( target, this ),