commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / bower_components / jquery / src / core.js
1 define([
2 "./var/deletedIds",
3 "./var/slice",
4 "./var/concat",
5 "./var/push",
6 "./var/indexOf",
7 "./var/class2type",
8 "./var/toString",
9 "./var/hasOwn",
10 "./var/support"
11 ], function( deletedIds, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) {
12
13 var
14 version = "@VERSION",
15
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 );
21 },
22
23 // Support: Android<4.1, IE<9
24 // Make sure we trim BOM and NBSP
25 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
26
27 // Matches dashed string for camelizing
28 rmsPrefix = /^-ms-/,
29 rdashAlpha = /-([\da-z])/gi,
30
31 // Used by jQuery.camelCase as callback to replace()
32 fcamelCase = function( all, letter ) {
33 return letter.toUpperCase();
34 };
35
36 jQuery.fn = jQuery.prototype = {
37 // The current version of jQuery being used
38 jquery: version,
39
40 constructor: jQuery,
41
42 // Start with an empty selector
43 selector: "",
44
45 // The default length of a jQuery object is 0
46 length: 0,
47
48 toArray: function() {
49 return slice.call( this );
50 },
51
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 ) {
55 return num != null ?
56
57 // Return just the one element from the set
58 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
59
60 // Return all the elements in a clean array
61 slice.call( this );
62 },
63
64 // Take an array of elements and push it onto the stack
65 // (returning the new matched element set)
66 pushStack: function( elems ) {
67
68 // Build a new jQuery matched element set
69 var ret = jQuery.merge( this.constructor(), elems );
70
71 // Add the old object onto the stack (as a reference)
72 ret.prevObject = this;
73 ret.context = this.context;
74
75 // Return the newly-formed element set
76 return ret;
77 },
78
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 );
84 },
85
86 map: function( callback ) {
87 return this.pushStack( jQuery.map(this, function( elem, i ) {
88 return callback.call( elem, i, elem );
89 }));
90 },
91
92 slice: function() {
93 return this.pushStack( slice.apply( this, arguments ) );
94 },
95
96 first: function() {
97 return this.eq( 0 );
98 },
99
100 last: function() {
101 return this.eq( -1 );
102 },
103
104 eq: function( i ) {
105 var len = this.length,
106 j = +i + ( i < 0 ? len : 0 );
107 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
108 },
109
110 end: function() {
111 return this.prevObject || this.constructor(null);
112 },
113
114 // For internal use only.
115 // Behaves like an Array's method, not like a jQuery method.
116 push: push,
117 sort: deletedIds.sort,
118 splice: deletedIds.splice
119 };
120
121 jQuery.extend = jQuery.fn.extend = function() {
122 var src, copyIsArray, copy, name, options, clone,
123 target = arguments[0] || {},
124 i = 1,
125 length = arguments.length,
126 deep = false;
127
128 // Handle a deep copy situation
129 if ( typeof target === "boolean" ) {
130 deep = target;
131
132 // skip the boolean and the target
133 target = arguments[ i ] || {};
134 i++;
135 }
136
137 // Handle case when target is a string or something (possible in deep copy)
138 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
139 target = {};
140 }
141
142 // extend jQuery itself if only one argument is passed
143 if ( i === length ) {
144 target = this;
145 i--;
146 }
147
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 ];
155
156 // Prevent never-ending loop
157 if ( target === copy ) {
158 continue;
159 }
160
161 // Recurse if we're merging plain objects or arrays
162 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
163 if ( copyIsArray ) {
164 copyIsArray = false;
165 clone = src && jQuery.isArray(src) ? src : [];
166
167 } else {
168 clone = src && jQuery.isPlainObject(src) ? src : {};
169 }
170
171 // Never move original objects, clone them
172 target[ name ] = jQuery.extend( deep, clone, copy );
173
174 // Don't bring in undefined values
175 } else if ( copy !== undefined ) {
176 target[ name ] = copy;
177 }
178 }
179 }
180 }
181
182 // Return the modified object
183 return target;
184 };
185
186 jQuery.extend({
187 // Unique for each copy of jQuery on the page
188 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
189
190 // Assume jQuery is ready without the ready module
191 isReady: true,
192
193 error: function( msg ) {
194 throw new Error( msg );
195 },
196
197 noop: function() {},
198
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";
204 },
205
206 isArray: Array.isArray || function( obj ) {
207 return jQuery.type(obj) === "array";
208 },
209
210 isWindow: function( obj ) {
211 /* jshint eqeqeq: false */
212 return obj != null && obj == obj.window;
213 },
214
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 // adding 1 corrects loss of precision from parseFloat (#15100)
220 return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
221 },
222
223 isEmptyObject: function( obj ) {
224 var name;
225 for ( name in obj ) {
226 return false;
227 }
228 return true;
229 },
230
231 isPlainObject: function( obj ) {
232 var key;
233
234 // Must be an Object.
235 // Because of IE, we also have to check the presence of the constructor property.
236 // Make sure that DOM nodes and window objects don't pass through, as well
237 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
238 return false;
239 }
240
241 try {
242 // Not own constructor property must be Object
243 if ( obj.constructor &&
244 !hasOwn.call(obj, "constructor") &&
245 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
246 return false;
247 }
248 } catch ( e ) {
249 // IE8,9 Will throw exceptions on certain host objects #9897
250 return false;
251 }
252
253 // Support: IE<9
254 // Handle iteration over inherited properties before own properties.
255 if ( support.ownLast ) {
256 for ( key in obj ) {
257 return hasOwn.call( obj, key );
258 }
259 }
260
261 // Own properties are enumerated firstly, so to speed up,
262 // if last one is own, then all properties are own.
263 for ( key in obj ) {}
264
265 return key === undefined || hasOwn.call( obj, key );
266 },
267
268 type: function( obj ) {
269 if ( obj == null ) {
270 return obj + "";
271 }
272 return typeof obj === "object" || typeof obj === "function" ?
273 class2type[ toString.call(obj) ] || "object" :
274 typeof obj;
275 },
276
277 // Evaluates a script in a global context
278 // Workarounds based on findings by Jim Driscoll
279 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
280 globalEval: function( data ) {
281 if ( data && jQuery.trim( data ) ) {
282 // We use execScript on Internet Explorer
283 // We use an anonymous function so that context is window
284 // rather than jQuery in Firefox
285 ( window.execScript || function( data ) {
286 window[ "eval" ].call( window, data );
287 } )( data );
288 }
289 },
290
291 // Convert dashed to camelCase; used by the css and data modules
292 // Microsoft forgot to hump their vendor prefix (#9572)
293 camelCase: function( string ) {
294 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
295 },
296
297 nodeName: function( elem, name ) {
298 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
299 },
300
301 // args is for internal usage only
302 each: function( obj, callback, args ) {
303 var value,
304 i = 0,
305 length = obj.length,
306 isArray = isArraylike( obj );
307
308 if ( args ) {
309 if ( isArray ) {
310 for ( ; i < length; i++ ) {
311 value = callback.apply( obj[ i ], args );
312
313 if ( value === false ) {
314 break;
315 }
316 }
317 } else {
318 for ( i in obj ) {
319 value = callback.apply( obj[ i ], args );
320
321 if ( value === false ) {
322 break;
323 }
324 }
325 }
326
327 // A special, fast, case for the most common use of each
328 } else {
329 if ( isArray ) {
330 for ( ; i < length; i++ ) {
331 value = callback.call( obj[ i ], i, obj[ i ] );
332
333 if ( value === false ) {
334 break;
335 }
336 }
337 } else {
338 for ( i in obj ) {
339 value = callback.call( obj[ i ], i, obj[ i ] );
340
341 if ( value === false ) {
342 break;
343 }
344 }
345 }
346 }
347
348 return obj;
349 },
350
351 // Support: Android<4.1, IE<9
352 trim: function( text ) {
353 return text == null ?
354 "" :
355 ( text + "" ).replace( rtrim, "" );
356 },
357
358 // results is for internal usage only
359 makeArray: function( arr, results ) {
360 var ret = results || [];
361
362 if ( arr != null ) {
363 if ( isArraylike( Object(arr) ) ) {
364 jQuery.merge( ret,
365 typeof arr === "string" ?
366 [ arr ] : arr
367 );
368 } else {
369 push.call( ret, arr );
370 }
371 }
372
373 return ret;
374 },
375
376 inArray: function( elem, arr, i ) {
377 var len;
378
379 if ( arr ) {
380 if ( indexOf ) {
381 return indexOf.call( arr, elem, i );
382 }
383
384 len = arr.length;
385 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
386
387 for ( ; i < len; i++ ) {
388 // Skip accessing in sparse arrays
389 if ( i in arr && arr[ i ] === elem ) {
390 return i;
391 }
392 }
393 }
394
395 return -1;
396 },
397
398 merge: function( first, second ) {
399 var len = +second.length,
400 j = 0,
401 i = first.length;
402
403 while ( j < len ) {
404 first[ i++ ] = second[ j++ ];
405 }
406
407 // Support: IE<9
408 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
409 if ( len !== len ) {
410 while ( second[j] !== undefined ) {
411 first[ i++ ] = second[ j++ ];
412 }
413 }
414
415 first.length = i;
416
417 return first;
418 },
419
420 grep: function( elems, callback, invert ) {
421 var callbackInverse,
422 matches = [],
423 i = 0,
424 length = elems.length,
425 callbackExpect = !invert;
426
427 // Go through the array, only saving the items
428 // that pass the validator function
429 for ( ; i < length; i++ ) {
430 callbackInverse = !callback( elems[ i ], i );
431 if ( callbackInverse !== callbackExpect ) {
432 matches.push( elems[ i ] );
433 }
434 }
435
436 return matches;
437 },
438
439 // arg is for internal usage only
440 map: function( elems, callback, arg ) {
441 var value,
442 i = 0,
443 length = elems.length,
444 isArray = isArraylike( elems ),
445 ret = [];
446
447 // Go through the array, translating each of the items to their new values
448 if ( isArray ) {
449 for ( ; i < length; i++ ) {
450 value = callback( elems[ i ], i, arg );
451
452 if ( value != null ) {
453 ret.push( value );
454 }
455 }
456
457 // Go through every key on the object,
458 } else {
459 for ( i in elems ) {
460 value = callback( elems[ i ], i, arg );
461
462 if ( value != null ) {
463 ret.push( value );
464 }
465 }
466 }
467
468 // Flatten any nested arrays
469 return concat.apply( [], ret );
470 },
471
472 // A global GUID counter for objects
473 guid: 1,
474
475 // Bind a function to a context, optionally partially applying any
476 // arguments.
477 proxy: function( fn, context ) {
478 var args, proxy, tmp;
479
480 if ( typeof context === "string" ) {
481 tmp = fn[ context ];
482 context = fn;
483 fn = tmp;
484 }
485
486 // Quick check to determine if target is callable, in the spec
487 // this throws a TypeError, but we will just return undefined.
488 if ( !jQuery.isFunction( fn ) ) {
489 return undefined;
490 }
491
492 // Simulated bind
493 args = slice.call( arguments, 2 );
494 proxy = function() {
495 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
496 };
497
498 // Set the guid of unique handler to the same of original handler, so it can be removed
499 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
500
501 return proxy;
502 },
503
504 now: function() {
505 return +( new Date() );
506 },
507
508 // jQuery.support is not used in Core but other projects attach their
509 // properties to it so it needs to exist.
510 support: support
511 });
512
513 // Populate the class2type map
514 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
515 class2type[ "[object " + name + "]" ] = name.toLowerCase();
516 });
517
518 function isArraylike( obj ) {
519
520 // Support: iOS 8.2 (not reproducible in simulator)
521 // `in` check used to prevent JIT error (gh-2145)
522 // hasOwn isn't used here due to false negatives
523 // regarding Nodelist length in IE
524 var length = "length" in obj && obj.length,
525 type = jQuery.type( obj );
526
527 if ( type === "function" || jQuery.isWindow( obj ) ) {
528 return false;
529 }
530
531 if ( obj.nodeType === 1 && length ) {
532 return true;
533 }
534
535 return type === "array" || length === 0 ||
536 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
537 }
538
539 return jQuery;
540 });