2 // Defining this global in .eslintrc.json would create a danger of using the global
3 // unguarded in another place, it seems safer to define global only for this module
16 "./var/ObjectFunctionString",
22 ], function( arr, getProto, slice, flat, push, indexOf,
23 class2type, toString, hasOwn, fnToString, ObjectFunctionString,
24 support, isFunction, isWindow, DOMEval, toType ) {
31 // Define a local copy of jQuery
32 jQuery = function( selector, context ) {
34 // The jQuery object is actually just the init constructor 'enhanced'
35 // Need init if jQuery is called (just allow error to be thrown if not included)
36 return new jQuery.fn.init( selector, context );
39 jQuery.fn = jQuery.prototype = {
41 // The current version of jQuery being used
46 // The default length of a jQuery object is 0
50 return slice.call( this );
53 // Get the Nth element in the matched element set OR
54 // Get the whole matched element set as a clean array
55 get: function( num ) {
57 // Return all the elements in a clean array
59 return slice.call( this );
62 // Return just the one element from the set
63 return num < 0 ? this[ num + this.length ] : this[ num ];
66 // Take an array of elements and push it onto the stack
67 // (returning the new matched element set)
68 pushStack: function( elems ) {
70 // Build a new jQuery matched element set
71 var ret = jQuery.merge( this.constructor(), elems );
73 // Add the old object onto the stack (as a reference)
74 ret.prevObject = this;
76 // Return the newly-formed element set
80 // Execute a callback for every element in the matched set.
81 each: function( callback ) {
82 return jQuery.each( this, callback );
85 map: function( callback ) {
86 return this.pushStack( jQuery.map( this, function( elem, i ) {
87 return callback.call( elem, i, elem );
92 return this.pushStack( slice.apply( this, arguments ) );
100 return this.eq( -1 );
104 return this.pushStack( jQuery.grep( this, function( _elem, i ) {
105 return ( i + 1 ) % 2;
110 return this.pushStack( jQuery.grep( this, function( _elem, i ) {
116 var len = this.length,
117 j = +i + ( i < 0 ? len : 0 );
118 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
122 return this.prevObject || this.constructor();
125 // For internal use only.
126 // Behaves like an Array's method, not like a jQuery method.
132 jQuery.extend = jQuery.fn.extend = function() {
133 var options, name, src, copy, copyIsArray, clone,
134 target = arguments[ 0 ] || {},
136 length = arguments.length,
139 // Handle a deep copy situation
140 if ( typeof target === "boolean" ) {
143 // Skip the boolean and the target
144 target = arguments[ i ] || {};
148 // Handle case when target is a string or something (possible in deep copy)
149 if ( typeof target !== "object" && !isFunction( target ) ) {
153 // Extend jQuery itself if only one argument is passed
154 if ( i === length ) {
159 for ( ; i < length; i++ ) {
161 // Only deal with non-null/undefined values
162 if ( ( options = arguments[ i ] ) != null ) {
164 // Extend the base object
165 for ( name in options ) {
166 copy = options[ name ];
168 // Prevent Object.prototype pollution
169 // Prevent never-ending loop
170 if ( name === "__proto__" || target === copy ) {
174 // Recurse if we're merging plain objects or arrays
175 if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
176 ( copyIsArray = Array.isArray( copy ) ) ) ) {
177 src = target[ name ];
179 // Ensure proper type for the source value
180 if ( copyIsArray && !Array.isArray( src ) ) {
182 } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
189 // Never move original objects, clone them
190 target[ name ] = jQuery.extend( deep, clone, copy );
192 // Don't bring in undefined values
193 } else if ( copy !== undefined ) {
194 target[ name ] = copy;
200 // Return the modified object
206 // Unique for each copy of jQuery on the page
207 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
209 // Assume jQuery is ready without the ready module
212 error: function( msg ) {
213 throw new Error( msg );
218 isPlainObject: function( obj ) {
221 // Detect obvious negatives
222 // Use toString instead of jQuery.type to catch host objects
223 if ( !obj || toString.call( obj ) !== "[object Object]" ) {
227 proto = getProto( obj );
229 // Objects with no prototype (e.g., `Object.create( null )`) are plain
234 // Objects with prototype are plain iff they were constructed by a global Object function
235 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
236 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
239 isEmptyObject: function( obj ) {
242 for ( name in obj ) {
248 // Evaluates a script in a provided context; falls back to the global one
250 globalEval: function( code, options, doc ) {
251 DOMEval( code, { nonce: options && options.nonce }, doc );
254 each: function( obj, callback ) {
257 if ( isArrayLike( obj ) ) {
259 for ( ; i < length; i++ ) {
260 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
266 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
275 // results is for internal usage only
276 makeArray: function( arr, results ) {
277 var ret = results || [];
280 if ( isArrayLike( Object( arr ) ) ) {
282 typeof arr === "string" ?
286 push.call( ret, arr );
293 inArray: function( elem, arr, i ) {
294 return arr == null ? -1 : indexOf.call( arr, elem, i );
297 // Support: Android <=4.0 only, PhantomJS 1 only
298 // push.apply(_, arraylike) throws on ancient WebKit
299 merge: function( first, second ) {
300 var len = +second.length,
304 for ( ; j < len; j++ ) {
305 first[ i++ ] = second[ j ];
313 grep: function( elems, callback, invert ) {
317 length = elems.length,
318 callbackExpect = !invert;
320 // Go through the array, only saving the items
321 // that pass the validator function
322 for ( ; i < length; i++ ) {
323 callbackInverse = !callback( elems[ i ], i );
324 if ( callbackInverse !== callbackExpect ) {
325 matches.push( elems[ i ] );
332 // arg is for internal usage only
333 map: function( elems, callback, arg ) {
338 // Go through the array, translating each of the items to their new values
339 if ( isArrayLike( elems ) ) {
340 length = elems.length;
341 for ( ; i < length; i++ ) {
342 value = callback( elems[ i ], i, arg );
344 if ( value != null ) {
349 // Go through every key on the object,
352 value = callback( elems[ i ], i, arg );
354 if ( value != null ) {
360 // Flatten any nested arrays
364 // A global GUID counter for objects
367 // jQuery.support is not used in Core but other projects attach their
368 // properties to it so it needs to exist.
372 if ( typeof Symbol === "function" ) {
373 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
376 // Populate the class2type map
377 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
378 function( _i, name ) {
379 class2type[ "[object " + name + "]" ] = name.toLowerCase();
382 function isArrayLike( obj ) {
384 // Support: real iOS 8.2 only (not reproducible in simulator)
385 // `in` check used to prevent JIT error (gh-2145)
386 // hasOwn isn't used here due to false negatives
387 // regarding Nodelist length in IE
388 var length = !!obj && "length" in obj && obj.length,
389 type = toType( obj );
391 if ( isFunction( obj ) || isWindow( obj ) ) {
395 return type === "array" || length === 0 ||
396 typeof length === "number" && length > 0 && ( length - 1 ) in obj;