11 ], function( deletedIds, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) {
16 // Define a local copy of jQuery
17 jQuery = function( selector, context ) {
18 // The jQuery object is actually just the init constructor 'enhanced'
19 // Need init if jQuery is called (just allow error to be thrown if not included)
20 return new jQuery.fn.init( selector, context );
23 // Support: Android<4.1, IE<9
24 // Make sure we trim BOM and NBSP
25 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
27 // Matches dashed string for camelizing
29 rdashAlpha = /-([\da-z])/gi,
31 // Used by jQuery.camelCase as callback to replace()
32 fcamelCase = function( all, letter ) {
33 return letter.toUpperCase();
36 jQuery.fn = jQuery.prototype = {
37 // The current version of jQuery being used
42 // Start with an empty selector
45 // The default length of a jQuery object is 0
49 return slice.call( this );
52 // Get the Nth element in the matched element set OR
53 // Get the whole matched element set as a clean array
54 get: function( num ) {
57 // Return just the one element from the set
58 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
60 // Return all the elements in a clean array
64 // Take an array of elements and push it onto the stack
65 // (returning the new matched element set)
66 pushStack: function( elems ) {
68 // Build a new jQuery matched element set
69 var ret = jQuery.merge( this.constructor(), elems );
71 // Add the old object onto the stack (as a reference)
72 ret.prevObject = this;
73 ret.context = this.context;
75 // Return the newly-formed element set
79 // Execute a callback for every element in the matched set.
80 // (You can seed the arguments with an array of args, but this is
81 // only used internally.)
82 each: function( callback, args ) {
83 return jQuery.each( this, callback, args );
86 map: function( callback ) {
87 return this.pushStack( jQuery.map(this, function( elem, i ) {
88 return callback.call( elem, i, elem );
93 return this.pushStack( slice.apply( this, arguments ) );
101 return this.eq( -1 );
105 var len = this.length,
106 j = +i + ( i < 0 ? len : 0 );
107 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
111 return this.prevObject || this.constructor(null);
114 // For internal use only.
115 // Behaves like an Array's method, not like a jQuery method.
117 sort: deletedIds.sort,
118 splice: deletedIds.splice
121 jQuery.extend = jQuery.fn.extend = function() {
122 var src, copyIsArray, copy, name, options, clone,
123 target = arguments[0] || {},
125 length = arguments.length,
128 // Handle a deep copy situation
129 if ( typeof target === "boolean" ) {
132 // skip the boolean and the target
133 target = arguments[ i ] || {};
137 // Handle case when target is a string or something (possible in deep copy)
138 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
142 // extend jQuery itself if only one argument is passed
143 if ( i === length ) {
148 for ( ; i < length; i++ ) {
149 // Only deal with non-null/undefined values
150 if ( (options = arguments[ i ]) != null ) {
151 // Extend the base object
152 for ( name in options ) {
153 src = target[ name ];
154 copy = options[ name ];
156 // Prevent never-ending loop
157 if ( target === copy ) {
161 // Recurse if we're merging plain objects or arrays
162 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
165 clone = src && jQuery.isArray(src) ? src : [];
168 clone = src && jQuery.isPlainObject(src) ? src : {};
171 // Never move original objects, clone them
172 target[ name ] = jQuery.extend( deep, clone, copy );
174 // Don't bring in undefined values
175 } else if ( copy !== undefined ) {
176 target[ name ] = copy;
182 // Return the modified object
187 // Unique for each copy of jQuery on the page
188 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
190 // Assume jQuery is ready without the ready module
193 error: function( msg ) {
194 throw new Error( msg );
199 // See test/unit/core.js for details concerning isFunction.
200 // Since version 1.3, DOM methods and functions like alert
201 // aren't supported. They return false on IE (#2968).
202 isFunction: function( obj ) {
203 return jQuery.type(obj) === "function";
206 isArray: Array.isArray || function( obj ) {
207 return jQuery.type(obj) === "array";
210 isWindow: function( obj ) {
211 /* jshint eqeqeq: false */
212 return obj != null && obj == obj.window;
215 isNumeric: function( obj ) {
216 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
217 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
218 // subtraction forces infinities to NaN
219 return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
222 isEmptyObject: function( obj ) {
224 for ( name in obj ) {
230 isPlainObject: function( obj ) {
233 // Must be an Object.
234 // Because of IE, we also have to check the presence of the constructor property.
235 // Make sure that DOM nodes and window objects don't pass through, as well
236 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
241 // Not own constructor property must be Object
242 if ( obj.constructor &&
243 !hasOwn.call(obj, "constructor") &&
244 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
248 // IE8,9 Will throw exceptions on certain host objects #9897
253 // Handle iteration over inherited properties before own properties.
254 if ( support.ownLast ) {
256 return hasOwn.call( obj, key );
260 // Own properties are enumerated firstly, so to speed up,
261 // if last one is own, then all properties are own.
262 for ( key in obj ) {}
264 return key === undefined || hasOwn.call( obj, key );
267 type: function( obj ) {
271 return typeof obj === "object" || typeof obj === "function" ?
272 class2type[ toString.call(obj) ] || "object" :
276 // Evaluates a script in a global context
277 // Workarounds based on findings by Jim Driscoll
278 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
279 globalEval: function( data ) {
280 if ( data && jQuery.trim( data ) ) {
281 // We use execScript on Internet Explorer
282 // We use an anonymous function so that context is window
283 // rather than jQuery in Firefox
284 ( window.execScript || function( data ) {
285 window[ "eval" ].call( window, data );
290 // Convert dashed to camelCase; used by the css and data modules
291 // Microsoft forgot to hump their vendor prefix (#9572)
292 camelCase: function( string ) {
293 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
296 nodeName: function( elem, name ) {
297 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
300 // args is for internal usage only
301 each: function( obj, callback, args ) {
305 isArray = isArraylike( obj );
309 for ( ; i < length; i++ ) {
310 value = callback.apply( obj[ i ], args );
312 if ( value === false ) {
318 value = callback.apply( obj[ i ], args );
320 if ( value === false ) {
326 // A special, fast, case for the most common use of each
329 for ( ; i < length; i++ ) {
330 value = callback.call( obj[ i ], i, obj[ i ] );
332 if ( value === false ) {
338 value = callback.call( obj[ i ], i, obj[ i ] );
340 if ( value === false ) {
350 // Support: Android<4.1, IE<9
351 trim: function( text ) {
352 return text == null ?
354 ( text + "" ).replace( rtrim, "" );
357 // results is for internal usage only
358 makeArray: function( arr, results ) {
359 var ret = results || [];
362 if ( isArraylike( Object(arr) ) ) {
364 typeof arr === "string" ?
368 push.call( ret, arr );
375 inArray: function( elem, arr, i ) {
380 return indexOf.call( arr, elem, i );
384 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
386 for ( ; i < len; i++ ) {
387 // Skip accessing in sparse arrays
388 if ( i in arr && arr[ i ] === elem ) {
397 merge: function( first, second ) {
398 var len = +second.length,
403 first[ i++ ] = second[ j++ ];
407 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
409 while ( second[j] !== undefined ) {
410 first[ i++ ] = second[ j++ ];
419 grep: function( elems, callback, invert ) {
423 length = elems.length,
424 callbackExpect = !invert;
426 // Go through the array, only saving the items
427 // that pass the validator function
428 for ( ; i < length; i++ ) {
429 callbackInverse = !callback( elems[ i ], i );
430 if ( callbackInverse !== callbackExpect ) {
431 matches.push( elems[ i ] );
438 // arg is for internal usage only
439 map: function( elems, callback, arg ) {
442 length = elems.length,
443 isArray = isArraylike( elems ),
446 // Go through the array, translating each of the items to their new values
448 for ( ; i < length; i++ ) {
449 value = callback( elems[ i ], i, arg );
451 if ( value != null ) {
456 // Go through every key on the object,
459 value = callback( elems[ i ], i, arg );
461 if ( value != null ) {
467 // Flatten any nested arrays
468 return concat.apply( [], ret );
471 // A global GUID counter for objects
474 // Bind a function to a context, optionally partially applying any
476 proxy: function( fn, context ) {
477 var args, proxy, tmp;
479 if ( typeof context === "string" ) {
485 // Quick check to determine if target is callable, in the spec
486 // this throws a TypeError, but we will just return undefined.
487 if ( !jQuery.isFunction( fn ) ) {
492 args = slice.call( arguments, 2 );
494 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
497 // Set the guid of unique handler to the same of original handler, so it can be removed
498 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
504 return +( new Date() );
507 // jQuery.support is not used in Core but other projects attach their
508 // properties to it so it needs to exist.
512 // Populate the class2type map
513 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
514 class2type[ "[object " + name + "]" ] = name.toLowerCase();
517 function isArraylike( obj ) {
518 var length = obj.length,
519 type = jQuery.type( obj );
521 if ( type === "function" || jQuery.isWindow( obj ) ) {
525 if ( obj.nodeType === 1 && length ) {
529 return type === "array" || length === 0 ||
530 typeof length === "number" && length > 0 && ( length - 1 ) in obj;