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