2
* jQuery JavaScript Library v2.2.1
8
* Copyright jQuery Foundation and other contributors
9
* Released under the MIT license
10
* http://jquery.org/license
12
* Date: 2016-02-22T19:11Z
15
(function( global, factory ) {
17
if ( typeof module === "object" && typeof module.exports === "object" ) {
18
// For CommonJS and CommonJS-like environments where a proper `window`
19
// is present, execute the factory and get jQuery.
20
// For environments that do not have a `window` with a `document`
21
// (such as Node.js), expose a 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 ) :
29
throw new Error( "jQuery requires a window with a document" );
37
// Pass this if window is not defined yet
38
}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
40
// Support: Firefox 18+
41
// Can't be in strict mode, several libs including ASP.NET trace
42
// the stack via arguments.caller.callee and Firefox dies if
43
// you try to trace through "use strict" call chains. (#13335)
47
var document = window.document;
49
var slice = arr.slice;
51
var concat = arr.concat;
55
var indexOf = arr.indexOf;
59
var toString = class2type.toString;
61
var hasOwn = class2type.hasOwnProperty;
70
// Define a local copy of jQuery
71
jQuery = function( selector, context ) {
73
// The jQuery object is actually just the init constructor 'enhanced'
74
// Need init if jQuery is called (just allow error to be thrown if not included)
75
return new jQuery.fn.init( selector, context );
78
// Support: Android<4.1
79
// Make sure we trim BOM and NBSP
80
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
82
// Matches dashed string for camelizing
84
rdashAlpha = /-([\da-z])/gi,
86
// Used by jQuery.camelCase as callback to replace()
87
fcamelCase = function( all, letter ) {
88
return letter.toUpperCase();
91
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 just the one element from the set
114
( num < 0 ? this[ num + this.length ] : this[ num ] ) :
116
// Return all the elements in a clean array
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
each: function( callback ) {
137
return jQuery.each( this, callback );
140
map: function( callback ) {
141
return this.pushStack( jQuery.map( this, function( elem, i ) {
142
return callback.call( elem, i, elem );
147
return this.pushStack( slice.apply( this, arguments ) );
155
return this.eq( -1 );
159
var len = this.length,
160
j = +i + ( i < 0 ? len : 0 );
161
return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
165
return this.prevObject || this.constructor();
168
// For internal use only.
169
// Behaves like an Array's method, not like a jQuery method.
175
jQuery.extend = jQuery.fn.extend = function() {
176
var options, name, src, copy, copyIsArray, clone,
177
target = arguments[ 0 ] || {},
179
length = arguments.length,
182
// Handle a deep copy situation
183
if ( typeof target === "boolean" ) {
186
// Skip the boolean and the target
187
target = arguments[ i ] || {};
191
// Handle case when target is a string or something (possible in deep copy)
192
if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
196
// Extend jQuery itself if only one argument is passed
197
if ( i === length ) {
202
for ( ; i < length; i++ ) {
204
// Only deal with non-null/undefined values
205
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 ) ||
219
( copyIsArray = jQuery.isArray( copy ) ) ) ) {
223
clone = src && jQuery.isArray( src ) ? src : [];
226
clone = src && jQuery.isPlainObject( src ) ? src : {};
229
// Never move original objects, clone them
230
target[ name ] = jQuery.extend( deep, clone, copy );
232
// Don't bring in undefined values
233
} else if ( copy !== undefined ) {
234
target[ name ] = copy;
240
// Return the modified object
246
// Unique for each copy of jQuery on the page
247
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
249
// Assume jQuery is ready without the ready module
252
error: function( msg ) {
253
throw new Error( msg );
258
isFunction: function( obj ) {
259
return jQuery.type( obj ) === "function";
262
isArray: Array.isArray,
264
isWindow: function( obj ) {
265
return obj != null && obj === obj.window;
268
isNumeric: function( obj ) {
270
// parseFloat NaNs numeric-cast false positives (null|true|false|"")
271
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
272
// subtraction forces infinities to NaN
273
// adding 1 corrects loss of precision from parseFloat (#15100)
274
var realStringObj = obj && obj.toString();
275
return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
278
isPlainObject: function( obj ) {
280
// Not plain objects:
281
// - Any object or value whose internal [[Class]] property is not "[object Object]"
284
if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
288
if ( obj.constructor &&
289
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
293
// If the function hasn't returned already, we're confident that
294
// |obj| is a plain object, created by {} or constructed with new Object
298
isEmptyObject: function( obj ) {
300
for ( name in obj ) {
306
type: function( obj ) {
311
// Support: Android<4.0, iOS<6 (functionish RegExp)
312
return typeof obj === "object" || typeof obj === "function" ?
313
class2type[ toString.call( obj ) ] || "object" :
317
// Evaluates a script in a global context
318
globalEval: function( code ) {
322
code = jQuery.trim( code );
326
// If the code includes a valid, prologue position
327
// strict mode pragma, execute code by injecting a
328
// script tag into the document.
329
if ( code.indexOf( "use strict" ) === 1 ) {
330
script = document.createElement( "script" );
332
document.head.appendChild( script ).parentNode.removeChild( script );
335
// Otherwise, avoid the DOM node creation, insertion
336
// and removal by using an indirect global eval
343
// Convert dashed to camelCase; used by the css and data modules
345
// Microsoft forgot to hump their vendor prefix (#9572)
346
camelCase: function( string ) {
347
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
350
nodeName: function( elem, name ) {
351
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
354
each: function( obj, callback ) {
357
if ( isArrayLike( obj ) ) {
359
for ( ; i < length; i++ ) {
360
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
366
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
375
// Support: Android<4.1
376
trim: function( text ) {
377
return text == null ?
379
( text + "" ).replace( rtrim, "" );
382
// results is for internal usage only
383
makeArray: function( arr, results ) {
384
var ret = results || [];
387
if ( isArrayLike( Object( arr ) ) ) {
389
typeof arr === "string" ?
393
push.call( ret, arr );
400
inArray: function( elem, arr, i ) {
401
return arr == null ? -1 : indexOf.call( arr, elem, i );
404
merge: function( first, second ) {
405
var len = +second.length,
409
for ( ; j < len; j++ ) {
410
first[ i++ ] = second[ j ];
418
grep: function( elems, callback, invert ) {
422
length = elems.length,
423
callbackExpect = !invert;
425
// Go through the array, only saving the items
426
// that pass the validator function
427
for ( ; i < length; i++ ) {
428
callbackInverse = !callback( elems[ i ], i );
429
if ( callbackInverse !== callbackExpect ) {
430
matches.push( elems[ i ] );
437
// arg is for internal usage only
438
map: function( elems, callback, arg ) {
443
// Go through the array, translating each of the items to their new values
444
if ( isArrayLike( elems ) ) {
445
length = elems.length;
446
for ( ; i < length; i++ ) {
447
value = callback( elems[ i ], i, arg );
449
if ( value != null ) {
454
// Go through every key on the object,
457
value = callback( elems[ i ], i, arg );
459
if ( value != null ) {
465
// Flatten any nested arrays
466
return concat.apply( [], ret );
469
// A global GUID counter for objects
472
// Bind a function to a context, optionally partially applying any
474
proxy: function( fn, context ) {
475
var tmp, args, proxy;
477
if ( typeof context === "string" ) {
483
// Quick check to determine if target is callable, in the spec
484
// this throws a TypeError, but we will just return undefined.
485
if ( !jQuery.isFunction( fn ) ) {
490
args = slice.call( arguments, 2 );
492
return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
495
// Set the guid of unique handler to the same of original handler, so it can be removed
496
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
503
// jQuery.support is not used in Core but other projects attach their
504
// properties to it so it needs to exist.
508
// JSHint would error on this code due to the Symbol not being defined in ES5.
509
// Defining this global in .jshintrc would create a danger of using the global
510
// unguarded in another place, it seems safer to just disable JSHint for these
512
/* jshint ignore: start */
513
if ( typeof Symbol === "function" ) {
514
jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
516
/* jshint ignore: end */
518
// Populate the class2type map
519
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
520
function( i, name ) {
521
class2type[ "[object " + name + "]" ] = name.toLowerCase();
524
function isArrayLike( obj ) {
526
// Support: iOS 8.2 (not reproducible in simulator)
527
// `in` check used to prevent JIT error (gh-2145)
528
// hasOwn isn't used here due to false negatives
529
// regarding Nodelist length in IE
530
var length = !!obj && "length" in obj && obj.length,
531
type = jQuery.type( obj );
533
if ( type === "function" || jQuery.isWindow( obj ) ) {
537
return type === "array" || length === 0 ||
538
typeof length === "number" && length > 0 && ( length - 1 ) in obj;
542
* Sizzle CSS Selector Engine v2.2.1
543
* http://sizzlejs.com/
545
* Copyright jQuery Foundation and other contributors
546
* Released under the MIT license
547
* http://jquery.org/license
551
(function( window ) {
565
// Local document vars
575
// Instance-specific data
576
expando = "sizzle" + 1 * new Date(),
577
preferredDoc = window.document,
580
classCache = createCache(),
581
tokenCache = createCache(),
582
compilerCache = createCache(),
583
sortOrder = function( a, b ) {
590
// General-purpose constants
591
MAX_NEGATIVE = 1 << 31,
594
hasOwn = ({}).hasOwnProperty,
597
push_native = arr.push,
600
// Use a stripped-down indexOf as it's faster than native
601
// http://jsperf.com/thor-indexof-vs-for/5
602
indexOf = function( list, elem ) {
605
for ( ; i < len; i++ ) {
606
if ( list[i] === elem ) {
613
booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
615
// Regular expressions
617
// http://www.w3.org/TR/css3-selectors/#whitespace
618
whitespace = "[\\x20\\t\\r\\n\\f]",
620
// http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
621
identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
623
// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
624
attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
625
// Operator (capture 2)
626
"*([*^$|!~]?=)" + whitespace +
627
// "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
628
"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
631
pseudos = ":(" + identifier + ")(?:\\((" +
632
// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
633
// 1. quoted (capture 3; capture 4 or capture 5)
634
"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
635
// 2. simple (capture 6)
636
"((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
637
// 3. anything else (capture 2)
641
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
642
rwhitespace = new RegExp( whitespace + "+", "g" ),
643
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
645
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
646
rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
648
rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
650
rpseudo = new RegExp( pseudos ),
651
ridentifier = new RegExp( "^" + identifier + "$" ),
654
"ID": new RegExp( "^#(" + identifier + ")" ),
655
"CLASS": new RegExp( "^\\.(" + identifier + ")" ),
656
"TAG": new RegExp( "^(" + identifier + "|[*])" ),
657
"ATTR": new RegExp( "^" + attributes ),
658
"PSEUDO": new RegExp( "^" + pseudos ),
659
"CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
660
"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
661
"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
662
"bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
663
// For use in libraries implementing .is()
664
// We use this for POS matching in `select`
665
"needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
666
whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
669
rinputs = /^(?:input|select|textarea|button)$/i,
672
rnative = /^[^{]+\{\s*\[native \w/,
674
// Easily-parseable/retrievable ID or TAG or CLASS selectors
675
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
680
// CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
681
runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
682
funescape = function( _, escaped, escapedWhitespace ) {
683
var high = "0x" + escaped - 0x10000;
684
// NaN means non-codepoint
685
// Support: Firefox<24
686
// Workaround erroneous numeric interpretation of +"0x"
687
return high !== high || escapedWhitespace ?
691
String.fromCharCode( high + 0x10000 ) :
692
// Supplemental Plane codepoint (surrogate pair)
693
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
698
// Removing the function wrapper causes a "Permission Denied"
700
unloadHandler = function() {
704
// Optimize for push.apply( _, NodeList )
707
(arr = slice.call( preferredDoc.childNodes )),
708
preferredDoc.childNodes
710
// Support: Android<4.0
711
// Detect silently failing push.apply
712
arr[ preferredDoc.childNodes.length ].nodeType;
714
push = { apply: arr.length ?
716
// Leverage slice if possible
717
function( target, els ) {
718
push_native.apply( target, slice.call(els) );
722
// Otherwise append directly
723
function( target, els ) {
724
var j = target.length,
726
// Can't trust NodeList.length
727
while ( (target[j++] = els[i++]) ) {}
728
target.length = j - 1;
733
function Sizzle( selector, context, results, seed ) {
734
var m, i, elem, nid, nidselect, match, groups, newSelector,
735
newContext = context && context.ownerDocument,
737
// nodeType defaults to 9, since context defaults to document
738
nodeType = context ? context.nodeType : 9;
740
results = results || [];
742
// Return early from calls with invalid selector or context
743
if ( typeof selector !== "string" || !selector ||
744
nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
749
// Try to shortcut find operations (as opposed to filters) in HTML documents
752
if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
753
setDocument( context );
755
context = context || document;
757
if ( documentIsHTML ) {
759
// If the selector is sufficiently simple, try using a "get*By*" DOM method
760
// (excepting DocumentFragment context, where the methods don't exist)
761
if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
764
if ( (m = match[1]) ) {
767
if ( nodeType === 9 ) {
768
if ( (elem = context.getElementById( m )) ) {
770
// Support: IE, Opera, Webkit
771
// TODO: identify versions
772
// getElementById can match elements by name instead of ID
773
if ( elem.id === m ) {
774
results.push( elem );
784
// Support: IE, Opera, Webkit
785
// TODO: identify versions
786
// getElementById can match elements by name instead of ID
787
if ( newContext && (elem = newContext.getElementById( m )) &&
788
contains( context, elem ) &&
791
results.push( elem );
797
} else if ( match[2] ) {
798
push.apply( results, context.getElementsByTagName( selector ) );
802
} else if ( (m = match[3]) && support.getElementsByClassName &&
803
context.getElementsByClassName ) {
805
push.apply( results, context.getElementsByClassName( m ) );
810
// Take advantage of querySelectorAll
812
!compilerCache[ selector + " " ] &&
813
(!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
815
if ( nodeType !== 1 ) {
816
newContext = context;
817
newSelector = selector;
819
// qSA looks outside Element context, which is not what we want
820
// Thanks to Andrew Dupont for this workaround technique
822
// Exclude object elements
823
} else if ( context.nodeName.toLowerCase() !== "object" ) {
825
// Capture the context ID, setting it first if necessary
826
if ( (nid = context.getAttribute( "id" )) ) {
827
nid = nid.replace( rescape, "\\$&" );
829
context.setAttribute( "id", (nid = expando) );
832
// Prefix every selector in the list
833
groups = tokenize( selector );
835
nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']";
837
groups[i] = nidselect + " " + toSelector( groups[i] );
839
newSelector = groups.join( "," );
841
// Expand context for sibling selectors
842
newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
849
newContext.querySelectorAll( newSelector )
852
} catch ( qsaError ) {
854
if ( nid === expando ) {
855
context.removeAttribute( "id" );
864
return select( selector.replace( rtrim, "$1" ), context, results, seed );
868
* Create key-value caches of limited size
869
* @returns {function(string, object)} Returns the Object data after storing it on itself with
870
* property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
871
* deleting the oldest entry
873
function createCache() {
876
function cache( key, value ) {
877
// Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
878
if ( keys.push( key + " " ) > Expr.cacheLength ) {
879
// Only keep the most recent entries
880
delete cache[ keys.shift() ];
882
return (cache[ key + " " ] = value);
888
* Mark a function for special use by Sizzle
889
* @param {Function} fn The function to mark
891
function markFunction( fn ) {
892
fn[ expando ] = true;
897
* Support testing using an element
898
* @param {Function} fn Passed the created div and expects a boolean result
900
function assert( fn ) {
901
var div = document.createElement("div");
908
// Remove from its parent by default
909
if ( div.parentNode ) {
910
div.parentNode.removeChild( div );
912
// release memory in IE
918
* Adds the same handler for all of the specified attrs
919
* @param {String} attrs Pipe-separated list of attributes
920
* @param {Function} handler The method that will be applied
922
function addHandle( attrs, handler ) {
923
var arr = attrs.split("|"),
927
Expr.attrHandle[ arr[i] ] = handler;
932
* Checks document order of two siblings
935
* @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
937
function siblingCheck( a, b ) {
939
diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
940
( ~b.sourceIndex || MAX_NEGATIVE ) -
941
( ~a.sourceIndex || MAX_NEGATIVE );
943
// Use IE sourceIndex if available on both nodes
948
// Check if b follows a
950
while ( (cur = cur.nextSibling) ) {
961
* Returns a function to use in pseudos for input types
962
* @param {String} type
964
function createInputPseudo( type ) {
965
return function( elem ) {
966
var name = elem.nodeName.toLowerCase();
967
return name === "input" && elem.type === type;
972
* Returns a function to use in pseudos for buttons
973
* @param {String} type
975
function createButtonPseudo( type ) {
976
return function( elem ) {
977
var name = elem.nodeName.toLowerCase();
978
return (name === "input" || name === "button") && elem.type === type;
983
* Returns a function to use in pseudos for positionals
984
* @param {Function} fn
986
function createPositionalPseudo( fn ) {
987
return markFunction(function( argument ) {
988
argument = +argument;
989
return markFunction(function( seed, matches ) {
991
matchIndexes = fn( [], seed.length, argument ),
992
i = matchIndexes.length;
994
// Match elements found at the specified indexes
996
if ( seed[ (j = matchIndexes[i]) ] ) {
997
seed[j] = !(matches[j] = seed[j]);
1005
* Checks a node for validity as a Sizzle context
1006
* @param {Element|Object=} context
1007
* @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1009
function testContext( context ) {
1010
return context && typeof context.getElementsByTagName !== "undefined" && context;
1013
// Expose support vars for convenience
1014
support = Sizzle.support = {};
1018
* @param {Element|Object} elem An element or a document
1019
* @returns {Boolean} True iff elem is a non-HTML XML node
1021
isXML = Sizzle.isXML = function( elem ) {
1022
// documentElement is verified for cases where it doesn't yet exist
1023
// (such as loading iframes in IE - #4833)
1024
var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1025
return documentElement ? documentElement.nodeName !== "HTML" : false;
1029
* Sets document-related variables once based on the current document
1030
* @param {Element|Object} [doc] An element or document object to use to set the document
1031
* @returns {Object} Returns the current document
1033
setDocument = Sizzle.setDocument = function( node ) {
1034
var hasCompare, parent,
1035
doc = node ? node.ownerDocument || node : preferredDoc;
1037
// Return early if doc is invalid or already selected
1038
if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1042
// Update global variables
1044
docElem = document.documentElement;
1045
documentIsHTML = !isXML( document );
1047
// Support: IE 9-11, Edge
1048
// Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1049
if ( (parent = document.defaultView) && parent.top !== parent ) {
1051
if ( parent.addEventListener ) {
1052
parent.addEventListener( "unload", unloadHandler, false );
1054
// Support: IE 9 - 10 only
1055
} else if ( parent.attachEvent ) {
1056
parent.attachEvent( "onunload", unloadHandler );
1061
---------------------------------------------------------------------- */
1064
// Verify that getAttribute really returns attributes and not properties
1065
// (excepting IE8 booleans)
1066
support.attributes = assert(function( div ) {
1067
div.className = "i";
1068
return !div.getAttribute("className");
1072
---------------------------------------------------------------------- */
1074
// Check if getElementsByTagName("*") returns only elements
1075
support.getElementsByTagName = assert(function( div ) {
1076
div.appendChild( document.createComment("") );
1077
return !div.getElementsByTagName("*").length;
1081
support.getElementsByClassName = rnative.test( document.getElementsByClassName );
1084
// Check if getElementById returns elements by name
1085
// The broken getElementById methods don't pick up programatically-set names,
1086
// so use a roundabout getElementsByName test
1087
support.getById = assert(function( div ) {
1088
docElem.appendChild( div ).id = expando;
1089
return !document.getElementsByName || !document.getElementsByName( expando ).length;
1092
// ID find and filter
1093
if ( support.getById ) {
1094
Expr.find["ID"] = function( id, context ) {
1095
if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1096
var m = context.getElementById( id );
1097
return m ? [ m ] : [];
1100
Expr.filter["ID"] = function( id ) {
1101
var attrId = id.replace( runescape, funescape );
1102
return function( elem ) {
1103
return elem.getAttribute("id") === attrId;
1108
// getElementById is not reliable as a find shortcut
1109
delete Expr.find["ID"];
1111
Expr.filter["ID"] = function( id ) {
1112
var attrId = id.replace( runescape, funescape );
1113
return function( elem ) {
1114
var node = typeof elem.getAttributeNode !== "undefined" &&
1115
elem.getAttributeNode("id");
1116
return node && node.value === attrId;
1122
Expr.find["TAG"] = support.getElementsByTagName ?
1123
function( tag, context ) {
1124
if ( typeof context.getElementsByTagName !== "undefined" ) {
1125
return context.getElementsByTagName( tag );
1127
// DocumentFragment nodes don't have gEBTN
1128
} else if ( support.qsa ) {
1129
return context.querySelectorAll( tag );
1133
function( tag, context ) {
1137
// By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1138
results = context.getElementsByTagName( tag );
1140
// Filter out possible comments
1141
if ( tag === "*" ) {
1142
while ( (elem = results[i++]) ) {
1143
if ( elem.nodeType === 1 ) {
1154
Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1155
if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
1156
return context.getElementsByClassName( className );
1160
/* QSA/matchesSelector
1161
---------------------------------------------------------------------- */
1163
// QSA and matchesSelector support
1165
// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1168
// qSa(:focus) reports false when true (Chrome 21)
1169
// We allow this because of a bug in IE8/9 that throws an error
1170
// whenever `document.activeElement` is accessed on an iframe
1171
// So, we allow :focus to pass through QSA all the time to avoid the IE error
1172
// See http://bugs.jquery.com/ticket/13378
1175
if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
1177
// Regex strategy adopted from Diego Perini
1178
assert(function( div ) {
1179
// Select is set to empty string on purpose
1180
// This is to test IE's treatment of not explicitly
1181
// setting a boolean content attribute,
1182
// since its presence should be enough
1183
// http://bugs.jquery.com/ticket/12359
1184
docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
1185
"<select id='" + expando + "-\r\\' msallowcapture=''>" +
1186
"<option selected=''></option></select>";
1188
// Support: IE8, Opera 11-12.16
1189
// Nothing should be selected when empty strings follow ^= or $= or *=
1190
// The test attribute must be unknown in Opera but "safe" for WinRT
1191
// http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1192
if ( div.querySelectorAll("[msallowcapture^='']").length ) {
1193
rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1197
// Boolean attributes and "value" are not treated correctly
1198
if ( !div.querySelectorAll("[selected]").length ) {
1199
rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1202
// Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1203
if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1204
rbuggyQSA.push("~=");
1207
// Webkit/Opera - :checked should return selected option elements
1208
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1209
// IE8 throws error here and will not see later tests
1210
if ( !div.querySelectorAll(":checked").length ) {
1211
rbuggyQSA.push(":checked");
1214
// Support: Safari 8+, iOS 8+
1215
// https://bugs.webkit.org/show_bug.cgi?id=136851
1216
// In-page `selector#id sibing-combinator selector` fails
1217
if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
1218
rbuggyQSA.push(".#.+[+~]");
1222
assert(function( div ) {
1223
// Support: Windows 8 Native Apps
1224
// The type and name attributes are restricted during .innerHTML assignment
1225
var input = document.createElement("input");
1226
input.setAttribute( "type", "hidden" );
1227
div.appendChild( input ).setAttribute( "name", "D" );
1230
// Enforce case-sensitivity of name attribute
1231
if ( div.querySelectorAll("[name=d]").length ) {
1232
rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1235
// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1236
// IE8 throws error here and will not see later tests
1237
if ( !div.querySelectorAll(":enabled").length ) {
1238
rbuggyQSA.push( ":enabled", ":disabled" );
1241
// Opera 10-11 does not throw on post-comma invalid pseudos
1242
div.querySelectorAll("*,:x");
1243
rbuggyQSA.push(",.*:");
1247
if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1248
docElem.webkitMatchesSelector ||
1249
docElem.mozMatchesSelector ||
1250
docElem.oMatchesSelector ||
1251
docElem.msMatchesSelector) )) ) {
1253
assert(function( div ) {
1254
// Check to see if it's possible to do matchesSelector
1255
// on a disconnected node (IE 9)
1256
support.disconnectedMatch = matches.call( div, "div" );
1258
// This should fail with an exception
1259
// Gecko does not error, returns false instead
1260
matches.call( div, "[s!='']:x" );
1261
rbuggyMatches.push( "!=", pseudos );
1265
rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1266
rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1269
---------------------------------------------------------------------- */
1270
hasCompare = rnative.test( docElem.compareDocumentPosition );
1272
// Element contains another
1273
// Purposefully self-exclusive
1274
// As in, an element does not contain itself
1275
contains = hasCompare || rnative.test( docElem.contains ) ?
1277
var adown = a.nodeType === 9 ? a.documentElement : a,
1278
bup = b && b.parentNode;
1279
return a === bup || !!( bup && bup.nodeType === 1 && (
1281
adown.contains( bup ) :
1282
a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1287
while ( (b = b.parentNode) ) {
1297
---------------------------------------------------------------------- */
1299
// Document order sorting
1300
sortOrder = hasCompare ?
1303
// Flag for duplicate removal
1305
hasDuplicate = true;
1309
// Sort on method existence if only one input has compareDocumentPosition
1310
var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1315
// Calculate position if both inputs belong to the same document
1316
compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1317
a.compareDocumentPosition( b ) :
1319
// Otherwise we know they are disconnected
1322
// Disconnected nodes
1324
(!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1326
// Choose the first element that is related to our preferred document
1327
if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1330
if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1334
// Maintain original order
1336
( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1340
return compare & 4 ? -1 : 1;
1343
// Exit early if the nodes are identical
1345
hasDuplicate = true;
1356
// Parentless nodes are either documents or disconnected
1357
if ( !aup || !bup ) {
1358
return a === document ? -1 :
1359
b === document ? 1 :
1363
( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1366
// If the nodes are siblings, we can do a quick check
1367
} else if ( aup === bup ) {
1368
return siblingCheck( a, b );
1371
// Otherwise we need full lists of their ancestors for comparison
1373
while ( (cur = cur.parentNode) ) {
1377
while ( (cur = cur.parentNode) ) {
1381
// Walk down the tree looking for a discrepancy
1382
while ( ap[i] === bp[i] ) {
1387
// Do a sibling check if the nodes have a common ancestor
1388
siblingCheck( ap[i], bp[i] ) :
1390
// Otherwise nodes in our document sort first
1391
ap[i] === preferredDoc ? -1 :
1392
bp[i] === preferredDoc ? 1 :
1399
Sizzle.matches = function( expr, elements ) {
1400
return Sizzle( expr, null, null, elements );
1403
Sizzle.matchesSelector = function( elem, expr ) {
1404
// Set document vars if needed
1405
if ( ( elem.ownerDocument || elem ) !== document ) {
1406
setDocument( elem );
1409
// Make sure that attribute selectors are quoted
1410
expr = expr.replace( rattributeQuotes, "='$1']" );
1412
if ( support.matchesSelector && documentIsHTML &&
1413
!compilerCache[ expr + " " ] &&
1414
( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1415
( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1418
var ret = matches.call( elem, expr );
1420
// IE 9's matchesSelector returns false on disconnected nodes
1421
if ( ret || support.disconnectedMatch ||
1422
// As well, disconnected nodes are said to be in a document
1424
elem.document && elem.document.nodeType !== 11 ) {
1430
return Sizzle( expr, document, null, [ elem ] ).length > 0;
1433
Sizzle.contains = function( context, elem ) {
1434
// Set document vars if needed
1435
if ( ( context.ownerDocument || context ) !== document ) {
1436
setDocument( context );
1438
return contains( context, elem );
1441
Sizzle.attr = function( elem, name ) {
1442
// Set document vars if needed
1443
if ( ( elem.ownerDocument || elem ) !== document ) {
1444
setDocument( elem );
1447
var fn = Expr.attrHandle[ name.toLowerCase() ],
1448
// Don't get fooled by Object.prototype properties (jQuery #13807)
1449
val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1450
fn( elem, name, !documentIsHTML ) :
1453
return val !== undefined ?
1455
support.attributes || !documentIsHTML ?
1456
elem.getAttribute( name ) :
1457
(val = elem.getAttributeNode(name)) && val.specified ?
1462
Sizzle.error = function( msg ) {
1463
throw new Error( "Syntax error, unrecognized expression: " + msg );
1467
* Document sorting and removing duplicates
1468
* @param {ArrayLike} results
1470
Sizzle.uniqueSort = function( results ) {
1476
// Unless we *know* we can detect duplicates, assume their presence
1477
hasDuplicate = !support.detectDuplicates;
1478
sortInput = !support.sortStable && results.slice( 0 );
1479
results.sort( sortOrder );
1481
if ( hasDuplicate ) {
1482
while ( (elem = results[i++]) ) {
1483
if ( elem === results[ i ] ) {
1484
j = duplicates.push( i );
1488
results.splice( duplicates[ j ], 1 );
1492
// Clear input after sorting to release objects
1493
// See https://github.com/jquery/sizzle/pull/225
1500
* Utility function for retrieving the text value of an array of DOM nodes
1501
* @param {Array|Element} elem
1503
getText = Sizzle.getText = function( elem ) {
1507
nodeType = elem.nodeType;
1510
// If no nodeType, this is expected to be an array
1511
while ( (node = elem[i++]) ) {
1512
// Do not traverse comment nodes
1513
ret += getText( node );
1515
} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1516
// Use textContent for elements
1517
// innerText usage removed for consistency of new lines (jQuery #11153)
1518
if ( typeof elem.textContent === "string" ) {
1519
return elem.textContent;
1521
// Traverse its children
1522
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1523
ret += getText( elem );
1526
} else if ( nodeType === 3 || nodeType === 4 ) {
1527
return elem.nodeValue;
1529
// Do not include comment or processing instruction nodes
1534
Expr = Sizzle.selectors = {
1536
// Can be adjusted by the user
1539
createPseudo: markFunction,
1548
">": { dir: "parentNode", first: true },
1549
" ": { dir: "parentNode" },
1550
"+": { dir: "previousSibling", first: true },
1551
"~": { dir: "previousSibling" }
1555
"ATTR": function( match ) {
1556
match[1] = match[1].replace( runescape, funescape );
1558
// Move the given value to match[3] whether quoted or unquoted
1559
match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1561
if ( match[2] === "~=" ) {
1562
match[3] = " " + match[3] + " ";
1565
return match.slice( 0, 4 );
1568
"CHILD": function( match ) {
1569
/* matches from matchExpr["CHILD"]
1570
1 type (only|nth|...)
1571
2 what (child|of-type)
1572
3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1573
4 xn-component of xn+y argument ([+-]?\d*n|)
1574
5 sign of xn-component
1576
7 sign of y-component
1579
match[1] = match[1].toLowerCase();
1581
if ( match[1].slice( 0, 3 ) === "nth" ) {
1582
// nth-* requires argument
1584
Sizzle.error( match[0] );
1587
// numeric x and y parameters for Expr.filter.CHILD
1588
// remember that false/true cast respectively to 0/1
1589
match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1590
match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1592
// other types prohibit arguments
1593
} else if ( match[3] ) {
1594
Sizzle.error( match[0] );
1600
"PSEUDO": function( match ) {
1602
unquoted = !match[6] && match[2];
1604
if ( matchExpr["CHILD"].test( match[0] ) ) {
1608
// Accept quoted arguments as-is
1610
match[2] = match[4] || match[5] || "";
1612
// Strip excess characters from unquoted arguments
1613
} else if ( unquoted && rpseudo.test( unquoted ) &&
1614
// Get excess from tokenize (recursively)
1615
(excess = tokenize( unquoted, true )) &&
1616
// advance to the next closing parenthesis
1617
(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1619
// excess is a negative index
1620
match[0] = match[0].slice( 0, excess );
1621
match[2] = unquoted.slice( 0, excess );
1624
// Return only captures needed by the pseudo filter method (type and argument)
1625
return match.slice( 0, 3 );
1631
"TAG": function( nodeNameSelector ) {
1632
var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1633
return nodeNameSelector === "*" ?
1634
function() { return true; } :
1636
return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1640
"CLASS": function( className ) {
1641
var pattern = classCache[ className + " " ];
1644
(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1645
classCache( className, function( elem ) {
1646
return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
1650
"ATTR": function( name, operator, check ) {
1651
return function( elem ) {
1652
var result = Sizzle.attr( elem, name );
1654
if ( result == null ) {
1655
return operator === "!=";
1663
return operator === "=" ? result === check :
1664
operator === "!=" ? result !== check :
1665
operator === "^=" ? check && result.indexOf( check ) === 0 :
1666
operator === "*=" ? check && result.indexOf( check ) > -1 :
1667
operator === "$=" ? check && result.slice( -check.length ) === check :
1668
operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1669
operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1674
"CHILD": function( type, what, argument, first, last ) {
1675
var simple = type.slice( 0, 3 ) !== "nth",
1676
forward = type.slice( -4 ) !== "last",
1677
ofType = what === "of-type";
1679
return first === 1 && last === 0 ?
1681
// Shortcut for :nth-*(n)
1683
return !!elem.parentNode;
1686
function( elem, context, xml ) {
1687
var cache, uniqueCache, outerCache, node, nodeIndex, start,
1688
dir = simple !== forward ? "nextSibling" : "previousSibling",
1689
parent = elem.parentNode,
1690
name = ofType && elem.nodeName.toLowerCase(),
1691
useCache = !xml && !ofType,
1696
// :(first|last|only)-(child|of-type)
1700
while ( (node = node[ dir ]) ) {
1702
node.nodeName.toLowerCase() === name :
1703
node.nodeType === 1 ) {
1708
// Reverse direction for :only-* (if we haven't yet done so)
1709
start = dir = type === "only" && !start && "nextSibling";
1714
start = [ forward ? parent.firstChild : parent.lastChild ];
1716
// non-xml :nth-child(...) stores cache data on `parent`
1717
if ( forward && useCache ) {
1719
// Seek `elem` from a previously-cached index
1721
// ...in a gzip-friendly way
1723
outerCache = node[ expando ] || (node[ expando ] = {});
1725
// Support: IE <9 only
1726
// Defend against cloned attroperties (jQuery gh-1709)
1727
uniqueCache = outerCache[ node.uniqueID ] ||
1728
(outerCache[ node.uniqueID ] = {});
1730
cache = uniqueCache[ type ] || [];
1731
nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1732
diff = nodeIndex && cache[ 2 ];
1733
node = nodeIndex && parent.childNodes[ nodeIndex ];
1735
while ( (node = ++nodeIndex && node && node[ dir ] ||
1737
// Fallback to seeking `elem` from the start
1738
(diff = nodeIndex = 0) || start.pop()) ) {
1740
// When found, cache indexes on `parent` and break
1741
if ( node.nodeType === 1 && ++diff && node === elem ) {
1742
uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
1748
// Use previously-cached element index if available
1750
// ...in a gzip-friendly way
1752
outerCache = node[ expando ] || (node[ expando ] = {});
1754
// Support: IE <9 only
1755
// Defend against cloned attroperties (jQuery gh-1709)
1756
uniqueCache = outerCache[ node.uniqueID ] ||
1757
(outerCache[ node.uniqueID ] = {});
1759
cache = uniqueCache[ type ] || [];
1760
nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1764
// xml :nth-child(...)
1765
// or :nth-last-child(...) or :nth(-last)?-of-type(...)
1766
if ( diff === false ) {
1767
// Use the same loop as above to seek `elem` from the start
1768
while ( (node = ++nodeIndex && node && node[ dir ] ||
1769
(diff = nodeIndex = 0) || start.pop()) ) {
1772
node.nodeName.toLowerCase() === name :
1773
node.nodeType === 1 ) &&
1776
// Cache the index of each encountered element
1778
outerCache = node[ expando ] || (node[ expando ] = {});
1780
// Support: IE <9 only
1781
// Defend against cloned attroperties (jQuery gh-1709)
1782
uniqueCache = outerCache[ node.uniqueID ] ||
1783
(outerCache[ node.uniqueID ] = {});
1785
uniqueCache[ type ] = [ dirruns, diff ];
1788
if ( node === elem ) {
1796
// Incorporate the offset, then check against cycle size
1798
return diff === first || ( diff % first === 0 && diff / first >= 0 );
1803
"PSEUDO": function( pseudo, argument ) {
1804
// pseudo-class names are case-insensitive
1805
// http://www.w3.org/TR/selectors/#pseudo-classes
1806
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1807
// Remember that setFilters inherits from pseudos
1809
fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1810
Sizzle.error( "unsupported pseudo: " + pseudo );
1812
// The user may use createPseudo to indicate that
1813
// arguments are needed to create the filter function
1814
// just as Sizzle does
1815
if ( fn[ expando ] ) {
1816
return fn( argument );
1819
// But maintain support for old signatures
1820
if ( fn.length > 1 ) {
1821
args = [ pseudo, pseudo, "", argument ];
1822
return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1823
markFunction(function( seed, matches ) {
1825
matched = fn( seed, argument ),
1828
idx = indexOf( seed, matched[i] );
1829
seed[ idx ] = !( matches[ idx ] = matched[i] );
1833
return fn( elem, 0, args );
1842
// Potentially complex pseudos
1843
"not": markFunction(function( selector ) {
1844
// Trim the selector passed to compile
1845
// to avoid treating leading and trailing
1846
// spaces as combinators
1849
matcher = compile( selector.replace( rtrim, "$1" ) );
1851
return matcher[ expando ] ?
1852
markFunction(function( seed, matches, context, xml ) {
1854
unmatched = matcher( seed, null, xml, [] ),
1857
// Match elements unmatched by `matcher`
1859
if ( (elem = unmatched[i]) ) {
1860
seed[i] = !(matches[i] = elem);
1864
function( elem, context, xml ) {
1866
matcher( input, null, xml, results );
1867
// Don't keep the element (issue #299)
1869
return !results.pop();
1873
"has": markFunction(function( selector ) {
1874
return function( elem ) {
1875
return Sizzle( selector, elem ).length > 0;
1879
"contains": markFunction(function( text ) {
1880
text = text.replace( runescape, funescape );
1881
return function( elem ) {
1882
return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1886
// "Whether an element is represented by a :lang() selector
1887
// is based solely on the element's language value
1888
// being equal to the identifier C,
1889
// or beginning with the identifier C immediately followed by "-".
1890
// The matching of C against the element's language value is performed case-insensitively.
1891
// The identifier C does not have to be a valid language name."
1892
// http://www.w3.org/TR/selectors/#lang-pseudo
1893
"lang": markFunction( function( lang ) {
1894
// lang value must be a valid identifier
1895
if ( !ridentifier.test(lang || "") ) {
1896
Sizzle.error( "unsupported lang: " + lang );
1898
lang = lang.replace( runescape, funescape ).toLowerCase();
1899
return function( elem ) {
1902
if ( (elemLang = documentIsHTML ?
1904
elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1906
elemLang = elemLang.toLowerCase();
1907
return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1909
} while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1915
"target": function( elem ) {
1916
var hash = window.location && window.location.hash;
1917
return hash && hash.slice( 1 ) === elem.id;
1920
"root": function( elem ) {
1921
return elem === docElem;
1924
"focus": function( elem ) {
1925
return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1928
// Boolean properties
1929
"enabled": function( elem ) {
1930
return elem.disabled === false;
1933
"disabled": function( elem ) {
1934
return elem.disabled === true;
1937
"checked": function( elem ) {
1938
// In CSS3, :checked should return both checked and selected elements
1939
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1940
var nodeName = elem.nodeName.toLowerCase();
1941
return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1944
"selected": function( elem ) {
1945
// Accessing this property makes selected-by-default
1946
// options in Safari work properly
1947
if ( elem.parentNode ) {
1948
elem.parentNode.selectedIndex;
1951
return elem.selected === true;
1955
"empty": function( elem ) {
1956
// http://www.w3.org/TR/selectors/#empty-pseudo
1957
// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1958
// but not by others (comment: 8; processing instruction: 7; etc.)
1959
// nodeType < 6 works because attributes (2) do not appear as children
1960
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1961
if ( elem.nodeType < 6 ) {
1968
"parent": function( elem ) {
1969
return !Expr.pseudos["empty"]( elem );
1972
// Element/input types
1973
"header": function( elem ) {
1974
return rheader.test( elem.nodeName );
1977
"input": function( elem ) {
1978
return rinputs.test( elem.nodeName );
1981
"button": function( elem ) {
1982
var name = elem.nodeName.toLowerCase();
1983
return name === "input" && elem.type === "button" || name === "button";
1986
"text": function( elem ) {
1988
return elem.nodeName.toLowerCase() === "input" &&
1989
elem.type === "text" &&
1992
// New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1993
( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1996
// Position-in-collection
1997
"first": createPositionalPseudo(function() {
2001
"last": createPositionalPseudo(function( matchIndexes, length ) {
2002
return [ length - 1 ];
2005
"eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
2006
return [ argument < 0 ? argument + length : argument ];
2009
"even": createPositionalPseudo(function( matchIndexes, length ) {
2011
for ( ; i < length; i += 2 ) {
2012
matchIndexes.push( i );
2014
return matchIndexes;
2017
"odd": createPositionalPseudo(function( matchIndexes, length ) {
2019
for ( ; i < length; i += 2 ) {
2020
matchIndexes.push( i );
2022
return matchIndexes;
2025
"lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2026
var i = argument < 0 ? argument + length : argument;
2027
for ( ; --i >= 0; ) {
2028
matchIndexes.push( i );
2030
return matchIndexes;
2033
"gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2034
var i = argument < 0 ? argument + length : argument;
2035
for ( ; ++i < length; ) {
2036
matchIndexes.push( i );
2038
return matchIndexes;
2043
Expr.pseudos["nth"] = Expr.pseudos["eq"];
2045
// Add button/input type pseudos
2046
for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2047
Expr.pseudos[ i ] = createInputPseudo( i );
2049
for ( i in { submit: true, reset: true } ) {
2050
Expr.pseudos[ i ] = createButtonPseudo( i );
2053
// Easy API for creating new setFilters
2054
function setFilters() {}
2055
setFilters.prototype = Expr.filters = Expr.pseudos;
2056
Expr.setFilters = new setFilters();
2058
tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2059
var matched, match, tokens, type,
2060
soFar, groups, preFilters,
2061
cached = tokenCache[ selector + " " ];
2064
return parseOnly ? 0 : cached.slice( 0 );
2069
preFilters = Expr.preFilter;
2073
// Comma and first run
2074
if ( !matched || (match = rcomma.exec( soFar )) ) {
2076
// Don't consume trailing commas as valid
2077
soFar = soFar.slice( match[0].length ) || soFar;
2079
groups.push( (tokens = []) );
2085
if ( (match = rcombinators.exec( soFar )) ) {
2086
matched = match.shift();
2089
// Cast descendant combinators to space
2090
type: match[0].replace( rtrim, " " )
2092
soFar = soFar.slice( matched.length );
2096
for ( type in Expr.filter ) {
2097
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2098
(match = preFilters[ type ]( match ))) ) {
2099
matched = match.shift();
2105
soFar = soFar.slice( matched.length );
2114
// Return the length of the invalid excess
2115
// if we're just parsing
2116
// Otherwise, throw an error or return tokens
2120
Sizzle.error( selector ) :
2122
tokenCache( selector, groups ).slice( 0 );
2125
function toSelector( tokens ) {
2127
len = tokens.length,
2129
for ( ; i < len; i++ ) {
2130
selector += tokens[i].value;
2135
function addCombinator( matcher, combinator, base ) {
2136
var dir = combinator.dir,
2137
checkNonElements = base && dir === "parentNode",
2140
return combinator.first ?
2141
// Check against closest ancestor/preceding element
2142
function( elem, context, xml ) {
2143
while ( (elem = elem[ dir ]) ) {
2144
if ( elem.nodeType === 1 || checkNonElements ) {
2145
return matcher( elem, context, xml );
2150
// Check against all ancestor/preceding elements
2151
function( elem, context, xml ) {
2152
var oldCache, uniqueCache, outerCache,
2153
newCache = [ dirruns, doneName ];
2155
// We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2157
while ( (elem = elem[ dir ]) ) {
2158
if ( elem.nodeType === 1 || checkNonElements ) {
2159
if ( matcher( elem, context, xml ) ) {
2165
while ( (elem = elem[ dir ]) ) {
2166
if ( elem.nodeType === 1 || checkNonElements ) {
2167
outerCache = elem[ expando ] || (elem[ expando ] = {});
2169
// Support: IE <9 only
2170
// Defend against cloned attroperties (jQuery gh-1709)
2171
uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
2173
if ( (oldCache = uniqueCache[ dir ]) &&
2174
oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2176
// Assign to newCache so results back-propagate to previous elements
2177
return (newCache[ 2 ] = oldCache[ 2 ]);
2179
// Reuse newcache so results back-propagate to previous elements
2180
uniqueCache[ dir ] = newCache;
2182
// A match means we're done; a fail means we have to keep checking
2183
if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2193
function elementMatcher( matchers ) {
2194
return matchers.length > 1 ?
2195
function( elem, context, xml ) {
2196
var i = matchers.length;
2198
if ( !matchers[i]( elem, context, xml ) ) {
2207
function multipleContexts( selector, contexts, results ) {
2209
len = contexts.length;
2210
for ( ; i < len; i++ ) {
2211
Sizzle( selector, contexts[i], results );
2216
function condense( unmatched, map, filter, context, xml ) {
2220
len = unmatched.length,
2221
mapped = map != null;
2223
for ( ; i < len; i++ ) {
2224
if ( (elem = unmatched[i]) ) {
2225
if ( !filter || filter( elem, context, xml ) ) {
2226
newUnmatched.push( elem );
2234
return newUnmatched;
2237
function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2238
if ( postFilter && !postFilter[ expando ] ) {
2239
postFilter = setMatcher( postFilter );
2241
if ( postFinder && !postFinder[ expando ] ) {
2242
postFinder = setMatcher( postFinder, postSelector );
2244
return markFunction(function( seed, results, context, xml ) {
2248
preexisting = results.length,
2250
// Get initial elements from seed or context
2251
elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2253
// Prefilter to get matcher input, preserving a map for seed-results synchronization
2254
matcherIn = preFilter && ( seed || !selector ) ?
2255
condense( elems, preMap, preFilter, context, xml ) :
2258
matcherOut = matcher ?
2259
// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2260
postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2262
// ...intermediate processing is necessary
2265
// ...otherwise use results directly
2269
// Find primary matches
2271
matcher( matcherIn, matcherOut, context, xml );
2276
temp = condense( matcherOut, postMap );
2277
postFilter( temp, [], context, xml );
2279
// Un-match failing elements by moving them back to matcherIn
2282
if ( (elem = temp[i]) ) {
2283
matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2289
if ( postFinder || preFilter ) {
2291
// Get the final matcherOut by condensing this intermediate into postFinder contexts
2293
i = matcherOut.length;
2295
if ( (elem = matcherOut[i]) ) {
2296
// Restore matcherIn since elem is not yet a final match
2297
temp.push( (matcherIn[i] = elem) );
2300
postFinder( null, (matcherOut = []), temp, xml );
2303
// Move matched elements from seed to results to keep them synchronized
2304
i = matcherOut.length;
2306
if ( (elem = matcherOut[i]) &&
2307
(temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
2309
seed[temp] = !(results[temp] = elem);
2314
// Add elements to results, through postFinder if defined
2316
matcherOut = condense(
2317
matcherOut === results ?
2318
matcherOut.splice( preexisting, matcherOut.length ) :
2322
postFinder( null, results, matcherOut, xml );
2324
push.apply( results, matcherOut );
2330
function matcherFromTokens( tokens ) {
2331
var checkContext, matcher, j,
2332
len = tokens.length,
2333
leadingRelative = Expr.relative[ tokens[0].type ],
2334
implicitRelative = leadingRelative || Expr.relative[" "],
2335
i = leadingRelative ? 1 : 0,
2337
// The foundational matcher ensures that elements are reachable from top-level context(s)
2338
matchContext = addCombinator( function( elem ) {
2339
return elem === checkContext;
2340
}, implicitRelative, true ),
2341
matchAnyContext = addCombinator( function( elem ) {
2342
return indexOf( checkContext, elem ) > -1;
2343
}, implicitRelative, true ),
2344
matchers = [ function( elem, context, xml ) {
2345
var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2346
(checkContext = context).nodeType ?
2347
matchContext( elem, context, xml ) :
2348
matchAnyContext( elem, context, xml ) );
2349
// Avoid hanging onto element (issue #299)
2350
checkContext = null;
2354
for ( ; i < len; i++ ) {
2355
if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2356
matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2358
matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2360
// Return special upon seeing a positional matcher
2361
if ( matcher[ expando ] ) {
2362
// Find the next relative operator (if any) for proper handling
2364
for ( ; j < len; j++ ) {
2365
if ( Expr.relative[ tokens[j].type ] ) {
2370
i > 1 && elementMatcher( matchers ),
2371
i > 1 && toSelector(
2372
// If the preceding token was a descendant combinator, insert an implicit any-element `*`
2373
tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2374
).replace( rtrim, "$1" ),
2376
i < j && matcherFromTokens( tokens.slice( i, j ) ),
2377
j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2378
j < len && toSelector( tokens )
2381
matchers.push( matcher );
2385
return elementMatcher( matchers );
2388
function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2389
var bySet = setMatchers.length > 0,
2390
byElement = elementMatchers.length > 0,
2391
superMatcher = function( seed, context, xml, results, outermost ) {
2392
var elem, j, matcher,
2395
unmatched = seed && [],
2397
contextBackup = outermostContext,
2398
// We must always have either seed elements or outermost context
2399
elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2400
// Use integer dirruns iff this is the outermost matcher
2401
dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2405
outermostContext = context === document || context || outermost;
2408
// Add elements passing elementMatchers directly to results
2409
// Support: IE<9, Safari
2410
// Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2411
for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2412
if ( byElement && elem ) {
2414
if ( !context && elem.ownerDocument !== document ) {
2415
setDocument( elem );
2416
xml = !documentIsHTML;
2418
while ( (matcher = elementMatchers[j++]) ) {
2419
if ( matcher( elem, context || document, xml) ) {
2420
results.push( elem );
2425
dirruns = dirrunsUnique;
2429
// Track unmatched elements for set filters
2431
// They will have gone through all possible matchers
2432
if ( (elem = !matcher && elem) ) {
2436
// Lengthen the array for every element, matched or not
2438
unmatched.push( elem );
2443
// `i` is now the count of elements visited above, and adding it to `matchedCount`
2444
// makes the latter nonnegative.
2447
// Apply set filters to unmatched elements
2448
// NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2449
// equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2450
// no element matchers and no seed.
2451
// Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2452
// case, which will result in a "00" `matchedCount` that differs from `i` but is also
2453
// numerically zero.
2454
if ( bySet && i !== matchedCount ) {
2456
while ( (matcher = setMatchers[j++]) ) {
2457
matcher( unmatched, setMatched, context, xml );
2461
// Reintegrate element matches to eliminate the need for sorting
2462
if ( matchedCount > 0 ) {
2464
if ( !(unmatched[i] || setMatched[i]) ) {
2465
setMatched[i] = pop.call( results );
2470
// Discard index placeholder values to get only actual matches
2471
setMatched = condense( setMatched );
2474
// Add matches to results
2475
push.apply( results, setMatched );
2477
// Seedless set matches succeeding multiple successful matchers stipulate sorting
2478
if ( outermost && !seed && setMatched.length > 0 &&
2479
( matchedCount + setMatchers.length ) > 1 ) {
2481
Sizzle.uniqueSort( results );
2485
// Override manipulation of globals by nested matchers
2487
dirruns = dirrunsUnique;
2488
outermostContext = contextBackup;
2495
markFunction( superMatcher ) :
2499
compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2502
elementMatchers = [],
2503
cached = compilerCache[ selector + " " ];
2506
// Generate a function of recursive functions that can be used to check each element
2508
match = tokenize( selector );
2512
cached = matcherFromTokens( match[i] );
2513
if ( cached[ expando ] ) {
2514
setMatchers.push( cached );
2516
elementMatchers.push( cached );
2520
// Cache the compiled function
2521
cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2523
// Save selector and tokenization
2524
cached.selector = selector;
2530
* A low-level selection function that works with Sizzle's compiled
2531
* selector functions
2532
* @param {String|Function} selector A selector or a pre-compiled
2533
* selector function built with Sizzle.compile
2534
* @param {Element} context
2535
* @param {Array} [results]
2536
* @param {Array} [seed] A set of elements to match against
2538
select = Sizzle.select = function( selector, context, results, seed ) {
2539
var i, tokens, token, type, find,
2540
compiled = typeof selector === "function" && selector,
2541
match = !seed && tokenize( (selector = compiled.selector || selector) );
2543
results = results || [];
2545
// Try to minimize operations if there is only one selector in the list and no seed
2546
// (the latter of which guarantees us context)
2547
if ( match.length === 1 ) {
2549
// Reduce context if the leading compound selector is an ID
2550
tokens = match[0] = match[0].slice( 0 );
2551
if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2552
support.getById && context.nodeType === 9 && documentIsHTML &&
2553
Expr.relative[ tokens[1].type ] ) {
2555
context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2559
// Precompiled matchers will still verify ancestry, so step up a level
2560
} else if ( compiled ) {
2561
context = context.parentNode;
2564
selector = selector.slice( tokens.shift().value.length );
2567
// Fetch a seed set for right-to-left matching
2568
i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2572
// Abort if we hit a combinator
2573
if ( Expr.relative[ (type = token.type) ] ) {
2576
if ( (find = Expr.find[ type ]) ) {
2577
// Search, expanding context for leading sibling combinators
2579
token.matches[0].replace( runescape, funescape ),
2580
rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2583
// If seed is empty or no tokens remain, we can return early
2584
tokens.splice( i, 1 );
2585
selector = seed.length && toSelector( tokens );
2587
push.apply( results, seed );
2597
// Compile and execute a filtering function if one is not provided
2598
// Provide `match` to avoid retokenization if we modified the selector above
2599
( compiled || compile( selector, match ) )(
2604
!context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2609
// One-time assignments
2612
support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2614
// Support: Chrome 14-35+
2615
// Always assume duplicates if they aren't passed to the comparison function
2616
support.detectDuplicates = !!hasDuplicate;
2618
// Initialize against the default document
2621
// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2622
// Detached nodes confoundingly follow *each other*
2623
support.sortDetached = assert(function( div1 ) {
2624
// Should return 1, but returns 4 (following)
2625
return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2629
// Prevent attribute/property "interpolation"
2630
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2631
if ( !assert(function( div ) {
2632
div.innerHTML = "<a href='#'></a>";
2633
return div.firstChild.getAttribute("href") === "#" ;
2635
addHandle( "type|href|height|width", function( elem, name, isXML ) {
2637
return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2643
// Use defaultValue in place of getAttribute("value")
2644
if ( !support.attributes || !assert(function( div ) {
2645
div.innerHTML = "<input/>";
2646
div.firstChild.setAttribute( "value", "" );
2647
return div.firstChild.getAttribute( "value" ) === "";
2649
addHandle( "value", function( elem, name, isXML ) {
2650
if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2651
return elem.defaultValue;
2657
// Use getAttributeNode to fetch booleans when getAttribute lies
2658
if ( !assert(function( div ) {
2659
return div.getAttribute("disabled") == null;
2661
addHandle( booleans, function( elem, name, isXML ) {
2664
return elem[ name ] === true ? name.toLowerCase() :
2665
(val = elem.getAttributeNode( name )) && val.specified ?
2678
jQuery.find = Sizzle;
2679
jQuery.expr = Sizzle.selectors;
2680
jQuery.expr[ ":" ] = jQuery.expr.pseudos;
2681
jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
2682
jQuery.text = Sizzle.getText;
2683
jQuery.isXMLDoc = Sizzle.isXML;
2684
jQuery.contains = Sizzle.contains;
2688
var dir = function( elem, dir, until ) {
2690
truncate = until !== undefined;
2692
while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
2693
if ( elem.nodeType === 1 ) {
2694
if ( truncate && jQuery( elem ).is( until ) ) {
2697
matched.push( elem );
2704
var siblings = function( n, elem ) {
2707
for ( ; n; n = n.nextSibling ) {
2708
if ( n.nodeType === 1 && n !== elem ) {
2717
var rneedsContext = jQuery.expr.match.needsContext;
2719
var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
2723
var risSimple = /^.[^:#\[\.,]*$/;
2725
// Implement the identical functionality for filter and not
2726
function winnow( elements, qualifier, not ) {
2727
if ( jQuery.isFunction( qualifier ) ) {
2728
return jQuery.grep( elements, function( elem, i ) {
2730
return !!qualifier.call( elem, i, elem ) !== not;
2735
if ( qualifier.nodeType ) {
2736
return jQuery.grep( elements, function( elem ) {
2737
return ( elem === qualifier ) !== not;
2742
if ( typeof qualifier === "string" ) {
2743
if ( risSimple.test( qualifier ) ) {
2744
return jQuery.filter( qualifier, elements, not );
2747
qualifier = jQuery.filter( qualifier, elements );
2750
return jQuery.grep( elements, function( elem ) {
2751
return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
2755
jQuery.filter = function( expr, elems, not ) {
2756
var elem = elems[ 0 ];
2759
expr = ":not(" + expr + ")";
2762
return elems.length === 1 && elem.nodeType === 1 ?
2763
jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2764
jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2765
return elem.nodeType === 1;
2770
find: function( selector ) {
2776
if ( typeof selector !== "string" ) {
2777
return this.pushStack( jQuery( selector ).filter( function() {
2778
for ( i = 0; i < len; i++ ) {
2779
if ( jQuery.contains( self[ i ], this ) ) {
2786
for ( i = 0; i < len; i++ ) {
2787
jQuery.find( selector, self[ i ], ret );
2790
// Needed because $( selector, context ) becomes $( context ).find( selector )
2791
ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2792
ret.selector = this.selector ? this.selector + " " + selector : selector;
2795
filter: function( selector ) {
2796
return this.pushStack( winnow( this, selector || [], false ) );
2798
not: function( selector ) {
2799
return this.pushStack( winnow( this, selector || [], true ) );
2801
is: function( selector ) {
2805
// If this is a positional/relative selector, check membership in the returned set
2806
// so $("p:first").is("p:last") won't return true for a doc with two "p".
2807
typeof selector === "string" && rneedsContext.test( selector ) ?
2808
jQuery( selector ) :
2816
// Initialize a jQuery object
2819
// A central reference to the root jQuery(document)
2822
// A simple way to check for HTML strings
2823
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2824
// Strict HTML recognition (#11290: must start with <)
2825
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2827
init = jQuery.fn.init = function( selector, context, root ) {
2830
// HANDLE: $(""), $(null), $(undefined), $(false)
2835
// Method init() accepts an alternate rootjQuery
2836
// so migrate can support jQuery.sub (gh-2101)
2837
root = root || rootjQuery;
2839
// Handle HTML strings
2840
if ( typeof selector === "string" ) {
2841
if ( selector[ 0 ] === "<" &&
2842
selector[ selector.length - 1 ] === ">" &&
2843
selector.length >= 3 ) {
2845
// Assume that strings that start and end with <> are HTML and skip the regex check
2846
match = [ null, selector, null ];
2849
match = rquickExpr.exec( selector );
2852
// Match html or make sure no context is specified for #id
2853
if ( match && ( match[ 1 ] || !context ) ) {
2855
// HANDLE: $(html) -> $(array)
2857
context = context instanceof jQuery ? context[ 0 ] : context;
2859
// Option to run scripts is true for back-compat
2860
// Intentionally let the error be thrown if parseHTML is not present
2861
jQuery.merge( this, jQuery.parseHTML(
2863
context && context.nodeType ? context.ownerDocument || context : document,
2867
// HANDLE: $(html, props)
2868
if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
2869
for ( match in context ) {
2871
// Properties of context are called as methods if possible
2872
if ( jQuery.isFunction( this[ match ] ) ) {
2873
this[ match ]( context[ match ] );
2875
// ...and otherwise set as attributes
2877
this.attr( match, context[ match ] );
2886
elem = document.getElementById( match[ 2 ] );
2888
// Support: Blackberry 4.6
2889
// gEBID returns nodes no longer in the document (#6963)
2890
if ( elem && elem.parentNode ) {
2892
// Inject the element directly into the jQuery object
2897
this.context = document;
2898
this.selector = selector;
2902
// HANDLE: $(expr, $(...))
2903
} else if ( !context || context.jquery ) {
2904
return ( context || root ).find( selector );
2906
// HANDLE: $(expr, context)
2907
// (which is just equivalent to: $(context).find(expr)
2909
return this.constructor( context ).find( selector );
2912
// HANDLE: $(DOMElement)
2913
} else if ( selector.nodeType ) {
2914
this.context = this[ 0 ] = selector;
2918
// HANDLE: $(function)
2919
// Shortcut for document ready
2920
} else if ( jQuery.isFunction( selector ) ) {
2921
return root.ready !== undefined ?
2922
root.ready( selector ) :
2924
// Execute immediately if ready is not present
2928
if ( selector.selector !== undefined ) {
2929
this.selector = selector.selector;
2930
this.context = selector.context;
2933
return jQuery.makeArray( selector, this );
2936
// Give the init function the jQuery prototype for later instantiation
2937
init.prototype = jQuery.fn;
2939
// Initialize central reference
2940
rootjQuery = jQuery( document );
2943
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2945
// Methods guaranteed to produce a unique set when starting from a unique set
2946
guaranteedUnique = {
2954
has: function( target ) {
2955
var targets = jQuery( target, this ),
2958
return this.filter( function() {
2960
for ( ; i < l; i++ ) {
2961
if ( jQuery.contains( this, targets[ i ] ) ) {
2968
closest: function( selectors, context ) {
2973
pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
2974
jQuery( selectors, context || this.context ) :
2977
for ( ; i < l; i++ ) {
2978
for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
2980
// Always skip document fragments
2981
if ( cur.nodeType < 11 && ( pos ?
2982
pos.index( cur ) > -1 :
2984
// Don't pass non-elements to Sizzle
2985
cur.nodeType === 1 &&
2986
jQuery.find.matchesSelector( cur, selectors ) ) ) {
2988
matched.push( cur );
2994
return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
2997
// Determine the position of an element within the set
2998
index: function( elem ) {
3000
// No argument, return index in parent
3002
return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
3005
// Index in selector
3006
if ( typeof elem === "string" ) {
3007
return indexOf.call( jQuery( elem ), this[ 0 ] );
3010
// Locate the position of the desired element
3011
return indexOf.call( this,
3013
// If it receives a jQuery object, the first element is used
3014
elem.jquery ? elem[ 0 ] : elem
3018
add: function( selector, context ) {
3019
return this.pushStack(
3021
jQuery.merge( this.get(), jQuery( selector, context ) )
3026
addBack: function( selector ) {
3027
return this.add( selector == null ?
3028
this.prevObject : this.prevObject.filter( selector )
3033
function sibling( cur, dir ) {
3034
while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
3039
parent: function( elem ) {
3040
var parent = elem.parentNode;
3041
return parent && parent.nodeType !== 11 ? parent : null;
3043
parents: function( elem ) {
3044
return dir( elem, "parentNode" );
3046
parentsUntil: function( elem, i, until ) {
3047
return dir( elem, "parentNode", until );
3049
next: function( elem ) {
3050
return sibling( elem, "nextSibling" );
3052
prev: function( elem ) {
3053
return sibling( elem, "previousSibling" );
3055
nextAll: function( elem ) {
3056
return dir( elem, "nextSibling" );
3058
prevAll: function( elem ) {
3059
return dir( elem, "previousSibling" );
3061
nextUntil: function( elem, i, until ) {
3062
return dir( elem, "nextSibling", until );
3064
prevUntil: function( elem, i, until ) {
3065
return dir( elem, "previousSibling", until );
3067
siblings: function( elem ) {
3068
return siblings( ( elem.parentNode || {} ).firstChild, elem );
3070
children: function( elem ) {
3071
return siblings( elem.firstChild );
3073
contents: function( elem ) {
3074
return elem.contentDocument || jQuery.merge( [], elem.childNodes );
3076
}, function( name, fn ) {
3077
jQuery.fn[ name ] = function( until, selector ) {
3078
var matched = jQuery.map( this, fn, until );
3080
if ( name.slice( -5 ) !== "Until" ) {
3084
if ( selector && typeof selector === "string" ) {
3085
matched = jQuery.filter( selector, matched );
3088
if ( this.length > 1 ) {
3090
// Remove duplicates
3091
if ( !guaranteedUnique[ name ] ) {
3092
jQuery.uniqueSort( matched );
3095
// Reverse order for parents* and prev-derivatives
3096
if ( rparentsprev.test( name ) ) {
3101
return this.pushStack( matched );
3104
var rnotwhite = ( /\S+/g );
3108
// Convert String-formatted options into Object-formatted ones
3109
function createOptions( options ) {
3111
jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
3112
object[ flag ] = true;
3118
* Create a callback list using the following parameters:
3120
* options: an optional list of space-separated options that will change how
3121
* the callback list behaves or a more traditional option object
3123
* By default a callback list will act like an event callback list and can be
3124
* "fired" multiple times.
3128
* once: will ensure the callback list can only be fired once (like a Deferred)
3130
* memory: will keep track of previous values and will call any callback added
3131
* after the list has been fired right away with the latest "memorized"
3132
* values (like a Deferred)
3134
* unique: will ensure a callback can only be added once (no duplicate in the list)
3136
* stopOnFalse: interrupt callings when a callback returns false
3139
jQuery.Callbacks = function( options ) {
3141
// Convert options from String-formatted to Object-formatted if needed
3142
// (we check in cache first)
3143
options = typeof options === "string" ?
3144
createOptions( options ) :
3145
jQuery.extend( {}, options );
3147
var // Flag to know if list is currently firing
3150
// Last fire value for non-forgettable lists
3153
// Flag to know if list was already fired
3156
// Flag to prevent firing
3159
// Actual callback list
3162
// Queue of execution data for repeatable lists
3165
// Index of currently firing callback (modified by add/remove as needed)
3171
// Enforce single-firing
3172
locked = options.once;
3174
// Execute callbacks for all pending executions,
3175
// respecting firingIndex overrides and runtime changes
3176
fired = firing = true;
3177
for ( ; queue.length; firingIndex = -1 ) {
3178
memory = queue.shift();
3179
while ( ++firingIndex < list.length ) {
3181
// Run callback and check for early termination
3182
if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
3183
options.stopOnFalse ) {
3185
// Jump to end and forget the data so .add doesn't re-fire
3186
firingIndex = list.length;
3192
// Forget the data if we're done with it
3193
if ( !options.memory ) {
3199
// Clean up if we're done firing for good
3202
// Keep an empty list if we have data for future add calls
3206
// Otherwise, this object is spent
3213
// Actual Callbacks object
3216
// Add a callback or a collection of callbacks to the list
3220
// If we have memory from a past run, we should fire after adding
3221
if ( memory && !firing ) {
3222
firingIndex = list.length - 1;
3223
queue.push( memory );
3226
( function add( args ) {
3227
jQuery.each( args, function( _, arg ) {
3228
if ( jQuery.isFunction( arg ) ) {
3229
if ( !options.unique || !self.has( arg ) ) {
3232
} else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
3234
// Inspect recursively
3240
if ( memory && !firing ) {
3247
// Remove a callback from the list
3248
remove: function() {
3249
jQuery.each( arguments, function( _, arg ) {
3251
while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3252
list.splice( index, 1 );
3254
// Handle firing indexes
3255
if ( index <= firingIndex ) {
3263
// Check if a given callback is in the list.
3264
// If no argument is given, return whether or not list has callbacks attached.
3265
has: function( fn ) {
3267
jQuery.inArray( fn, list ) > -1 :
3271
// Remove all callbacks from the list
3279
// Disable .fire and .add
3280
// Abort any current/pending executions
3281
// Clear all callbacks and values
3282
disable: function() {
3283
locked = queue = [];
3287
disabled: function() {
3292
// Also disable .add unless we have memory (since it would have no effect)
3293
// Abort any pending executions
3295
locked = queue = [];
3301
locked: function() {
3305
// Call all callbacks with the given context and arguments
3306
fireWith: function( context, args ) {
3309
args = [ context, args.slice ? args.slice() : args ];
3318
// Call all the callbacks with the given arguments
3320
self.fireWith( this, arguments );
3324
// To know if the callbacks have already been called at least once
3336
Deferred: function( func ) {
3339
// action, add listener, listener list, final state
3340
[ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
3341
[ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
3342
[ "notify", "progress", jQuery.Callbacks( "memory" ) ]
3349
always: function() {
3350
deferred.done( arguments ).fail( arguments );
3353
then: function( /* fnDone, fnFail, fnProgress */ ) {
3354
var fns = arguments;
3355
return jQuery.Deferred( function( newDefer ) {
3356
jQuery.each( tuples, function( i, tuple ) {
3357
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
3359
// deferred[ done | fail | progress ] for forwarding actions to newDefer
3360
deferred[ tuple[ 1 ] ]( function() {
3361
var returned = fn && fn.apply( this, arguments );
3362
if ( returned && jQuery.isFunction( returned.promise ) ) {
3364
.progress( newDefer.notify )
3365
.done( newDefer.resolve )
3366
.fail( newDefer.reject );
3368
newDefer[ tuple[ 0 ] + "With" ](
3369
this === promise ? newDefer.promise() : this,
3370
fn ? [ returned ] : arguments
3379
// Get a promise for this deferred
3380
// If obj is provided, the promise aspect is added to the object
3381
promise: function( obj ) {
3382
return obj != null ? jQuery.extend( obj, promise ) : promise;
3387
// Keep pipe for back-compat
3388
promise.pipe = promise.then;
3390
// Add list-specific methods
3391
jQuery.each( tuples, function( i, tuple ) {
3392
var list = tuple[ 2 ],
3393
stateString = tuple[ 3 ];
3395
// promise[ done | fail | progress ] = list.add
3396
promise[ tuple[ 1 ] ] = list.add;
3399
if ( stateString ) {
3400
list.add( function() {
3402
// state = [ resolved | rejected ]
3403
state = stateString;
3405
// [ reject_list | resolve_list ].disable; progress_list.lock
3406
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
3409
// deferred[ resolve | reject | notify ]
3410
deferred[ tuple[ 0 ] ] = function() {
3411
deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
3414
deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
3417
// Make the deferred a promise
3418
promise.promise( deferred );
3420
// Call given func if any
3422
func.call( deferred, deferred );
3430
when: function( subordinate /* , ..., subordinateN */ ) {
3432
resolveValues = slice.call( arguments ),
3433
length = resolveValues.length,
3435
// the count of uncompleted subordinates
3436
remaining = length !== 1 ||
3437
( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3439
// the master Deferred.
3440
// If resolveValues consist of only a single Deferred, just use that.
3441
deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
3443
// Update function for both resolve and progress values
3444
updateFunc = function( i, contexts, values ) {
3445
return function( value ) {
3446
contexts[ i ] = this;
3447
values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3448
if ( values === progressValues ) {
3449
deferred.notifyWith( contexts, values );
3450
} else if ( !( --remaining ) ) {
3451
deferred.resolveWith( contexts, values );
3456
progressValues, progressContexts, resolveContexts;
3458
// Add listeners to Deferred subordinates; treat others as resolved
3460
progressValues = new Array( length );
3461
progressContexts = new Array( length );
3462
resolveContexts = new Array( length );
3463
for ( ; i < length; i++ ) {
3464
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
3465
resolveValues[ i ].promise()
3466
.progress( updateFunc( i, progressContexts, progressValues ) )
3467
.done( updateFunc( i, resolveContexts, resolveValues ) )
3468
.fail( deferred.reject );
3475
// If we're not waiting on anything, resolve the master
3477
deferred.resolveWith( resolveContexts, resolveValues );
3480
return deferred.promise();
3485
// The deferred used on DOM ready
3488
jQuery.fn.ready = function( fn ) {
3491
jQuery.ready.promise().done( fn );
3498
// Is the DOM ready to be used? Set to true once it occurs.
3501
// A counter to track how many items to wait for before
3502
// the ready event fires. See #6781
3505
// Hold (or release) the ready event
3506
holdReady: function( hold ) {
3510
jQuery.ready( true );
3514
// Handle when the DOM is ready
3515
ready: function( wait ) {
3517
// Abort if there are pending holds or we're already ready
3518
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3522
// Remember that the DOM is ready
3523
jQuery.isReady = true;
3525
// If a normal DOM Ready event fired, decrement, and wait if need be
3526
if ( wait !== true && --jQuery.readyWait > 0 ) {
3530
// If there are functions bound, to execute
3531
readyList.resolveWith( document, [ jQuery ] );
3533
// Trigger any bound ready events
3534
if ( jQuery.fn.triggerHandler ) {
3535
jQuery( document ).triggerHandler( "ready" );
3536
jQuery( document ).off( "ready" );
3542
* The ready event handler and self cleanup method
3544
function completed() {
3545
document.removeEventListener( "DOMContentLoaded", completed );
3546
window.removeEventListener( "load", completed );
3550
jQuery.ready.promise = function( obj ) {
3553
readyList = jQuery.Deferred();
3555
// Catch cases where $(document).ready() is called
3556
// after the browser event has already occurred.
3557
// Support: IE9-10 only
3558
// Older IE sometimes signals "interactive" too soon
3559
if ( document.readyState === "complete" ||
3560
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
3562
// Handle it asynchronously to allow scripts the opportunity to delay ready
3563
window.setTimeout( jQuery.ready );
3567
// Use the handy event callback
3568
document.addEventListener( "DOMContentLoaded", completed );
3570
// A fallback to window.onload, that will always work
3571
window.addEventListener( "load", completed );
3574
return readyList.promise( obj );
3577
// Kick off the DOM ready check even if the user does not
3578
jQuery.ready.promise();
3583
// Multifunctional method to get and set values of a collection
3584
// The value/s can optionally be executed if it's a function
3585
var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
3591
if ( jQuery.type( key ) === "object" ) {
3594
access( elems, fn, i, key[ i ], true, emptyGet, raw );
3598
} else if ( value !== undefined ) {
3601
if ( !jQuery.isFunction( value ) ) {
3607
// Bulk operations run against the entire set
3609
fn.call( elems, value );
3612
// ...except when executing function values
3615
fn = function( elem, key, value ) {
3616
return bulk.call( jQuery( elem ), value );
3622
for ( ; i < len; i++ ) {
3624
elems[ i ], key, raw ?
3626
value.call( elems[ i ], i, fn( elems[ i ], key ) )
3638
len ? fn( elems[ 0 ], key ) : emptyGet;
3640
var acceptData = function( owner ) {
3644
// - Node.ELEMENT_NODE
3645
// - Node.DOCUMENT_NODE
3649
return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
3656
this.expando = jQuery.expando + Data.uid++;
3663
register: function( owner, initial ) {
3664
var value = initial || {};
3666
// If it is a node unlikely to be stringify-ed or looped over
3667
// use plain assignment
3668
if ( owner.nodeType ) {
3669
owner[ this.expando ] = value;
3671
// Otherwise secure it in a non-enumerable, non-writable property
3672
// configurability must be true to allow the property to be
3673
// deleted with the delete operator
3675
Object.defineProperty( owner, this.expando, {
3681
return owner[ this.expando ];
3683
cache: function( owner ) {
3685
// We can accept data for non-element nodes in modern browsers,
3686
// but we should not, see #8335.
3687
// Always return an empty object.
3688
if ( !acceptData( owner ) ) {
3692
// Check if the owner object already has a cache
3693
var value = owner[ this.expando ];
3695
// If not, create one
3699
// We can accept data for non-element nodes in modern browsers,
3700
// but we should not, see #8335.
3701
// Always return an empty object.
3702
if ( acceptData( owner ) ) {
3704
// If it is a node unlikely to be stringify-ed or looped over
3705
// use plain assignment
3706
if ( owner.nodeType ) {
3707
owner[ this.expando ] = value;
3709
// Otherwise secure it in a non-enumerable property
3710
// configurable must be true to allow the property to be
3711
// deleted when data is removed
3713
Object.defineProperty( owner, this.expando, {
3723
set: function( owner, data, value ) {
3725
cache = this.cache( owner );
3727
// Handle: [ owner, key, value ] args
3728
if ( typeof data === "string" ) {
3729
cache[ data ] = value;
3731
// Handle: [ owner, { properties } ] args
3734
// Copy the properties one-by-one to the cache object
3735
for ( prop in data ) {
3736
cache[ prop ] = data[ prop ];
3741
get: function( owner, key ) {
3742
return key === undefined ?
3743
this.cache( owner ) :
3744
owner[ this.expando ] && owner[ this.expando ][ key ];
3746
access: function( owner, key, value ) {
3749
// In cases where either:
3751
// 1. No key was specified
3752
// 2. A string key was specified, but no value provided
3754
// Take the "read" path and allow the get method to determine
3755
// which value to return, respectively either:
3757
// 1. The entire cache object
3758
// 2. The data stored at the key
3760
if ( key === undefined ||
3761
( ( key && typeof key === "string" ) && value === undefined ) ) {
3763
stored = this.get( owner, key );
3765
return stored !== undefined ?
3766
stored : this.get( owner, jQuery.camelCase( key ) );
3769
// When the key is not a string, or both a key and value
3770
// are specified, set or extend (existing objects) with either:
3772
// 1. An object of properties
3773
// 2. A key and value
3775
this.set( owner, key, value );
3777
// Since the "set" path can have two possible entry points
3778
// return the expected data based on which path was taken[*]
3779
return value !== undefined ? value : key;
3781
remove: function( owner, key ) {
3783
cache = owner[ this.expando ];
3785
if ( cache === undefined ) {
3789
if ( key === undefined ) {
3790
this.register( owner );
3794
// Support array or space separated string of keys
3795
if ( jQuery.isArray( key ) ) {
3797
// If "name" is an array of keys...
3798
// When data is initially created, via ("key", "val") signature,
3799
// keys will be converted to camelCase.
3800
// Since there is no way to tell _how_ a key was added, remove
3801
// both plain key and camelCase key. #12786
3802
// This will only penalize the array argument path.
3803
name = key.concat( key.map( jQuery.camelCase ) );
3805
camel = jQuery.camelCase( key );
3807
// Try the string as a key before any manipulation
3808
if ( key in cache ) {
3809
name = [ key, camel ];
3812
// If a key with the spaces exists, use it.
3813
// Otherwise, create an array by matching non-whitespace
3815
name = name in cache ?
3816
[ name ] : ( name.match( rnotwhite ) || [] );
3823
delete cache[ name[ i ] ];
3827
// Remove the expando if there's no more data
3828
if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
3830
// Support: Chrome <= 35-45+
3831
// Webkit & Blink performance suffers when deleting properties
3832
// from DOM nodes, so set to undefined instead
3833
// https://code.google.com/p/chromium/issues/detail?id=378607
3834
if ( owner.nodeType ) {
3835
owner[ this.expando ] = undefined;
3837
delete owner[ this.expando ];
3841
hasData: function( owner ) {
3842
var cache = owner[ this.expando ];
3843
return cache !== undefined && !jQuery.isEmptyObject( cache );
3846
var dataPriv = new Data();
3848
var dataUser = new Data();
3852
// Implementation Summary
3854
// 1. Enforce API surface and semantic compatibility with 1.9.x branch
3855
// 2. Improve the module's maintainability by reducing the storage
3856
// paths to a single mechanism.
3857
// 3. Use the same single mechanism to support "private" and "user" data.
3858
// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
3859
// 5. Avoid exposing implementation details on user objects (eg. expando properties)
3860
// 6. Provide a clear path for implementation upgrade to WeakMap in 2014
3862
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
3863
rmultiDash = /[A-Z]/g;
3865
function dataAttr( elem, key, data ) {
3868
// If nothing was found internally, try to fetch any
3869
// data from the HTML5 data-* attribute
3870
if ( data === undefined && elem.nodeType === 1 ) {
3871
name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
3872
data = elem.getAttribute( name );
3874
if ( typeof data === "string" ) {
3876
data = data === "true" ? true :
3877
data === "false" ? false :
3878
data === "null" ? null :
3880
// Only convert to a number if it doesn't change the string
3881
+data + "" === data ? +data :
3882
rbrace.test( data ) ? jQuery.parseJSON( data ) :
3886
// Make sure we set the data so it isn't changed later
3887
dataUser.set( elem, key, data );
3896
hasData: function( elem ) {
3897
return dataUser.hasData( elem ) || dataPriv.hasData( elem );
3900
data: function( elem, name, data ) {
3901
return dataUser.access( elem, name, data );
3904
removeData: function( elem, name ) {
3905
dataUser.remove( elem, name );
3908
// TODO: Now that all calls to _data and _removeData have been replaced
3909
// with direct calls to dataPriv methods, these can be deprecated.
3910
_data: function( elem, name, data ) {
3911
return dataPriv.access( elem, name, data );
3914
_removeData: function( elem, name ) {
3915
dataPriv.remove( elem, name );
3920
data: function( key, value ) {
3923
attrs = elem && elem.attributes;
3926
if ( key === undefined ) {
3927
if ( this.length ) {
3928
data = dataUser.get( elem );
3930
if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
3935
// The attrs elements can be null (#14894)
3937
name = attrs[ i ].name;
3938
if ( name.indexOf( "data-" ) === 0 ) {
3939
name = jQuery.camelCase( name.slice( 5 ) );
3940
dataAttr( elem, name, data[ name ] );
3944
dataPriv.set( elem, "hasDataAttrs", true );
3951
// Sets multiple values
3952
if ( typeof key === "object" ) {
3953
return this.each( function() {
3954
dataUser.set( this, key );
3958
return access( this, function( value ) {
3961
// The calling jQuery object (element matches) is not empty
3962
// (and therefore has an element appears at this[ 0 ]) and the
3963
// `value` parameter was not undefined. An empty jQuery object
3964
// will result in `undefined` for elem = this[ 0 ] which will
3965
// throw an exception if an attempt to read a data cache is made.
3966
if ( elem && value === undefined ) {
3968
// Attempt to get data from the cache
3969
// with the key as-is
3970
data = dataUser.get( elem, key ) ||
3972
// Try to find dashed key if it exists (gh-2779)
3973
// This is for 2.2.x only
3974
dataUser.get( elem, key.replace( rmultiDash, "-$&" ).toLowerCase() );
3976
if ( data !== undefined ) {
3980
camelKey = jQuery.camelCase( key );
3982
// Attempt to get data from the cache
3983
// with the key camelized
3984
data = dataUser.get( elem, camelKey );
3985
if ( data !== undefined ) {
3989
// Attempt to "discover" the data in
3990
// HTML5 custom data-* attrs
3991
data = dataAttr( elem, camelKey, undefined );
3992
if ( data !== undefined ) {
3996
// We tried really hard, but the data doesn't exist.
4001
camelKey = jQuery.camelCase( key );
4002
this.each( function() {
4004
// First, attempt to store a copy or reference of any
4005
// data that might've been store with a camelCased key.
4006
var data = dataUser.get( this, camelKey );
4008
// For HTML5 data-* attribute interop, we have to
4009
// store property names with dashes in a camelCase form.
4010
// This might not apply to all properties...*
4011
dataUser.set( this, camelKey, value );
4013
// *... In the case of properties that might _actually_
4014
// have dashes, we need to also store a copy of that
4015
// unchanged property.
4016
if ( key.indexOf( "-" ) > -1 && data !== undefined ) {
4017
dataUser.set( this, key, value );
4020
}, null, value, arguments.length > 1, null, true );
4023
removeData: function( key ) {
4024
return this.each( function() {
4025
dataUser.remove( this, key );
4032
queue: function( elem, type, data ) {
4036
type = ( type || "fx" ) + "queue";
4037
queue = dataPriv.get( elem, type );
4039
// Speed up dequeue by getting out quickly if this is just a lookup
4041
if ( !queue || jQuery.isArray( data ) ) {
4042
queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
4051
dequeue: function( elem, type ) {
4052
type = type || "fx";
4054
var queue = jQuery.queue( elem, type ),
4055
startLength = queue.length,
4057
hooks = jQuery._queueHooks( elem, type ),
4059
jQuery.dequeue( elem, type );
4062
// If the fx queue is dequeued, always remove the progress sentinel
4063
if ( fn === "inprogress" ) {
4070
// Add a progress sentinel to prevent the fx queue from being
4071
// automatically dequeued
4072
if ( type === "fx" ) {
4073
queue.unshift( "inprogress" );
4076
// Clear up the last queue stop function
4078
fn.call( elem, next, hooks );
4081
if ( !startLength && hooks ) {
4086
// Not public - generate a queueHooks object, or return the current one
4087
_queueHooks: function( elem, type ) {
4088
var key = type + "queueHooks";
4089
return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
4090
empty: jQuery.Callbacks( "once memory" ).add( function() {
4091
dataPriv.remove( elem, [ type + "queue", key ] );
4098
queue: function( type, data ) {
4101
if ( typeof type !== "string" ) {
4107
if ( arguments.length < setter ) {
4108
return jQuery.queue( this[ 0 ], type );
4111
return data === undefined ?
4113
this.each( function() {
4114
var queue = jQuery.queue( this, type, data );
4116
// Ensure a hooks for this queue
4117
jQuery._queueHooks( this, type );
4119
if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
4120
jQuery.dequeue( this, type );
4124
dequeue: function( type ) {
4125
return this.each( function() {
4126
jQuery.dequeue( this, type );
4129
clearQueue: function( type ) {
4130
return this.queue( type || "fx", [] );
4133
// Get a promise resolved when queues of a certain type
4134
// are emptied (fx is the type by default)
4135
promise: function( type, obj ) {
4138
defer = jQuery.Deferred(),
4141
resolve = function() {
4142
if ( !( --count ) ) {
4143
defer.resolveWith( elements, [ elements ] );
4147
if ( typeof type !== "string" ) {
4151
type = type || "fx";
4154
tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
4155
if ( tmp && tmp.empty ) {
4157
tmp.empty.add( resolve );
4161
return defer.promise( obj );
4164
var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
4166
var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
4169
var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4171
var isHidden = function( elem, el ) {
4173
// isHidden might be called from jQuery#filter function;
4174
// in that case, element will be second argument
4176
return jQuery.css( elem, "display" ) === "none" ||
4177
!jQuery.contains( elem.ownerDocument, elem );
4182
function adjustCSS( elem, prop, valueParts, tween ) {
4186
currentValue = tween ?
4187
function() { return tween.cur(); } :
4188
function() { return jQuery.css( elem, prop, "" ); },
4189
initial = currentValue(),
4190
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4192
// Starting value computation is required for potential unit mismatches
4193
initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
4194
rcssNum.exec( jQuery.css( elem, prop ) );
4196
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
4198
// Trust units reported by jQuery.css
4199
unit = unit || initialInUnit[ 3 ];
4201
// Make sure we update the tween properties later on
4202
valueParts = valueParts || [];
4204
// Iteratively approximate from a nonzero starting point
4205
initialInUnit = +initial || 1;
4209
// If previous iteration zeroed out, double until we get *something*.
4210
// Use string for doubling so we don't accidentally see scale as unchanged below
4211
scale = scale || ".5";
4214
initialInUnit = initialInUnit / scale;
4215
jQuery.style( elem, prop, initialInUnit + unit );
4217
// Update scale, tolerating zero or NaN from tween.cur()
4218
// Break the loop if scale is unchanged or perfect, or if we've just had enough.
4220
scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
4225
initialInUnit = +initialInUnit || +initial || 0;
4227
// Apply relative offset (+=/-=) if specified
4228
adjusted = valueParts[ 1 ] ?
4229
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
4233
tween.start = initialInUnit;
4234
tween.end = adjusted;
4239
var rcheckableType = ( /^(?:checkbox|radio)$/i );
4241
var rtagName = ( /<([\w:-]+)/ );
4243
var rscriptType = ( /^$|\/(?:java|ecma)script/i );
4247
// We have to close these tags to support XHTML (#13200)
4251
option: [ 1, "<select multiple='multiple'>", "</select>" ],
4253
// XHTML parsers do not magically insert elements in the
4254
// same way that tag soup parsers do. So we cannot shorten
4255
// this by omitting <tbody> or other required elements.
4256
thead: [ 1, "<table>", "</table>" ],
4257
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4258
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4259
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4261
_default: [ 0, "", "" ]
4265
wrapMap.optgroup = wrapMap.option;
4267
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4268
wrapMap.th = wrapMap.td;
4271
function getAll( context, tag ) {
4274
// Use typeof to avoid zero-argument method invocation on host objects (#15151)
4275
var ret = typeof context.getElementsByTagName !== "undefined" ?
4276
context.getElementsByTagName( tag || "*" ) :
4277
typeof context.querySelectorAll !== "undefined" ?
4278
context.querySelectorAll( tag || "*" ) :
4281
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
4282
jQuery.merge( [ context ], ret ) :
4287
// Mark scripts as having already been evaluated
4288
function setGlobalEval( elems, refElements ) {
4292
for ( ; i < l; i++ ) {
4296
!refElements || dataPriv.get( refElements[ i ], "globalEval" )
4302
var rhtml = /<|&#?\w+;/;
4304
function buildFragment( elems, context, scripts, selection, ignored ) {
4305
var elem, tmp, tag, wrap, contains, j,
4306
fragment = context.createDocumentFragment(),
4311
for ( ; i < l; i++ ) {
4314
if ( elem || elem === 0 ) {
4316
// Add nodes directly
4317
if ( jQuery.type( elem ) === "object" ) {
4319
// Support: Android<4.1, PhantomJS<2
4320
// push.apply(_, arraylike) throws on ancient WebKit
4321
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
4323
// Convert non-html into a text node
4324
} else if ( !rhtml.test( elem ) ) {
4325
nodes.push( context.createTextNode( elem ) );
4327
// Convert html into DOM nodes
4329
tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
4331
// Deserialize a standard representation
4332
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
4333
wrap = wrapMap[ tag ] || wrapMap._default;
4334
tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
4336
// Descend through wrappers to the right content
4339
tmp = tmp.lastChild;
4342
// Support: Android<4.1, PhantomJS<2
4343
// push.apply(_, arraylike) throws on ancient WebKit
4344
jQuery.merge( nodes, tmp.childNodes );
4346
// Remember the top-level container
4347
tmp = fragment.firstChild;
4349
// Ensure the created nodes are orphaned (#12392)
4350
tmp.textContent = "";
4355
// Remove wrapper from fragment
4356
fragment.textContent = "";
4359
while ( ( elem = nodes[ i++ ] ) ) {
4361
// Skip elements already in the context collection (trac-4087)
4362
if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
4364
ignored.push( elem );
4369
contains = jQuery.contains( elem.ownerDocument, elem );
4371
// Append to fragment
4372
tmp = getAll( fragment.appendChild( elem ), "script" );
4374
// Preserve script evaluation history
4376
setGlobalEval( tmp );
4379
// Capture executables
4382
while ( ( elem = tmp[ j++ ] ) ) {
4383
if ( rscriptType.test( elem.type || "" ) ) {
4384
scripts.push( elem );
4395
var fragment = document.createDocumentFragment(),
4396
div = fragment.appendChild( document.createElement( "div" ) ),
4397
input = document.createElement( "input" );
4399
// Support: Android 4.0-4.3, Safari<=5.1
4400
// Check state lost if the name is set (#11217)
4401
// Support: Windows Web Apps (WWA)
4402
// `name` and `type` must use .setAttribute for WWA (#14901)
4403
input.setAttribute( "type", "radio" );
4404
input.setAttribute( "checked", "checked" );
4405
input.setAttribute( "name", "t" );
4407
div.appendChild( input );
4409
// Support: Safari<=5.1, Android<4.2
4410
// Older WebKit doesn't clone checked state correctly in fragments
4411
support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4414
// Make sure textarea (and checkbox) defaultValue is properly cloned
4415
div.innerHTML = "<textarea>x</textarea>";
4416
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4422
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
4423
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
4425
function returnTrue() {
4429
function returnFalse() {
4434
// See #13393 for more info
4435
function safeActiveElement() {
4437
return document.activeElement;
4441
function on( elem, types, selector, data, fn, one ) {
4444
// Types can be a map of types/handlers
4445
if ( typeof types === "object" ) {
4447
// ( types-Object, selector, data )
4448
if ( typeof selector !== "string" ) {
4450
// ( types-Object, data )
4451
data = data || selector;
4452
selector = undefined;
4454
for ( type in types ) {
4455
on( elem, type, selector, data, types[ type ], one );
4460
if ( data == null && fn == null ) {
4464
data = selector = undefined;
4465
} else if ( fn == null ) {
4466
if ( typeof selector === "string" ) {
4468
// ( types, selector, fn )
4473
// ( types, data, fn )
4476
selector = undefined;
4479
if ( fn === false ) {
4487
fn = function( event ) {
4489
// Can use an empty set, since event contains the info
4490
jQuery().off( event );
4491
return origFn.apply( this, arguments );
4494
// Use same guid so caller can remove using origFn
4495
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4497
return elem.each( function() {
4498
jQuery.event.add( this, types, fn, data, selector );
4503
* Helper functions for managing events -- not part of the public interface.
4504
* Props to Dean Edwards' addEvent library for many of the ideas.
4510
add: function( elem, types, handler, data, selector ) {
4512
var handleObjIn, eventHandle, tmp,
4513
events, t, handleObj,
4514
special, handlers, type, namespaces, origType,
4515
elemData = dataPriv.get( elem );
4517
// Don't attach events to noData or text/comment nodes (but allow plain objects)
4522
// Caller can pass in an object of custom data in lieu of the handler
4523
if ( handler.handler ) {
4524
handleObjIn = handler;
4525
handler = handleObjIn.handler;
4526
selector = handleObjIn.selector;
4529
// Make sure that the handler has a unique ID, used to find/remove it later
4530
if ( !handler.guid ) {
4531
handler.guid = jQuery.guid++;
4534
// Init the element's event structure and main handler, if this is the first
4535
if ( !( events = elemData.events ) ) {
4536
events = elemData.events = {};
4538
if ( !( eventHandle = elemData.handle ) ) {
4539
eventHandle = elemData.handle = function( e ) {
4541
// Discard the second event of a jQuery.event.trigger() and
4542
// when an event is called after a page has unloaded
4543
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
4544
jQuery.event.dispatch.apply( elem, arguments ) : undefined;
4548
// Handle multiple events separated by a space
4549
types = ( types || "" ).match( rnotwhite ) || [ "" ];
4552
tmp = rtypenamespace.exec( types[ t ] ) || [];
4553
type = origType = tmp[ 1 ];
4554
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
4556
// There *must* be a type, no attaching namespace-only handlers
4561
// If event changes its type, use the special event handlers for the changed type
4562
special = jQuery.event.special[ type ] || {};
4564
// If selector defined, determine special event api type, otherwise given type
4565
type = ( selector ? special.delegateType : special.bindType ) || type;
4567
// Update special based on newly reset type
4568
special = jQuery.event.special[ type ] || {};
4570
// handleObj is passed to all event handlers
4571
handleObj = jQuery.extend( {
4578
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4579
namespace: namespaces.join( "." )
4582
// Init the event handler queue if we're the first
4583
if ( !( handlers = events[ type ] ) ) {
4584
handlers = events[ type ] = [];
4585
handlers.delegateCount = 0;
4587
// Only use addEventListener if the special events handler returns false
4588
if ( !special.setup ||
4589
special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
4591
if ( elem.addEventListener ) {
4592
elem.addEventListener( type, eventHandle );
4597
if ( special.add ) {
4598
special.add.call( elem, handleObj );
4600
if ( !handleObj.handler.guid ) {
4601
handleObj.handler.guid = handler.guid;
4605
// Add to the element's handler list, delegates in front
4607
handlers.splice( handlers.delegateCount++, 0, handleObj );
4609
handlers.push( handleObj );
4612
// Keep track of which events have ever been used, for event optimization
4613
jQuery.event.global[ type ] = true;
4618
// Detach an event or set of events from an element
4619
remove: function( elem, types, handler, selector, mappedTypes ) {
4621
var j, origCount, tmp,
4622
events, t, handleObj,
4623
special, handlers, type, namespaces, origType,
4624
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
4626
if ( !elemData || !( events = elemData.events ) ) {
4630
// Once for each type.namespace in types; type may be omitted
4631
types = ( types || "" ).match( rnotwhite ) || [ "" ];
4634
tmp = rtypenamespace.exec( types[ t ] ) || [];
4635
type = origType = tmp[ 1 ];
4636
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
4638
// Unbind all events (on this namespace, if provided) for the element
4640
for ( type in events ) {
4641
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
4646
special = jQuery.event.special[ type ] || {};
4647
type = ( selector ? special.delegateType : special.bindType ) || type;
4648
handlers = events[ type ] || [];
4650
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
4652
// Remove matching events
4653
origCount = j = handlers.length;
4655
handleObj = handlers[ j ];
4657
if ( ( mappedTypes || origType === handleObj.origType ) &&
4658
( !handler || handler.guid === handleObj.guid ) &&
4659
( !tmp || tmp.test( handleObj.namespace ) ) &&
4660
( !selector || selector === handleObj.selector ||
4661
selector === "**" && handleObj.selector ) ) {
4662
handlers.splice( j, 1 );
4664
if ( handleObj.selector ) {
4665
handlers.delegateCount--;
4667
if ( special.remove ) {
4668
special.remove.call( elem, handleObj );
4673
// Remove generic event handler if we removed something and no more handlers exist
4674
// (avoids potential for endless recursion during removal of special event handlers)
4675
if ( origCount && !handlers.length ) {
4676
if ( !special.teardown ||
4677
special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
4679
jQuery.removeEvent( elem, type, elemData.handle );
4682
delete events[ type ];
4686
// Remove data and the expando if it's no longer used
4687
if ( jQuery.isEmptyObject( events ) ) {
4688
dataPriv.remove( elem, "handle events" );
4692
dispatch: function( event ) {
4694
// Make a writable jQuery.Event from the native event object
4695
event = jQuery.event.fix( event );
4697
var i, j, ret, matched, handleObj,
4699
args = slice.call( arguments ),
4700
handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
4701
special = jQuery.event.special[ event.type ] || {};
4703
// Use the fix-ed jQuery.Event rather than the (read-only) native event
4705
event.delegateTarget = this;
4707
// Call the preDispatch hook for the mapped type, and let it bail if desired
4708
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
4712
// Determine handlers
4713
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
4715
// Run delegates first; they may want to stop propagation beneath us
4717
while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
4718
event.currentTarget = matched.elem;
4721
while ( ( handleObj = matched.handlers[ j++ ] ) &&
4722
!event.isImmediatePropagationStopped() ) {
4724
// Triggered event must either 1) have no namespace, or 2) have namespace(s)
4725
// a subset or equal to those in the bound event (both can have no namespace).
4726
if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
4728
event.handleObj = handleObj;
4729
event.data = handleObj.data;
4731
ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
4732
handleObj.handler ).apply( matched.elem, args );
4734
if ( ret !== undefined ) {
4735
if ( ( event.result = ret ) === false ) {
4736
event.preventDefault();
4737
event.stopPropagation();
4744
// Call the postDispatch hook for the mapped type
4745
if ( special.postDispatch ) {
4746
special.postDispatch.call( this, event );
4749
return event.result;
4752
handlers: function( event, handlers ) {
4753
var i, matches, sel, handleObj,
4755
delegateCount = handlers.delegateCount,
4758
// Support (at least): Chrome, IE9
4759
// Find delegate handlers
4760
// Black-hole SVG <use> instance trees (#13180)
4762
// Support: Firefox<=42+
4763
// Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
4764
if ( delegateCount && cur.nodeType &&
4765
( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
4767
for ( ; cur !== this; cur = cur.parentNode || this ) {
4769
// Don't check non-elements (#13208)
4770
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
4771
if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
4773
for ( i = 0; i < delegateCount; i++ ) {
4774
handleObj = handlers[ i ];
4776
// Don't conflict with Object.prototype properties (#13203)
4777
sel = handleObj.selector + " ";
4779
if ( matches[ sel ] === undefined ) {
4780
matches[ sel ] = handleObj.needsContext ?
4781
jQuery( sel, this ).index( cur ) > -1 :
4782
jQuery.find( sel, this, null, [ cur ] ).length;
4784
if ( matches[ sel ] ) {
4785
matches.push( handleObj );
4788
if ( matches.length ) {
4789
handlerQueue.push( { elem: cur, handlers: matches } );
4795
// Add the remaining (directly-bound) handlers
4796
if ( delegateCount < handlers.length ) {
4797
handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
4800
return handlerQueue;
4803
// Includes some event props shared by KeyEvent and MouseEvent
4804
props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
4805
"metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
4810
props: "char charCode key keyCode".split( " " ),
4811
filter: function( event, original ) {
4813
// Add which for key events
4814
if ( event.which == null ) {
4815
event.which = original.charCode != null ? original.charCode : original.keyCode;
4823
props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " +
4824
"screenX screenY toElement" ).split( " " ),
4825
filter: function( event, original ) {
4826
var eventDoc, doc, body,
4827
button = original.button;
4829
// Calculate pageX/Y if missing and clientX/Y available
4830
if ( event.pageX == null && original.clientX != null ) {
4831
eventDoc = event.target.ownerDocument || document;
4832
doc = eventDoc.documentElement;
4833
body = eventDoc.body;
4835
event.pageX = original.clientX +
4836
( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
4837
( doc && doc.clientLeft || body && body.clientLeft || 0 );
4838
event.pageY = original.clientY +
4839
( doc && doc.scrollTop || body && body.scrollTop || 0 ) -
4840
( doc && doc.clientTop || body && body.clientTop || 0 );
4843
// Add which for click: 1 === left; 2 === middle; 3 === right
4844
// Note: button is not normalized, so don't use it
4845
if ( !event.which && button !== undefined ) {
4846
event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
4853
fix: function( event ) {
4854
if ( event[ jQuery.expando ] ) {
4858
// Create a writable copy of the event object and normalize some properties
4861
originalEvent = event,
4862
fixHook = this.fixHooks[ type ];
4865
this.fixHooks[ type ] = fixHook =
4866
rmouseEvent.test( type ) ? this.mouseHooks :
4867
rkeyEvent.test( type ) ? this.keyHooks :
4870
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
4872
event = new jQuery.Event( originalEvent );
4877
event[ prop ] = originalEvent[ prop ];
4880
// Support: Cordova 2.5 (WebKit) (#13255)
4881
// All events should have a target; Cordova deviceready doesn't
4882
if ( !event.target ) {
4883
event.target = document;
4886
// Support: Safari 6.0+, Chrome<28
4887
// Target should not be a text node (#504, #13143)
4888
if ( event.target.nodeType === 3 ) {
4889
event.target = event.target.parentNode;
4892
return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
4898
// Prevent triggered image.load events from bubbling to window.load
4903
// Fire native event if possible so blur/focus sequence is correct
4904
trigger: function() {
4905
if ( this !== safeActiveElement() && this.focus ) {
4910
delegateType: "focusin"
4913
trigger: function() {
4914
if ( this === safeActiveElement() && this.blur ) {
4919
delegateType: "focusout"
4923
// For checkbox, fire native event so checked state will be right
4924
trigger: function() {
4925
if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
4931
// For cross-browser consistency, don't fire native .click() on links
4932
_default: function( event ) {
4933
return jQuery.nodeName( event.target, "a" );
4938
postDispatch: function( event ) {
4940
// Support: Firefox 20+
4941
// Firefox doesn't alert if the returnValue field is not set.
4942
if ( event.result !== undefined && event.originalEvent ) {
4943
event.originalEvent.returnValue = event.result;
4950
jQuery.removeEvent = function( elem, type, handle ) {
4952
// This "if" is needed for plain objects
4953
if ( elem.removeEventListener ) {
4954
elem.removeEventListener( type, handle );
4958
jQuery.Event = function( src, props ) {
4960
// Allow instantiation without the 'new' keyword
4961
if ( !( this instanceof jQuery.Event ) ) {
4962
return new jQuery.Event( src, props );
4966
if ( src && src.type ) {
4967
this.originalEvent = src;
4968
this.type = src.type;
4970
// Events bubbling up the document may have been marked as prevented
4971
// by a handler lower down the tree; reflect the correct value.
4972
this.isDefaultPrevented = src.defaultPrevented ||
4973
src.defaultPrevented === undefined &&
4975
// Support: Android<4.0
4976
src.returnValue === false ?
4985
// Put explicitly provided properties onto the event object
4987
jQuery.extend( this, props );
4990
// Create a timestamp if incoming event doesn't have one
4991
this.timeStamp = src && src.timeStamp || jQuery.now();
4994
this[ jQuery.expando ] = true;
4997
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
4998
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
4999
jQuery.Event.prototype = {
5000
constructor: jQuery.Event,
5001
isDefaultPrevented: returnFalse,
5002
isPropagationStopped: returnFalse,
5003
isImmediatePropagationStopped: returnFalse,
5005
preventDefault: function() {
5006
var e = this.originalEvent;
5008
this.isDefaultPrevented = returnTrue;
5014
stopPropagation: function() {
5015
var e = this.originalEvent;
5017
this.isPropagationStopped = returnTrue;
5020
e.stopPropagation();
5023
stopImmediatePropagation: function() {
5024
var e = this.originalEvent;
5026
this.isImmediatePropagationStopped = returnTrue;
5029
e.stopImmediatePropagation();
5032
this.stopPropagation();
5036
// Create mouseenter/leave events using mouseover/out and event-time checks
5037
// so that event delegation works in jQuery.
5038
// Do the same for pointerenter/pointerleave and pointerover/pointerout
5040
// Support: Safari 7 only
5041
// Safari sends mouseenter too often; see:
5042
// https://code.google.com/p/chromium/issues/detail?id=470258
5043
// for the description of the bug (it existed in older Chrome versions as well).
5045
mouseenter: "mouseover",
5046
mouseleave: "mouseout",
5047
pointerenter: "pointerover",
5048
pointerleave: "pointerout"
5049
}, function( orig, fix ) {
5050
jQuery.event.special[ orig ] = {
5054
handle: function( event ) {
5057
related = event.relatedTarget,
5058
handleObj = event.handleObj;
5060
// For mouseenter/leave call the handler if related is outside the target.
5061
// NB: No relatedTarget if the mouse left/entered the browser window
5062
if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
5063
event.type = handleObj.origType;
5064
ret = handleObj.handler.apply( this, arguments );
5073
on: function( types, selector, data, fn ) {
5074
return on( this, types, selector, data, fn );
5076
one: function( types, selector, data, fn ) {
5077
return on( this, types, selector, data, fn, 1 );
5079
off: function( types, selector, fn ) {
5080
var handleObj, type;
5081
if ( types && types.preventDefault && types.handleObj ) {
5083
// ( event ) dispatched jQuery.Event
5084
handleObj = types.handleObj;
5085
jQuery( types.delegateTarget ).off(
5086
handleObj.namespace ?
5087
handleObj.origType + "." + handleObj.namespace :
5094
if ( typeof types === "object" ) {
5096
// ( types-object [, selector] )
5097
for ( type in types ) {
5098
this.off( type, selector, types[ type ] );
5102
if ( selector === false || typeof selector === "function" ) {
5106
selector = undefined;
5108
if ( fn === false ) {
5111
return this.each( function() {
5112
jQuery.event.remove( this, types, fn, selector );
5119
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
5121
// Support: IE 10-11, Edge 10240+
5122
// In IE/Edge using regex groups here causes severe slowdowns.
5123
// See https://connect.microsoft.com/IE/feedback/details/1736512/
5124
rnoInnerhtml = /<script|<style|<link/i,
5126
// checked="checked" or checked
5127
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5128
rscriptTypeMasked = /^true\/(.*)/,
5129
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
5131
// Manipulating tables requires a tbody
5132
function manipulationTarget( elem, content ) {
5133
return jQuery.nodeName( elem, "table" ) &&
5134
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
5136
elem.getElementsByTagName( "tbody" )[ 0 ] ||
5137
elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) :
5141
// Replace/restore the type attribute of script elements for safe DOM manipulation
5142
function disableScript( elem ) {
5143
elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
5146
function restoreScript( elem ) {
5147
var match = rscriptTypeMasked.exec( elem.type );
5150
elem.type = match[ 1 ];
5152
elem.removeAttribute( "type" );
5158
function cloneCopyEvent( src, dest ) {
5159
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
5161
if ( dest.nodeType !== 1 ) {
5165
// 1. Copy private data: events, handlers, etc.
5166
if ( dataPriv.hasData( src ) ) {
5167
pdataOld = dataPriv.access( src );
5168
pdataCur = dataPriv.set( dest, pdataOld );
5169
events = pdataOld.events;
5172
delete pdataCur.handle;
5173
pdataCur.events = {};
5175
for ( type in events ) {
5176
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5177
jQuery.event.add( dest, type, events[ type ][ i ] );
5183
// 2. Copy user data
5184
if ( dataUser.hasData( src ) ) {
5185
udataOld = dataUser.access( src );
5186
udataCur = jQuery.extend( {}, udataOld );
5188
dataUser.set( dest, udataCur );
5192
// Fix IE bugs, see support tests
5193
function fixInput( src, dest ) {
5194
var nodeName = dest.nodeName.toLowerCase();
5196
// Fails to persist the checked state of a cloned checkbox or radio button.
5197
if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5198
dest.checked = src.checked;
5200
// Fails to return the selected option to the default selected state when cloning options
5201
} else if ( nodeName === "input" || nodeName === "textarea" ) {
5202
dest.defaultValue = src.defaultValue;
5206
function domManip( collection, args, callback, ignored ) {
5208
// Flatten any nested arrays
5209
args = concat.apply( [], args );
5211
var fragment, first, scripts, hasScripts, node, doc,
5213
l = collection.length,
5216
isFunction = jQuery.isFunction( value );
5218
// We can't cloneNode fragments that contain checked, in WebKit
5220
( l > 1 && typeof value === "string" &&
5221
!support.checkClone && rchecked.test( value ) ) ) {
5222
return collection.each( function( index ) {
5223
var self = collection.eq( index );
5225
args[ 0 ] = value.call( this, index, self.html() );
5227
domManip( self, args, callback, ignored );
5232
fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
5233
first = fragment.firstChild;
5235
if ( fragment.childNodes.length === 1 ) {
5239
// Require either new content or an interest in ignored elements to invoke the callback
5240
if ( first || ignored ) {
5241
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5242
hasScripts = scripts.length;
5244
// Use the original fragment for the last item
5245
// instead of the first because it can end up
5246
// being emptied incorrectly in certain situations (#8070).
5247
for ( ; i < l; i++ ) {
5250
if ( i !== iNoClone ) {
5251
node = jQuery.clone( node, true, true );
5253
// Keep references to cloned scripts for later restoration
5256
// Support: Android<4.1, PhantomJS<2
5257
// push.apply(_, arraylike) throws on ancient WebKit
5258
jQuery.merge( scripts, getAll( node, "script" ) );
5262
callback.call( collection[ i ], node, i );
5266
doc = scripts[ scripts.length - 1 ].ownerDocument;
5269
jQuery.map( scripts, restoreScript );
5271
// Evaluate executable scripts on first document insertion
5272
for ( i = 0; i < hasScripts; i++ ) {
5273
node = scripts[ i ];
5274
if ( rscriptType.test( node.type || "" ) &&
5275
!dataPriv.access( node, "globalEval" ) &&
5276
jQuery.contains( doc, node ) ) {
5280
// Optional AJAX dependency, but won't run scripts if not present
5281
if ( jQuery._evalUrl ) {
5282
jQuery._evalUrl( node.src );
5285
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
5296
function remove( elem, selector, keepData ) {
5298
nodes = selector ? jQuery.filter( selector, elem ) : elem,
5301
for ( ; ( node = nodes[ i ] ) != null; i++ ) {
5302
if ( !keepData && node.nodeType === 1 ) {
5303
jQuery.cleanData( getAll( node ) );
5306
if ( node.parentNode ) {
5307
if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
5308
setGlobalEval( getAll( node, "script" ) );
5310
node.parentNode.removeChild( node );
5318
htmlPrefilter: function( html ) {
5319
return html.replace( rxhtmlTag, "<$1></$2>" );
5322
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5323
var i, l, srcElements, destElements,
5324
clone = elem.cloneNode( true ),
5325
inPage = jQuery.contains( elem.ownerDocument, elem );
5327
// Fix IE cloning issues
5328
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
5329
!jQuery.isXMLDoc( elem ) ) {
5331
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
5332
destElements = getAll( clone );
5333
srcElements = getAll( elem );
5335
for ( i = 0, l = srcElements.length; i < l; i++ ) {
5336
fixInput( srcElements[ i ], destElements[ i ] );
5340
// Copy the events from the original to the clone
5341
if ( dataAndEvents ) {
5342
if ( deepDataAndEvents ) {
5343
srcElements = srcElements || getAll( elem );
5344
destElements = destElements || getAll( clone );
5346
for ( i = 0, l = srcElements.length; i < l; i++ ) {
5347
cloneCopyEvent( srcElements[ i ], destElements[ i ] );
5350
cloneCopyEvent( elem, clone );
5354
// Preserve script evaluation history
5355
destElements = getAll( clone, "script" );
5356
if ( destElements.length > 0 ) {
5357
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
5360
// Return the cloned set
5364
cleanData: function( elems ) {
5365
var data, elem, type,
5366
special = jQuery.event.special,
5369
for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
5370
if ( acceptData( elem ) ) {
5371
if ( ( data = elem[ dataPriv.expando ] ) ) {
5372
if ( data.events ) {
5373
for ( type in data.events ) {
5374
if ( special[ type ] ) {
5375
jQuery.event.remove( elem, type );
5377
// This is a shortcut to avoid jQuery.event.remove's overhead
5379
jQuery.removeEvent( elem, type, data.handle );
5384
// Support: Chrome <= 35-45+
5385
// Assign undefined instead of using delete, see Data#remove
5386
elem[ dataPriv.expando ] = undefined;
5388
if ( elem[ dataUser.expando ] ) {
5390
// Support: Chrome <= 35-45+
5391
// Assign undefined instead of using delete, see Data#remove
5392
elem[ dataUser.expando ] = undefined;
5401
// Keep domManip exposed until 3.0 (gh-2225)
5404
detach: function( selector ) {
5405
return remove( this, selector, true );
5408
remove: function( selector ) {
5409
return remove( this, selector );
5412
text: function( value ) {
5413
return access( this, function( value ) {
5414
return value === undefined ?
5415
jQuery.text( this ) :
5416
this.empty().each( function() {
5417
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5418
this.textContent = value;
5421
}, null, value, arguments.length );
5424
append: function() {
5425
return domManip( this, arguments, function( elem ) {
5426
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5427
var target = manipulationTarget( this, elem );
5428
target.appendChild( elem );
5433
prepend: function() {
5434
return domManip( this, arguments, function( elem ) {
5435
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5436
var target = manipulationTarget( this, elem );
5437
target.insertBefore( elem, target.firstChild );
5442
before: function() {
5443
return domManip( this, arguments, function( elem ) {
5444
if ( this.parentNode ) {
5445
this.parentNode.insertBefore( elem, this );
5451
return domManip( this, arguments, function( elem ) {
5452
if ( this.parentNode ) {
5453
this.parentNode.insertBefore( elem, this.nextSibling );
5462
for ( ; ( elem = this[ i ] ) != null; i++ ) {
5463
if ( elem.nodeType === 1 ) {
5465
// Prevent memory leaks
5466
jQuery.cleanData( getAll( elem, false ) );
5468
// Remove any remaining nodes
5469
elem.textContent = "";
5476
clone: function( dataAndEvents, deepDataAndEvents ) {
5477
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5478
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5480
return this.map( function() {
5481
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5485
html: function( value ) {
5486
return access( this, function( value ) {
5487
var elem = this[ 0 ] || {},
5491
if ( value === undefined && elem.nodeType === 1 ) {
5492
return elem.innerHTML;
5495
// See if we can take a shortcut and just use innerHTML
5496
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5497
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5499
value = jQuery.htmlPrefilter( value );
5502
for ( ; i < l; i++ ) {
5503
elem = this[ i ] || {};
5505
// Remove element nodes and prevent memory leaks
5506
if ( elem.nodeType === 1 ) {
5507
jQuery.cleanData( getAll( elem, false ) );
5508
elem.innerHTML = value;
5514
// If using innerHTML throws an exception, use the fallback method
5519
this.empty().append( value );
5521
}, null, value, arguments.length );
5524
replaceWith: function() {
5527
// Make the changes, replacing each non-ignored context element with the new content
5528
return domManip( this, arguments, function( elem ) {
5529
var parent = this.parentNode;
5531
if ( jQuery.inArray( this, ignored ) < 0 ) {
5532
jQuery.cleanData( getAll( this ) );
5534
parent.replaceChild( elem, this );
5538
// Force callback invocation
5545
prependTo: "prepend",
5546
insertBefore: "before",
5547
insertAfter: "after",
5548
replaceAll: "replaceWith"
5549
}, function( name, original ) {
5550
jQuery.fn[ name ] = function( selector ) {
5553
insert = jQuery( selector ),
5554
last = insert.length - 1,
5557
for ( ; i <= last; i++ ) {
5558
elems = i === last ? this : this.clone( true );
5559
jQuery( insert[ i ] )[ original ]( elems );
5561
// Support: QtWebKit
5562
// .get() because push.apply(_, arraylike) throws
5563
push.apply( ret, elems.get() );
5566
return this.pushStack( ret );
5575
// We have to pre-define these values for FF (#10227)
5581
* Retrieve the actual display of a element
5582
* @param {String} name nodeName of the element
5583
* @param {Object} doc Document object
5586
// Called only from within defaultDisplay
5587
function actualDisplay( name, doc ) {
5588
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
5590
display = jQuery.css( elem[ 0 ], "display" );
5592
// We don't have any data stored on the element,
5593
// so use "detach" method as fast way to get rid of the element
5600
* Try to determine the default display value of an element
5601
* @param {String} nodeName
5603
function defaultDisplay( nodeName ) {
5605
display = elemdisplay[ nodeName ];
5608
display = actualDisplay( nodeName, doc );
5610
// If the simple way fails, read from inside an iframe
5611
if ( display === "none" || !display ) {
5613
// Use the already-created iframe if possible
5614
iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
5615
.appendTo( doc.documentElement );
5617
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
5618
doc = iframe[ 0 ].contentDocument;
5624
display = actualDisplay( nodeName, doc );
5628
// Store the correct default display
5629
elemdisplay[ nodeName ] = display;
5634
var rmargin = ( /^margin/ );
5636
var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
5638
var getStyles = function( elem ) {
5640
// Support: IE<=11+, Firefox<=30+ (#15098, #14150)
5641
// IE throws on elements created in popups
5642
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
5643
var view = elem.ownerDocument.defaultView;
5645
if ( !view || !view.opener ) {
5649
return view.getComputedStyle( elem );
5652
var swap = function( elem, options, callback, args ) {
5656
// Remember the old values, and insert the new ones
5657
for ( name in options ) {
5658
old[ name ] = elem.style[ name ];
5659
elem.style[ name ] = options[ name ];
5662
ret = callback.apply( elem, args || [] );
5664
// Revert the old values
5665
for ( name in options ) {
5666
elem.style[ name ] = old[ name ];
5673
var documentElement = document.documentElement;
5678
var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
5679
container = document.createElement( "div" ),
5680
div = document.createElement( "div" );
5682
// Finish early in limited (non-browser) environments
5688
// Style of cloned element affects source element cloned (#8908)
5689
div.style.backgroundClip = "content-box";
5690
div.cloneNode( true ).style.backgroundClip = "";
5691
support.clearCloneStyle = div.style.backgroundClip === "content-box";
5693
container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
5694
"padding:0;margin-top:1px;position:absolute";
5695
container.appendChild( div );
5697
// Executing both pixelPosition & boxSizingReliable tests require only one layout
5698
// so they're executed at the same time to save the second computation.
5699
function computeStyleTests() {
5702
// Support: Firefox<29, Android 2.3
5703
// Vendor-prefix box-sizing
5704
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" +
5705
"position:relative;display:block;" +
5706
"margin:auto;border:1px;padding:1px;" +
5709
documentElement.appendChild( container );
5711
var divStyle = window.getComputedStyle( div );
5712
pixelPositionVal = divStyle.top !== "1%";
5713
reliableMarginLeftVal = divStyle.marginLeft === "2px";
5714
boxSizingReliableVal = divStyle.width === "4px";
5716
// Support: Android 4.0 - 4.3 only
5717
// Some styles come back with percentage values, even though they shouldn't
5718
div.style.marginRight = "50%";
5719
pixelMarginRightVal = divStyle.marginRight === "4px";
5721
documentElement.removeChild( container );
5724
jQuery.extend( support, {
5725
pixelPosition: function() {
5727
// This test is executed only once but we still do memoizing
5728
// since we can use the boxSizingReliable pre-computing.
5729
// No need to check if the test was already performed, though.
5730
computeStyleTests();
5731
return pixelPositionVal;
5733
boxSizingReliable: function() {
5734
if ( boxSizingReliableVal == null ) {
5735
computeStyleTests();
5737
return boxSizingReliableVal;
5739
pixelMarginRight: function() {
5741
// Support: Android 4.0-4.3
5742
// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
5743
// since that compresses better and they're computed together anyway.
5744
if ( boxSizingReliableVal == null ) {
5745
computeStyleTests();
5747
return pixelMarginRightVal;
5749
reliableMarginLeft: function() {
5751
// Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
5752
if ( boxSizingReliableVal == null ) {
5753
computeStyleTests();
5755
return reliableMarginLeftVal;
5757
reliableMarginRight: function() {
5759
// Support: Android 2.3
5760
// Check if div with explicit width and no margin-right incorrectly
5761
// gets computed margin-right based on width of container. (#3333)
5762
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
5763
// This support function is only executed once so no memoizing is needed.
5765
marginDiv = div.appendChild( document.createElement( "div" ) );
5767
// Reset CSS: box-sizing; display; margin; border; padding
5768
marginDiv.style.cssText = div.style.cssText =
5770
// Support: Android 2.3
5771
// Vendor-prefix box-sizing
5772
"-webkit-box-sizing:content-box;box-sizing:content-box;" +
5773
"display:block;margin:0;border:0;padding:0";
5774
marginDiv.style.marginRight = marginDiv.style.width = "0";
5775
div.style.width = "1px";
5776
documentElement.appendChild( container );
5778
ret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight );
5780
documentElement.removeChild( container );
5781
div.removeChild( marginDiv );
5789
function curCSS( elem, name, computed ) {
5790
var width, minWidth, maxWidth, ret,
5793
computed = computed || getStyles( elem );
5794
ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
5796
// Support: Opera 12.1x only
5797
// Fall back to style even without computed
5798
// computed is undefined for elems on document fragments
5799
if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) {
5800
ret = jQuery.style( elem, name );
5804
// getPropertyValue is only needed for .css('filter') (#12537)
5807
// A tribute to the "awesome hack by Dean Edwards"
5808
// Android Browser returns percentage for some values,
5809
// but width seems to be reliably pixels.
5810
// This is against the CSSOM draft spec:
5811
// http://dev.w3.org/csswg/cssom/#resolved-values
5812
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
5814
// Remember the original values
5815
width = style.width;
5816
minWidth = style.minWidth;
5817
maxWidth = style.maxWidth;
5819
// Put in the new values to get a computed value out
5820
style.minWidth = style.maxWidth = style.width = ret;
5821
ret = computed.width;
5823
// Revert the changed values
5824
style.width = width;
5825
style.minWidth = minWidth;
5826
style.maxWidth = maxWidth;
5830
return ret !== undefined ?
5833
// IE returns zIndex value as an integer.
5839
function addGetHookIf( conditionFn, hookFn ) {
5841
// Define the hook, we'll check on the first run if it's really needed.
5844
if ( conditionFn() ) {
5846
// Hook not needed (or it's not possible to use it due
5847
// to missing dependency), remove it.
5852
// Hook needed; redefine it so that the support test is not executed again.
5853
return ( this.get = hookFn ).apply( this, arguments );
5861
// Swappable if display is none or starts with table
5862
// except "table", "table-cell", or "table-caption"
5863
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
5864
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
5866
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
5867
cssNormalTransform = {
5872
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
5873
emptyStyle = document.createElement( "div" ).style;
5875
// Return a css property mapped to a potentially vendor prefixed property
5876
function vendorPropName( name ) {
5878
// Shortcut for names that are not vendor prefixed
5879
if ( name in emptyStyle ) {
5883
// Check for vendor prefixed names
5884
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
5885
i = cssPrefixes.length;
5888
name = cssPrefixes[ i ] + capName;
5889
if ( name in emptyStyle ) {
5895
function setPositiveNumber( elem, value, subtract ) {
5897
// Any relative (+/-) values have already been
5898
// normalized at this point
5899
var matches = rcssNum.exec( value );
5902
// Guard against undefined "subtract", e.g., when used as in cssHooks
5903
Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
5907
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
5908
var i = extra === ( isBorderBox ? "border" : "content" ) ?
5910
// If we already have the right measurement, avoid augmentation
5913
// Otherwise initialize for horizontal or vertical properties
5914
name === "width" ? 1 : 0,
5918
for ( ; i < 4; i += 2 ) {
5920
// Both box models exclude margin, so add it if we want it
5921
if ( extra === "margin" ) {
5922
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
5925
if ( isBorderBox ) {
5927
// border-box includes padding, so remove it if we want content
5928
if ( extra === "content" ) {
5929
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
5932
// At this point, extra isn't border nor margin, so remove border
5933
if ( extra !== "margin" ) {
5934
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
5938
// At this point, extra isn't content, so add padding
5939
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
5941
// At this point, extra isn't content nor padding, so add border
5942
if ( extra !== "padding" ) {
5943
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
5951
function getWidthOrHeight( elem, name, extra ) {
5953
// Start with offset property, which is equivalent to the border-box value
5954
var valueIsBorderBox = true,
5955
val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
5956
styles = getStyles( elem ),
5957
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
5959
// Support: IE11 only
5960
// In IE 11 fullscreen elements inside of an iframe have
5961
// 100x too small dimensions (gh-1764).
5962
if ( document.msFullscreenElement && window.top !== window ) {
5964
// Support: IE11 only
5965
// Running getBoundingClientRect on a disconnected node
5966
// in IE throws an error.
5967
if ( elem.getClientRects().length ) {
5968
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
5972
// Some non-html elements return undefined for offsetWidth, so check for null/undefined
5973
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
5974
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
5975
if ( val <= 0 || val == null ) {
5977
// Fall back to computed then uncomputed css if necessary
5978
val = curCSS( elem, name, styles );
5979
if ( val < 0 || val == null ) {
5980
val = elem.style[ name ];
5983
// Computed unit is not pixels. Stop here and return.
5984
if ( rnumnonpx.test( val ) ) {
5988
// Check for style in case a browser which returns unreliable values
5989
// for getComputedStyle silently falls back to the reliable elem.style
5990
valueIsBorderBox = isBorderBox &&
5991
( support.boxSizingReliable() || val === elem.style[ name ] );
5993
// Normalize "", auto, and prepare for extra
5994
val = parseFloat( val ) || 0;
5997
// Use the active box-sizing model to add/subtract irrelevant styles
5999
augmentWidthOrHeight(
6002
extra || ( isBorderBox ? "border" : "content" ),
6009
function showHide( elements, show ) {
6010
var display, elem, hidden,
6013
length = elements.length;
6015
for ( ; index < length; index++ ) {
6016
elem = elements[ index ];
6017
if ( !elem.style ) {
6021
values[ index ] = dataPriv.get( elem, "olddisplay" );
6022
display = elem.style.display;
6025
// Reset the inline display of this element to learn if it is
6026
// being hidden by cascaded rules or not
6027
if ( !values[ index ] && display === "none" ) {
6028
elem.style.display = "";
6031
// Set elements which have been overridden with display: none
6032
// in a stylesheet to whatever the default browser style is
6033
// for such an element
6034
if ( elem.style.display === "" && isHidden( elem ) ) {
6035
values[ index ] = dataPriv.access(
6038
defaultDisplay( elem.nodeName )
6042
hidden = isHidden( elem );
6044
if ( display !== "none" || !hidden ) {
6048
hidden ? display : jQuery.css( elem, "display" )
6054
// Set the display of most of the elements in a second loop
6055
// to avoid the constant reflow
6056
for ( index = 0; index < length; index++ ) {
6057
elem = elements[ index ];
6058
if ( !elem.style ) {
6061
if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6062
elem.style.display = show ? values[ index ] || "" : "none";
6071
// Add in style property hooks for overriding the default
6072
// behavior of getting and setting a style property
6075
get: function( elem, computed ) {
6078
// We should always get a number back from opacity
6079
var ret = curCSS( elem, "opacity" );
6080
return ret === "" ? "1" : ret;
6086
// Don't automatically add "px" to these possibly-unitless properties
6088
"animationIterationCount": true,
6089
"columnCount": true,
6090
"fillOpacity": true,
6103
// Add in properties whose names you wish to fix before
6104
// setting or getting the value
6109
// Get and set the style property on a DOM Node
6110
style: function( elem, name, value, extra ) {
6112
// Don't set styles on text and comment nodes
6113
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6117
// Make sure that we're working with the right name
6118
var ret, type, hooks,
6119
origName = jQuery.camelCase( name ),
6122
name = jQuery.cssProps[ origName ] ||
6123
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
6125
// Gets hook for the prefixed version, then unprefixed version
6126
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6128
// Check if we're setting a value
6129
if ( value !== undefined ) {
6130
type = typeof value;
6132
// Convert "+=" or "-=" to relative numbers (#7345)
6133
if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
6134
value = adjustCSS( elem, name, ret );
6140
// Make sure that null and NaN values aren't set (#7116)
6141
if ( value == null || value !== value ) {
6145
// If a number was passed in, add the unit (except for certain CSS properties)
6146
if ( type === "number" ) {
6147
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
6151
// background-* props affect original clone's values
6152
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
6153
style[ name ] = "inherit";
6156
// If a hook was provided, use that value, otherwise just set the specified value
6157
if ( !hooks || !( "set" in hooks ) ||
6158
( value = hooks.set( elem, value, extra ) ) !== undefined ) {
6160
style[ name ] = value;
6165
// If a hook was provided get the non-computed value from there
6166
if ( hooks && "get" in hooks &&
6167
( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
6172
// Otherwise just get the value from the style object
6173
return style[ name ];
6177
css: function( elem, name, extra, styles ) {
6178
var val, num, hooks,
6179
origName = jQuery.camelCase( name );
6181
// Make sure that we're working with the right name
6182
name = jQuery.cssProps[ origName ] ||
6183
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
6185
// Try prefixed name followed by the unprefixed name
6186
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6188
// If a hook was provided get the computed value from there
6189
if ( hooks && "get" in hooks ) {
6190
val = hooks.get( elem, true, extra );
6193
// Otherwise, if a way to get the computed value exists, use that
6194
if ( val === undefined ) {
6195
val = curCSS( elem, name, styles );
6198
// Convert "normal" to computed value
6199
if ( val === "normal" && name in cssNormalTransform ) {
6200
val = cssNormalTransform[ name ];
6203
// Make numeric if forced or a qualifier was provided and val looks numeric
6204
if ( extra === "" || extra ) {
6205
num = parseFloat( val );
6206
return extra === true || isFinite( num ) ? num || 0 : val;
6212
jQuery.each( [ "height", "width" ], function( i, name ) {
6213
jQuery.cssHooks[ name ] = {
6214
get: function( elem, computed, extra ) {
6217
// Certain elements can have dimension info if we invisibly show them
6218
// but it must have a current display style that would benefit
6219
return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
6220
elem.offsetWidth === 0 ?
6221
swap( elem, cssShow, function() {
6222
return getWidthOrHeight( elem, name, extra );
6224
getWidthOrHeight( elem, name, extra );
6228
set: function( elem, value, extra ) {
6230
styles = extra && getStyles( elem ),
6231
subtract = extra && augmentWidthOrHeight(
6235
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6239
// Convert to pixels if value adjustment is needed
6240
if ( subtract && ( matches = rcssNum.exec( value ) ) &&
6241
( matches[ 3 ] || "px" ) !== "px" ) {
6243
elem.style[ name ] = value;
6244
value = jQuery.css( elem, name );
6247
return setPositiveNumber( elem, value, subtract );
6252
jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
6253
function( elem, computed ) {
6255
return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
6256
elem.getBoundingClientRect().left -
6257
swap( elem, { marginLeft: 0 }, function() {
6258
return elem.getBoundingClientRect().left;
6265
// Support: Android 2.3
6266
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
6267
function( elem, computed ) {
6269
return swap( elem, { "display": "inline-block" },
6270
curCSS, [ elem, "marginRight" ] );
6275
// These hooks are used by animate to expand properties
6280
}, function( prefix, suffix ) {
6281
jQuery.cssHooks[ prefix + suffix ] = {
6282
expand: function( value ) {
6286
// Assumes a single number if not a string
6287
parts = typeof value === "string" ? value.split( " " ) : [ value ];
6289
for ( ; i < 4; i++ ) {
6290
expanded[ prefix + cssExpand[ i ] + suffix ] =
6291
parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
6298
if ( !rmargin.test( prefix ) ) {
6299
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
6304
css: function( name, value ) {
6305
return access( this, function( elem, name, value ) {
6310
if ( jQuery.isArray( name ) ) {
6311
styles = getStyles( elem );
6314
for ( ; i < len; i++ ) {
6315
map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6321
return value !== undefined ?
6322
jQuery.style( elem, name, value ) :
6323
jQuery.css( elem, name );
6324
}, name, value, arguments.length > 1 );
6327
return showHide( this, true );
6330
return showHide( this );
6332
toggle: function( state ) {
6333
if ( typeof state === "boolean" ) {
6334
return state ? this.show() : this.hide();
6337
return this.each( function() {
6338
if ( isHidden( this ) ) {
6339
jQuery( this ).show();
6341
jQuery( this ).hide();
6348
function Tween( elem, options, prop, end, easing ) {
6349
return new Tween.prototype.init( elem, options, prop, end, easing );
6351
jQuery.Tween = Tween;
6355
init: function( elem, options, prop, end, easing, unit ) {
6358
this.easing = easing || jQuery.easing._default;
6359
this.options = options;
6360
this.start = this.now = this.cur();
6362
this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
6365
var hooks = Tween.propHooks[ this.prop ];
6367
return hooks && hooks.get ?
6369
Tween.propHooks._default.get( this );
6371
run: function( percent ) {
6373
hooks = Tween.propHooks[ this.prop ];
6375
if ( this.options.duration ) {
6376
this.pos = eased = jQuery.easing[ this.easing ](
6377
percent, this.options.duration * percent, 0, 1, this.options.duration
6380
this.pos = eased = percent;
6382
this.now = ( this.end - this.start ) * eased + this.start;
6384
if ( this.options.step ) {
6385
this.options.step.call( this.elem, this.now, this );
6388
if ( hooks && hooks.set ) {
6391
Tween.propHooks._default.set( this );
6397
Tween.prototype.init.prototype = Tween.prototype;
6401
get: function( tween ) {
6404
// Use a property on the element directly when it is not a DOM element,
6405
// or when there is no matching style property that exists.
6406
if ( tween.elem.nodeType !== 1 ||
6407
tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
6408
return tween.elem[ tween.prop ];
6411
// Passing an empty string as a 3rd parameter to .css will automatically
6412
// attempt a parseFloat and fallback to a string if the parse fails.
6413
// Simple values such as "10px" are parsed to Float;
6414
// complex values such as "rotate(1rad)" are returned as-is.
6415
result = jQuery.css( tween.elem, tween.prop, "" );
6417
// Empty strings, null, undefined and "auto" are converted to 0.
6418
return !result || result === "auto" ? 0 : result;
6420
set: function( tween ) {
6422
// Use step hook for back compat.
6423
// Use cssHook if its there.
6424
// Use .style if available and use plain properties where available.
6425
if ( jQuery.fx.step[ tween.prop ] ) {
6426
jQuery.fx.step[ tween.prop ]( tween );
6427
} else if ( tween.elem.nodeType === 1 &&
6428
( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
6429
jQuery.cssHooks[ tween.prop ] ) ) {
6430
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
6432
tween.elem[ tween.prop ] = tween.now;
6439
// Panic based approach to setting things on disconnected nodes
6440
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
6441
set: function( tween ) {
6442
if ( tween.elem.nodeType && tween.elem.parentNode ) {
6443
tween.elem[ tween.prop ] = tween.now;
6449
linear: function( p ) {
6452
swing: function( p ) {
6453
return 0.5 - Math.cos( p * Math.PI ) / 2;
6458
jQuery.fx = Tween.prototype.init;
6460
// Back Compat <1.8 extension point
6461
jQuery.fx.step = {};
6468
rfxtypes = /^(?:toggle|show|hide)$/,
6469
rrun = /queueHooks$/;
6471
// Animations created synchronously will run synchronously
6472
function createFxNow() {
6473
window.setTimeout( function() {
6476
return ( fxNow = jQuery.now() );
6479
// Generate parameters to create a standard animation
6480
function genFx( type, includeWidth ) {
6483
attrs = { height: type };
6485
// If we include width, step value is 1 to do all cssExpand values,
6486
// otherwise step value is 2 to skip over Left and Right
6487
includeWidth = includeWidth ? 1 : 0;
6488
for ( ; i < 4 ; i += 2 - includeWidth ) {
6489
which = cssExpand[ i ];
6490
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
6493
if ( includeWidth ) {
6494
attrs.opacity = attrs.width = type;
6500
function createTween( value, prop, animation ) {
6502
collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
6504
length = collection.length;
6505
for ( ; index < length; index++ ) {
6506
if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
6508
// We're done with this property
6514
function defaultPrefilter( elem, props, opts ) {
6515
/* jshint validthis: true */
6516
var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
6520
hidden = elem.nodeType && isHidden( elem ),
6521
dataShow = dataPriv.get( elem, "fxshow" );
6523
// Handle queue: false promises
6524
if ( !opts.queue ) {
6525
hooks = jQuery._queueHooks( elem, "fx" );
6526
if ( hooks.unqueued == null ) {
6528
oldfire = hooks.empty.fire;
6529
hooks.empty.fire = function() {
6530
if ( !hooks.unqueued ) {
6537
anim.always( function() {
6539
// Ensure the complete handler is called before this completes
6540
anim.always( function() {
6542
if ( !jQuery.queue( elem, "fx" ).length ) {
6549
// Height/width overflow pass
6550
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
6552
// Make sure that nothing sneaks out
6553
// Record all 3 overflow attributes because IE9-10 do not
6554
// change the overflow attribute when overflowX and
6555
// overflowY are set to the same value
6556
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
6558
// Set display property to inline-block for height/width
6559
// animations on inline elements that are having width/height animated
6560
display = jQuery.css( elem, "display" );
6562
// Test default display if display is currently "none"
6563
checkDisplay = display === "none" ?
6564
dataPriv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
6566
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
6567
style.display = "inline-block";
6571
if ( opts.overflow ) {
6572
style.overflow = "hidden";
6573
anim.always( function() {
6574
style.overflow = opts.overflow[ 0 ];
6575
style.overflowX = opts.overflow[ 1 ];
6576
style.overflowY = opts.overflow[ 2 ];
6581
for ( prop in props ) {
6582
value = props[ prop ];
6583
if ( rfxtypes.exec( value ) ) {
6584
delete props[ prop ];
6585
toggle = toggle || value === "toggle";
6586
if ( value === ( hidden ? "hide" : "show" ) ) {
6588
// If there is dataShow left over from a stopped hide or show
6589
// and we are going to proceed with show, we should pretend to be hidden
6590
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
6596
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
6598
// Any non-fx value stops us from restoring the original display value
6600
display = undefined;
6604
if ( !jQuery.isEmptyObject( orig ) ) {
6606
if ( "hidden" in dataShow ) {
6607
hidden = dataShow.hidden;
6610
dataShow = dataPriv.access( elem, "fxshow", {} );
6613
// Store state if its toggle - enables .stop().toggle() to "reverse"
6615
dataShow.hidden = !hidden;
6618
jQuery( elem ).show();
6620
anim.done( function() {
6621
jQuery( elem ).hide();
6624
anim.done( function() {
6627
dataPriv.remove( elem, "fxshow" );
6628
for ( prop in orig ) {
6629
jQuery.style( elem, prop, orig[ prop ] );
6632
for ( prop in orig ) {
6633
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
6635
if ( !( prop in dataShow ) ) {
6636
dataShow[ prop ] = tween.start;
6638
tween.end = tween.start;
6639
tween.start = prop === "width" || prop === "height" ? 1 : 0;
6644
// If this is a noop like .hide().hide(), restore an overwritten display value
6645
} else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
6646
style.display = display;
6650
function propFilter( props, specialEasing ) {
6651
var index, name, easing, value, hooks;
6653
// camelCase, specialEasing and expand cssHook pass
6654
for ( index in props ) {
6655
name = jQuery.camelCase( index );
6656
easing = specialEasing[ name ];
6657
value = props[ index ];
6658
if ( jQuery.isArray( value ) ) {
6659
easing = value[ 1 ];
6660
value = props[ index ] = value[ 0 ];
6663
if ( index !== name ) {
6664
props[ name ] = value;
6665
delete props[ index ];
6668
hooks = jQuery.cssHooks[ name ];
6669
if ( hooks && "expand" in hooks ) {
6670
value = hooks.expand( value );
6671
delete props[ name ];
6673
// Not quite $.extend, this won't overwrite existing keys.
6674
// Reusing 'index' because we have the correct "name"
6675
for ( index in value ) {
6676
if ( !( index in props ) ) {
6677
props[ index ] = value[ index ];
6678
specialEasing[ index ] = easing;
6682
specialEasing[ name ] = easing;
6687
function Animation( elem, properties, options ) {
6691
length = Animation.prefilters.length,
6692
deferred = jQuery.Deferred().always( function() {
6694
// Don't match elem in the :animated selector
6701
var currentTime = fxNow || createFxNow(),
6702
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
6704
// Support: Android 2.3
6705
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
6706
temp = remaining / animation.duration || 0,
6709
length = animation.tweens.length;
6711
for ( ; index < length ; index++ ) {
6712
animation.tweens[ index ].run( percent );
6715
deferred.notifyWith( elem, [ animation, percent, remaining ] );
6717
if ( percent < 1 && length ) {
6720
deferred.resolveWith( elem, [ animation ] );
6724
animation = deferred.promise( {
6726
props: jQuery.extend( {}, properties ),
6727
opts: jQuery.extend( true, {
6729
easing: jQuery.easing._default
6731
originalProperties: properties,
6732
originalOptions: options,
6733
startTime: fxNow || createFxNow(),
6734
duration: options.duration,
6736
createTween: function( prop, end ) {
6737
var tween = jQuery.Tween( elem, animation.opts, prop, end,
6738
animation.opts.specialEasing[ prop ] || animation.opts.easing );
6739
animation.tweens.push( tween );
6742
stop: function( gotoEnd ) {
6745
// If we are going to the end, we want to run all the tweens
6746
// otherwise we skip this part
6747
length = gotoEnd ? animation.tweens.length : 0;
6752
for ( ; index < length ; index++ ) {
6753
animation.tweens[ index ].run( 1 );
6756
// Resolve when we played the last frame; otherwise, reject
6758
deferred.notifyWith( elem, [ animation, 1, 0 ] );
6759
deferred.resolveWith( elem, [ animation, gotoEnd ] );
6761
deferred.rejectWith( elem, [ animation, gotoEnd ] );
6766
props = animation.props;
6768
propFilter( props, animation.opts.specialEasing );
6770
for ( ; index < length ; index++ ) {
6771
result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
6773
if ( jQuery.isFunction( result.stop ) ) {
6774
jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
6775
jQuery.proxy( result.stop, result );
6781
jQuery.map( props, createTween, animation );
6783
if ( jQuery.isFunction( animation.opts.start ) ) {
6784
animation.opts.start.call( elem, animation );
6788
jQuery.extend( tick, {
6791
queue: animation.opts.queue
6795
// attach callbacks from options
6796
return animation.progress( animation.opts.progress )
6797
.done( animation.opts.done, animation.opts.complete )
6798
.fail( animation.opts.fail )
6799
.always( animation.opts.always );
6802
jQuery.Animation = jQuery.extend( Animation, {
6804
"*": [ function( prop, value ) {
6805
var tween = this.createTween( prop, value );
6806
adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
6811
tweener: function( props, callback ) {
6812
if ( jQuery.isFunction( props ) ) {
6816
props = props.match( rnotwhite );
6821
length = props.length;
6823
for ( ; index < length ; index++ ) {
6824
prop = props[ index ];
6825
Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
6826
Animation.tweeners[ prop ].unshift( callback );
6830
prefilters: [ defaultPrefilter ],
6832
prefilter: function( callback, prepend ) {
6834
Animation.prefilters.unshift( callback );
6836
Animation.prefilters.push( callback );
6841
jQuery.speed = function( speed, easing, fn ) {
6842
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
6843
complete: fn || !fn && easing ||
6844
jQuery.isFunction( speed ) && speed,
6846
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
6849
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ?
6850
opt.duration : opt.duration in jQuery.fx.speeds ?
6851
jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
6853
// Normalize opt.queue - true/undefined/null -> "fx"
6854
if ( opt.queue == null || opt.queue === true ) {
6859
opt.old = opt.complete;
6861
opt.complete = function() {
6862
if ( jQuery.isFunction( opt.old ) ) {
6863
opt.old.call( this );
6867
jQuery.dequeue( this, opt.queue );
6875
fadeTo: function( speed, to, easing, callback ) {
6877
// Show any hidden elements after setting opacity to 0
6878
return this.filter( isHidden ).css( "opacity", 0 ).show()
6880
// Animate to the value specified
6881
.end().animate( { opacity: to }, speed, easing, callback );
6883
animate: function( prop, speed, easing, callback ) {
6884
var empty = jQuery.isEmptyObject( prop ),
6885
optall = jQuery.speed( speed, easing, callback ),
6886
doAnimation = function() {
6888
// Operate on a copy of prop so per-property easing won't be lost
6889
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
6891
// Empty animations, or finishing resolves immediately
6892
if ( empty || dataPriv.get( this, "finish" ) ) {
6896
doAnimation.finish = doAnimation;
6898
return empty || optall.queue === false ?
6899
this.each( doAnimation ) :
6900
this.queue( optall.queue, doAnimation );
6902
stop: function( type, clearQueue, gotoEnd ) {
6903
var stopQueue = function( hooks ) {
6904
var stop = hooks.stop;
6909
if ( typeof type !== "string" ) {
6910
gotoEnd = clearQueue;
6914
if ( clearQueue && type !== false ) {
6915
this.queue( type || "fx", [] );
6918
return this.each( function() {
6920
index = type != null && type + "queueHooks",
6921
timers = jQuery.timers,
6922
data = dataPriv.get( this );
6925
if ( data[ index ] && data[ index ].stop ) {
6926
stopQueue( data[ index ] );
6929
for ( index in data ) {
6930
if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
6931
stopQueue( data[ index ] );
6936
for ( index = timers.length; index--; ) {
6937
if ( timers[ index ].elem === this &&
6938
( type == null || timers[ index ].queue === type ) ) {
6940
timers[ index ].anim.stop( gotoEnd );
6942
timers.splice( index, 1 );
6946
// Start the next in the queue if the last step wasn't forced.
6947
// Timers currently will call their complete callbacks, which
6948
// will dequeue but only if they were gotoEnd.
6949
if ( dequeue || !gotoEnd ) {
6950
jQuery.dequeue( this, type );
6954
finish: function( type ) {
6955
if ( type !== false ) {
6956
type = type || "fx";
6958
return this.each( function() {
6960
data = dataPriv.get( this ),
6961
queue = data[ type + "queue" ],
6962
hooks = data[ type + "queueHooks" ],
6963
timers = jQuery.timers,
6964
length = queue ? queue.length : 0;
6966
// Enable finishing flag on private data
6969
// Empty the queue first
6970
jQuery.queue( this, type, [] );
6972
if ( hooks && hooks.stop ) {
6973
hooks.stop.call( this, true );
6976
// Look for any active animations, and finish them
6977
for ( index = timers.length; index--; ) {
6978
if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
6979
timers[ index ].anim.stop( true );
6980
timers.splice( index, 1 );
6984
// Look for any animations in the old queue and finish them
6985
for ( index = 0; index < length; index++ ) {
6986
if ( queue[ index ] && queue[ index ].finish ) {
6987
queue[ index ].finish.call( this );
6991
// Turn off finishing flag
6997
jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
6998
var cssFn = jQuery.fn[ name ];
6999
jQuery.fn[ name ] = function( speed, easing, callback ) {
7000
return speed == null || typeof speed === "boolean" ?
7001
cssFn.apply( this, arguments ) :
7002
this.animate( genFx( name, true ), speed, easing, callback );
7006
// Generate shortcuts for custom animations
7008
slideDown: genFx( "show" ),
7009
slideUp: genFx( "hide" ),
7010
slideToggle: genFx( "toggle" ),
7011
fadeIn: { opacity: "show" },
7012
fadeOut: { opacity: "hide" },
7013
fadeToggle: { opacity: "toggle" }
7014
}, function( name, props ) {
7015
jQuery.fn[ name ] = function( speed, easing, callback ) {
7016
return this.animate( props, speed, easing, callback );
7021
jQuery.fx.tick = function() {
7024
timers = jQuery.timers;
7026
fxNow = jQuery.now();
7028
for ( ; i < timers.length; i++ ) {
7029
timer = timers[ i ];
7031
// Checks the timer has not already been removed
7032
if ( !timer() && timers[ i ] === timer ) {
7033
timers.splice( i--, 1 );
7037
if ( !timers.length ) {
7043
jQuery.fx.timer = function( timer ) {
7044
jQuery.timers.push( timer );
7048
jQuery.timers.pop();
7052
jQuery.fx.interval = 13;
7053
jQuery.fx.start = function() {
7055
timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
7059
jQuery.fx.stop = function() {
7060
window.clearInterval( timerId );
7065
jQuery.fx.speeds = {
7074
// Based off of the plugin by Clint Helfers, with permission.
7075
// http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
7076
jQuery.fn.delay = function( time, type ) {
7077
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
7078
type = type || "fx";
7080
return this.queue( type, function( next, hooks ) {
7081
var timeout = window.setTimeout( next, time );
7082
hooks.stop = function() {
7083
window.clearTimeout( timeout );
7090
var input = document.createElement( "input" ),
7091
select = document.createElement( "select" ),
7092
opt = select.appendChild( document.createElement( "option" ) );
7094
input.type = "checkbox";
7096
// Support: iOS<=5.1, Android<=4.2+
7097
// Default value for a checkbox should be "on"
7098
support.checkOn = input.value !== "";
7101
// Must access selectedIndex to make default options select
7102
support.optSelected = opt.selected;
7104
// Support: Android<=2.3
7105
// Options inside disabled selects are incorrectly marked as disabled
7106
select.disabled = true;
7107
support.optDisabled = !opt.disabled;
7110
// An input loses its value after becoming a radio
7111
input = document.createElement( "input" );
7113
input.type = "radio";
7114
support.radioValue = input.value === "t";
7119
attrHandle = jQuery.expr.attrHandle;
7122
attr: function( name, value ) {
7123
return access( this, jQuery.attr, name, value, arguments.length > 1 );
7126
removeAttr: function( name ) {
7127
return this.each( function() {
7128
jQuery.removeAttr( this, name );
7134
attr: function( elem, name, value ) {
7136
nType = elem.nodeType;
7138
// Don't get/set attributes on text, comment and attribute nodes
7139
if ( nType === 3 || nType === 8 || nType === 2 ) {
7143
// Fallback to prop when attributes are not supported
7144
if ( typeof elem.getAttribute === "undefined" ) {
7145
return jQuery.prop( elem, name, value );
7148
// All attributes are lowercase
7149
// Grab necessary hook if one is defined
7150
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
7151
name = name.toLowerCase();
7152
hooks = jQuery.attrHooks[ name ] ||
7153
( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
7156
if ( value !== undefined ) {
7157
if ( value === null ) {
7158
jQuery.removeAttr( elem, name );
7162
if ( hooks && "set" in hooks &&
7163
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
7167
elem.setAttribute( name, value + "" );
7171
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
7175
ret = jQuery.find.attr( elem, name );
7177
// Non-existent attributes return null, we normalize to undefined
7178
return ret == null ? undefined : ret;
7183
set: function( elem, value ) {
7184
if ( !support.radioValue && value === "radio" &&
7185
jQuery.nodeName( elem, "input" ) ) {
7186
var val = elem.value;
7187
elem.setAttribute( "type", value );
7197
removeAttr: function( elem, value ) {
7200
attrNames = value && value.match( rnotwhite );
7202
if ( attrNames && elem.nodeType === 1 ) {
7203
while ( ( name = attrNames[ i++ ] ) ) {
7204
propName = jQuery.propFix[ name ] || name;
7206
// Boolean attributes get special treatment (#10870)
7207
if ( jQuery.expr.match.bool.test( name ) ) {
7209
// Set corresponding property to false
7210
elem[ propName ] = false;
7213
elem.removeAttribute( name );
7219
// Hooks for boolean attributes
7221
set: function( elem, value, name ) {
7222
if ( value === false ) {
7224
// Remove boolean attributes when set to false
7225
jQuery.removeAttr( elem, name );
7227
elem.setAttribute( name, name );
7232
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
7233
var getter = attrHandle[ name ] || jQuery.find.attr;
7235
attrHandle[ name ] = function( elem, name, isXML ) {
7239
// Avoid an infinite loop by temporarily removing this function from the getter
7240
handle = attrHandle[ name ];
7241
attrHandle[ name ] = ret;
7242
ret = getter( elem, name, isXML ) != null ?
7243
name.toLowerCase() :
7245
attrHandle[ name ] = handle;
7254
var rfocusable = /^(?:input|select|textarea|button)$/i,
7255
rclickable = /^(?:a|area)$/i;
7258
prop: function( name, value ) {
7259
return access( this, jQuery.prop, name, value, arguments.length > 1 );
7262
removeProp: function( name ) {
7263
return this.each( function() {
7264
delete this[ jQuery.propFix[ name ] || name ];
7270
prop: function( elem, name, value ) {
7272
nType = elem.nodeType;
7274
// Don't get/set properties on text, comment and attribute nodes
7275
if ( nType === 3 || nType === 8 || nType === 2 ) {
7279
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
7281
// Fix name and attach hooks
7282
name = jQuery.propFix[ name ] || name;
7283
hooks = jQuery.propHooks[ name ];
7286
if ( value !== undefined ) {
7287
if ( hooks && "set" in hooks &&
7288
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
7292
return ( elem[ name ] = value );
7295
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
7299
return elem[ name ];
7304
get: function( elem ) {
7306
// elem.tabIndex doesn't always return the
7307
// correct value when it hasn't been explicitly set
7308
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
7309
// Use proper attribute retrieval(#12072)
7310
var tabindex = jQuery.find.attr( elem, "tabindex" );
7313
parseInt( tabindex, 10 ) :
7314
rfocusable.test( elem.nodeName ) ||
7315
rclickable.test( elem.nodeName ) && elem.href ?
7324
"class": "className"
7328
if ( !support.optSelected ) {
7329
jQuery.propHooks.selected = {
7330
get: function( elem ) {
7331
var parent = elem.parentNode;
7332
if ( parent && parent.parentNode ) {
7333
parent.parentNode.selectedIndex;
7352
jQuery.propFix[ this.toLowerCase() ] = this;
7358
var rclass = /[\t\r\n\f]/g;
7360
function getClass( elem ) {
7361
return elem.getAttribute && elem.getAttribute( "class" ) || "";
7365
addClass: function( value ) {
7366
var classes, elem, cur, curValue, clazz, j, finalValue,
7369
if ( jQuery.isFunction( value ) ) {
7370
return this.each( function( j ) {
7371
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
7375
if ( typeof value === "string" && value ) {
7376
classes = value.match( rnotwhite ) || [];
7378
while ( ( elem = this[ i++ ] ) ) {
7379
curValue = getClass( elem );
7380
cur = elem.nodeType === 1 &&
7381
( " " + curValue + " " ).replace( rclass, " " );
7385
while ( ( clazz = classes[ j++ ] ) ) {
7386
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
7391
// Only assign if different to avoid unneeded rendering.
7392
finalValue = jQuery.trim( cur );
7393
if ( curValue !== finalValue ) {
7394
elem.setAttribute( "class", finalValue );
7403
removeClass: function( value ) {
7404
var classes, elem, cur, curValue, clazz, j, finalValue,
7407
if ( jQuery.isFunction( value ) ) {
7408
return this.each( function( j ) {
7409
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
7413
if ( !arguments.length ) {
7414
return this.attr( "class", "" );
7417
if ( typeof value === "string" && value ) {
7418
classes = value.match( rnotwhite ) || [];
7420
while ( ( elem = this[ i++ ] ) ) {
7421
curValue = getClass( elem );
7423
// This expression is here for better compressibility (see addClass)
7424
cur = elem.nodeType === 1 &&
7425
( " " + curValue + " " ).replace( rclass, " " );
7429
while ( ( clazz = classes[ j++ ] ) ) {
7431
// Remove *all* instances
7432
while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
7433
cur = cur.replace( " " + clazz + " ", " " );
7437
// Only assign if different to avoid unneeded rendering.
7438
finalValue = jQuery.trim( cur );
7439
if ( curValue !== finalValue ) {
7440
elem.setAttribute( "class", finalValue );
7449
toggleClass: function( value, stateVal ) {
7450
var type = typeof value;
7452
if ( typeof stateVal === "boolean" && type === "string" ) {
7453
return stateVal ? this.addClass( value ) : this.removeClass( value );
7456
if ( jQuery.isFunction( value ) ) {
7457
return this.each( function( i ) {
7458
jQuery( this ).toggleClass(
7459
value.call( this, i, getClass( this ), stateVal ),
7465
return this.each( function() {
7466
var className, i, self, classNames;
7468
if ( type === "string" ) {
7470
// Toggle individual class names
7472
self = jQuery( this );
7473
classNames = value.match( rnotwhite ) || [];
7475
while ( ( className = classNames[ i++ ] ) ) {
7477
// Check each className given, space separated list
7478
if ( self.hasClass( className ) ) {
7479
self.removeClass( className );
7481
self.addClass( className );
7485
// Toggle whole class name
7486
} else if ( value === undefined || type === "boolean" ) {
7487
className = getClass( this );
7490
// Store className if set
7491
dataPriv.set( this, "__className__", className );
7494
// If the element has a class name or if we're passed `false`,
7495
// then remove the whole classname (if there was one, the above saved it).
7496
// Otherwise bring back whatever was previously saved (if anything),
7497
// falling back to the empty string if nothing was stored.
7498
if ( this.setAttribute ) {
7499
this.setAttribute( "class",
7500
className || value === false ?
7502
dataPriv.get( this, "__className__" ) || ""
7509
hasClass: function( selector ) {
7510
var className, elem,
7513
className = " " + selector + " ";
7514
while ( ( elem = this[ i++ ] ) ) {
7515
if ( elem.nodeType === 1 &&
7516
( " " + getClass( elem ) + " " ).replace( rclass, " " )
7517
.indexOf( className ) > -1
7530
var rreturn = /\r/g;
7533
val: function( value ) {
7534
var hooks, ret, isFunction,
7537
if ( !arguments.length ) {
7539
hooks = jQuery.valHooks[ elem.type ] ||
7540
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
7544
( ret = hooks.get( elem, "value" ) ) !== undefined
7551
return typeof ret === "string" ?
7553
// Handle most common string cases
7554
ret.replace( rreturn, "" ) :
7556
// Handle cases where value is null/undef or number
7557
ret == null ? "" : ret;
7563
isFunction = jQuery.isFunction( value );
7565
return this.each( function( i ) {
7568
if ( this.nodeType !== 1 ) {
7573
val = value.call( this, i, jQuery( this ).val() );
7578
// Treat null/undefined as ""; convert numbers to string
7579
if ( val == null ) {
7582
} else if ( typeof val === "number" ) {
7585
} else if ( jQuery.isArray( val ) ) {
7586
val = jQuery.map( val, function( value ) {
7587
return value == null ? "" : value + "";
7591
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
7593
// If set returns undefined, fall back to normal setting
7594
if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
7604
get: function( elem ) {
7607
// option.value not trimmed (#14858)
7608
return jQuery.trim( elem.value );
7612
get: function( elem ) {
7614
options = elem.options,
7615
index = elem.selectedIndex,
7616
one = elem.type === "select-one" || index < 0,
7617
values = one ? null : [],
7618
max = one ? index + 1 : options.length,
7623
// Loop through all the selected options
7624
for ( ; i < max; i++ ) {
7625
option = options[ i ];
7627
// IE8-9 doesn't update selected after form reset (#2551)
7628
if ( ( option.selected || i === index ) &&
7630
// Don't return options that are disabled or in a disabled optgroup
7631
( support.optDisabled ?
7632
!option.disabled : option.getAttribute( "disabled" ) === null ) &&
7633
( !option.parentNode.disabled ||
7634
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
7636
// Get the specific value for the option
7637
value = jQuery( option ).val();
7639
// We don't need an array for one selects
7644
// Multi-Selects return an array
7645
values.push( value );
7652
set: function( elem, value ) {
7653
var optionSet, option,
7654
options = elem.options,
7655
values = jQuery.makeArray( value ),
7659
option = options[ i ];
7660
if ( option.selected =
7661
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
7667
// Force browsers to behave consistently when non-matching value is set
7669
elem.selectedIndex = -1;
7677
// Radios and checkboxes getter/setter
7678
jQuery.each( [ "radio", "checkbox" ], function() {
7679
jQuery.valHooks[ this ] = {
7680
set: function( elem, value ) {
7681
if ( jQuery.isArray( value ) ) {
7682
return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
7686
if ( !support.checkOn ) {
7687
jQuery.valHooks[ this ].get = function( elem ) {
7688
return elem.getAttribute( "value" ) === null ? "on" : elem.value;
7696
// Return jQuery for attributes-only inclusion
7699
var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;
7701
jQuery.extend( jQuery.event, {
7703
trigger: function( event, data, elem, onlyHandlers ) {
7705
var i, cur, tmp, bubbleType, ontype, handle, special,
7706
eventPath = [ elem || document ],
7707
type = hasOwn.call( event, "type" ) ? event.type : event,
7708
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
7710
cur = tmp = elem = elem || document;
7712
// Don't do events on text and comment nodes
7713
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
7717
// focus/blur morphs to focusin/out; ensure we're not firing them right now
7718
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
7722
if ( type.indexOf( "." ) > -1 ) {
7724
// Namespaced trigger; create a regexp to match event type in handle()
7725
namespaces = type.split( "." );
7726
type = namespaces.shift();
7729
ontype = type.indexOf( ":" ) < 0 && "on" + type;
7731
// Caller can pass in a jQuery.Event object, Object, or just an event type string
7732
event = event[ jQuery.expando ] ?
7734
new jQuery.Event( type, typeof event === "object" && event );
7736
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
7737
event.isTrigger = onlyHandlers ? 2 : 3;
7738
event.namespace = namespaces.join( "." );
7739
event.rnamespace = event.namespace ?
7740
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
7743
// Clean up the event in case it is being reused
7744
event.result = undefined;
7745
if ( !event.target ) {
7746
event.target = elem;
7749
// Clone any incoming data and prepend the event, creating the handler arg list
7750
data = data == null ?
7752
jQuery.makeArray( data, [ event ] );
7754
// Allow special events to draw outside the lines
7755
special = jQuery.event.special[ type ] || {};
7756
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
7760
// Determine event propagation path in advance, per W3C events spec (#9951)
7761
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
7762
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
7764
bubbleType = special.delegateType || type;
7765
if ( !rfocusMorph.test( bubbleType + type ) ) {
7766
cur = cur.parentNode;
7768
for ( ; cur; cur = cur.parentNode ) {
7769
eventPath.push( cur );
7773
// Only add window if we got to document (e.g., not plain obj or detached DOM)
7774
if ( tmp === ( elem.ownerDocument || document ) ) {
7775
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
7779
// Fire handlers on the event path
7781
while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
7783
event.type = i > 1 ?
7785
special.bindType || type;
7788
handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
7789
dataPriv.get( cur, "handle" );
7791
handle.apply( cur, data );
7795
handle = ontype && cur[ ontype ];
7796
if ( handle && handle.apply && acceptData( cur ) ) {
7797
event.result = handle.apply( cur, data );
7798
if ( event.result === false ) {
7799
event.preventDefault();
7805
// If nobody prevented the default action, do it now
7806
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
7808
if ( ( !special._default ||
7809
special._default.apply( eventPath.pop(), data ) === false ) &&
7810
acceptData( elem ) ) {
7812
// Call a native DOM method on the target with the same name name as the event.
7813
// Don't do default actions on window, that's where global variables be (#6170)
7814
if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
7816
// Don't re-trigger an onFOO event when we call its FOO() method
7817
tmp = elem[ ontype ];
7820
elem[ ontype ] = null;
7823
// Prevent re-triggering of the same event, since we already bubbled it above
7824
jQuery.event.triggered = type;
7826
jQuery.event.triggered = undefined;
7829
elem[ ontype ] = tmp;
7835
return event.result;
7838
// Piggyback on a donor event to simulate a different one
7839
simulate: function( type, elem, event ) {
7840
var e = jQuery.extend(
7847
// Previously, `originalEvent: {}` was set here, so stopPropagation call
7848
// would not be triggered on donor event, since in our own
7849
// jQuery.event.stopPropagation function we had a check for existence of
7850
// originalEvent.stopPropagation method, so, consequently it would be a noop.
7852
// But now, this "simulate" function is used only for events
7853
// for which stopPropagation() is noop, so there is no need for that anymore.
7855
// For the 1.x branch though, guard for "click" and "submit"
7856
// events is still used, but was moved to jQuery.event.stopPropagation function
7857
// because `originalEvent` should point to the original event for the constancy
7858
// with other events and for more focused logic
7862
jQuery.event.trigger( e, null, elem );
7864
if ( e.isDefaultPrevented() ) {
7865
event.preventDefault();
7873
trigger: function( type, data ) {
7874
return this.each( function() {
7875
jQuery.event.trigger( type, data, this );
7878
triggerHandler: function( type, data ) {
7879
var elem = this[ 0 ];
7881
return jQuery.event.trigger( type, data, elem, true );
7887
jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " +
7888
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
7889
"change select submit keydown keypress keyup error contextmenu" ).split( " " ),
7890
function( i, name ) {
7892
// Handle event binding
7893
jQuery.fn[ name ] = function( data, fn ) {
7894
return arguments.length > 0 ?
7895
this.on( name, null, data, fn ) :
7896
this.trigger( name );
7901
hover: function( fnOver, fnOut ) {
7902
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
7909
support.focusin = "onfocusin" in window;
7913
// Firefox doesn't have focus(in | out) events
7914
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
7916
// Support: Chrome, Safari
7917
// focus(in | out) events fire after focus & blur events,
7918
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
7919
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
7920
if ( !support.focusin ) {
7921
jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
7923
// Attach a single capturing handler on the document while someone wants focusin/focusout
7924
var handler = function( event ) {
7925
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
7928
jQuery.event.special[ fix ] = {
7930
var doc = this.ownerDocument || this,
7931
attaches = dataPriv.access( doc, fix );
7934
doc.addEventListener( orig, handler, true );
7936
dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
7938
teardown: function() {
7939
var doc = this.ownerDocument || this,
7940
attaches = dataPriv.access( doc, fix ) - 1;
7943
doc.removeEventListener( orig, handler, true );
7944
dataPriv.remove( doc, fix );
7947
dataPriv.access( doc, fix, attaches );
7953
var location = window.location;
7955
var nonce = jQuery.now();
7957
var rquery = ( /\?/ );
7961
// Support: Android 2.3
7962
// Workaround failure to string-cast null input
7963
jQuery.parseJSON = function( data ) {
7964
return JSON.parse( data + "" );
7968
// Cross-browser xml parsing
7969
jQuery.parseXML = function( data ) {
7971
if ( !data || typeof data !== "string" ) {
7977
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
7982
if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
7983
jQuery.error( "Invalid XML: " + data );
7991
rts = /([?&])_=[^&]*/,
7992
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
7994
// #7653, #8125, #8152: local protocol detection
7995
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
7996
rnoContent = /^(?:GET|HEAD)$/,
7997
rprotocol = /^\/\//,
8000
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
8001
* 2) These are called:
8002
* - BEFORE asking for a transport
8003
* - AFTER param serialization (s.data is a string if s.processData is true)
8004
* 3) key is the dataType
8005
* 4) the catchall symbol "*" can be used
8006
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
8010
/* Transports bindings
8011
* 1) key is the dataType
8012
* 2) the catchall symbol "*" can be used
8013
* 3) selection will start with transport dataType and THEN go to "*" if needed
8017
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
8018
allTypes = "*/".concat( "*" ),
8020
// Anchor tag for parsing the document origin
8021
originAnchor = document.createElement( "a" );
8022
originAnchor.href = location.href;
8024
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
8025
function addToPrefiltersOrTransports( structure ) {
8027
// dataTypeExpression is optional and defaults to "*"
8028
return function( dataTypeExpression, func ) {
8030
if ( typeof dataTypeExpression !== "string" ) {
8031
func = dataTypeExpression;
8032
dataTypeExpression = "*";
8037
dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
8039
if ( jQuery.isFunction( func ) ) {
8041
// For each dataType in the dataTypeExpression
8042
while ( ( dataType = dataTypes[ i++ ] ) ) {
8044
// Prepend if requested
8045
if ( dataType[ 0 ] === "+" ) {
8046
dataType = dataType.slice( 1 ) || "*";
8047
( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
8051
( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
8058
// Base inspection function for prefilters and transports
8059
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
8062
seekingTransport = ( structure === transports );
8064
function inspect( dataType ) {
8066
inspected[ dataType ] = true;
8067
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
8068
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
8069
if ( typeof dataTypeOrTransport === "string" &&
8070
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
8072
options.dataTypes.unshift( dataTypeOrTransport );
8073
inspect( dataTypeOrTransport );
8075
} else if ( seekingTransport ) {
8076
return !( selected = dataTypeOrTransport );
8082
return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
8085
// A special extend for ajax options
8086
// that takes "flat" options (not to be deep extended)
8088
function ajaxExtend( target, src ) {
8090
flatOptions = jQuery.ajaxSettings.flatOptions || {};
8092
for ( key in src ) {
8093
if ( src[ key ] !== undefined ) {
8094
( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
8098
jQuery.extend( true, target, deep );
8104
/* Handles responses to an ajax request:
8105
* - finds the right dataType (mediates between content-type and expected dataType)
8106
* - returns the corresponding response
8108
function ajaxHandleResponses( s, jqXHR, responses ) {
8110
var ct, type, finalDataType, firstDataType,
8111
contents = s.contents,
8112
dataTypes = s.dataTypes;
8114
// Remove auto dataType and get content-type in the process
8115
while ( dataTypes[ 0 ] === "*" ) {
8117
if ( ct === undefined ) {
8118
ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
8122
// Check if we're dealing with a known content-type
8124
for ( type in contents ) {
8125
if ( contents[ type ] && contents[ type ].test( ct ) ) {
8126
dataTypes.unshift( type );
8132
// Check to see if we have a response for the expected dataType
8133
if ( dataTypes[ 0 ] in responses ) {
8134
finalDataType = dataTypes[ 0 ];
8137
// Try convertible dataTypes
8138
for ( type in responses ) {
8139
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
8140
finalDataType = type;
8143
if ( !firstDataType ) {
8144
firstDataType = type;
8148
// Or just use first one
8149
finalDataType = finalDataType || firstDataType;
8152
// If we found a dataType
8153
// We add the dataType to the list if needed
8154
// and return the corresponding response
8155
if ( finalDataType ) {
8156
if ( finalDataType !== dataTypes[ 0 ] ) {
8157
dataTypes.unshift( finalDataType );
8159
return responses[ finalDataType ];
8163
/* Chain conversions given the request and the original response
8164
* Also sets the responseXXX fields on the jqXHR instance
8166
function ajaxConvert( s, response, jqXHR, isSuccess ) {
8167
var conv2, current, conv, tmp, prev,
8170
// Work with a copy of dataTypes in case we need to modify it for conversion
8171
dataTypes = s.dataTypes.slice();
8173
// Create converters map with lowercased keys
8174
if ( dataTypes[ 1 ] ) {
8175
for ( conv in s.converters ) {
8176
converters[ conv.toLowerCase() ] = s.converters[ conv ];
8180
current = dataTypes.shift();
8182
// Convert to each sequential dataType
8185
if ( s.responseFields[ current ] ) {
8186
jqXHR[ s.responseFields[ current ] ] = response;
8189
// Apply the dataFilter if provided
8190
if ( !prev && isSuccess && s.dataFilter ) {
8191
response = s.dataFilter( response, s.dataType );
8195
current = dataTypes.shift();
8199
// There's only work to do if current dataType is non-auto
8200
if ( current === "*" ) {
8204
// Convert response if prev dataType is non-auto and differs from current
8205
} else if ( prev !== "*" && prev !== current ) {
8207
// Seek a direct converter
8208
conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8210
// If none found, seek a pair
8212
for ( conv2 in converters ) {
8214
// If conv2 outputs current
8215
tmp = conv2.split( " " );
8216
if ( tmp[ 1 ] === current ) {
8218
// If prev can be converted to accepted input
8219
conv = converters[ prev + " " + tmp[ 0 ] ] ||
8220
converters[ "* " + tmp[ 0 ] ];
8223
// Condense equivalence converters
8224
if ( conv === true ) {
8225
conv = converters[ conv2 ];
8227
// Otherwise, insert the intermediate dataType
8228
} else if ( converters[ conv2 ] !== true ) {
8230
dataTypes.unshift( tmp[ 1 ] );
8238
// Apply converter (if not an equivalence)
8239
if ( conv !== true ) {
8241
// Unless errors are allowed to bubble, catch and return them
8242
if ( conv && s.throws ) {
8243
response = conv( response );
8246
response = conv( response );
8249
state: "parsererror",
8250
error: conv ? e : "No conversion from " + prev + " to " + current
8259
return { state: "success", data: response };
8264
// Counter for holding the number of active queries
8267
// Last-Modified header cache for next request
8274
isLocal: rlocalProtocol.test( location.protocol ),
8278
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
8295
xml: "application/xml, text/xml",
8296
json: "application/json, text/javascript"
8307
text: "responseText",
8308
json: "responseJSON"
8312
// Keys separate source (or catchall "*") and destination types with a single space
8315
// Convert anything to text
8318
// Text to html (true = no transformation)
8321
// Evaluate text as a json expression
8322
"text json": jQuery.parseJSON,
8324
// Parse text as xml
8325
"text xml": jQuery.parseXML
8328
// For options that shouldn't be deep extended:
8329
// you can add your own custom options here if
8330
// and when you create one that shouldn't be
8331
// deep extended (see ajaxExtend)
8338
// Creates a full fledged settings object into target
8339
// with both ajaxSettings and settings fields.
8340
// If target is omitted, writes into ajaxSettings.
8341
ajaxSetup: function( target, settings ) {
8344
// Building a settings object
8345
ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
8347
// Extending ajaxSettings
8348
ajaxExtend( jQuery.ajaxSettings, target );
8351
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
8352
ajaxTransport: addToPrefiltersOrTransports( transports ),
8355
ajax: function( url, options ) {
8357
// If url is an object, simulate pre-1.5 signature
8358
if ( typeof url === "object" ) {
8363
// Force options to be an object
8364
options = options || {};
8368
// URL without anti-cache param
8372
responseHeadersString,
8381
// To know if global events are to be dispatched
8387
// Create the final options object
8388
s = jQuery.ajaxSetup( {}, options ),
8390
// Callbacks context
8391
callbackContext = s.context || s,
8393
// Context for global events is callbackContext if it is a DOM node or jQuery collection
8394
globalEventContext = s.context &&
8395
( callbackContext.nodeType || callbackContext.jquery ) ?
8396
jQuery( callbackContext ) :
8400
deferred = jQuery.Deferred(),
8401
completeDeferred = jQuery.Callbacks( "once memory" ),
8403
// Status-dependent callbacks
8404
statusCode = s.statusCode || {},
8406
// Headers (they are sent all at once)
8407
requestHeaders = {},
8408
requestHeadersNames = {},
8413
// Default abort message
8414
strAbort = "canceled",
8420
// Builds headers hashtable if needed
8421
getResponseHeader: function( key ) {
8423
if ( state === 2 ) {
8424
if ( !responseHeaders ) {
8425
responseHeaders = {};
8426
while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
8427
responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
8430
match = responseHeaders[ key.toLowerCase() ];
8432
return match == null ? null : match;
8436
getAllResponseHeaders: function() {
8437
return state === 2 ? responseHeadersString : null;
8440
// Caches the header
8441
setRequestHeader: function( name, value ) {
8442
var lname = name.toLowerCase();
8444
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
8445
requestHeaders[ name ] = value;
8450
// Overrides response content-type header
8451
overrideMimeType: function( type ) {
8458
// Status-dependent callbacks
8459
statusCode: function( map ) {
8463
for ( code in map ) {
8465
// Lazy-add the new callback in a way that preserves old ones
8466
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
8470
// Execute the appropriate callbacks
8471
jqXHR.always( map[ jqXHR.status ] );
8477
// Cancel the request
8478
abort: function( statusText ) {
8479
var finalText = statusText || strAbort;
8481
transport.abort( finalText );
8483
done( 0, finalText );
8489
deferred.promise( jqXHR ).complete = completeDeferred.add;
8490
jqXHR.success = jqXHR.done;
8491
jqXHR.error = jqXHR.fail;
8493
// Remove hash character (#7531: and string promotion)
8494
// Add protocol if not provided (prefilters might expect it)
8495
// Handle falsy url in the settings object (#10093: consistency with old signature)
8496
// We also use the url parameter if available
8497
s.url = ( ( url || s.url || location.href ) + "" ).replace( rhash, "" )
8498
.replace( rprotocol, location.protocol + "//" );
8500
// Alias method option to type as per ticket #12004
8501
s.type = options.method || options.type || s.method || s.type;
8503
// Extract dataTypes list
8504
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
8506
// A cross-domain request is in order when the origin doesn't match the current origin.
8507
if ( s.crossDomain == null ) {
8508
urlAnchor = document.createElement( "a" );
8511
// IE throws exception if url is malformed, e.g. http://example.com:80x/
8513
urlAnchor.href = s.url;
8516
// Anchor's host property isn't correctly set when s.url is relative
8517
urlAnchor.href = urlAnchor.href;
8518
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
8519
urlAnchor.protocol + "//" + urlAnchor.host;
8522
// If there is an error parsing the URL, assume it is crossDomain,
8523
// it can be rejected by the transport if it is invalid
8524
s.crossDomain = true;
8528
// Convert data if not already a string
8529
if ( s.data && s.processData && typeof s.data !== "string" ) {
8530
s.data = jQuery.param( s.data, s.traditional );
8534
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
8536
// If request was aborted inside a prefilter, stop there
8537
if ( state === 2 ) {
8541
// We can fire global events as of now if asked to
8542
// Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
8543
fireGlobals = jQuery.event && s.global;
8545
// Watch for a new set of requests
8546
if ( fireGlobals && jQuery.active++ === 0 ) {
8547
jQuery.event.trigger( "ajaxStart" );
8550
// Uppercase the type
8551
s.type = s.type.toUpperCase();
8553
// Determine if request has content
8554
s.hasContent = !rnoContent.test( s.type );
8556
// Save the URL in case we're toying with the If-Modified-Since
8557
// and/or If-None-Match header later on
8560
// More options handling for requests with no content
8561
if ( !s.hasContent ) {
8563
// If data is available, append data to url
8565
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
8567
// #9682: remove data so that it's not used in an eventual retry
8571
// Add anti-cache in url if needed
8572
if ( s.cache === false ) {
8573
s.url = rts.test( cacheURL ) ?
8575
// If there is already a '_' parameter, set its value
8576
cacheURL.replace( rts, "$1_=" + nonce++ ) :
8578
// Otherwise add one to the end
8579
cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
8583
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8584
if ( s.ifModified ) {
8585
if ( jQuery.lastModified[ cacheURL ] ) {
8586
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
8588
if ( jQuery.etag[ cacheURL ] ) {
8589
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
8593
// Set the correct header, if data is being sent
8594
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
8595
jqXHR.setRequestHeader( "Content-Type", s.contentType );
8598
// Set the Accepts header for the server, depending on the dataType
8599
jqXHR.setRequestHeader(
8601
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
8602
s.accepts[ s.dataTypes[ 0 ] ] +
8603
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
8607
// Check for headers option
8608
for ( i in s.headers ) {
8609
jqXHR.setRequestHeader( i, s.headers[ i ] );
8612
// Allow custom headers/mimetypes and early abort
8613
if ( s.beforeSend &&
8614
( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
8616
// Abort if not done already and return
8617
return jqXHR.abort();
8620
// Aborting is no longer a cancellation
8623
// Install callbacks on deferreds
8624
for ( i in { success: 1, error: 1, complete: 1 } ) {
8625
jqXHR[ i ]( s[ i ] );
8629
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
8631
// If no transport, we auto-abort
8633
done( -1, "No Transport" );
8635
jqXHR.readyState = 1;
8637
// Send global event
8638
if ( fireGlobals ) {
8639
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
8642
// If request was aborted inside ajaxSend, stop there
8643
if ( state === 2 ) {
8648
if ( s.async && s.timeout > 0 ) {
8649
timeoutTimer = window.setTimeout( function() {
8650
jqXHR.abort( "timeout" );
8656
transport.send( requestHeaders, done );
8659
// Propagate exception as error if not done
8663
// Simply rethrow otherwise
8670
// Callback for when everything is done
8671
function done( status, nativeStatusText, responses, headers ) {
8672
var isSuccess, success, error, response, modified,
8673
statusText = nativeStatusText;
8676
if ( state === 2 ) {
8680
// State is "done" now
8683
// Clear timeout if it exists
8684
if ( timeoutTimer ) {
8685
window.clearTimeout( timeoutTimer );
8688
// Dereference transport for early garbage collection
8689
// (no matter how long the jqXHR object will be used)
8690
transport = undefined;
8692
// Cache response headers
8693
responseHeadersString = headers || "";
8696
jqXHR.readyState = status > 0 ? 4 : 0;
8698
// Determine if successful
8699
isSuccess = status >= 200 && status < 300 || status === 304;
8701
// Get response data
8703
response = ajaxHandleResponses( s, jqXHR, responses );
8706
// Convert no matter what (that way responseXXX fields are always set)
8707
response = ajaxConvert( s, response, jqXHR, isSuccess );
8709
// If successful, handle type chaining
8712
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8713
if ( s.ifModified ) {
8714
modified = jqXHR.getResponseHeader( "Last-Modified" );
8716
jQuery.lastModified[ cacheURL ] = modified;
8718
modified = jqXHR.getResponseHeader( "etag" );
8720
jQuery.etag[ cacheURL ] = modified;
8725
if ( status === 204 || s.type === "HEAD" ) {
8726
statusText = "nocontent";
8729
} else if ( status === 304 ) {
8730
statusText = "notmodified";
8732
// If we have data, let's convert it
8734
statusText = response.state;
8735
success = response.data;
8736
error = response.error;
8741
// Extract error from statusText and normalize for non-aborts
8743
if ( status || !statusText ) {
8744
statusText = "error";
8751
// Set data for the fake xhr object
8752
jqXHR.status = status;
8753
jqXHR.statusText = ( nativeStatusText || statusText ) + "";
8757
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
8759
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
8762
// Status-dependent callbacks
8763
jqXHR.statusCode( statusCode );
8764
statusCode = undefined;
8766
if ( fireGlobals ) {
8767
globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
8768
[ jqXHR, s, isSuccess ? success : error ] );
8772
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
8774
if ( fireGlobals ) {
8775
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
8777
// Handle the global AJAX counter
8778
if ( !( --jQuery.active ) ) {
8779
jQuery.event.trigger( "ajaxStop" );
8787
getJSON: function( url, data, callback ) {
8788
return jQuery.get( url, data, callback, "json" );
8791
getScript: function( url, callback ) {
8792
return jQuery.get( url, undefined, callback, "script" );
8796
jQuery.each( [ "get", "post" ], function( i, method ) {
8797
jQuery[ method ] = function( url, data, callback, type ) {
8799
// Shift arguments if data argument was omitted
8800
if ( jQuery.isFunction( data ) ) {
8801
type = type || callback;
8806
// The url can be an options object (which then must have .url)
8807
return jQuery.ajax( jQuery.extend( {
8813
}, jQuery.isPlainObject( url ) && url ) );
8818
jQuery._evalUrl = function( url ) {
8819
return jQuery.ajax( {
8822
// Make this explicit, since user can override this through ajaxSetup (#11264)
8833
wrapAll: function( html ) {
8836
if ( jQuery.isFunction( html ) ) {
8837
return this.each( function( i ) {
8838
jQuery( this ).wrapAll( html.call( this, i ) );
8844
// The elements to wrap the target around
8845
wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
8847
if ( this[ 0 ].parentNode ) {
8848
wrap.insertBefore( this[ 0 ] );
8851
wrap.map( function() {
8854
while ( elem.firstElementChild ) {
8855
elem = elem.firstElementChild;
8865
wrapInner: function( html ) {
8866
if ( jQuery.isFunction( html ) ) {
8867
return this.each( function( i ) {
8868
jQuery( this ).wrapInner( html.call( this, i ) );
8872
return this.each( function() {
8873
var self = jQuery( this ),
8874
contents = self.contents();
8876
if ( contents.length ) {
8877
contents.wrapAll( html );
8880
self.append( html );
8885
wrap: function( html ) {
8886
var isFunction = jQuery.isFunction( html );
8888
return this.each( function( i ) {
8889
jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
8893
unwrap: function() {
8894
return this.parent().each( function() {
8895
if ( !jQuery.nodeName( this, "body" ) ) {
8896
jQuery( this ).replaceWith( this.childNodes );
8903
jQuery.expr.filters.hidden = function( elem ) {
8904
return !jQuery.expr.filters.visible( elem );
8906
jQuery.expr.filters.visible = function( elem ) {
8908
// Support: Opera <= 12.12
8909
// Opera reports offsetWidths and offsetHeights less than zero on some elements
8910
// Use OR instead of AND as the element is not visible if either is true
8911
// See tickets #10406 and #13132
8912
return elem.offsetWidth > 0 || elem.offsetHeight > 0 || elem.getClientRects().length > 0;
8921
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
8922
rsubmittable = /^(?:input|select|textarea|keygen)/i;
8924
function buildParams( prefix, obj, traditional, add ) {
8927
if ( jQuery.isArray( obj ) ) {
8929
// Serialize array item.
8930
jQuery.each( obj, function( i, v ) {
8931
if ( traditional || rbracket.test( prefix ) ) {
8933
// Treat each array item as a scalar.
8938
// Item is non-scalar (array or object), encode its numeric index.
8940
prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
8948
} else if ( !traditional && jQuery.type( obj ) === "object" ) {
8950
// Serialize object item.
8951
for ( name in obj ) {
8952
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
8957
// Serialize scalar item.
8962
// Serialize an array of form elements or a set of
8963
// key/values into a query string
8964
jQuery.param = function( a, traditional ) {
8967
add = function( key, value ) {
8969
// If value is a function, invoke it and return its value
8970
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
8971
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
8974
// Set traditional to true for jQuery <= 1.3.2 behavior.
8975
if ( traditional === undefined ) {
8976
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
8979
// If an array was passed in, assume that it is an array of form elements.
8980
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
8982
// Serialize the form elements
8983
jQuery.each( a, function() {
8984
add( this.name, this.value );
8989
// If traditional, encode the "old" way (the way 1.3.2 or older
8990
// did it), otherwise encode params recursively.
8991
for ( prefix in a ) {
8992
buildParams( prefix, a[ prefix ], traditional, add );
8996
// Return the resulting serialization
8997
return s.join( "&" ).replace( r20, "+" );
9001
serialize: function() {
9002
return jQuery.param( this.serializeArray() );
9004
serializeArray: function() {
9005
return this.map( function() {
9007
// Can add propHook for "elements" to filter or add form elements
9008
var elements = jQuery.prop( this, "elements" );
9009
return elements ? jQuery.makeArray( elements ) : this;
9011
.filter( function() {
9012
var type = this.type;
9014
// Use .is( ":disabled" ) so that fieldset[disabled] works
9015
return this.name && !jQuery( this ).is( ":disabled" ) &&
9016
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
9017
( this.checked || !rcheckableType.test( type ) );
9019
.map( function( i, elem ) {
9020
var val = jQuery( this ).val();
9022
return val == null ?
9024
jQuery.isArray( val ) ?
9025
jQuery.map( val, function( val ) {
9026
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9028
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9034
jQuery.ajaxSettings.xhr = function() {
9036
return new window.XMLHttpRequest();
9040
var xhrSuccessStatus = {
9042
// File protocol always yields status code 0, assume 200
9046
// #1450: sometimes IE returns 1223 when it should be 204
9049
xhrSupported = jQuery.ajaxSettings.xhr();
9051
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
9052
support.ajax = xhrSupported = !!xhrSupported;
9054
jQuery.ajaxTransport( function( options ) {
9055
var callback, errorCallback;
9057
// Cross domain only allowed if supported through XMLHttpRequest
9058
if ( support.cors || xhrSupported && !options.crossDomain ) {
9060
send: function( headers, complete ) {
9062
xhr = options.xhr();
9072
// Apply custom fields if provided
9073
if ( options.xhrFields ) {
9074
for ( i in options.xhrFields ) {
9075
xhr[ i ] = options.xhrFields[ i ];
9079
// Override mime type if needed
9080
if ( options.mimeType && xhr.overrideMimeType ) {
9081
xhr.overrideMimeType( options.mimeType );
9084
// X-Requested-With header
9085
// For cross-domain requests, seeing as conditions for a preflight are
9086
// akin to a jigsaw puzzle, we simply never set it to be sure.
9087
// (it can always be set on a per-request basis or even using ajaxSetup)
9088
// For same-domain requests, won't change header if already provided.
9089
if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
9090
headers[ "X-Requested-With" ] = "XMLHttpRequest";
9094
for ( i in headers ) {
9095
xhr.setRequestHeader( i, headers[ i ] );
9099
callback = function( type ) {
9102
callback = errorCallback = xhr.onload =
9103
xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
9105
if ( type === "abort" ) {
9107
} else if ( type === "error" ) {
9110
// On a manual native abort, IE9 throws
9111
// errors on any property access that is not readyState
9112
if ( typeof xhr.status !== "number" ) {
9113
complete( 0, "error" );
9117
// File: protocol always yields status 0; see #8605, #14207
9124
xhrSuccessStatus[ xhr.status ] || xhr.status,
9127
// Support: IE9 only
9128
// IE9 has no XHR2 but throws on binary (trac-11426)
9129
// For XHR2 non-text, let the caller handle it (gh-2498)
9130
( xhr.responseType || "text" ) !== "text" ||
9131
typeof xhr.responseText !== "string" ?
9132
{ binary: xhr.response } :
9133
{ text: xhr.responseText },
9134
xhr.getAllResponseHeaders()
9142
xhr.onload = callback();
9143
errorCallback = xhr.onerror = callback( "error" );
9146
// Use onreadystatechange to replace onabort
9147
// to handle uncaught aborts
9148
if ( xhr.onabort !== undefined ) {
9149
xhr.onabort = errorCallback;
9151
xhr.onreadystatechange = function() {
9153
// Check readyState before timeout as it changes
9154
if ( xhr.readyState === 4 ) {
9156
// Allow onerror to be called first,
9157
// but that will not handle a native abort
9158
// Also, save errorCallback to a variable
9159
// as xhr.onerror cannot be accessed
9160
window.setTimeout( function() {
9169
// Create the abort callback
9170
callback = callback( "abort" );
9174
// Do send the request (this may raise an exception)
9175
xhr.send( options.hasContent && options.data || null );
9178
// #14683: Only rethrow if this hasn't been notified as an error yet
9197
// Install script dataType
9200
script: "text/javascript, application/javascript, " +
9201
"application/ecmascript, application/x-ecmascript"
9204
script: /\b(?:java|ecma)script\b/
9207
"text script": function( text ) {
9208
jQuery.globalEval( text );
9214
// Handle cache's special case and crossDomain
9215
jQuery.ajaxPrefilter( "script", function( s ) {
9216
if ( s.cache === undefined ) {
9219
if ( s.crossDomain ) {
9224
// Bind script tag hack transport
9225
jQuery.ajaxTransport( "script", function( s ) {
9227
// This transport only deals with cross domain requests
9228
if ( s.crossDomain ) {
9229
var script, callback;
9231
send: function( _, complete ) {
9232
script = jQuery( "<script>" ).prop( {
9233
charset: s.scriptCharset,
9237
callback = function( evt ) {
9241
complete( evt.type === "error" ? 404 : 200, evt.type );
9246
// Use native DOM manipulation to avoid our domManip AJAX trickery
9247
document.head.appendChild( script[ 0 ] );
9261
var oldCallbacks = [],
9262
rjsonp = /(=)\?(?=&|$)|\?\?/;
9264
// Default jsonp settings
9267
jsonpCallback: function() {
9268
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
9269
this[ callback ] = true;
9274
// Detect, normalize options and install callbacks for jsonp requests
9275
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
9277
var callbackName, overwritten, responseContainer,
9278
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
9280
typeof s.data === "string" &&
9281
( s.contentType || "" )
9282
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
9283
rjsonp.test( s.data ) && "data"
9286
// Handle iff the expected data type is "jsonp" or we have a parameter to set
9287
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
9289
// Get callback name, remembering preexisting value associated with it
9290
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
9294
// Insert callback into url or form data
9296
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
9297
} else if ( s.jsonp !== false ) {
9298
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
9301
// Use data converter to retrieve json after script execution
9302
s.converters[ "script json" ] = function() {
9303
if ( !responseContainer ) {
9304
jQuery.error( callbackName + " was not called" );
9306
return responseContainer[ 0 ];
9309
// Force json dataType
9310
s.dataTypes[ 0 ] = "json";
9313
overwritten = window[ callbackName ];
9314
window[ callbackName ] = function() {
9315
responseContainer = arguments;
9318
// Clean-up function (fires after converters)
9319
jqXHR.always( function() {
9321
// If previous value didn't exist - remove it
9322
if ( overwritten === undefined ) {
9323
jQuery( window ).removeProp( callbackName );
9325
// Otherwise restore preexisting value
9327
window[ callbackName ] = overwritten;
9330
// Save back as free
9331
if ( s[ callbackName ] ) {
9333
// Make sure that re-using the options doesn't screw things around
9334
s.jsonpCallback = originalSettings.jsonpCallback;
9336
// Save the callback name for future use
9337
oldCallbacks.push( callbackName );
9340
// Call if it was a function and we have a response
9341
if ( responseContainer && jQuery.isFunction( overwritten ) ) {
9342
overwritten( responseContainer[ 0 ] );
9345
responseContainer = overwritten = undefined;
9348
// Delegate to script
9356
// Support: Safari 8+
9357
// In Safari 8 documents created via document.implementation.createHTMLDocument
9358
// collapse sibling forms: the second one becomes a child of the first one.
9359
// Because of that, this security measure has to be disabled in Safari 8.
9360
// https://bugs.webkit.org/show_bug.cgi?id=137337
9361
support.createHTMLDocument = ( function() {
9362
var body = document.implementation.createHTMLDocument( "" ).body;
9363
body.innerHTML = "<form></form><form></form>";
9364
return body.childNodes.length === 2;
9368
// Argument "data" should be string of html
9369
// context (optional): If specified, the fragment will be created in this context,
9370
// defaults to document
9371
// keepScripts (optional): If true, will include scripts passed in the html string
9372
jQuery.parseHTML = function( data, context, keepScripts ) {
9373
if ( !data || typeof data !== "string" ) {
9376
if ( typeof context === "boolean" ) {
9377
keepScripts = context;
9381
// Stop scripts or inline event handlers from being executed immediately
9382
// by using document.implementation
9383
context = context || ( support.createHTMLDocument ?
9384
document.implementation.createHTMLDocument( "" ) :
9387
var parsed = rsingleTag.exec( data ),
9388
scripts = !keepScripts && [];
9392
return [ context.createElement( parsed[ 1 ] ) ];
9395
parsed = buildFragment( [ data ], context, scripts );
9397
if ( scripts && scripts.length ) {
9398
jQuery( scripts ).remove();
9401
return jQuery.merge( [], parsed.childNodes );
9405
// Keep a copy of the old load method
9406
var _load = jQuery.fn.load;
9409
* Load a url into a page
9411
jQuery.fn.load = function( url, params, callback ) {
9412
if ( typeof url !== "string" && _load ) {
9413
return _load.apply( this, arguments );
9416
var selector, type, response,
9418
off = url.indexOf( " " );
9421
selector = jQuery.trim( url.slice( off ) );
9422
url = url.slice( 0, off );
9425
// If it's a function
9426
if ( jQuery.isFunction( params ) ) {
9428
// We assume that it's the callback
9432
// Otherwise, build a param string
9433
} else if ( params && typeof params === "object" ) {
9437
// If we have elements to modify, make the request
9438
if ( self.length > 0 ) {
9442
// If "type" variable is undefined, then "GET" method will be used.
9443
// Make value of this field explicit since
9444
// user can override it through ajaxSetup method
9445
type: type || "GET",
9448
} ).done( function( responseText ) {
9450
// Save response for use in complete callback
9451
response = arguments;
9453
self.html( selector ?
9455
// If a selector was specified, locate the right elements in a dummy div
9456
// Exclude scripts to avoid IE 'Permission Denied' errors
9457
jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
9459
// Otherwise use the full result
9462
// If the request succeeds, this function gets "data", "status", "jqXHR"
9463
// but they are ignored because response was set above.
9464
// If it fails, this function gets "jqXHR", "status", "error"
9465
} ).always( callback && function( jqXHR, status ) {
9466
self.each( function() {
9467
callback.apply( self, response || [ jqXHR.responseText, status, jqXHR ] );
9478
// Attach a bunch of functions for handling common AJAX events
9486
], function( i, type ) {
9487
jQuery.fn[ type ] = function( fn ) {
9488
return this.on( type, fn );
9495
jQuery.expr.filters.animated = function( elem ) {
9496
return jQuery.grep( jQuery.timers, function( fn ) {
9497
return elem === fn.elem;
9505
* Gets a window from an element
9507
function getWindow( elem ) {
9508
return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
9512
setOffset: function( elem, options, i ) {
9513
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
9514
position = jQuery.css( elem, "position" ),
9515
curElem = jQuery( elem ),
9518
// Set position first, in-case top/left are set even on static elem
9519
if ( position === "static" ) {
9520
elem.style.position = "relative";
9523
curOffset = curElem.offset();
9524
curCSSTop = jQuery.css( elem, "top" );
9525
curCSSLeft = jQuery.css( elem, "left" );
9526
calculatePosition = ( position === "absolute" || position === "fixed" ) &&
9527
( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
9529
// Need to be able to calculate position if either
9530
// top or left is auto and position is either absolute or fixed
9531
if ( calculatePosition ) {
9532
curPosition = curElem.position();
9533
curTop = curPosition.top;
9534
curLeft = curPosition.left;
9537
curTop = parseFloat( curCSSTop ) || 0;
9538
curLeft = parseFloat( curCSSLeft ) || 0;
9541
if ( jQuery.isFunction( options ) ) {
9543
// Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
9544
options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
9547
if ( options.top != null ) {
9548
props.top = ( options.top - curOffset.top ) + curTop;
9550
if ( options.left != null ) {
9551
props.left = ( options.left - curOffset.left ) + curLeft;
9554
if ( "using" in options ) {
9555
options.using.call( elem, props );
9558
curElem.css( props );
9564
offset: function( options ) {
9565
if ( arguments.length ) {
9566
return options === undefined ?
9568
this.each( function( i ) {
9569
jQuery.offset.setOffset( this, options, i );
9575
box = { top: 0, left: 0 },
9576
doc = elem && elem.ownerDocument;
9582
docElem = doc.documentElement;
9584
// Make sure it's not a disconnected DOM node
9585
if ( !jQuery.contains( docElem, elem ) ) {
9589
box = elem.getBoundingClientRect();
9590
win = getWindow( doc );
9592
top: box.top + win.pageYOffset - docElem.clientTop,
9593
left: box.left + win.pageXOffset - docElem.clientLeft
9597
position: function() {
9602
var offsetParent, offset,
9604
parentOffset = { top: 0, left: 0 };
9606
// Fixed elements are offset from window (parentOffset = {top:0, left: 0},
9607
// because it is its only offset parent
9608
if ( jQuery.css( elem, "position" ) === "fixed" ) {
9610
// Assume getBoundingClientRect is there when computed position is fixed
9611
offset = elem.getBoundingClientRect();
9615
// Get *real* offsetParent
9616
offsetParent = this.offsetParent();
9618
// Get correct offsets
9619
offset = this.offset();
9620
if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
9621
parentOffset = offsetParent.offset();
9624
// Add offsetParent borders
9625
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
9626
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
9629
// Subtract parent offsets and element margins
9631
top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
9632
left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
9636
// This method will return documentElement in the following cases:
9637
// 1) For the element inside the iframe without offsetParent, this method will return
9638
// documentElement of the parent window
9639
// 2) For the hidden or detached element
9640
// 3) For body or html element, i.e. in case of the html node - it will return itself
9642
// but those exceptions were never presented as a real life use-cases
9643
// and might be considered as more preferable results.
9645
// This logic, however, is not guaranteed and can change at any point in the future
9646
offsetParent: function() {
9647
return this.map( function() {
9648
var offsetParent = this.offsetParent;
9650
while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
9651
offsetParent = offsetParent.offsetParent;
9654
return offsetParent || documentElement;
9659
// Create scrollLeft and scrollTop methods
9660
jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
9661
var top = "pageYOffset" === prop;
9663
jQuery.fn[ method ] = function( val ) {
9664
return access( this, function( elem, method, val ) {
9665
var win = getWindow( elem );
9667
if ( val === undefined ) {
9668
return win ? win[ prop ] : elem[ method ];
9673
!top ? val : win.pageXOffset,
9674
top ? val : win.pageYOffset
9678
elem[ method ] = val;
9680
}, method, val, arguments.length );
9684
// Support: Safari<7-8+, Chrome<37-44+
9685
// Add the top/left cssHooks using jQuery.fn.position
9686
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
9687
// Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280
9688
// getComputedStyle returns percent when specified for top/left/bottom/right;
9689
// rather than make the css module depend on the offset module, just check for it here
9690
jQuery.each( [ "top", "left" ], function( i, prop ) {
9691
jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
9692
function( elem, computed ) {
9694
computed = curCSS( elem, prop );
9696
// If curCSS returns percentage, fallback to offset
9697
return rnumnonpx.test( computed ) ?
9698
jQuery( elem ).position()[ prop ] + "px" :
9706
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9707
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9708
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
9709
function( defaultExtra, funcName ) {
9711
// Margin is only for outerHeight, outerWidth
9712
jQuery.fn[ funcName ] = function( margin, value ) {
9713
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
9714
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
9716
return access( this, function( elem, type, value ) {
9719
if ( jQuery.isWindow( elem ) ) {
9721
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9722
// isn't a whole lot we can do. See pull request at this URL for discussion:
9723
// https://github.com/jquery/jquery/pull/764
9724
return elem.document.documentElement[ "client" + name ];
9727
// Get document width or height
9728
if ( elem.nodeType === 9 ) {
9729
doc = elem.documentElement;
9731
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
9732
// whichever is greatest
9734
elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9735
elem.body[ "offset" + name ], doc[ "offset" + name ],
9736
doc[ "client" + name ]
9740
return value === undefined ?
9742
// Get width or height on the element, requesting but not forcing parseFloat
9743
jQuery.css( elem, type, extra ) :
9745
// Set width or height on the element
9746
jQuery.style( elem, type, value, extra );
9747
}, type, chainable ? margin : undefined, chainable, null );
9755
bind: function( types, data, fn ) {
9756
return this.on( types, null, data, fn );
9758
unbind: function( types, fn ) {
9759
return this.off( types, null, fn );
9762
delegate: function( selector, types, data, fn ) {
9763
return this.on( types, selector, data, fn );
9765
undelegate: function( selector, types, fn ) {
9767
// ( namespace ) or ( selector, types [, fn] )
9768
return arguments.length === 1 ?
9769
this.off( selector, "**" ) :
9770
this.off( types, selector || "**", fn );
9777
jQuery.fn.andSelf = jQuery.fn.addBack;
9782
// Register as a named AMD module, since jQuery can be concatenated with other
9783
// files that may use define, but not via a proper concatenation script that
9784
// understands anonymous AMD modules. A named AMD is safest and most robust
9785
// way to register. Lowercase jquery is used because AMD module names are
9786
// derived from file names, and jQuery is normally delivered in a lowercase
9787
// file name. Do this after creating the global so that if an AMD module wants
9788
// to call noConflict to hide this version of jQuery, it will work.
9790
// Note that for maximum portability, libraries that are not jQuery should
9791
// declare themselves as anonymous modules, and avoid setting a global if an
9792
// AMD loader is present. jQuery is a special case. For more information, see
9793
// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
9795
if ( typeof define === "function" && define.amd ) {
9796
define( "jquery", [], function() {
9805
// Map over jQuery in case of overwrite
9806
_jQuery = window.jQuery,
9808
// Map over the $ in case of overwrite
9811
jQuery.noConflict = function( deep ) {
9812
if ( window.$ === jQuery ) {
9816
if ( deep && window.jQuery === jQuery ) {
9817
window.jQuery = _jQuery;
9823
// Expose jQuery and $ identifiers, even in AMD
9824
// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
9825
// and CommonJS for browser emulators (#13566)
9827
window.jQuery = window.$ = jQuery;