12 ], function( arr, document, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) {
17 // Define a local copy of jQuery
18 jQuery = function( selector, context ) {
19 // The jQuery object is actually just the init constructor 'enhanced'
20 // Need init if jQuery is called (just allow error to be thrown if not included)
21 return new jQuery.fn.init( selector, context );
24 // Support: Android<4.1
25 // Make sure we trim BOM and NBSP
26 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
28 // Matches dashed string for camelizing
30 rdashAlpha = /-([\da-z])/gi,
32 // Used by jQuery.camelCase as callback to replace()
33 fcamelCase = function( all, letter ) {
34 return letter.toUpperCase();
37 jQuery.fn = jQuery.prototype = {
38 // The current version of jQuery being used
43 // The default length of a jQuery object is 0
47 return slice.call( this );
50 // Get the Nth element in the matched element set OR
51 // Get the whole matched element set as a clean array
52 get: function( num ) {
55 // Return just the one element from the set
56 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
58 // Return all the elements in a clean array
62 // Take an array of elements and push it onto the stack
63 // (returning the new matched element set)
64 pushStack: function( elems ) {
66 // Build a new jQuery matched element set
67 var ret = jQuery.merge( this.constructor(), elems );
69 // Add the old object onto the stack (as a reference)
70 ret.prevObject = this;
72 // Return the newly-formed element set
76 // Execute a callback for every element in the matched set.
77 // (You can seed the arguments with an array of args, but this is
78 // only used internally.)
79 each: function( callback, args ) {
80 return jQuery.each( this, callback, args );
83 map: function( callback ) {
84 return this.pushStack( jQuery.map(this, function( elem, i ) {
85 return callback.call( elem, i, elem );
90 return this.pushStack( slice.apply( this, arguments ) );
102 var len = this.length,
103 j = +i + ( i < 0 ? len : 0 );
104 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
108 return this.prevObject || this.constructor(null);
111 // For internal use only.
112 // Behaves like an Array's method, not like a jQuery method.
118 jQuery.extend = jQuery.fn.extend = function() {
119 var options, name, src, copy, copyIsArray, clone,
120 target = arguments[0] || {},
122 length = arguments.length,
125 // Handle a deep copy situation
126 if ( typeof target === "boolean" ) {
129 // Skip the boolean and the target
130 target = arguments[ i ] || {};
134 // Handle case when target is a string or something (possible in deep copy)
135 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
139 // Extend jQuery itself if only one argument is passed
140 if ( i === length ) {
145 for ( ; i < length; i++ ) {
146 // Only deal with non-null/undefined values
147 if ( (options = arguments[ i ]) != null ) {
148 // Extend the base object
149 for ( name in options ) {
150 src = target[ name ];
151 copy = options[ name ];
153 // Prevent never-ending loop
154 if ( target === copy ) {
158 // Recurse if we're merging plain objects or arrays
159 if ( deep && copy && ( jQuery.isPlainObject(copy) ||
160 (copyIsArray = jQuery.isArray(copy)) ) ) {
164 clone = src && jQuery.isArray(src) ? src : [];
167 clone = src && jQuery.isPlainObject(src) ? src : {};
170 // Never move original objects, clone them
171 target[ name ] = jQuery.extend( deep, clone, copy );
173 // Don't bring in undefined values
174 } else if ( copy !== undefined ) {
175 target[ name ] = copy;
181 // Return the modified object
186 // Unique for each copy of jQuery on the page
187 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
189 // Assume jQuery is ready without the ready module
192 error: function( msg ) {
193 throw new Error( msg );
198 isFunction: function( obj ) {
199 return jQuery.type(obj) === "function";
202 isArray: Array.isArray,
204 isWindow: function( obj ) {
205 return obj != null && obj === obj.window;
208 isNumeric: function( obj ) {
209 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
210 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
211 // subtraction forces infinities to NaN
212 // adding 1 corrects loss of precision from parseFloat (#15100)
213 return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
216 isPlainObject: function( obj ) {
217 // Not plain objects:
218 // - Any object or value whose internal [[Class]] property is not "[object Object]"
221 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
225 if ( obj.constructor &&
226 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
230 // If the function hasn't returned already, we're confident that
231 // |obj| is a plain object, created by {} or constructed with new Object
235 isEmptyObject: function( obj ) {
237 for ( name in obj ) {
243 type: function( obj ) {
247 // Support: Android<4.0 (functionish RegExp)
248 return typeof obj === "object" || typeof obj === "function" ?
249 class2type[ toString.call(obj) ] || "object" :
253 // Evaluates a script in a global context
254 globalEval: function( code ) {
255 var script = document.createElement( "script" );
258 document.head.appendChild( script ).parentNode.removeChild( script );
261 // Convert dashed to camelCase; used by the css and data modules
263 // Microsoft forgot to hump their vendor prefix (#9572)
264 camelCase: function( string ) {
265 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
268 nodeName: function( elem, name ) {
269 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
272 // args is for internal usage only
273 each: function( obj, callback, args ) {
276 isArray = isArraylike( obj );
280 for ( ; i < length; i++ ) {
281 if ( callback.apply( obj[ i ], args ) === false ) {
287 if ( callback.apply( obj[ i ], args ) === false ) {
293 // A special, fast, case for the most common use of each
296 for ( ; i < length; i++ ) {
297 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
303 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
313 // Support: Android<4.1
314 trim: function( text ) {
315 return text == null ?
317 ( text + "" ).replace( rtrim, "" );
320 // results is for internal usage only
321 makeArray: function( arr, results ) {
322 var ret = results || [];
325 if ( isArraylike( Object(arr) ) ) {
327 typeof arr === "string" ?
331 push.call( ret, arr );
338 inArray: function( elem, arr, i ) {
339 return arr == null ? -1 : indexOf.call( arr, elem, i );
342 // Support: Android<4.1, PhantomJS<2
343 // push.apply(_, arraylike) throws on ancient WebKit
344 merge: function( first, second ) {
345 var len = +second.length,
349 for ( ; j < len; j++ ) {
350 first[ i++ ] = second[ j ];
358 grep: function( elems, callback, invert ) {
362 length = elems.length,
363 callbackExpect = !invert;
365 // Go through the array, only saving the items
366 // that pass the validator function
367 for ( ; i < length; i++ ) {
368 callbackInverse = !callback( elems[ i ], i );
369 if ( callbackInverse !== callbackExpect ) {
370 matches.push( elems[ i ] );
377 // arg is for internal usage only
378 map: function( elems, callback, arg ) {
381 length = elems.length,
382 isArray = isArraylike( elems ),
385 // Go through the array, translating each of the items to their new values
387 for ( ; i < length; i++ ) {
388 value = callback( elems[ i ], i, arg );
390 if ( value != null ) {
395 // Go through every key on the object,
398 value = callback( elems[ i ], i, arg );
400 if ( value != null ) {
406 // Flatten any nested arrays
407 return concat.apply( [], ret );
410 // A global GUID counter for objects
413 // Bind a function to a context, optionally partially applying any
415 proxy: function( fn, context ) {
416 var tmp, args, proxy;
418 if ( typeof context === "string" ) {
424 // Quick check to determine if target is callable, in the spec
425 // this throws a TypeError, but we will just return undefined.
426 if ( !jQuery.isFunction( fn ) ) {
431 args = slice.call( arguments, 2 );
433 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
436 // Set the guid of unique handler to the same of original handler, so it can be removed
437 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
444 // jQuery.support is not used in Core but other projects attach their
445 // properties to it so it needs to exist.
449 // Populate the class2type map
450 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),
452 class2type[ "[object " + name + "]" ] = name.toLowerCase();
455 function isArraylike( obj ) {
456 var length = obj.length,
457 type = jQuery.type( obj );
459 if ( type === "function" || jQuery.isWindow( obj ) ) {
463 if ( obj.nodeType === 1 && length ) {
467 return type === "array" || length === 0 ||
468 typeof length === "number" && length > 0 && ( length - 1 ) in obj;