11 ], function( arr, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) {
14 // Use the correct document accordingly with window argument (sandbox)
15 document = window.document,
19 // Define a local copy of jQuery
20 jQuery = function( selector, context ) {
21 // The jQuery object is actually just the init constructor 'enhanced'
22 // Need init if jQuery is called (just allow error to be thrown if not included)
23 return new jQuery.fn.init( selector, context );
26 // Support: Android<4.1
27 // Make sure we trim BOM and NBSP
28 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
30 // Matches dashed string for camelizing
32 rdashAlpha = /-([\da-z])/gi,
34 // Used by jQuery.camelCase as callback to replace()
35 fcamelCase = function( all, letter ) {
36 return letter.toUpperCase();
39 jQuery.fn = jQuery.prototype = {
40 // The current version of jQuery being used
45 // Start with an empty selector
48 // The default length of a jQuery object is 0
52 return slice.call( this );
55 // Get the Nth element in the matched element set OR
56 // Get the whole matched element set as a clean array
57 get: function( num ) {
60 // Return just the one element from the set
61 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
63 // Return all the elements in a clean array
67 // Take an array of elements and push it onto the stack
68 // (returning the new matched element set)
69 pushStack: function( elems ) {
71 // Build a new jQuery matched element set
72 var ret = jQuery.merge( this.constructor(), elems );
74 // Add the old object onto the stack (as a reference)
75 ret.prevObject = this;
76 ret.context = this.context;
78 // Return the newly-formed element set
82 // Execute a callback for every element in the matched set.
83 // (You can seed the arguments with an array of args, but this is
84 // only used internally.)
85 each: function( callback, args ) {
86 return jQuery.each( this, callback, args );
89 map: function( callback ) {
90 return this.pushStack( jQuery.map(this, function( elem, i ) {
91 return callback.call( elem, i, elem );
96 return this.pushStack( slice.apply( this, arguments ) );
104 return this.eq( -1 );
108 var len = this.length,
109 j = +i + ( i < 0 ? len : 0 );
110 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
114 return this.prevObject || this.constructor(null);
117 // For internal use only.
118 // Behaves like an Array's method, not like a jQuery method.
124 jQuery.extend = jQuery.fn.extend = function() {
125 var options, name, src, copy, copyIsArray, clone,
126 target = arguments[0] || {},
128 length = arguments.length,
131 // Handle a deep copy situation
132 if ( typeof target === "boolean" ) {
135 // Skip the boolean and the target
136 target = arguments[ i ] || {};
140 // Handle case when target is a string or something (possible in deep copy)
141 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
145 // Extend jQuery itself if only one argument is passed
146 if ( i === length ) {
151 for ( ; i < length; i++ ) {
152 // Only deal with non-null/undefined values
153 if ( (options = arguments[ i ]) != null ) {
154 // Extend the base object
155 for ( name in options ) {
156 src = target[ name ];
157 copy = options[ name ];
159 // Prevent never-ending loop
160 if ( target === copy ) {
164 // Recurse if we're merging plain objects or arrays
165 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
168 clone = src && jQuery.isArray(src) ? src : [];
171 clone = src && jQuery.isPlainObject(src) ? src : {};
174 // Never move original objects, clone them
175 target[ name ] = jQuery.extend( deep, clone, copy );
177 // Don't bring in undefined values
178 } else if ( copy !== undefined ) {
179 target[ name ] = copy;
185 // Return the modified object
190 // Unique for each copy of jQuery on the page
191 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
193 // Assume jQuery is ready without the ready module
196 error: function( msg ) {
197 throw new Error( msg );
202 isFunction: function( obj ) {
203 return jQuery.type(obj) === "function";
206 isArray: Array.isArray,
208 isWindow: function( obj ) {
209 return obj != null && obj === obj.window;
212 isNumeric: function( obj ) {
213 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
214 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
215 // subtraction forces infinities to NaN
216 // adding 1 corrects loss of precision from parseFloat (#15100)
217 return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
220 isPlainObject: function( obj ) {
221 // Not plain objects:
222 // - Any object or value whose internal [[Class]] property is not "[object Object]"
225 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
229 if ( obj.constructor &&
230 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
234 // If the function hasn't returned already, we're confident that
235 // |obj| is a plain object, created by {} or constructed with new Object
239 isEmptyObject: function( obj ) {
241 for ( name in obj ) {
247 type: function( obj ) {
251 // Support: Android<4.0, iOS<6 (functionish RegExp)
252 return typeof obj === "object" || typeof obj === "function" ?
253 class2type[ toString.call(obj) ] || "object" :
257 // Evaluates a script in a global context
258 globalEval: function( code ) {
262 code = jQuery.trim( code );
265 // If the code includes a valid, prologue position
266 // strict mode pragma, execute code by injecting a
267 // script tag into the document.
268 if ( code.indexOf("use strict") === 1 ) {
269 script = document.createElement("script");
271 document.head.appendChild( script ).parentNode.removeChild( script );
273 // Otherwise, avoid the DOM node creation, insertion
274 // and removal by using an indirect global eval
280 // Convert dashed to camelCase; used by the css and data modules
282 // Microsoft forgot to hump their vendor prefix (#9572)
283 camelCase: function( string ) {
284 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
287 nodeName: function( elem, name ) {
288 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
291 // args is for internal usage only
292 each: function( obj, callback, args ) {
296 isArray = isArraylike( obj );
300 for ( ; i < length; i++ ) {
301 value = callback.apply( obj[ i ], args );
303 if ( value === false ) {
309 value = callback.apply( obj[ i ], args );
311 if ( value === false ) {
317 // A special, fast, case for the most common use of each
320 for ( ; i < length; i++ ) {
321 value = callback.call( obj[ i ], i, obj[ i ] );
323 if ( value === false ) {
329 value = callback.call( obj[ i ], i, obj[ i ] );
331 if ( value === false ) {
341 // Support: Android<4.1
342 trim: function( text ) {
343 return text == null ?
345 ( text + "" ).replace( rtrim, "" );
348 // results is for internal usage only
349 makeArray: function( arr, results ) {
350 var ret = results || [];
353 if ( isArraylike( Object(arr) ) ) {
355 typeof arr === "string" ?
359 push.call( ret, arr );
366 inArray: function( elem, arr, i ) {
367 return arr == null ? -1 : indexOf.call( arr, elem, i );
370 merge: function( first, second ) {
371 var len = +second.length,
375 for ( ; j < len; j++ ) {
376 first[ i++ ] = second[ j ];
384 grep: function( elems, callback, invert ) {
388 length = elems.length,
389 callbackExpect = !invert;
391 // Go through the array, only saving the items
392 // that pass the validator function
393 for ( ; i < length; i++ ) {
394 callbackInverse = !callback( elems[ i ], i );
395 if ( callbackInverse !== callbackExpect ) {
396 matches.push( elems[ i ] );
403 // arg is for internal usage only
404 map: function( elems, callback, arg ) {
407 length = elems.length,
408 isArray = isArraylike( elems ),
411 // Go through the array, translating each of the items to their new values
413 for ( ; i < length; i++ ) {
414 value = callback( elems[ i ], i, arg );
416 if ( value != null ) {
421 // Go through every key on the object,
424 value = callback( elems[ i ], i, arg );
426 if ( value != null ) {
432 // Flatten any nested arrays
433 return concat.apply( [], ret );
436 // A global GUID counter for objects
439 // Bind a function to a context, optionally partially applying any
441 proxy: function( fn, context ) {
442 var tmp, args, proxy;
444 if ( typeof context === "string" ) {
450 // Quick check to determine if target is callable, in the spec
451 // this throws a TypeError, but we will just return undefined.
452 if ( !jQuery.isFunction( fn ) ) {
457 args = slice.call( arguments, 2 );
459 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
462 // Set the guid of unique handler to the same of original handler, so it can be removed
463 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
470 // jQuery.support is not used in Core but other projects attach their
471 // properties to it so it needs to exist.
475 // Populate the class2type map
476 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
477 class2type[ "[object " + name + "]" ] = name.toLowerCase();
480 function isArraylike( obj ) {
482 // Support: iOS 8.2 (not reproducible in simulator)
483 // `in` check used to prevent JIT error (gh-2145)
484 // hasOwn isn't used here due to false negatives
485 // regarding Nodelist length in IE
486 var length = "length" in obj && obj.length,
487 type = jQuery.type( obj );
489 if ( type === "function" || jQuery.isWindow( obj ) ) {
493 if ( obj.nodeType === 1 && length ) {
497 return type === "array" || length === 0 ||
498 typeof length === "number" && length > 0 && ( length - 1 ) in obj;