Blame view

bower_components/jquery/src/core.js 11.3 KB
a1a3bc73   Luigi Serra   graphs updates
1
  define( [
74249687   Luigi Serra   Cross browser con...
2
  	"./var/arr",
a1a3bc73   Luigi Serra   graphs updates
3
  	"./var/document",
74249687   Luigi Serra   Cross browser con...
4
5
6
7
8
9
10
11
  	"./var/slice",
  	"./var/concat",
  	"./var/push",
  	"./var/indexOf",
  	"./var/class2type",
  	"./var/toString",
  	"./var/hasOwn",
  	"./var/support"
a1a3bc73   Luigi Serra   graphs updates
12
  ], function( arr, document, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) {
74249687   Luigi Serra   Cross browser con...
13
14
  
  var
74249687   Luigi Serra   Cross browser con...
15
16
17
18
  	version = "@VERSION",
  
  	// Define a local copy of jQuery
  	jQuery = function( selector, context ) {
a1a3bc73   Luigi Serra   graphs updates
19
  
74249687   Luigi Serra   Cross browser con...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  		// The jQuery object is actually just the init constructor 'enhanced'
  		// Need init if jQuery is called (just allow error to be thrown if not included)
  		return new jQuery.fn.init( selector, context );
  	},
  
  	// Support: Android<4.1
  	// Make sure we trim BOM and NBSP
  	rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  
  	// Matches dashed string for camelizing
  	rmsPrefix = /^-ms-/,
  	rdashAlpha = /-([\da-z])/gi,
  
  	// Used by jQuery.camelCase as callback to replace()
  	fcamelCase = function( all, letter ) {
  		return letter.toUpperCase();
  	};
  
  jQuery.fn = jQuery.prototype = {
a1a3bc73   Luigi Serra   graphs updates
39
  
74249687   Luigi Serra   Cross browser con...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  	// The current version of jQuery being used
  	jquery: version,
  
  	constructor: jQuery,
  
  	// Start with an empty selector
  	selector: "",
  
  	// The default length of a jQuery object is 0
  	length: 0,
  
  	toArray: function() {
  		return slice.call( this );
  	},
  
  	// Get the Nth element in the matched element set OR
  	// Get the whole matched element set as a clean array
  	get: function( num ) {
  		return num != null ?
  
  			// Return just the one element from the set
  			( num < 0 ? this[ num + this.length ] : this[ num ] ) :
  
  			// Return all the elements in a clean array
  			slice.call( this );
  	},
  
  	// Take an array of elements and push it onto the stack
  	// (returning the new matched element set)
  	pushStack: function( elems ) {
  
  		// Build a new jQuery matched element set
  		var ret = jQuery.merge( this.constructor(), elems );
  
  		// Add the old object onto the stack (as a reference)
  		ret.prevObject = this;
  		ret.context = this.context;
  
  		// Return the newly-formed element set
  		return ret;
  	},
  
  	// Execute a callback for every element in the matched set.
a1a3bc73   Luigi Serra   graphs updates
83
84
  	each: function( callback ) {
  		return jQuery.each( this, callback );
74249687   Luigi Serra   Cross browser con...
85
86
87
  	},
  
  	map: function( callback ) {
a1a3bc73   Luigi Serra   graphs updates
88
  		return this.pushStack( jQuery.map( this, function( elem, i ) {
74249687   Luigi Serra   Cross browser con...
89
  			return callback.call( elem, i, elem );
a1a3bc73   Luigi Serra   graphs updates
90
  		} ) );
74249687   Luigi Serra   Cross browser con...
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  	},
  
  	slice: function() {
  		return this.pushStack( slice.apply( this, arguments ) );
  	},
  
  	first: function() {
  		return this.eq( 0 );
  	},
  
  	last: function() {
  		return this.eq( -1 );
  	},
  
  	eq: function( i ) {
  		var len = this.length,
  			j = +i + ( i < 0 ? len : 0 );
a1a3bc73   Luigi Serra   graphs updates
108
  		return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
74249687   Luigi Serra   Cross browser con...
109
110
111
  	},
  
  	end: function() {
a1a3bc73   Luigi Serra   graphs updates
112
  		return this.prevObject || this.constructor();
74249687   Luigi Serra   Cross browser con...
113
114
115
116
117
118
119
120
121
122
123
  	},
  
  	// For internal use only.
  	// Behaves like an Array's method, not like a jQuery method.
  	push: push,
  	sort: arr.sort,
  	splice: arr.splice
  };
  
  jQuery.extend = jQuery.fn.extend = function() {
  	var options, name, src, copy, copyIsArray, clone,
a1a3bc73   Luigi Serra   graphs updates
124
  		target = arguments[ 0 ] || {},
74249687   Luigi Serra   Cross browser con...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
  		i = 1,
  		length = arguments.length,
  		deep = false;
  
  	// Handle a deep copy situation
  	if ( typeof target === "boolean" ) {
  		deep = target;
  
  		// Skip the boolean and the target
  		target = arguments[ i ] || {};
  		i++;
  	}
  
  	// Handle case when target is a string or something (possible in deep copy)
a1a3bc73   Luigi Serra   graphs updates
139
  	if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
74249687   Luigi Serra   Cross browser con...
140
141
142
143
144
145
146
147
148
149
  		target = {};
  	}
  
  	// Extend jQuery itself if only one argument is passed
  	if ( i === length ) {
  		target = this;
  		i--;
  	}
  
  	for ( ; i < length; i++ ) {
a1a3bc73   Luigi Serra   graphs updates
150
  
74249687   Luigi Serra   Cross browser con...
151
  		// Only deal with non-null/undefined values
a1a3bc73   Luigi Serra   graphs updates
152
153
  		if ( ( options = arguments[ i ] ) != null ) {
  
74249687   Luigi Serra   Cross browser con...
154
155
156
157
158
159
160
161
162
163
164
  			// Extend the base object
  			for ( name in options ) {
  				src = target[ name ];
  				copy = options[ name ];
  
  				// Prevent never-ending loop
  				if ( target === copy ) {
  					continue;
  				}
  
  				// Recurse if we're merging plain objects or arrays
a1a3bc73   Luigi Serra   graphs updates
165
166
167
  				if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  					( copyIsArray = jQuery.isArray( copy ) ) ) ) {
  
74249687   Luigi Serra   Cross browser con...
168
169
  					if ( copyIsArray ) {
  						copyIsArray = false;
a1a3bc73   Luigi Serra   graphs updates
170
  						clone = src && jQuery.isArray( src ) ? src : [];
74249687   Luigi Serra   Cross browser con...
171
172
  
  					} else {
a1a3bc73   Luigi Serra   graphs updates
173
  						clone = src && jQuery.isPlainObject( src ) ? src : {};
74249687   Luigi Serra   Cross browser con...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
  					}
  
  					// Never move original objects, clone them
  					target[ name ] = jQuery.extend( deep, clone, copy );
  
  				// Don't bring in undefined values
  				} else if ( copy !== undefined ) {
  					target[ name ] = copy;
  				}
  			}
  		}
  	}
  
  	// Return the modified object
  	return target;
  };
  
a1a3bc73   Luigi Serra   graphs updates
191
192
  jQuery.extend( {
  
74249687   Luigi Serra   Cross browser con...
193
194
195
196
197
198
199
200
201
202
203
204
205
  	// Unique for each copy of jQuery on the page
  	expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  
  	// Assume jQuery is ready without the ready module
  	isReady: true,
  
  	error: function( msg ) {
  		throw new Error( msg );
  	},
  
  	noop: function() {},
  
  	isFunction: function( obj ) {
a1a3bc73   Luigi Serra   graphs updates
206
  		return jQuery.type( obj ) === "function";
74249687   Luigi Serra   Cross browser con...
207
208
209
210
211
212
213
214
215
  	},
  
  	isArray: Array.isArray,
  
  	isWindow: function( obj ) {
  		return obj != null && obj === obj.window;
  	},
  
  	isNumeric: function( obj ) {
a1a3bc73   Luigi Serra   graphs updates
216
  
74249687   Luigi Serra   Cross browser con...
217
218
219
220
  		// parseFloat NaNs numeric-cast false positives (null|true|false|"")
  		// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  		// subtraction forces infinities to NaN
  		// adding 1 corrects loss of precision from parseFloat (#15100)
a1a3bc73   Luigi Serra   graphs updates
221
222
  		var realStringObj = obj && obj.toString();
  		return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
74249687   Luigi Serra   Cross browser con...
223
224
225
  	},
  
  	isPlainObject: function( obj ) {
a1a3bc73   Luigi Serra   graphs updates
226
  
74249687   Luigi Serra   Cross browser con...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
  		// Not plain objects:
  		// - Any object or value whose internal [[Class]] property is not "[object Object]"
  		// - DOM nodes
  		// - window
  		if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  			return false;
  		}
  
  		if ( obj.constructor &&
  				!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
  			return false;
  		}
  
  		// If the function hasn't returned already, we're confident that
  		// |obj| is a plain object, created by {} or constructed with new Object
  		return true;
  	},
  
  	isEmptyObject: function( obj ) {
  		var name;
  		for ( name in obj ) {
  			return false;
  		}
  		return true;
  	},
  
  	type: function( obj ) {
  		if ( obj == null ) {
  			return obj + "";
  		}
a1a3bc73   Luigi Serra   graphs updates
257
  
74249687   Luigi Serra   Cross browser con...
258
259
  		// Support: Android<4.0, iOS<6 (functionish RegExp)
  		return typeof obj === "object" || typeof obj === "function" ?
a1a3bc73   Luigi Serra   graphs updates
260
  			class2type[ toString.call( obj ) ] || "object" :
74249687   Luigi Serra   Cross browser con...
261
262
263
264
265
266
267
268
269
270
271
  			typeof obj;
  	},
  
  	// Evaluates a script in a global context
  	globalEval: function( code ) {
  		var script,
  			indirect = eval;
  
  		code = jQuery.trim( code );
  
  		if ( code ) {
a1a3bc73   Luigi Serra   graphs updates
272
  
74249687   Luigi Serra   Cross browser con...
273
274
275
  			// If the code includes a valid, prologue position
  			// strict mode pragma, execute code by injecting a
  			// script tag into the document.
a1a3bc73   Luigi Serra   graphs updates
276
277
  			if ( code.indexOf( "use strict" ) === 1 ) {
  				script = document.createElement( "script" );
74249687   Luigi Serra   Cross browser con...
278
279
280
  				script.text = code;
  				document.head.appendChild( script ).parentNode.removeChild( script );
  			} else {
a1a3bc73   Luigi Serra   graphs updates
281
282
283
284
  
  				// Otherwise, avoid the DOM node creation, insertion
  				// and removal by using an indirect global eval
  
74249687   Luigi Serra   Cross browser con...
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
  				indirect( code );
  			}
  		}
  	},
  
  	// Convert dashed to camelCase; used by the css and data modules
  	// Support: IE9-11+
  	// Microsoft forgot to hump their vendor prefix (#9572)
  	camelCase: function( string ) {
  		return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  	},
  
  	nodeName: function( elem, name ) {
  		return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  	},
  
a1a3bc73   Luigi Serra   graphs updates
301
302
  	each: function( obj, callback ) {
  		var length, i = 0;
74249687   Luigi Serra   Cross browser con...
303
  
a1a3bc73   Luigi Serra   graphs updates
304
305
306
307
308
  		if ( isArrayLike( obj ) ) {
  			length = obj.length;
  			for ( ; i < length; i++ ) {
  				if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  					break;
74249687   Luigi Serra   Cross browser con...
309
310
  				}
  			}
74249687   Luigi Serra   Cross browser con...
311
  		} else {
a1a3bc73   Luigi Serra   graphs updates
312
313
314
  			for ( i in obj ) {
  				if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  					break;
74249687   Luigi Serra   Cross browser con...
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
  				}
  			}
  		}
  
  		return obj;
  	},
  
  	// Support: Android<4.1
  	trim: function( text ) {
  		return text == null ?
  			"" :
  			( text + "" ).replace( rtrim, "" );
  	},
  
  	// results is for internal usage only
  	makeArray: function( arr, results ) {
  		var ret = results || [];
  
  		if ( arr != null ) {
a1a3bc73   Luigi Serra   graphs updates
334
  			if ( isArrayLike( Object( arr ) ) ) {
74249687   Luigi Serra   Cross browser con...
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
  				jQuery.merge( ret,
  					typeof arr === "string" ?
  					[ arr ] : arr
  				);
  			} else {
  				push.call( ret, arr );
  			}
  		}
  
  		return ret;
  	},
  
  	inArray: function( elem, arr, i ) {
  		return arr == null ? -1 : indexOf.call( arr, elem, i );
  	},
  
  	merge: function( first, second ) {
  		var len = +second.length,
  			j = 0,
  			i = first.length;
  
  		for ( ; j < len; j++ ) {
  			first[ i++ ] = second[ j ];
  		}
  
  		first.length = i;
  
  		return first;
  	},
  
  	grep: function( elems, callback, invert ) {
  		var callbackInverse,
  			matches = [],
  			i = 0,
  			length = elems.length,
  			callbackExpect = !invert;
  
  		// Go through the array, only saving the items
  		// that pass the validator function
  		for ( ; i < length; i++ ) {
  			callbackInverse = !callback( elems[ i ], i );
  			if ( callbackInverse !== callbackExpect ) {
  				matches.push( elems[ i ] );
  			}
  		}
  
  		return matches;
  	},
  
  	// arg is for internal usage only
  	map: function( elems, callback, arg ) {
a1a3bc73   Luigi Serra   graphs updates
386
  		var length, value,
74249687   Luigi Serra   Cross browser con...
387
  			i = 0,
74249687   Luigi Serra   Cross browser con...
388
389
390
  			ret = [];
  
  		// Go through the array, translating each of the items to their new values
a1a3bc73   Luigi Serra   graphs updates
391
392
  		if ( isArrayLike( elems ) ) {
  			length = elems.length;
74249687   Luigi Serra   Cross browser con...
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
  			for ( ; i < length; i++ ) {
  				value = callback( elems[ i ], i, arg );
  
  				if ( value != null ) {
  					ret.push( value );
  				}
  			}
  
  		// Go through every key on the object,
  		} else {
  			for ( i in elems ) {
  				value = callback( elems[ i ], i, arg );
  
  				if ( value != null ) {
  					ret.push( value );
  				}
  			}
  		}
  
  		// Flatten any nested arrays
  		return concat.apply( [], ret );
  	},
  
  	// A global GUID counter for objects
  	guid: 1,
  
  	// Bind a function to a context, optionally partially applying any
  	// arguments.
  	proxy: function( fn, context ) {
  		var tmp, args, proxy;
  
  		if ( typeof context === "string" ) {
  			tmp = fn[ context ];
  			context = fn;
  			fn = tmp;
  		}
  
  		// Quick check to determine if target is callable, in the spec
  		// this throws a TypeError, but we will just return undefined.
  		if ( !jQuery.isFunction( fn ) ) {
  			return undefined;
  		}
  
  		// Simulated bind
  		args = slice.call( arguments, 2 );
  		proxy = function() {
  			return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  		};
  
  		// Set the guid of unique handler to the same of original handler, so it can be removed
  		proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  
  		return proxy;
  	},
  
  	now: Date.now,
  
  	// jQuery.support is not used in Core but other projects attach their
  	// properties to it so it needs to exist.
  	support: support
a1a3bc73   Luigi Serra   graphs updates
453
454
455
456
457
458
459
460
461
462
463
  } );
  
  // JSHint would error on this code due to the Symbol not being defined in ES5.
  // Defining this global in .jshintrc would create a danger of using the global
  // unguarded in another place, it seems safer to just disable JSHint for these
  // three lines.
  /* jshint ignore: start */
  if ( typeof Symbol === "function" ) {
  	jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  }
  /* jshint ignore: end */
74249687   Luigi Serra   Cross browser con...
464
465
  
  // Populate the class2type map
a1a3bc73   Luigi Serra   graphs updates
466
467
  jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  function( i, name ) {
74249687   Luigi Serra   Cross browser con...
468
  	class2type[ "[object " + name + "]" ] = name.toLowerCase();
a1a3bc73   Luigi Serra   graphs updates
469
  } );
74249687   Luigi Serra   Cross browser con...
470
  
a1a3bc73   Luigi Serra   graphs updates
471
  function isArrayLike( obj ) {
74249687   Luigi Serra   Cross browser con...
472
473
474
475
476
  
  	// Support: iOS 8.2 (not reproducible in simulator)
  	// `in` check used to prevent JIT error (gh-2145)
  	// hasOwn isn't used here due to false negatives
  	// regarding Nodelist length in IE
a1a3bc73   Luigi Serra   graphs updates
477
  	var length = !!obj && "length" in obj && obj.length,
74249687   Luigi Serra   Cross browser con...
478
479
480
481
482
483
  		type = jQuery.type( obj );
  
  	if ( type === "function" || jQuery.isWindow( obj ) ) {
  		return false;
  	}
  
74249687   Luigi Serra   Cross browser con...
484
485
486
487
488
  	return type === "array" || length === 0 ||
  		typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  }
  
  return jQuery;
a1a3bc73   Luigi Serra   graphs updates
489
  } );