2013-09-09 13:50:12 +00:00
|
|
|
define(function( require ) {
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2012-06-16 01:01:44 +00:00
|
|
|
var
|
2013-09-09 13:50:12 +00:00
|
|
|
arr = require( "./var/arr" ),
|
|
|
|
slice = require( "./var/slice" ),
|
|
|
|
concat = require( "./var/concat" ),
|
|
|
|
push = require( "./var/push" ),
|
|
|
|
indexOf = require( "./var/indexOf" ),
|
|
|
|
class2type = require( "./var/class2type" ),
|
|
|
|
toString = require( "./var/toString" ),
|
|
|
|
hasOwn = require( "./var/hasOwn" ),
|
|
|
|
trim = require( "./var/trim" ),
|
|
|
|
support = require( "./var/support" ),
|
|
|
|
|
2012-06-16 01:01:44 +00:00
|
|
|
// Use the correct document accordingly with window argument (sandbox)
|
2013-02-22 21:33:52 +00:00
|
|
|
document = window.document,
|
2012-06-16 01:01:44 +00:00
|
|
|
|
|
|
|
// Map over jQuery in case of overwrite
|
|
|
|
_jQuery = window.jQuery,
|
|
|
|
|
|
|
|
// Map over the $ in case of overwrite
|
|
|
|
_$ = window.$,
|
2010-03-23 16:12:16 +00:00
|
|
|
|
2013-08-15 18:15:49 +00:00
|
|
|
version = "@VERSION",
|
2012-06-04 16:48:18 +00:00
|
|
|
|
|
|
|
// Define a local copy of jQuery
|
|
|
|
jQuery = function( selector, context ) {
|
2009-05-20 21:12:08 +00:00
|
|
|
// The jQuery object is actually just the init constructor 'enhanced'
|
2013-09-10 00:13:01 +00:00
|
|
|
// Need init if jQuery is called (just allow error to be thrown if not included)
|
|
|
|
return new jQuery.fn.init( selector, context );
|
2009-05-20 21:12:08 +00:00
|
|
|
},
|
2009-03-31 17:35:20 +00:00
|
|
|
|
2011-05-25 19:10:49 +00:00
|
|
|
// Matches dashed string for camelizing
|
2011-08-17 21:30:31 +00:00
|
|
|
rmsPrefix = /^-ms-/,
|
2012-06-16 01:01:44 +00:00
|
|
|
rdashAlpha = /-([\da-z])/gi,
|
2011-05-25 19:10:49 +00:00
|
|
|
|
|
|
|
// Used by jQuery.camelCase as callback to replace()
|
|
|
|
fcamelCase = function( all, letter ) {
|
2012-11-26 08:20:43 +00:00
|
|
|
return letter.toUpperCase();
|
|
|
|
};
|
2009-03-31 17:35:20 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
jQuery.fn = jQuery.prototype = {
|
2012-11-26 08:20:43 +00:00
|
|
|
// The current version of jQuery being used
|
2013-08-15 18:15:49 +00:00
|
|
|
jquery: version,
|
2012-11-26 08:20:43 +00:00
|
|
|
|
2010-10-10 00:32:54 +00:00
|
|
|
constructor: jQuery,
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2008-12-19 04:37:10 +00:00
|
|
|
// Start with an empty selector
|
|
|
|
selector: "",
|
|
|
|
|
2009-07-17 01:47:26 +00:00
|
|
|
// The default length of a jQuery object is 0
|
|
|
|
length: 0,
|
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
toArray: function() {
|
2013-08-15 18:15:49 +00:00
|
|
|
return slice.call( this );
|
2009-07-23 13:22:55 +00:00
|
|
|
},
|
2009-07-16 07:31:32 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Get the Nth element in the matched element set OR
|
|
|
|
// Get the whole matched element set as a clean array
|
|
|
|
get: function( num ) {
|
2009-03-31 17:35:20 +00:00
|
|
|
return num == null ?
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Return a 'clean' array
|
2009-07-16 07:31:41 +00:00
|
|
|
this.toArray() :
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Return just the object
|
2010-11-19 11:28:13 +00:00
|
|
|
( num < 0 ? this[ this.length + num ] : this[ num ] );
|
2008-01-14 22:30:48 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Take an array of elements and push it onto the stack
|
|
|
|
// (returning the new matched element set)
|
2012-10-24 00:22:34 +00:00
|
|
|
pushStack: function( elems ) {
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2012-06-28 00:55:36 +00:00
|
|
|
// Build a new jQuery matched element set
|
|
|
|
var ret = jQuery.merge( this.constructor(), elems );
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Add the old object onto the stack (as a reference)
|
|
|
|
ret.prevObject = this;
|
2008-12-19 04:37:10 +00:00
|
|
|
ret.context = this.context;
|
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Return the newly-formed element set
|
|
|
|
return ret;
|
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Execute a callback for every element in the matched set.
|
|
|
|
// (You can seed the arguments with an array of args, but this is
|
|
|
|
// only used internally.)
|
|
|
|
each: function( callback, args ) {
|
|
|
|
return jQuery.each( this, callback, args );
|
|
|
|
},
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2012-10-19 21:08:50 +00:00
|
|
|
slice: function() {
|
2013-08-15 18:15:49 +00:00
|
|
|
return this.pushStack( slice.apply( this, arguments ) );
|
2009-12-10 17:25:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
first: function() {
|
|
|
|
return this.eq( 0 );
|
|
|
|
},
|
|
|
|
|
|
|
|
last: function() {
|
|
|
|
return this.eq( -1 );
|
|
|
|
},
|
|
|
|
|
2012-10-19 21:08:50 +00:00
|
|
|
eq: function( i ) {
|
|
|
|
var len = this.length,
|
|
|
|
j = +i + ( i < 0 ? len : 0 );
|
|
|
|
return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
|
2009-12-10 17:25:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
map: function( callback ) {
|
2009-12-22 00:58:13 +00:00
|
|
|
return this.pushStack( jQuery.map(this, function( elem, i ) {
|
2009-12-10 17:25:25 +00:00
|
|
|
return callback.call( elem, i, elem );
|
|
|
|
}));
|
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-10 17:25:25 +00:00
|
|
|
end: function() {
|
2010-10-10 00:32:54 +00:00
|
|
|
return this.prevObject || this.constructor(null);
|
2009-12-10 17:25:25 +00:00
|
|
|
},
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2009-03-17 20:39:29 +00:00
|
|
|
// For internal use only.
|
|
|
|
// Behaves like an Array's method, not like a jQuery method.
|
2013-08-15 18:15:49 +00:00
|
|
|
push: push,
|
|
|
|
sort: arr.sort,
|
|
|
|
splice: arr.splice
|
2008-01-14 22:30:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
jQuery.extend = jQuery.fn.extend = function() {
|
2011-02-15 21:03:23 +00:00
|
|
|
var options, name, src, copy, copyIsArray, clone,
|
2010-11-09 16:09:07 +00:00
|
|
|
target = arguments[0] || {},
|
|
|
|
i = 1,
|
|
|
|
length = arguments.length,
|
|
|
|
deep = false;
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Handle a deep copy situation
|
2008-11-17 16:32:05 +00:00
|
|
|
if ( typeof target === "boolean" ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
deep = target;
|
|
|
|
target = arguments[1] || {};
|
|
|
|
// skip the boolean and the target
|
|
|
|
i = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle case when target is a string or something (possible in deep copy)
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
target = {};
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// extend jQuery itself if only one argument is passed
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( length === i ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
target = this;
|
2008-04-30 00:09:55 +00:00
|
|
|
--i;
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
|
|
|
|
2009-03-31 17:35:20 +00:00
|
|
|
for ( ; i < length; i++ ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
// Only deal with non-null/undefined values
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( (options = arguments[ i ]) != null ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
// Extend the base object
|
2009-03-31 17:35:20 +00:00
|
|
|
for ( name in options ) {
|
|
|
|
src = target[ name ];
|
|
|
|
copy = options[ name ];
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Prevent never-ending loop
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( target === copy ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
continue;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2010-01-30 18:50:49 +00:00
|
|
|
// Recurse if we're merging plain objects or arrays
|
|
|
|
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
|
|
|
|
if ( copyIsArray ) {
|
|
|
|
copyIsArray = false;
|
|
|
|
clone = src && jQuery.isArray(src) ? src : [];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
clone = src && jQuery.isPlainObject(src) ? src : {};
|
|
|
|
}
|
2009-07-16 07:32:03 +00:00
|
|
|
|
|
|
|
// Never move original objects, clone them
|
|
|
|
target[ name ] = jQuery.extend( deep, clone, copy );
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Don't bring in undefined values
|
2009-03-31 17:35:20 +00:00
|
|
|
} else if ( copy !== undefined ) {
|
2008-04-30 00:09:55 +00:00
|
|
|
target[ name ] = copy;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Return the modified object
|
|
|
|
return target;
|
|
|
|
};
|
|
|
|
|
|
|
|
jQuery.extend({
|
2013-02-25 20:48:22 +00:00
|
|
|
// Unique for each copy of jQuery on the page
|
2013-08-15 18:15:49 +00:00
|
|
|
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
|
|
|
|
|
|
|
|
// Assume jQuery is ready without the ready module
|
|
|
|
isReady: true,
|
2013-02-25 20:48:22 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
noConflict: function( deep ) {
|
2010-11-22 04:12:12 +00:00
|
|
|
if ( window.$ === jQuery ) {
|
|
|
|
window.$ = _$;
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2010-10-19 05:29:20 +00:00
|
|
|
if ( deep && window.jQuery === jQuery ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
window.jQuery = _jQuery;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
return jQuery;
|
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2008-11-17 16:32:05 +00:00
|
|
|
// See test/unit/core.js for details concerning isFunction.
|
2008-10-18 22:22:08 +00:00
|
|
|
// Since version 1.3, DOM methods and functions like alert
|
2008-07-23 16:18:05 +00:00
|
|
|
// aren't supported. They return false on IE (#2968).
|
2008-11-17 16:32:05 +00:00
|
|
|
isFunction: function( obj ) {
|
2010-08-25 16:57:34 +00:00
|
|
|
return jQuery.type(obj) === "function";
|
2008-01-14 22:30:48 +00:00
|
|
|
},
|
2008-11-17 16:32:05 +00:00
|
|
|
|
2012-12-17 22:09:30 +00:00
|
|
|
isArray: Array.isArray,
|
2010-08-25 16:57:34 +00:00
|
|
|
|
2010-09-22 20:41:51 +00:00
|
|
|
isWindow: function( obj ) {
|
2013-03-13 23:23:36 +00:00
|
|
|
return obj != null && obj === obj.window;
|
2010-09-22 20:41:51 +00:00
|
|
|
},
|
|
|
|
|
2011-10-12 01:04:22 +00:00
|
|
|
isNumeric: function( obj ) {
|
2011-11-07 16:25:51 +00:00
|
|
|
return !isNaN( parseFloat(obj) ) && isFinite( obj );
|
2010-09-27 15:51:01 +00:00
|
|
|
},
|
|
|
|
|
2010-08-25 16:57:34 +00:00
|
|
|
type: function( obj ) {
|
2012-12-18 15:33:32 +00:00
|
|
|
if ( obj == null ) {
|
|
|
|
return String( obj );
|
|
|
|
}
|
2013-08-21 22:33:57 +00:00
|
|
|
// Support: Android < 4.0, iOS < 6 (functionish RegExp)
|
2013-01-29 18:03:45 +00:00
|
|
|
return typeof obj === "object" || typeof obj === "function" ?
|
2013-08-15 18:15:49 +00:00
|
|
|
class2type[ toString.call(obj) ] || "object" :
|
2012-12-18 15:33:32 +00:00
|
|
|
typeof obj;
|
2008-10-29 02:01:22 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2009-12-06 22:11:51 +00:00
|
|
|
isPlainObject: function( obj ) {
|
2012-12-24 15:54:11 +00:00
|
|
|
// Not plain objects:
|
|
|
|
// - Any object or value whose internal [[Class]] property is not "[object Object]"
|
|
|
|
// - DOM nodes
|
|
|
|
// - window
|
2012-12-17 22:30:38 +00:00
|
|
|
if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
2009-11-08 23:26:01 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2013-04-04 20:04:39 +00:00
|
|
|
// Support: Firefox <20
|
2013-02-21 17:00:51 +00:00
|
|
|
// The try/catch suppresses exceptions thrown when attempting to access
|
2012-12-24 15:54:11 +00:00
|
|
|
// the "constructor" property of certain host objects, ie. |window.location|
|
2013-04-04 20:04:39 +00:00
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=814622
|
2011-07-25 21:06:38 +00:00
|
|
|
try {
|
|
|
|
if ( obj.constructor &&
|
2013-08-15 18:15:49 +00:00
|
|
|
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
|
2011-07-25 21:06:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch ( e ) {
|
2009-11-12 04:50:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2013-03-06 20:11:20 +00:00
|
|
|
// 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;
|
2009-07-16 07:32:03 +00:00
|
|
|
},
|
|
|
|
|
2009-07-16 07:32:31 +00:00
|
|
|
isEmptyObject: function( obj ) {
|
2012-07-10 01:38:11 +00:00
|
|
|
var name;
|
|
|
|
for ( name in obj ) {
|
2009-07-16 15:16:44 +00:00
|
|
|
return false;
|
2009-07-19 19:55:21 +00:00
|
|
|
}
|
2009-07-16 15:16:44 +00:00
|
|
|
return true;
|
2009-07-16 07:32:31 +00:00
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-01-23 21:48:47 +00:00
|
|
|
error: function( msg ) {
|
2011-11-07 16:40:39 +00:00
|
|
|
throw new Error( msg );
|
2010-01-23 21:48:47 +00:00
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-31 14:50:49 +00:00
|
|
|
noop: function() {},
|
|
|
|
|
2011-04-07 04:47:15 +00:00
|
|
|
// Evaluates a script in a global context
|
2013-04-03 15:26:07 +00:00
|
|
|
globalEval: function( code ) {
|
|
|
|
var script,
|
2013-08-15 18:15:49 +00:00
|
|
|
indirect = eval;
|
2013-04-03 15:26:07 +00:00
|
|
|
|
2013-04-03 17:01:49 +00:00
|
|
|
code = jQuery.trim( code );
|
2013-04-03 15:26:07 +00:00
|
|
|
|
|
|
|
if ( code ) {
|
|
|
|
// If the code includes a valid, prologue position
|
|
|
|
// strict mode pragma, execute code by injecting a
|
|
|
|
// script tag into the document.
|
|
|
|
if ( code.indexOf("use strict") === 1 ) {
|
|
|
|
script = document.createElement("script");
|
|
|
|
script.text = code;
|
|
|
|
document.head.appendChild( script ).parentNode.removeChild( script );
|
|
|
|
} else {
|
|
|
|
// Otherwise, avoid the DOM node creation, insertion
|
|
|
|
// and removal by using an indirect global eval
|
|
|
|
indirect( code );
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-17 21:30:31 +00:00
|
|
|
// Convert dashed to camelCase; used by the css and data modules
|
|
|
|
// Microsoft forgot to hump their vendor prefix (#9572)
|
2011-05-25 19:10:49 +00:00
|
|
|
camelCase: function( string ) {
|
2011-08-17 21:30:31 +00:00
|
|
|
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
|
2011-05-25 19:10:49 +00:00
|
|
|
},
|
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
nodeName: function( elem, name ) {
|
2012-09-18 21:39:44 +00:00
|
|
|
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
|
2008-01-14 22:30:48 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// args is for internal usage only
|
2012-06-29 01:39:58 +00:00
|
|
|
each: function( obj, callback, args ) {
|
2012-12-10 18:52:02 +00:00
|
|
|
var value,
|
2012-07-10 01:38:11 +00:00
|
|
|
i = 0,
|
2012-06-29 01:39:58 +00:00
|
|
|
length = obj.length,
|
2012-12-10 18:52:02 +00:00
|
|
|
isArray = isArraylike( obj );
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
if ( args ) {
|
2012-12-10 18:52:02 +00:00
|
|
|
if ( isArray ) {
|
|
|
|
for ( ; i < length; i++ ) {
|
|
|
|
value = callback.apply( obj[ i ], args );
|
|
|
|
|
|
|
|
if ( value === false ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
break;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2012-12-10 18:52:02 +00:00
|
|
|
for ( i in obj ) {
|
|
|
|
value = callback.apply( obj[ i ], args );
|
|
|
|
|
|
|
|
if ( value === false ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
break;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// A special, fast, case for the most common use of each
|
|
|
|
} else {
|
2012-12-10 18:52:02 +00:00
|
|
|
if ( isArray ) {
|
|
|
|
for ( ; i < length; i++ ) {
|
|
|
|
value = callback.call( obj[ i ], i, obj[ i ] );
|
|
|
|
|
|
|
|
if ( value === false ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
break;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2012-12-10 18:52:02 +00:00
|
|
|
for ( i in obj ) {
|
|
|
|
value = callback.call( obj[ i ], i, obj[ i ] );
|
|
|
|
|
|
|
|
if ( value === false ) {
|
2011-03-30 17:17:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 01:39:58 +00:00
|
|
|
return obj;
|
2008-01-14 22:30:48 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2012-12-17 21:56:36 +00:00
|
|
|
trim: function( text ) {
|
2013-08-15 18:15:49 +00:00
|
|
|
return text == null ? "" : trim.call( text );
|
2012-12-17 21:56:36 +00:00
|
|
|
},
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2009-11-18 02:26:42 +00:00
|
|
|
// results is for internal usage only
|
2012-06-29 01:39:58 +00:00
|
|
|
makeArray: function( arr, results ) {
|
2012-12-10 18:52:02 +00:00
|
|
|
var ret = results || [];
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2012-06-29 01:39:58 +00:00
|
|
|
if ( arr != null ) {
|
2012-12-10 18:52:02 +00:00
|
|
|
if ( isArraylike( Object(arr) ) ) {
|
|
|
|
jQuery.merge( ret,
|
|
|
|
typeof arr === "string" ?
|
|
|
|
[ arr ] : arr
|
|
|
|
);
|
2009-03-31 17:35:20 +00:00
|
|
|
} else {
|
2013-08-15 18:15:49 +00:00
|
|
|
push.call( ret, arr );
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-04-25 03:48:07 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
2012-06-29 01:39:58 +00:00
|
|
|
inArray: function( elem, arr, i ) {
|
2013-08-15 18:15:49 +00:00
|
|
|
return arr == null ? -1 : indexOf.call( arr, elem, i );
|
2008-01-14 22:30:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
merge: function( first, second ) {
|
2013-09-03 05:24:01 +00:00
|
|
|
var len = +second.length,
|
|
|
|
j = 0,
|
|
|
|
i = first.length;
|
2009-05-02 19:22:55 +00:00
|
|
|
|
2013-09-03 05:24:01 +00:00
|
|
|
for ( ; j < len; j++ ) {
|
|
|
|
first[ i++ ] = second[ j ];
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2009-12-10 05:43:20 +00:00
|
|
|
first.length = i;
|
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
return first;
|
|
|
|
},
|
|
|
|
|
|
|
|
grep: function( elems, callback, inv ) {
|
2012-07-10 01:38:11 +00:00
|
|
|
var retVal,
|
|
|
|
ret = [],
|
|
|
|
i = 0,
|
|
|
|
length = elems.length;
|
2010-03-02 02:24:49 +00:00
|
|
|
inv = !!inv;
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Go through the array, only saving the items
|
|
|
|
// that pass the validator function
|
2012-07-10 01:38:11 +00:00
|
|
|
for ( ; i < length; i++ ) {
|
2010-03-02 02:24:49 +00:00
|
|
|
retVal = !!callback( elems[ i ], i );
|
|
|
|
if ( inv !== retVal ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
ret.push( elems[ i ] );
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
2009-12-04 17:28:47 +00:00
|
|
|
// arg is for internal usage only
|
|
|
|
map: function( elems, callback, arg ) {
|
2012-12-10 18:52:02 +00:00
|
|
|
var value,
|
2011-04-05 06:59:54 +00:00
|
|
|
i = 0,
|
2011-03-21 19:24:53 +00:00
|
|
|
length = elems.length,
|
2012-12-10 18:52:02 +00:00
|
|
|
isArray = isArraylike( elems ),
|
|
|
|
ret = [];
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Go through the array, translating each of the items to their
|
2011-03-21 19:12:31 +00:00
|
|
|
if ( isArray ) {
|
|
|
|
for ( ; i < length; i++ ) {
|
|
|
|
value = callback( elems[ i ], i, arg );
|
|
|
|
|
2011-02-27 18:47:35 +00:00
|
|
|
if ( value != null ) {
|
|
|
|
ret[ ret.length ] = value;
|
|
|
|
}
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2011-04-22 01:51:23 +00:00
|
|
|
// Go through every key on the object,
|
2011-04-05 06:59:54 +00:00
|
|
|
} else {
|
2012-12-10 18:52:02 +00:00
|
|
|
for ( i in elems ) {
|
|
|
|
value = callback( elems[ i ], i, arg );
|
2011-03-21 19:12:31 +00:00
|
|
|
|
|
|
|
if ( value != null ) {
|
|
|
|
ret[ ret.length ] = value;
|
|
|
|
}
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-27 22:15:33 +00:00
|
|
|
// Flatten any nested arrays
|
2013-08-15 18:15:49 +00:00
|
|
|
return concat.apply( [], ret );
|
2009-03-31 17:35:20 +00:00
|
|
|
},
|
|
|
|
|
2009-12-31 20:06:45 +00:00
|
|
|
// A global GUID counter for objects
|
|
|
|
guid: 1,
|
|
|
|
|
2010-12-15 02:53:04 +00:00
|
|
|
// Bind a function to a context, optionally partially applying any
|
|
|
|
// arguments.
|
|
|
|
proxy: function( fn, context ) {
|
2012-07-10 01:38:11 +00:00
|
|
|
var tmp, args, proxy;
|
|
|
|
|
2011-01-21 15:33:50 +00:00
|
|
|
if ( typeof context === "string" ) {
|
2012-07-10 01:38:11 +00:00
|
|
|
tmp = fn[ context ];
|
2011-04-17 21:11:40 +00:00
|
|
|
context = fn;
|
|
|
|
fn = tmp;
|
2009-12-31 20:06:45 +00:00
|
|
|
}
|
|
|
|
|
2010-12-15 02:53:04 +00:00
|
|
|
// Quick check to determine if target is callable, in the spec
|
|
|
|
// this throws a TypeError, but we will just return undefined.
|
2011-04-17 21:11:40 +00:00
|
|
|
if ( !jQuery.isFunction( fn ) ) {
|
2010-12-15 02:53:04 +00:00
|
|
|
return undefined;
|
2009-12-31 20:17:52 +00:00
|
|
|
}
|
2009-12-31 20:06:45 +00:00
|
|
|
|
2011-04-17 21:11:40 +00:00
|
|
|
// Simulated bind
|
2013-08-15 18:15:49 +00:00
|
|
|
args = slice.call( arguments, 2 );
|
2012-07-10 01:38:11 +00:00
|
|
|
proxy = function() {
|
2013-08-15 18:15:49 +00:00
|
|
|
return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
|
2012-07-10 01:38:11 +00:00
|
|
|
};
|
2009-12-31 20:06:45 +00:00
|
|
|
|
|
|
|
// Set the guid of unique handler to the same of original handler, so it can be removed
|
2012-09-18 21:39:44 +00:00
|
|
|
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
|
2009-12-31 20:06:45 +00:00
|
|
|
|
|
|
|
return proxy;
|
|
|
|
},
|
|
|
|
|
2013-08-26 22:54:13 +00:00
|
|
|
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
|
2008-01-14 22:30:48 +00:00
|
|
|
});
|
|
|
|
|
2010-08-27 23:14:59 +00:00
|
|
|
// Populate the class2type map
|
2012-11-24 22:22:14 +00:00
|
|
|
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
|
2010-08-27 23:14:59 +00:00
|
|
|
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
|
|
|
});
|
|
|
|
|
2012-12-10 18:52:02 +00:00
|
|
|
function isArraylike( obj ) {
|
|
|
|
var length = obj.length,
|
|
|
|
type = jQuery.type( obj );
|
|
|
|
|
|
|
|
if ( jQuery.isWindow( obj ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-12-11 01:19:26 +00:00
|
|
|
if ( obj.nodeType === 1 && length ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-10 18:52:02 +00:00
|
|
|
return type === "array" || type !== "function" &&
|
|
|
|
( length === 0 ||
|
|
|
|
typeof length === "number" && length > 0 && ( length - 1 ) in obj );
|
|
|
|
}
|
|
|
|
|
2013-08-15 18:15:49 +00:00
|
|
|
return jQuery;
|
|
|
|
});
|