aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2013-08-15 14:15:49 -0400
committerTimmy Willison <timmywillisn@gmail.com>2013-08-15 14:15:49 -0400
commit6318ae6ab90d4b450dfadf32ab95fe52ed6331cb (patch)
tree50b247fed8569e909e380b281e9145bd1458a39e /src
parent7627b8b6d9ef6e57dbd20a55b946bd1991c1223e (diff)
downloadjquery-6318ae6ab90d4b450dfadf32ab95fe52ed6331cb.tar.gz
jquery-6318ae6ab90d4b450dfadf32ab95fe52ed6331cb.zip
AMD-ify jQuery sourcegit s! Woo! Fixes #14113, #14163.
Diffstat (limited to 'src')
-rw-r--r--src/ajax.js84
-rw-r--r--src/ajax/jsonp.js13
-rw-r--r--src/ajax/load.js71
-rw-r--r--src/ajax/script.js7
-rw-r--r--src/ajax/var/nonce.js5
-rw-r--r--src/ajax/var/rquery.js3
-rw-r--r--src/ajax/xhr.js7
-rw-r--r--src/attributes.js508
-rw-r--r--src/attributes/attr.js143
-rw-r--r--src/attributes/classes.js148
-rw-r--r--src/attributes/prop.js94
-rw-r--r--src/attributes/val.js157
-rw-r--r--src/callbacks.js9
-rw-r--r--src/core.js198
-rw-r--r--src/core/ready.js92
-rw-r--r--src/core/swap.js29
-rw-r--r--src/css.js85
-rw-r--r--src/css/defaultDisplay.js58
-rw-r--r--src/css/hidden-visible-selectors.js15
-rw-r--r--src/css/var/cssExpand.js3
-rw-r--r--src/css/var/isHidden.js13
-rw-r--r--src/data.js202
-rw-r--r--src/data/Data.js181
-rw-r--r--src/data/accepts.js20
-rw-r--r--src/data/var/data_priv.js5
-rw-r--r--src/data/var/data_user.js5
-rw-r--r--src/deferred.js11
-rw-r--r--src/deprecated.js10
-rw-r--r--src/dimensions.js5
-rw-r--r--src/effects.js129
-rw-r--r--src/effects/Tween.js114
-rw-r--r--src/effects/animated-selector.js11
-rw-r--r--src/event.js26
-rw-r--r--src/event/alias.js (renamed from src/event-alias.js)7
-rw-r--r--src/exports/amd.js12
-rw-r--r--src/intro.js16
-rw-r--r--src/jquery.js38
-rw-r--r--src/manipulation.js51
-rw-r--r--src/manipulation/_evalUrl.js16
-rw-r--r--src/manipulation/var/rcheckableType.js3
-rw-r--r--src/offset.js21
-rw-r--r--src/outro.js7
-rw-r--r--src/queue.js22
-rw-r--r--src/queue/delay.js22
-rw-r--r--src/selector-native.js9
-rw-r--r--src/selector-sizzle.js (renamed from src/sizzle-jquery.js)7
-rw-r--r--src/selector.js1
-rw-r--r--src/serialize.js14
-rw-r--r--src/support.js6
-rw-r--r--src/traversing.js12
-rw-r--r--src/var/arr.js3
-rw-r--r--src/var/class2type.js3
-rw-r--r--src/var/concat.js5
-rw-r--r--src/var/hasOwn.js5
-rw-r--r--src/var/indexOf.js5
-rw-r--r--src/var/pnum.js3
-rw-r--r--src/var/push.js5
-rw-r--r--src/var/rnotwhite.js3
-rw-r--r--src/var/slice.js5
-rw-r--r--src/var/strundefined.js3
-rw-r--r--src/var/toString.js5
-rw-r--r--src/var/trim.js3
-rw-r--r--src/wrap.js5
63 files changed, 1598 insertions, 1180 deletions
diff --git a/src/ajax.js b/src/ajax.js
index 8facc17fe..3fd882a2f 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -1,11 +1,16 @@
+define([
+ "./core",
+ "./var/rnotwhite",
+ "./ajax/var/nonce",
+ "./ajax/var/rquery",
+ "./deferred"
+], function( jQuery, rnotwhite, nonce, rquery ) {
+
var
// Document location
ajaxLocParts,
ajaxLocation,
- ajax_nonce = jQuery.now(),
-
- ajax_rquery = /\?/,
rhash = /#.*$/,
rts = /([?&])_=[^&]*/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
@@ -15,9 +20,6 @@ var
rprotocol = /^\/\//,
rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
- // Keep a copy of the old load method
- _load = jQuery.fn.load,
-
/* Prefilters
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
* 2) These are called:
@@ -67,7 +69,7 @@ function addToPrefiltersOrTransports( structure ) {
var dataType,
i = 0,
- dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || [];
+ dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
if ( jQuery.isFunction( func ) ) {
// For each dataType in the dataTypeExpression
@@ -130,63 +132,6 @@ function ajaxExtend( target, src ) {
return target;
}
-jQuery.fn.load = function( url, params, callback ) {
- if ( typeof url !== "string" && _load ) {
- return _load.apply( this, arguments );
- }
-
- var selector, type, response,
- self = this,
- off = url.indexOf(" ");
-
- if ( off >= 0 ) {
- selector = url.slice( off );
- url = url.slice( 0, off );
- }
-
- // If it's a function
- if ( jQuery.isFunction( params ) ) {
-
- // We assume that it's the callback
- callback = params;
- params = undefined;
-
- // Otherwise, build a param string
- } else if ( params && typeof params === "object" ) {
- type = "POST";
- }
-
- // If we have elements to modify, make the request
- if ( self.length > 0 ) {
- jQuery.ajax({
- url: url,
-
- // if "type" variable is undefined, then "GET" method will be used
- type: type,
- dataType: "html",
- data: params
- }).done(function( responseText ) {
-
- // Save response for use in complete callback
- response = arguments;
-
- self.html( selector ?
-
- // If a selector was specified, locate the right elements in a dummy div
- // Exclude scripts to avoid IE 'Permission Denied' errors
- jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
-
- // Otherwise use the full result
- responseText );
-
- }).complete( callback && function( jqXHR, status ) {
- self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
- });
- }
-
- return this;
-};
-
// Attach a bunch of functions for handling common AJAX events
jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
jQuery.fn[ type ] = function( fn ){
@@ -418,7 +363,7 @@ jQuery.extend({
s.type = options.method || options.type || s.method || s.type;
// Extract dataTypes list
- s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
+ s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [""];
// A cross-domain request is in order when we have a protocol:host:port mismatch
if ( s.crossDomain == null ) {
@@ -466,7 +411,7 @@ jQuery.extend({
// If data is available, append data to url
if ( s.data ) {
- cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
+ cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
// #9682: remove data so that it's not used in an eventual retry
delete s.data;
}
@@ -476,10 +421,10 @@ jQuery.extend({
s.url = rts.test( cacheURL ) ?
// If there is already a '_' parameter, set its value
- cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
+ cacheURL.replace( rts, "$1_=" + nonce++ ) :
// Otherwise add one to the end
- cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
+ cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
}
}
@@ -853,3 +798,6 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
return { state: "success", data: response };
}
+
+return jQuery;
+});
diff --git a/src/ajax/jsonp.js b/src/ajax/jsonp.js
index b8803df44..ff0d53899 100644
--- a/src/ajax/jsonp.js
+++ b/src/ajax/jsonp.js
@@ -1,3 +1,10 @@
+define([
+ "../core",
+ "./var/nonce",
+ "./var/rquery",
+ "../ajax"
+], function( jQuery, nonce, rquery ) {
+
var oldCallbacks = [],
rjsonp = /(=)\?(?=&|$)|\?\?/;
@@ -5,7 +12,7 @@ var oldCallbacks = [],
jQuery.ajaxSetup({
jsonp: "callback",
jsonpCallback: function() {
- var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
this[ callback ] = true;
return callback;
}
@@ -32,7 +39,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
if ( jsonProp ) {
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
} else if ( s.jsonp !== false ) {
- s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+ s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
}
// Use data converter to retrieve json after script execution
@@ -78,3 +85,5 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
return "script";
}
});
+
+});
diff --git a/src/ajax/load.js b/src/ajax/load.js
new file mode 100644
index 000000000..e9c21ef16
--- /dev/null
+++ b/src/ajax/load.js
@@ -0,0 +1,71 @@
+define([
+ "../core",
+ "../ajax",
+ "../traversing",
+ "../selector"
+], function( jQuery ) {
+
+// Keep a copy of the old load method
+var _load = jQuery.fn.load;
+
+/**
+ * Load a url into a page
+ */
+jQuery.fn.load = function( url, params, callback ) {
+ if ( typeof url !== "string" && _load ) {
+ return _load.apply( this, arguments );
+ }
+
+ var selector, type, response,
+ self = this,
+ off = url.indexOf(" ");
+
+ if ( off >= 0 ) {
+ selector = url.slice( off );
+ url = url.slice( 0, off );
+ }
+
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+
+ // We assume that it's the callback
+ callback = params;
+ params = undefined;
+
+ // Otherwise, build a param string
+ } else if ( params && typeof params === "object" ) {
+ type = "POST";
+ }
+
+ // If we have elements to modify, make the request
+ if ( self.length > 0 ) {
+ jQuery.ajax({
+ url: url,
+
+ // if "type" variable is undefined, then "GET" method will be used
+ type: type,
+ dataType: "html",
+ data: params
+ }).done(function( responseText ) {
+
+ // Save response for use in complete callback
+ response = arguments;
+
+ self.html( selector ?
+
+ // If a selector was specified, locate the right elements in a dummy div
+ // Exclude scripts to avoid IE 'Permission Denied' errors
+ jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
+
+ // Otherwise use the full result
+ responseText );
+
+ }).complete( callback && function( jqXHR, status ) {
+ self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
+ });
+ }
+
+ return this;
+};
+
+}); \ No newline at end of file
diff --git a/src/ajax/script.js b/src/ajax/script.js
index fe0562a84..f44329d4e 100644
--- a/src/ajax/script.js
+++ b/src/ajax/script.js
@@ -1,3 +1,8 @@
+define([
+ "../core",
+ "../ajax"
+], function( jQuery ) {
+
// Install script dataType
jQuery.ajaxSetup({
accepts: {
@@ -55,3 +60,5 @@ jQuery.ajaxTransport( "script", function( s ) {
};
}
});
+
+});
diff --git a/src/ajax/var/nonce.js b/src/ajax/var/nonce.js
new file mode 100644
index 000000000..0871aae88
--- /dev/null
+++ b/src/ajax/var/nonce.js
@@ -0,0 +1,5 @@
+define([
+ "../../core"
+], function( jQuery ) {
+ return jQuery.now();
+});
diff --git a/src/ajax/var/rquery.js b/src/ajax/var/rquery.js
new file mode 100644
index 000000000..eb26d4eb8
--- /dev/null
+++ b/src/ajax/var/rquery.js
@@ -0,0 +1,3 @@
+define(function() {
+ return /\?/;
+}); \ No newline at end of file
diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js
index 3a9c9e968..6feb94d57 100644
--- a/src/ajax/xhr.js
+++ b/src/ajax/xhr.js
@@ -1,3 +1,8 @@
+define([
+ "../core",
+ "../ajax"
+], function( jQuery ) {
+
jQuery.ajaxSettings.xhr = function() {
try {
return new XMLHttpRequest();
@@ -109,3 +114,5 @@ jQuery.ajaxTransport(function( options ) {
};
}
});
+
+});
diff --git a/src/attributes.js b/src/attributes.js
index 4da2db6c6..82a806630 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -1,502 +1,6 @@
-var nodeHook, boolHook,
- rclass = /[\t\r\n\f]/g,
- rreturn = /\r/g,
- rfocusable = /^(?:input|select|textarea|button)$/i;
-
-jQuery.fn.extend({
- attr: function( name, value ) {
- return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
- },
-
- removeAttr: function( name ) {
- return this.each(function() {
- jQuery.removeAttr( this, name );
- });
- },
-
- prop: function( name, value ) {
- return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
- },
-
- removeProp: function( name ) {
- return this.each(function() {
- delete this[ jQuery.propFix[ name ] || name ];
- });
- },
-
- addClass: function( value ) {
- var classes, elem, cur, clazz, j,
- i = 0,
- len = this.length,
- proceed = typeof value === "string" && value;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).addClass( value.call( this, j, this.className ) );
- });
- }
-
- if ( proceed ) {
- // The disjunction here is for better compressibility (see removeClass)
- classes = ( value || "" ).match( core_rnotwhite ) || [];
-
- for ( ; i < len; i++ ) {
- elem = this[ i ];
- cur = elem.nodeType === 1 && ( elem.className ?
- ( " " + elem.className + " " ).replace( rclass, " " ) :
- " "
- );
-
- if ( cur ) {
- j = 0;
- while ( (clazz = classes[j++]) ) {
- if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
- cur += clazz + " ";
- }
- }
- elem.className = jQuery.trim( cur );
-
- }
- }
- }
-
- return this;
- },
-
- removeClass: function( value ) {
- var classes, elem, cur, clazz, j,
- i = 0,
- len = this.length,
- proceed = arguments.length === 0 || typeof value === "string" && value;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).removeClass( value.call( this, j, this.className ) );
- });
- }
- if ( proceed ) {
- classes = ( value || "" ).match( core_rnotwhite ) || [];
-
- for ( ; i < len; i++ ) {
- elem = this[ i ];
- // This expression is here for better compressibility (see addClass)
- cur = elem.nodeType === 1 && ( elem.className ?
- ( " " + elem.className + " " ).replace( rclass, " " ) :
- ""
- );
-
- if ( cur ) {
- j = 0;
- while ( (clazz = classes[j++]) ) {
- // Remove *all* instances
- while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
- cur = cur.replace( " " + clazz + " ", " " );
- }
- }
- elem.className = value ? jQuery.trim( cur ) : "";
- }
- }
- }
-
- return this;
- },
-
- toggleClass: function( value, stateVal ) {
- var type = typeof value;
-
- if ( typeof stateVal === "boolean" && type === "string" ) {
- return stateVal ? this.addClass( value ) : this.removeClass( value );
- }
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( i ) {
- jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
- });
- }
-
- return this.each(function() {
- if ( type === "string" ) {
- // toggle individual class names
- var className,
- i = 0,
- self = jQuery( this ),
- classNames = value.match( core_rnotwhite ) || [];
-
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space separated list
- if ( self.hasClass( className ) ) {
- self.removeClass( className );
- } else {
- self.addClass( className );
- }
- }
-
- // Toggle whole class name
- } else if ( type === core_strundefined || type === "boolean" ) {
- if ( this.className ) {
- // store className if set
- data_priv.set( this, "__className__", this.className );
- }
-
- // If the element has a class name or if we're passed "false",
- // then remove the whole classname (if there was one, the above saved it).
- // Otherwise bring back whatever was previously saved (if anything),
- // falling back to the empty string if nothing was stored.
- this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
- }
- });
- },
-
- hasClass: function( selector ) {
- var className = " " + selector + " ",
- i = 0,
- l = this.length;
- for ( ; i < l; i++ ) {
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
- return true;
- }
- }
-
- return false;
- },
-
- val: function( value ) {
- var hooks, ret, isFunction,
- elem = this[0];
-
- if ( !arguments.length ) {
- if ( elem ) {
- hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
-
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
- return ret;
- }
-
- ret = elem.value;
-
- return typeof ret === "string" ?
- // handle most common string cases
- ret.replace(rreturn, "") :
- // handle cases where value is null/undef or number
- ret == null ? "" : ret;
- }
-
- return;
- }
-
- isFunction = jQuery.isFunction( value );
-
- return this.each(function( i ) {
- var val;
-
- if ( this.nodeType !== 1 ) {
- return;
- }
-
- if ( isFunction ) {
- val = value.call( this, i, jQuery( this ).val() );
- } else {
- val = value;
- }
-
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
- } else if ( typeof val === "number" ) {
- val += "";
- } else if ( jQuery.isArray( val ) ) {
- val = jQuery.map(val, function ( value ) {
- return value == null ? "" : value + "";
- });
- }
-
- hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
-
- // If set returns undefined, fall back to normal setting
- if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
- this.value = val;
- }
- });
- }
-});
-
-jQuery.extend({
- valHooks: {
- option: {
- get: function( elem ) {
- // attributes.value is undefined in Blackberry 4.7 but
- // uses .value. See #6932
- var val = elem.attributes.value;
- return !val || val.specified ? elem.value : elem.text;
- }
- },
- select: {
- get: function( elem ) {
- var value, option,
- options = elem.options,
- index = elem.selectedIndex,
- one = elem.type === "select-one" || index < 0,
- values = one ? null : [],
- max = one ? index + 1 : options.length,
- i = index < 0 ?
- max :
- one ? index : 0;
-
- // Loop through all the selected options
- for ( ; i < max; i++ ) {
- option = options[ i ];
-
- // IE6-9 doesn't update selected after form reset (#2551)
- if ( ( option.selected || i === index ) &&
- // Don't return options that are disabled or in a disabled optgroup
- ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
- ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
-
- // Get the specific value for the option
- value = jQuery( option ).val();
-
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
-
- // Multi-Selects return an array
- values.push( value );
- }
- }
-
- return values;
- },
-
- set: function( elem, value ) {
- var optionSet, option,
- options = elem.options,
- values = jQuery.makeArray( value ),
- i = options.length;
-
- while ( i-- ) {
- option = options[ i ];
- if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) {
- optionSet = true;
- }
- }
-
- // force browsers to behave consistently when non-matching value is set
- if ( !optionSet ) {
- elem.selectedIndex = -1;
- }
- return values;
- }
- }
- },
-
- attr: function( elem, name, value ) {
- var hooks, ret,
- nType = elem.nodeType;
-
- // don't get/set attributes on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- // Fallback to prop when attributes are not supported
- if ( typeof elem.getAttribute === core_strundefined ) {
- return jQuery.prop( elem, name, value );
- }
-
- // All attributes are lowercase
- // Grab necessary hook if one is defined
- if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
- name = name.toLowerCase();
- hooks = jQuery.attrHooks[ name ] ||
- ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
- }
-
- if ( value !== undefined ) {
-
- if ( value === null ) {
- jQuery.removeAttr( elem, name );
-
- } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- elem.setAttribute( name, value + "" );
- return value;
- }
-
- } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
- ret = jQuery.find.attr( elem, name );
-
- // Non-existent attributes return null, we normalize to undefined
- return ret == null ?
- undefined :
- ret;
- }
- },
-
- removeAttr: function( elem, value ) {
- var name, propName,
- i = 0,
- attrNames = value && value.match( core_rnotwhite );
-
- if ( attrNames && elem.nodeType === 1 ) {
- while ( (name = attrNames[i++]) ) {
- propName = jQuery.propFix[ name ] || name;
-
- // Boolean attributes get special treatment (#10870)
- if ( jQuery.expr.match.bool.test( name ) ) {
- // Set corresponding property to false
- elem[ propName ] = false;
- }
-
- elem.removeAttribute( name );
- }
- }
- },
-
- attrHooks: {
- type: {
- set: function( elem, value ) {
- if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
- // Setting the type on a radio button after the value resets the value in IE6-9
- // Reset value to default in case type is set after value during creation
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- }
- },
-
- propFix: {
- "for": "htmlFor",
- "class": "className"
- },
-
- prop: function( elem, name, value ) {
- var ret, hooks, notxml,
- nType = elem.nodeType;
-
- // don't get/set properties on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- if ( notxml ) {
- // Fix name and attach hooks
- name = jQuery.propFix[ name ] || name;
- hooks = jQuery.propHooks[ name ];
- }
-
- if ( value !== undefined ) {
- return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
- ret :
- ( elem[ name ] = value );
-
- } else {
- return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
- ret :
- elem[ name ];
- }
- },
-
- propHooks: {
- tabIndex: {
- get: function( elem ) {
- return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
- elem.tabIndex :
- -1;
- }
- }
- }
-});
-
-// Hooks for boolean attributes
-boolHook = {
- set: function( elem, value, name ) {
- if ( value === false ) {
- // Remove boolean attributes when set to false
- jQuery.removeAttr( elem, name );
- } else {
- elem.setAttribute( name, name );
- }
- return name;
- }
-};
-jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
- var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr;
-
- jQuery.expr.attrHandle[ name ] = function( elem, name, isXML ) {
- var fn = jQuery.expr.attrHandle[ name ],
- ret = isXML ?
- undefined :
- /* jshint eqeqeq: false */
- // Temporarily disable this handler to check existence
- (jQuery.expr.attrHandle[ name ] = undefined) !=
- getter( elem, name, isXML ) ?
-
- name.toLowerCase() :
- null;
-
- // Restore handler
- jQuery.expr.attrHandle[ name ] = fn;
-
- return ret;
- };
-});
-
-// Support: IE9+
-// Selectedness for an option in an optgroup can be inaccurate
-if ( !jQuery.support.optSelected ) {
- jQuery.propHooks.selected = {
- get: function( elem ) {
- var parent = elem.parentNode;
- if ( parent && parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- return null;
- }
- };
-}
-
-jQuery.each([
- "tabIndex",
- "readOnly",
- "maxLength",
- "cellSpacing",
- "cellPadding",
- "rowSpan",
- "colSpan",
- "useMap",
- "frameBorder",
- "contentEditable"
-], function() {
- jQuery.propFix[ this.toLowerCase() ] = this;
-});
-
-// Radios and checkboxes getter/setter
-jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = {
- set: function( elem, value ) {
- if ( jQuery.isArray( value ) ) {
- return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
- }
- }
- };
- if ( !jQuery.support.checkOn ) {
- jQuery.valHooks[ this ].get = function( elem ) {
- // Support: Webkit
- // "" is returned instead of "on" if a value isn't specified
- return elem.getAttribute("value") === null ? "on" : elem.value;
- };
- }
-});
+define([
+ "./attributes/attr",
+ "./attributes/prop",
+ "./attributes/classes",
+ "./attributes/val"
+]);
diff --git a/src/attributes/attr.js b/src/attributes/attr.js
new file mode 100644
index 000000000..4e0102bfa
--- /dev/null
+++ b/src/attributes/attr.js
@@ -0,0 +1,143 @@
+define([
+ "../core",
+ "../var/rnotwhite",
+ "../var/strundefined",
+ "../selector"
+], function( jQuery, rnotwhite, strundefined ) {
+
+var nodeHook, boolHook;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
+ },
+
+ removeAttr: function( name ) {
+ return this.each(function() {
+ jQuery.removeAttr( this, name );
+ });
+ }
+});
+
+jQuery.extend({
+ attr: function( elem, name, value ) {
+ var hooks, ret,
+ nType = elem.nodeType;
+
+ // don't get/set attributes on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ // Fallback to prop when attributes are not supported
+ if ( typeof elem.getAttribute === strundefined ) {
+ return jQuery.prop( elem, name, value );
+ }
+
+ // All attributes are lowercase
+ // Grab necessary hook if one is defined
+ if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
+ name = name.toLowerCase();
+ hooks = jQuery.attrHooks[ name ] ||
+ ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
+ }
+
+ if ( value !== undefined ) {
+
+ if ( value === null ) {
+ jQuery.removeAttr( elem, name );
+
+ } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
+ return ret;
+
+ } else {
+ elem.setAttribute( name, value + "" );
+ return value;
+ }
+
+ } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
+ return ret;
+
+ } else {
+ ret = jQuery.find.attr( elem, name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return ret == null ?
+ undefined :
+ ret;
+ }
+ },
+
+ removeAttr: function( elem, value ) {
+ var name, propName,
+ i = 0,
+ attrNames = value && value.match( rnotwhite );
+
+ if ( attrNames && elem.nodeType === 1 ) {
+ while ( (name = attrNames[i++]) ) {
+ propName = jQuery.propFix[ name ] || name;
+
+ // Boolean attributes get special treatment (#10870)
+ if ( jQuery.expr.match.bool.test( name ) ) {
+ // Set corresponding property to false
+ elem[ propName ] = false;
+ }
+
+ elem.removeAttribute( name );
+ }
+ }
+ },
+
+ attrHooks: {
+ type: {
+ set: function( elem, value ) {
+ if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
+ // Setting the type on a radio button after the value resets the value in IE6-9
+ // Reset value to default in case type is set after value during creation
+ var val = elem.value;
+ elem.setAttribute( "type", value );
+ if ( val ) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
+ }
+ }
+});
+
+// Hooks for boolean attributes
+boolHook = {
+ set: function( elem, value, name ) {
+ if ( value === false ) {
+ // Remove boolean attributes when set to false
+ jQuery.removeAttr( elem, name );
+ } else {
+ elem.setAttribute( name, name );
+ }
+ return name;
+ }
+};
+jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
+ var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr;
+
+ jQuery.expr.attrHandle[ name ] = function( elem, name, isXML ) {
+ var fn = jQuery.expr.attrHandle[ name ],
+ ret = isXML ?
+ undefined :
+ /* jshint eqeqeq: false */
+ // Temporarily disable this handler to check existence
+ (jQuery.expr.attrHandle[ name ] = undefined) !=
+ getter( elem, name, isXML ) ?
+
+ name.toLowerCase() :
+ null;
+
+ // Restore handler
+ jQuery.expr.attrHandle[ name ] = fn;
+
+ return ret;
+ };
+});
+
+});
diff --git a/src/attributes/classes.js b/src/attributes/classes.js
new file mode 100644
index 000000000..170787c83
--- /dev/null
+++ b/src/attributes/classes.js
@@ -0,0 +1,148 @@
+define([
+ "../core",
+ "../var/rnotwhite",
+ "../var/strundefined",
+ "../data/var/data_priv"
+], function( jQuery, rnotwhite, strundefined, data_priv ) {
+
+var rclass = /[\t\r\n\f]/g;
+
+jQuery.fn.extend({
+ addClass: function( value ) {
+ var classes, elem, cur, clazz, j,
+ i = 0,
+ len = this.length,
+ proceed = typeof value === "string" && value;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).addClass( value.call( this, j, this.className ) );
+ });
+ }
+
+ if ( proceed ) {
+ // The disjunction here is for better compressibility (see removeClass)
+ classes = ( value || "" ).match( rnotwhite ) || [];
+
+ for ( ; i < len; i++ ) {
+ elem = this[ i ];
+ cur = elem.nodeType === 1 && ( elem.className ?
+ ( " " + elem.className + " " ).replace( rclass, " " ) :
+ " "
+ );
+
+ if ( cur ) {
+ j = 0;
+ while ( (clazz = classes[j++]) ) {
+ if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
+ cur += clazz + " ";
+ }
+ }
+ elem.className = jQuery.trim( cur );
+
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ var classes, elem, cur, clazz, j,
+ i = 0,
+ len = this.length,
+ proceed = arguments.length === 0 || typeof value === "string" && value;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).removeClass( value.call( this, j, this.className ) );
+ });
+ }
+ if ( proceed ) {
+ classes = ( value || "" ).match( rnotwhite ) || [];
+
+ for ( ; i < len; i++ ) {
+ elem = this[ i ];
+ // This expression is here for better compressibility (see addClass)
+ cur = elem.nodeType === 1 && ( elem.className ?
+ ( " " + elem.className + " " ).replace( rclass, " " ) :
+ ""
+ );
+
+ if ( cur ) {
+ j = 0;
+ while ( (clazz = classes[j++]) ) {
+ // Remove *all* instances
+ while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
+ cur = cur.replace( " " + clazz + " ", " " );
+ }
+ }
+ elem.className = value ? jQuery.trim( cur ) : "";
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value;
+
+ if ( typeof stateVal === "boolean" && type === "string" ) {
+ return stateVal ? this.addClass( value ) : this.removeClass( value );
+ }
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( i ) {
+ jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className,
+ i = 0,
+ self = jQuery( this ),
+ classNames = value.match( rnotwhite ) || [];
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space separated list
+ if ( self.hasClass( className ) ) {
+ self.removeClass( className );
+ } else {
+ self.addClass( className );
+ }
+ }
+
+ // Toggle whole class name
+ } else if ( type === strundefined || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ data_priv.set( this, "__className__", this.className );
+ }
+
+ // If the element has a class name or if we're passed "false",
+ // then remove the whole classname (if there was one, the above saved it).
+ // Otherwise bring back whatever was previously saved (if anything),
+ // falling back to the empty string if nothing was stored.
+ this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ",
+ i = 0,
+ l = this.length;
+ for ( ; i < l; i++ ) {
+ if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+});
+
+});
diff --git a/src/attributes/prop.js b/src/attributes/prop.js
new file mode 100644
index 000000000..f7ce11f97
--- /dev/null
+++ b/src/attributes/prop.js
@@ -0,0 +1,94 @@
+define([
+ "../core"
+], function( jQuery ) {
+
+var rfocusable = /^(?:input|select|textarea|button)$/i;
+
+jQuery.fn.extend({
+ prop: function( name, value ) {
+ return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
+ },
+
+ removeProp: function( name ) {
+ return this.each(function() {
+ delete this[ jQuery.propFix[ name ] || name ];
+ });
+ }
+});
+
+jQuery.extend({
+ propFix: {
+ "for": "htmlFor",
+ "class": "className"
+ },
+
+ prop: function( elem, name, value ) {
+ var ret, hooks, notxml,
+ nType = elem.nodeType;
+
+ // don't get/set properties on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+ if ( notxml ) {
+ // Fix name and attach hooks
+ name = jQuery.propFix[ name ] || name;
+ hooks = jQuery.propHooks[ name ];
+ }
+
+ if ( value !== undefined ) {
+ return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
+ ret :
+ ( elem[ name ] = value );
+
+ } else {
+ return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
+ ret :
+ elem[ name ];
+ }
+ },
+
+ propHooks: {
+ tabIndex: {
+ get: function( elem ) {
+ return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
+ elem.tabIndex :
+ -1;
+ }
+ }
+ }
+});
+
+// Support: IE9+
+// Selectedness for an option in an optgroup can be inaccurate
+if ( !jQuery.support.optSelected ) {
+ jQuery.propHooks.selected = {
+ get: function( elem ) {
+ var parent = elem.parentNode;
+ if ( parent && parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ return null;
+ }
+ };
+}
+
+jQuery.each([
+ "tabIndex",
+ "readOnly",
+ "maxLength",
+ "cellSpacing",
+ "cellPadding",
+ "rowSpan",
+ "colSpan",
+ "useMap",
+ "frameBorder",
+ "contentEditable"
+], function() {
+ jQuery.propFix[ this.toLowerCase() ] = this;
+});
+
+});
diff --git a/src/attributes/val.js b/src/attributes/val.js
new file mode 100644
index 000000000..fd8badeb2
--- /dev/null
+++ b/src/attributes/val.js
@@ -0,0 +1,157 @@
+define([
+ "../core"
+], function( jQuery ) {
+
+var rreturn = /\r/g;
+
+jQuery.fn.extend({
+ val: function( value ) {
+ var hooks, ret, isFunction,
+ elem = this[0];
+
+ if ( !arguments.length ) {
+ if ( elem ) {
+ hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
+
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
+ return ret;
+ }
+
+ ret = elem.value;
+
+ return typeof ret === "string" ?
+ // handle most common string cases
+ ret.replace(rreturn, "") :
+ // handle cases where value is null/undef or number
+ ret == null ? "" : ret;
+ }
+
+ return;
+ }
+
+ isFunction = jQuery.isFunction( value );
+
+ return this.each(function( i ) {
+ var val;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call( this, i, jQuery( this ).val() );
+ } else {
+ val = value;
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == null ) {
+ val = "";
+ } else if ( typeof val === "number" ) {
+ val += "";
+ } else if ( jQuery.isArray( val ) ) {
+ val = jQuery.map(val, function ( value ) {
+ return value == null ? "" : value + "";
+ });
+ }
+
+ hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
+
+ // If set returns undefined, fall back to normal setting
+ if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ valHooks: {
+ option: {
+ get: function( elem ) {
+ // attributes.value is undefined in Blackberry 4.7 but
+ // uses .value. See #6932
+ var val = elem.attributes.value;
+ return !val || val.specified ? elem.value : elem.text;
+ }
+ },
+ select: {
+ get: function( elem ) {
+ var value, option,
+ options = elem.options,
+ index = elem.selectedIndex,
+ one = elem.type === "select-one" || index < 0,
+ values = one ? null : [],
+ max = one ? index + 1 : options.length,
+ i = index < 0 ?
+ max :
+ one ? index : 0;
+
+ // Loop through all the selected options
+ for ( ; i < max; i++ ) {
+ option = options[ i ];
+
+ // IE6-9 doesn't update selected after form reset (#2551)
+ if ( ( option.selected || i === index ) &&
+ // Don't return options that are disabled or in a disabled optgroup
+ ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
+ ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
+
+ // Get the specific value for the option
+ value = jQuery( option ).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ },
+
+ set: function( elem, value ) {
+ var optionSet, option,
+ options = elem.options,
+ values = jQuery.makeArray( value ),
+ i = options.length;
+
+ while ( i-- ) {
+ option = options[ i ];
+ if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) {
+ optionSet = true;
+ }
+ }
+
+ // force browsers to behave consistently when non-matching value is set
+ if ( !optionSet ) {
+ elem.selectedIndex = -1;
+ }
+ return values;
+ }
+ }
+ }
+});
+
+// Radios and checkboxes getter/setter
+jQuery.each([ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = {
+ set: function( elem, value ) {
+ if ( jQuery.isArray( value ) ) {
+ return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
+ }
+ }
+ };
+ if ( !jQuery.support.checkOn ) {
+ jQuery.valHooks[ this ].get = function( elem ) {
+ // Support: Webkit
+ // "" is returned instead of "on" if a value isn't specified
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ };
+ }
+});
+
+});
diff --git a/src/callbacks.js b/src/callbacks.js
index 84c834666..fd80bd905 100644
--- a/src/callbacks.js
+++ b/src/callbacks.js
@@ -1,10 +1,15 @@
+define([
+ "./core",
+ "./var/rnotwhite"
+], function( jQuery, rnotwhite ) {
+
// String to Object options format cache
var optionsCache = {};
// Convert String-formatted options into Object-formatted ones and store in cache
function createOptions( options ) {
var object = optionsCache[ options ] = {};
- jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
+ jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
object[ flag ] = true;
});
return object;
@@ -195,3 +200,5 @@ jQuery.Callbacks = function( options ) {
return self;
};
+
+});
diff --git a/src/core.js b/src/core.js
index 55a0c25d3..6d5c747f4 100644
--- a/src/core.js
+++ b/src/core.js
@@ -1,18 +1,24 @@
+define([
+ "./var/strundefined",
+ "./var/arr",
+ "./var/slice",
+ "./var/concat",
+ "./var/push",
+ "./var/indexOf",
+ // [[Class]] -> type pairs
+ "./var/class2type",
+ "./var/toString",
+ "./var/hasOwn",
+ "./var/trim"
+], function( strundefined, arr, slice, concat, push, indexOf,
+ class2type, toString, hasOwn, trim ) {
+
var
// A central reference to the root jQuery(document)
rootjQuery,
- // The deferred used on DOM ready
- readyList,
-
- // Support: IE9
- // For `typeof xmlNode.method` instead of `xmlNode.method !== undefined`
- core_strundefined = typeof undefined,
-
// Use the correct document accordingly with window argument (sandbox)
- location = window.location,
document = window.document,
- docElem = document.documentElement,
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
@@ -20,22 +26,7 @@ var
// Map over the $ in case of overwrite
_$ = window.$,
- // [[Class]] -> type pairs
- class2type = {},
-
- // List of deleted data cache ids, so we can reuse them
- core_deletedIds = [],
-
- core_version = "@VERSION",
-
- // Save a reference to some core methods
- core_concat = core_deletedIds.concat,
- core_push = core_deletedIds.push,
- core_slice = core_deletedIds.slice,
- core_indexOf = core_deletedIds.indexOf,
- core_toString = class2type.toString,
- core_hasOwn = class2type.hasOwnProperty,
- core_trim = core_version.trim,
+ version = "@VERSION",
// Define a local copy of jQuery
jQuery = function( selector, context ) {
@@ -43,12 +34,6 @@ var
return new jQuery.fn.init( selector, context, rootjQuery );
},
- // Used for matching numbers
- core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
-
- // Used for splitting on whitespace
- core_rnotwhite = /\S+/g,
-
// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
// Strict HTML recognition (#11290: must start with <)
@@ -64,20 +49,14 @@ var
// Used by jQuery.camelCase as callback to replace()
fcamelCase = function( all, letter ) {
return letter.toUpperCase();
- },
-
- // The ready event handler and self cleanup method
- completed = function() {
- document.removeEventListener( "DOMContentLoaded", completed, false );
- window.removeEventListener( "load", completed, false );
- jQuery.ready();
};
jQuery.fn = jQuery.prototype = {
// The current version of jQuery being used
- jquery: core_version,
+ jquery: version,
constructor: jQuery,
+
init: function( selector, context, rootjQuery ) {
var match, elem;
@@ -162,7 +141,10 @@ jQuery.fn = jQuery.prototype = {
// HANDLE: $(function)
// Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) {
- return rootjQuery.ready( selector );
+ return typeof rootjQuery.ready !== "undefined" ?
+ rootjQuery.ready( selector ) :
+ // Execute immediately if ready is not present
+ selector( jQuery );
}
if ( selector.selector !== undefined ) {
@@ -180,7 +162,7 @@ jQuery.fn = jQuery.prototype = {
length: 0,
toArray: function() {
- return core_slice.call( this );
+ return slice.call( this );
},
// Get the Nth element in the matched element set OR
@@ -217,15 +199,8 @@ jQuery.fn = jQuery.prototype = {
return jQuery.each( this, callback, args );
},
- ready: function( fn ) {
- // Add the callback
- jQuery.ready.promise().done( fn );
-
- return this;
- },
-
slice: function() {
- return this.pushStack( core_slice.apply( this, arguments ) );
+ return this.pushStack( slice.apply( this, arguments ) );
},
first: function() {
@@ -254,9 +229,9 @@ jQuery.fn = jQuery.prototype = {
// For internal use only.
// Behaves like an Array's method, not like a jQuery method.
- push: core_push,
- sort: [].sort,
- splice: [].splice
+ push: push,
+ sort: arr.sort,
+ splice: arr.splice
};
// Give the init function the jQuery prototype for later instantiation
@@ -328,7 +303,10 @@ jQuery.extend = jQuery.fn.extend = function() {
jQuery.extend({
// Unique for each copy of jQuery on the page
- expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
+ expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
+
+ // Assume jQuery is ready without the ready module
+ isReady: true,
noConflict: function( deep ) {
if ( window.$ === jQuery ) {
@@ -342,47 +320,6 @@ jQuery.extend({
return jQuery;
},
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
-
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
-
- // Hold (or release) the ready event
- holdReady: function( hold ) {
- if ( hold ) {
- jQuery.readyWait++;
- } else {
- jQuery.ready( true );
- }
- },
-
- // Handle when the DOM is ready
- ready: function( wait ) {
-
- // Abort if there are pending holds or we're already ready
- if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
- return;
- }
-
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
-
- // If there are functions bound, to execute
- readyList.resolveWith( document, [ jQuery ] );
-
- // Trigger any bound ready events
- if ( jQuery.fn.trigger ) {
- jQuery( document ).trigger("ready").off("ready");
- }
- },
-
// See test/unit/core.js for details concerning isFunction.
// Since version 1.3, DOM methods and functions like alert
// aren't supported. They return false on IE (#2968).
@@ -406,7 +343,7 @@ jQuery.extend({
}
// Support: Safari <= 5.1 (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ?
- class2type[ core_toString.call(obj) ] || "object" :
+ class2type[ toString.call(obj) ] || "object" :
typeof obj;
},
@@ -425,7 +362,7 @@ jQuery.extend({
// https://bugzilla.mozilla.org/show_bug.cgi?id=814622
try {
if ( obj.constructor &&
- !core_hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
+ !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
return false;
}
} catch ( e ) {
@@ -452,6 +389,7 @@ jQuery.extend({
// data: string of html
// context (optional): If specified, the fragment will be created in this context, defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string
+ // TODO: Circular reference core -> manipulation -> core
parseHTML: function( data, context, keepScripts ) {
if ( !data || typeof data !== "string" ) {
return null;
@@ -507,7 +445,7 @@ jQuery.extend({
// Evaluates a script in a global context
globalEval: function( code ) {
var script,
- indirect = eval;
+ indirect = eval;
code = jQuery.trim( code );
@@ -588,7 +526,7 @@ jQuery.extend({
},
trim: function( text ) {
- return text == null ? "" : core_trim.call( text );
+ return text == null ? "" : trim.call( text );
},
// results is for internal usage only
@@ -602,7 +540,7 @@ jQuery.extend({
[ arr ] : arr
);
} else {
- core_push.call( ret, arr );
+ push.call( ret, arr );
}
}
@@ -610,7 +548,7 @@ jQuery.extend({
},
inArray: function( elem, arr, i ) {
- return arr == null ? -1 : core_indexOf.call( arr, elem, i );
+ return arr == null ? -1 : indexOf.call( arr, elem, i );
},
merge: function( first, second ) {
@@ -682,7 +620,7 @@ jQuery.extend({
}
// Flatten any nested arrays
- return core_concat.apply( [], ret );
+ return concat.apply( [], ret );
},
// A global GUID counter for objects
@@ -706,9 +644,9 @@ jQuery.extend({
}
// Simulated bind
- args = core_slice.call( arguments, 2 );
+ args = slice.call( arguments, 2 );
proxy = function() {
- return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
+ 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
@@ -770,56 +708,9 @@ jQuery.extend({
length ? fn( elems[0], key ) : emptyGet;
},
- now: Date.now,
-
- // A method for quickly swapping in/out CSS properties to get correct calculations.
- // Note: this method belongs to the css module but it's needed here for the support module.
- // If support gets modularized, this method should be moved back to the css module.
- swap: function( elem, options, callback, args ) {
- var ret, name,
- old = {};
-
- // Remember the old values, and insert the new ones
- for ( name in options ) {
- old[ name ] = elem.style[ name ];
- elem.style[ name ] = options[ name ];
- }
-
- ret = callback.apply( elem, args || [] );
-
- // Revert the old values
- for ( name in options ) {
- elem.style[ name ] = old[ name ];
- }
-
- return ret;
- }
+ now: Date.now
});
-jQuery.ready.promise = function( obj ) {
- if ( !readyList ) {
-
- readyList = jQuery.Deferred();
-
- // Catch cases where $(document).ready() is called after the browser event has already occurred.
- // we once tried to use readyState "interactive" here, but it caused issues like the one
- // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
- if ( document.readyState === "complete" ) {
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- setTimeout( jQuery.ready );
-
- } else {
-
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", completed, false );
-
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", completed, false );
- }
- }
- return readyList.promise( obj );
-};
-
// Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
class2type[ "[object " + name + "]" ] = name.toLowerCase();
@@ -843,4 +734,7 @@ function isArraylike( obj ) {
}
// All jQuery objects should point back to these
-rootjQuery = jQuery(document);
+rootjQuery = jQuery( document );
+
+return jQuery;
+});
diff --git a/src/core/ready.js b/src/core/ready.js
new file mode 100644
index 000000000..ab9f0801e
--- /dev/null
+++ b/src/core/ready.js
@@ -0,0 +1,92 @@
+define([
+ "../core",
+ "../deferred"
+], function( jQuery ) {
+
+// The deferred used on DOM ready
+var readyList;
+
+jQuery.fn.ready = function( fn ) {
+ // Add the callback
+ jQuery.ready.promise().done( fn );
+
+ return this;
+};
+
+jQuery.extend({
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Hold (or release) the ready event
+ holdReady: function( hold ) {
+ if ( hold ) {
+ jQuery.readyWait++;
+ } else {
+ jQuery.ready( true );
+ }
+ },
+
+ // Handle when the DOM is ready
+ ready: function( wait ) {
+
+ // Abort if there are pending holds or we're already ready
+ if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
+ return;
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if ( wait !== true && --jQuery.readyWait > 0 ) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ readyList.resolveWith( document, [ jQuery ] );
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.trigger ) {
+ jQuery( document ).trigger("ready").off("ready");
+ }
+ }
+});
+
+/**
+ * The ready event handler and self cleanup method
+ */
+function completed() {
+ document.removeEventListener( "DOMContentLoaded", completed, false );
+ window.removeEventListener( "load", completed, false );
+ jQuery.ready();
+}
+
+jQuery.ready.promise = function( obj ) {
+ if ( !readyList ) {
+
+ readyList = jQuery.Deferred();
+
+ // Catch cases where $(document).ready() is called after the browser event has already occurred.
+ // we once tried to use readyState "interactive" here, but it caused issues like the one
+ // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
+ if ( document.readyState === "complete" ) {
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ setTimeout( jQuery.ready );
+
+ } else {
+
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", completed, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", completed, false );
+ }
+ }
+ return readyList.promise( obj );
+};
+
+});
diff --git a/src/core/swap.js b/src/core/swap.js
new file mode 100644
index 000000000..95f4e2c69
--- /dev/null
+++ b/src/core/swap.js
@@ -0,0 +1,29 @@
+define([
+ "../core"
+], function( jQuery ) {
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations.
+ // Note: this method belongs to the css module but it's needed here for the support module.
+ // If support gets modularized, this method should be moved back to the css module.
+ jQuery.swap = function( elem, options, callback, args ) {
+ var ret, name,
+ old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ ret = callback.apply( elem, args || [] );
+
+ // Revert the old values
+ for ( name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+
+ return ret;
+ };
+
+ return jQuery.swap;
+});
diff --git a/src/css.js b/src/css.js
index 34b4d1203..f35700247 100644
--- a/src/css.js
+++ b/src/css.js
@@ -1,12 +1,21 @@
-var curCSS, iframe,
+define([
+ "./core",
+ "./var/pnum",
+ "./css/var/cssExpand",
+ "./css/var/isHidden",
+ "./css/defaultDisplay",
+ "./data/var/data_priv",
+ "./core/swap",
+ "./selector" // contains
+], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) {
+var curCSS,
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
rmargin = /^margin/,
- rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
- rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
- rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
- elemdisplay = { BODY: "block" },
+ rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
+ rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ),
+ rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
cssNormalTransform = {
@@ -14,7 +23,6 @@ var curCSS, iframe,
fontWeight: 400
},
- cssExpand = [ "Top", "Right", "Bottom", "Left" ],
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
// return a css property mapped to a potentially vendor prefixed property
@@ -40,13 +48,6 @@ function vendorPropName( style, name ) {
return origName;
}
-function isHidden( elem, el ) {
- // isHidden might be called from jQuery#filter function;
- // in that case, element will be second argument
- elem = el || elem;
- return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
-}
-
// NOTE: we've included the "window" in window.getComputedStyle
// because jsdom on node.js will break without it.
function getStyles( elem ) {
@@ -78,7 +79,7 @@ function showHide( elements, show ) {
// in a stylesheet to whatever the default browser style is
// for such an element
if ( elem.style.display === "" && isHidden( elem ) ) {
- values[ index ] = data_priv.access( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
+ values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
}
} else {
@@ -414,46 +415,6 @@ function getWidthOrHeight( elem, name, extra ) {
) + "px";
}
-// Try to determine the default display value of an element
-function css_defaultDisplay( nodeName ) {
- var doc = document,
- display = elemdisplay[ nodeName ];
-
- if ( !display ) {
- display = actualDisplay( nodeName, doc );
-
- // If the simple way fails, read from inside an iframe
- if ( display === "none" || !display ) {
- // Use the already-created iframe if possible
- iframe = ( iframe ||
- jQuery("<iframe frameborder='0' width='0' height='0'/>")
- .css( "cssText", "display:block !important" )
- ).appendTo( doc.documentElement );
-
- // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
- doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
- doc.write("<!doctype html><html><body>");
- doc.close();
-
- display = actualDisplay( nodeName, doc );
- iframe.detach();
- }
-
- // Store the correct default display
- elemdisplay[ nodeName ] = display;
- }
-
- return display;
-}
-
-// Called ONLY from within css_defaultDisplay
-function actualDisplay( name, doc ) {
- var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
- display = jQuery.css( elem[0], "display" );
- elem.remove();
- return display;
-}
-
jQuery.each([ "height", "width" ], function( i, name ) {
jQuery.cssHooks[ name ] = {
get: function( elem, computed, extra ) {
@@ -504,6 +465,7 @@ jQuery(function() {
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
// getComputedStyle returns percent when specified for top/left/bottom/right
// rather than make the css module depend on the offset module, we just check for it here
+ // TODO: Optional dependency on offset
if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
jQuery.each( [ "top", "left" ], function( i, prop ) {
jQuery.cssHooks[ prop ] = {
@@ -519,21 +481,8 @@ jQuery(function() {
};
});
}
-
});
-if ( jQuery.expr && jQuery.expr.filters ) {
- jQuery.expr.filters.hidden = function( elem ) {
- // Support: Opera <= 12.12
- // Opera reports offsetWidths and offsetHeights less than zero on some elements
- return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
- };
-
- jQuery.expr.filters.visible = function( elem ) {
- return !jQuery.expr.filters.hidden( elem );
- };
-}
-
// These hooks are used by animate to expand properties
jQuery.each({
margin: "",
@@ -561,3 +510,5 @@ jQuery.each({
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
}
});
+
+});
diff --git a/src/css/defaultDisplay.js b/src/css/defaultDisplay.js
new file mode 100644
index 000000000..78acb2bcd
--- /dev/null
+++ b/src/css/defaultDisplay.js
@@ -0,0 +1,58 @@
+define([
+ "../core",
+ "../manipulation" // appendTo
+], function( jQuery ) {
+
+var iframe,
+ elemdisplay = { BODY: "block" };
+
+/**
+ * Retrieve the actual display of a element
+ * @param {String} name nodeName of the element
+ * @param {Object} doc Document object
+ */
+function actualDisplay( name, doc ) {
+ var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
+ display = jQuery.css( elem[0], "display" );
+ elem.remove();
+ return display;
+}
+
+/**
+ * Try to determine the default display value of an element
+ * @param {String} nodeName
+ */
+function defaultDisplay( nodeName ) {
+ var doc = document,
+ display = elemdisplay[ nodeName ];
+
+ if ( !display ) {
+ display = actualDisplay( nodeName, doc );
+
+ // If the simple way fails, read from inside an iframe
+ if ( display === "none" || !display ) {
+ // Use the already-created iframe if possible
+ iframe = ( iframe ||
+ jQuery("<iframe frameborder='0' width='0' height='0'/>")
+ .css( "cssText", "display:block !important" )
+ ).appendTo( doc.documentElement );
+
+ // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
+ doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
+ doc.write("<!doctype html><html><body>");
+ doc.close();
+
+ display = actualDisplay( nodeName, doc );
+ iframe.detach();
+ }
+
+ // Store the correct default display
+ elemdisplay[ nodeName ] = display;
+ }
+
+ return display;
+}
+
+return defaultDisplay;
+
+});
diff --git a/src/css/hidden-visible-selectors.js b/src/css/hidden-visible-selectors.js
new file mode 100644
index 000000000..c7f1c7ee7
--- /dev/null
+++ b/src/css/hidden-visible-selectors.js
@@ -0,0 +1,15 @@
+define([
+ "../core",
+ "../selector"
+], function( jQuery ) {
+
+jQuery.expr.filters.hidden = function( elem ) {
+ // Support: Opera <= 12.12
+ // Opera reports offsetWidths and offsetHeights less than zero on some elements
+ return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
+};
+jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+};
+
+});
diff --git a/src/css/var/cssExpand.js b/src/css/var/cssExpand.js
new file mode 100644
index 000000000..5bb6e8f85
--- /dev/null
+++ b/src/css/var/cssExpand.js
@@ -0,0 +1,3 @@
+define(function() {
+ return [ "Top", "Right", "Bottom", "Left" ];
+}); \ No newline at end of file
diff --git a/src/css/var/isHidden.js b/src/css/var/isHidden.js
new file mode 100644
index 000000000..085833db0
--- /dev/null
+++ b/src/css/var/isHidden.js
@@ -0,0 +1,13 @@
+define([
+ "../../core",
+ "../../selector"
+ // css is assumed
+], function( jQuery ) {
+
+ return function( elem, el ) {
+ // isHidden might be called from jQuery#filter function;
+ // in that case, element will be second argument
+ elem = el || elem;
+ return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
+ };
+}); \ No newline at end of file
diff --git a/src/data.js b/src/data.js
index 96afe6f4e..db34e2dee 100644
--- a/src/data.js
+++ b/src/data.js
@@ -1,3 +1,10 @@
+define([
+ "./core",
+ "./var/rnotwhite",
+ "./data/var/data_priv",
+ "./data/var/data_user"
+], function( jQuery, rnotwhite, data_priv, data_user ) {
+
/*
Implementation Summary
@@ -9,201 +16,10 @@
5. Avoid exposing implementation details on user objects (eg. expando properties)
6. Provide a clear path for implementation upgrade to WeakMap in 2014
*/
-var data_user, data_priv,
- rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
+var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
rmultiDash = /([A-Z])/g;
-function Data() {
- // Support: Android < 4,
- // Old WebKit does not have Object.preventExtensions/freeze method,
- // return new empty object instead with no [[set]] accessor
- Object.defineProperty( this.cache = {}, 0, {
- get: function() {
- return {};
- }
- });
-
- this.expando = jQuery.expando + Math.random();
-}
-
-Data.uid = 1;
-
-Data.accepts = function( owner ) {
- // Accepts only:
- // - Node
- // - Node.ELEMENT_NODE
- // - Node.DOCUMENT_NODE
- // - Object
- // - Any
- return owner.nodeType ?
- owner.nodeType === 1 || owner.nodeType === 9 : true;
-};
-
-Data.prototype = {
- key: function( owner ) {
- // We can accept data for non-element nodes in modern browsers,
- // but we should not, see #8335.
- // Always return the key for a frozen object.
- if ( !Data.accepts( owner ) ) {
- return 0;
- }
-
- var descriptor = {},
- // Check if the owner object already has a cache key
- unlock = owner[ this.expando ];
-
- // If not, create one
- if ( !unlock ) {
- unlock = Data.uid++;
-
- // Secure it in a non-enumerable, non-writable property
- try {
- descriptor[ this.expando ] = { value: unlock };
- Object.defineProperties( owner, descriptor );
-
- // Support: Android < 4
- // Fallback to a less secure definition
- } catch ( e ) {
- descriptor[ this.expando ] = unlock;
- jQuery.extend( owner, descriptor );
- }
- }
-
- // Ensure the cache object
- if ( !this.cache[ unlock ] ) {
- this.cache[ unlock ] = {};
- }
-
- return unlock;
- },
- set: function( owner, data, value ) {
- var prop,
- // There may be an unlock assigned to this node,
- // if there is no entry for this "owner", create one inline
- // and set the unlock as though an owner entry had always existed
- unlock = this.key( owner ),
- cache = this.cache[ unlock ];
-
- // Handle: [ owner, key, value ] args
- if ( typeof data === "string" ) {
- cache[ data ] = value;
-
- // Handle: [ owner, { properties } ] args
- } else {
- // Fresh assignments by object are shallow copied
- if ( jQuery.isEmptyObject( cache ) ) {
- jQuery.extend( this.cache[ unlock ], data );
- // Otherwise, copy the properties one-by-one to the cache object
- } else {
- for ( prop in data ) {
- cache[ prop ] = data[ prop ];
- }
- }
- }
- return cache;
- },
- get: function( owner, key ) {
- // Either a valid cache is found, or will be created.
- // New caches will be created and the unlock returned,
- // allowing direct access to the newly created
- // empty data object. A valid owner object must be provided.
- var cache = this.cache[ this.key( owner ) ];
-
- return key === undefined ?
- cache : cache[ key ];
- },
- access: function( owner, key, value ) {
- var stored;
- // In cases where either:
- //
- // 1. No key was specified
- // 2. A string key was specified, but no value provided
- //
- // Take the "read" path and allow the get method to determine
- // which value to return, respectively either:
- //
- // 1. The entire cache object
- // 2. The data stored at the key
- //
- if ( key === undefined ||
- ((key && typeof key === "string") && value === undefined) ) {
-
- stored = this.get( owner, key );
-
- return stored !== undefined ?
- stored : this.get( owner, jQuery.camelCase(key) );
- }
-
- // [*]When the key is not a string, or both a key and value
- // are specified, set or extend (existing objects) with either:
- //
- // 1. An object of properties
- // 2. A key and value
- //
- this.set( owner, key, value );
-
- // Since the "set" path can have two possible entry points
- // return the expected data based on which path was taken[*]
- return value !== undefined ? value : key;
- },
- remove: function( owner, key ) {
- var i, name, camel,
- unlock = this.key( owner ),
- cache = this.cache[ unlock ];
-
- if ( key === undefined ) {
- this.cache[ unlock ] = {};
-
- } else {
- // Support array or space separated string of keys
- if ( jQuery.isArray( key ) ) {
- // If "name" is an array of keys...
- // When data is initially created, via ("key", "val") signature,
- // keys will be converted to camelCase.
- // Since there is no way to tell _how_ a key was added, remove
- // both plain key and camelCase key. #12786
- // This will only penalize the array argument path.
- name = key.concat( key.map( jQuery.camelCase ) );
- } else {
- camel = jQuery.camelCase( key );
- // Try the string as a key before any manipulation
- if ( key in cache ) {
- name = [ key, camel ];
- } else {
- // If a key with the spaces exists, use it.
- // Otherwise, create an array by matching non-whitespace
- name = camel;
- name = name in cache ?
- [ name ] : ( name.match( core_rnotwhite ) || [] );
- }
- }
-
- i = name.length;
- while ( i-- ) {
- delete cache[ name[ i ] ];
- }
- }
- },
- hasData: function( owner ) {
- return !jQuery.isEmptyObject(
- this.cache[ owner[ this.expando ] ] || {}
- );
- },
- discard: function( owner ) {
- if ( owner[ this.expando ] ) {
- delete this.cache[ owner[ this.expando ] ];
- }
- }
-};
-
-// These may be used throughout the jQuery core codebase
-data_user = new Data();
-data_priv = new Data();
-
-
jQuery.extend({
- acceptData: Data.accepts,
-
hasData: function( elem ) {
return data_user.hasData( elem ) || data_priv.hasData( elem );
},
@@ -354,3 +170,5 @@ function dataAttr( elem, key, data ) {
}
return data;
}
+
+});
diff --git a/src/data/Data.js b/src/data/Data.js
new file mode 100644
index 000000000..d34606bf2
--- /dev/null
+++ b/src/data/Data.js
@@ -0,0 +1,181 @@
+define([
+ "../core",
+ "../var/rnotwhite",
+ "./accepts"
+], function( jQuery, rnotwhite ) {
+
+function Data() {
+ // Support: Android < 4,
+ // Old WebKit does not have Object.preventExtensions/freeze method,
+ // return new empty object instead with no [[set]] accessor
+ Object.defineProperty( this.cache = {}, 0, {
+ get: function() {
+ return {};
+ }
+ });
+
+ this.expando = jQuery.expando + Math.random();
+}
+
+Data.uid = 1;
+Data.accepts = jQuery.acceptData;
+
+Data.prototype = {
+ key: function( owner ) {
+ // We can accept data for non-element nodes in modern browsers,
+ // but we should not, see #8335.
+ // Always return the key for a frozen object.
+ if ( !Data.accepts( owner ) ) {
+ return 0;
+ }
+
+ var descriptor = {},
+ // Check if the owner object already has a cache key
+ unlock = owner[ this.expando ];
+
+ // If not, create one
+ if ( !unlock ) {
+ unlock = Data.uid++;
+
+ // Secure it in a non-enumerable, non-writable property
+ try {
+ descriptor[ this.expando ] = { value: unlock };
+ Object.defineProperties( owner, descriptor );
+
+ // Support: Android < 4
+ // Fallback to a less secure definition
+ } catch ( e ) {
+ descriptor[ this.expando ] = unlock;
+ jQuery.extend( owner, descriptor );
+ }
+ }
+
+ // Ensure the cache object
+ if ( !this.cache[ unlock ] ) {
+ this.cache[ unlock ] = {};
+ }
+
+ return unlock;
+ },
+ set: function( owner, data, value ) {
+ var prop,
+ // There may be an unlock assigned to this node,
+ // if there is no entry for this "owner", create one inline
+ // and set the unlock as though an owner entry had always existed
+ unlock = this.key( owner ),
+ cache = this.cache[ unlock ];
+
+ // Handle: [ owner, key, value ] args
+ if ( typeof data === "string" ) {
+ cache[ data ] = value;
+
+ // Handle: [ owner, { properties } ] args
+ } else {
+ // Fresh assignments by object are shallow copied
+ if ( jQuery.isEmptyObject( cache ) ) {
+ jQuery.extend( this.cache[ unlock ], data );
+ // Otherwise, copy the properties one-by-one to the cache object
+ } else {
+ for ( prop in data ) {
+ cache[ prop ] = data[ prop ];
+ }
+ }
+ }
+ return cache;
+ },
+ get: function( owner, key ) {
+ // Either a valid cache is found, or will be created.
+ // New caches will be created and the unlock returned,
+ // allowing direct access to the newly created
+ // empty data object. A valid owner object must be provided.
+ var cache = this.cache[ this.key( owner ) ];
+
+ return key === undefined ?
+ cache : cache[ key ];
+ },
+ access: function( owner, key, value ) {
+ var stored;
+ // In cases where either:
+ //
+ // 1. No key was specified
+ // 2. A string key was specified, but no value provided
+ //
+ // Take the "read" path and allow the get method to determine
+ // which value to return, respectively either:
+ //
+ // 1. The entire cache object
+ // 2. The data stored at the key
+ //
+ if ( key === undefined ||
+ ((key && typeof key === "string") && value === undefined) ) {
+
+ stored = this.get( owner, key );
+
+ return stored !== undefined ?
+ stored : this.get( owner, jQuery.camelCase(key) );
+ }
+
+ // [*]When the key is not a string, or both a key and value
+ // are specified, set or extend (existing objects) with either:
+ //
+ // 1. An object of properties
+ // 2. A key and value
+ //
+ this.set( owner, key, value );
+
+ // Since the "set" path can have two possible entry points
+ // return the expected data based on which path was taken[*]
+ return value !== undefined ? value : key;
+ },
+ remove: function( owner, key ) {
+ var i, name, camel,
+ unlock = this.key( owner ),
+ cache = this.cache[ unlock ];
+
+ if ( key === undefined ) {
+ this.cache[ unlock ] = {};
+
+ } else {
+ // Support array or space separated string of keys
+ if ( jQuery.isArray( key ) ) {
+ // If "name" is an array of keys...
+ // When data is initially created, via ("key", "val") signature,
+ // keys will be converted to camelCase.
+ // Since there is no way to tell _how_ a key was added, remove
+ // both plain key and camelCase key. #12786
+ // This will only penalize the array argument path.
+ name = key.concat( key.map( jQuery.camelCase ) );
+ } else {
+ camel = jQuery.camelCase( key );
+ // Try the string as a key before any manipulation
+ if ( key in cache ) {
+ name = [ key, camel ];
+ } else {
+ // If a key with the spaces exists, use it.
+ // Otherwise, create an array by matching non-whitespace
+ name = camel;
+ name = name in cache ?
+ [ name ] : ( name.match( rnotwhite ) || [] );
+ }
+ }
+
+ i = name.length;
+ while ( i-- ) {
+ delete cache[ name[ i ] ];
+ }
+ }
+ },
+ hasData: function( owner ) {
+ return !jQuery.isEmptyObject(
+ this.cache[ owner[ this.expando ] ] || {}
+ );
+ },
+ discard: function( owner ) {
+ if ( owner[ this.expando ] ) {
+ delete this.cache[ owner[ this.expando ] ];
+ }
+ }
+};
+
+return Data;
+});
diff --git a/src/data/accepts.js b/src/data/accepts.js
new file mode 100644
index 000000000..f3abe06af
--- /dev/null
+++ b/src/data/accepts.js
@@ -0,0 +1,20 @@
+define([
+ "../core"
+], function( jQuery ) {
+
+/**
+ * Determines whether an object can have data
+ */
+jQuery.acceptData = function( owner ) {
+ // Accepts only:
+ // - Node
+ // - Node.ELEMENT_NODE
+ // - Node.DOCUMENT_NODE
+ // - Object
+ // - Any
+ return owner.nodeType ?
+ owner.nodeType === 1 || owner.nodeType === 9 : true;
+};
+
+return jQuery.acceptData;
+});
diff --git a/src/data/var/data_priv.js b/src/data/var/data_priv.js
new file mode 100644
index 000000000..24399e468
--- /dev/null
+++ b/src/data/var/data_priv.js
@@ -0,0 +1,5 @@
+define([
+ "../Data"
+], function( Data ) {
+ return new Data();
+});
diff --git a/src/data/var/data_user.js b/src/data/var/data_user.js
new file mode 100644
index 000000000..24399e468
--- /dev/null
+++ b/src/data/var/data_user.js
@@ -0,0 +1,5 @@
+define([
+ "../Data"
+], function( Data ) {
+ return new Data();
+});
diff --git a/src/deferred.js b/src/deferred.js
index 3c0edc038..7ba164a8f 100644
--- a/src/deferred.js
+++ b/src/deferred.js
@@ -1,3 +1,9 @@
+define([
+ "./core",
+ "./var/slice",
+ "./callbacks"
+], function( jQuery, slice ) {
+
jQuery.extend({
Deferred: function( func ) {
@@ -89,7 +95,7 @@ jQuery.extend({
// Deferred helper
when: function( subordinate /* , ..., subordinateN */ ) {
var i = 0,
- resolveValues = core_slice.call( arguments ),
+ resolveValues = slice.call( arguments ),
length = resolveValues.length,
// the count of uncompleted subordinates
@@ -102,7 +108,7 @@ jQuery.extend({
updateFunc = function( i, contexts, values ) {
return function( value ) {
contexts[ i ] = this;
- values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
+ values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
if( values === progressValues ) {
deferred.notifyWith( contexts, values );
} else if ( !( --remaining ) ) {
@@ -138,3 +144,4 @@ jQuery.extend({
return deferred.promise();
}
});
+});
diff --git a/src/deprecated.js b/src/deprecated.js
index 40f8dd6cd..8a9ba1b4b 100644
--- a/src/deprecated.js
+++ b/src/deprecated.js
@@ -1,11 +1,11 @@
-// Limit scope pollution from any deprecated API
-// (function() {
-
+define([
+ "./core",
+ "./traversing"
+], function( jQuery ) {
// The number of elements contained in the matched element set
jQuery.fn.size = function() {
return this.length;
};
jQuery.fn.andSelf = jQuery.fn.addBack;
-
-// })();
+});
diff --git a/src/dimensions.js b/src/dimensions.js
index ae59fb05d..7fc766452 100644
--- a/src/dimensions.js
+++ b/src/dimensions.js
@@ -1,3 +1,7 @@
+define([
+ "./core",
+ "./css"
+], function( jQuery ) {
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
@@ -39,3 +43,4 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
};
});
});
+});
diff --git a/src/effects.js b/src/effects.js
index b0a9083e7..54905307d 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -1,6 +1,19 @@
+define([
+ "./core",
+ "./var/pnum",
+ "./css/var/cssExpand",
+ "./css/var/isHidden",
+ "./effects/Tween",
+ "./data/var/data_priv",
+ "./queue",
+ "./css",
+ "./deferred",
+ "./traversing"
+], function( jQuery, pnum, cssExpand, isHidden, Tween, data_priv ) {
+
var fxNow, timerId,
rfxtypes = /^(?:toggle|show|hide)$/,
- rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
+ rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
rrun = /queueHooks$/,
animationPrefilters = [ defaultPrefilter ],
tweeners = {
@@ -370,100 +383,6 @@ function defaultPrefilter( elem, props, opts ) {
}
}
-function Tween( elem, options, prop, end, easing ) {
- return new Tween.prototype.init( elem, options, prop, end, easing );
-}
-jQuery.Tween = Tween;
-
-Tween.prototype = {
- constructor: Tween,
- init: function( elem, options, prop, end, easing, unit ) {
- this.elem = elem;
- this.prop = prop;
- this.easing = easing || "swing";
- this.options = options;
- this.start = this.now = this.cur();
- this.end = end;
- this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
- },
- cur: function() {
- var hooks = Tween.propHooks[ this.prop ];
-
- return hooks && hooks.get ?
- hooks.get( this ) :
- Tween.propHooks._default.get( this );
- },
- run: function( percent ) {
- var eased,
- hooks = Tween.propHooks[ this.prop ];
-
- if ( this.options.duration ) {
- this.pos = eased = jQuery.easing[ this.easing ](
- percent, this.options.duration * percent, 0, 1, this.options.duration
- );
- } else {
- this.pos = eased = percent;
- }
- this.now = ( this.end - this.start ) * eased + this.start;
-
- if ( this.options.step ) {
- this.options.step.call( this.elem, this.now, this );
- }
-
- if ( hooks && hooks.set ) {
- hooks.set( this );
- } else {
- Tween.propHooks._default.set( this );
- }
- return this;
- }
-};
-
-Tween.prototype.init.prototype = Tween.prototype;
-
-Tween.propHooks = {
- _default: {
- get: function( tween ) {
- var result;
-
- if ( tween.elem[ tween.prop ] != null &&
- (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
- return tween.elem[ tween.prop ];
- }
-
- // passing an empty string as a 3rd parameter to .css will automatically
- // attempt a parseFloat and fallback to a string if the parse fails
- // so, simple values such as "10px" are parsed to Float.
- // complex values such as "rotate(1rad)" are returned as is.
- result = jQuery.css( tween.elem, tween.prop, "" );
- // Empty strings, null, undefined and "auto" are converted to 0.
- return !result || result === "auto" ? 0 : result;
- },
- set: function( tween ) {
- // use step hook for back compat - use cssHook if its there - use .style if its
- // available and use plain properties where available
- if ( jQuery.fx.step[ tween.prop ] ) {
- jQuery.fx.step[ tween.prop ]( tween );
- } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
- jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
- } else {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
- }
-};
-
-// Support: IE9
-// Panic based approach to setting things on disconnected nodes
-
-Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
- set: function( tween ) {
- if ( tween.elem.nodeType && tween.elem.parentNode ) {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
-};
-
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
var cssFn = jQuery.fn[ name ];
jQuery.fn[ name ] = function( speed, easing, callback ) {
@@ -660,17 +579,7 @@ jQuery.speed = function( speed, easing, fn ) {
return opt;
};
-jQuery.easing = {
- linear: function( p ) {
- return p;
- },
- swing: function( p ) {
- return 0.5 - Math.cos( p*Math.PI ) / 2;
- }
-};
-
jQuery.timers = [];
-jQuery.fx = Tween.prototype.init;
jQuery.fx.tick = function() {
var timer,
timers = jQuery.timers,
@@ -718,13 +627,5 @@ jQuery.fx.speeds = {
_default: 400
};
-// Back Compat <1.8 extension point
-jQuery.fx.step = {};
-if ( jQuery.expr && jQuery.expr.filters ) {
- jQuery.expr.filters.animated = function( elem ) {
- return jQuery.grep(jQuery.timers, function( fn ) {
- return elem === fn.elem;
- }).length;
- };
-}
+});
diff --git a/src/effects/Tween.js b/src/effects/Tween.js
new file mode 100644
index 000000000..582d42a8b
--- /dev/null
+++ b/src/effects/Tween.js
@@ -0,0 +1,114 @@
+define([
+ "../core",
+ "../css"
+], function( jQuery ) {
+
+function Tween( elem, options, prop, end, easing ) {
+ return new Tween.prototype.init( elem, options, prop, end, easing );
+}
+jQuery.Tween = Tween;
+
+Tween.prototype = {
+ constructor: Tween,
+ init: function( elem, options, prop, end, easing, unit ) {
+ this.elem = elem;
+ this.prop = prop;
+ this.easing = easing || "swing";
+ this.options = options;
+ this.start = this.now = this.cur();
+ this.end = end;
+ this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+ },
+ cur: function() {
+ var hooks = Tween.propHooks[ this.prop ];
+
+ return hooks && hooks.get ?
+ hooks.get( this ) :
+ Tween.propHooks._default.get( this );
+ },
+ run: function( percent ) {
+ var eased,
+ hooks = Tween.propHooks[ this.prop ];
+
+ if ( this.options.duration ) {
+ this.pos = eased = jQuery.easing[ this.easing ](
+ percent, this.options.duration * percent, 0, 1, this.options.duration
+ );
+ } else {
+ this.pos = eased = percent;
+ }
+ this.now = ( this.end - this.start ) * eased + this.start;
+
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ if ( hooks && hooks.set ) {
+ hooks.set( this );
+ } else {
+ Tween.propHooks._default.set( this );
+ }
+ return this;
+ }
+};
+
+Tween.prototype.init.prototype = Tween.prototype;
+
+Tween.propHooks = {
+ _default: {
+ get: function( tween ) {
+ var result;
+
+ if ( tween.elem[ tween.prop ] != null &&
+ (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
+ return tween.elem[ tween.prop ];
+ }
+
+ // passing an empty string as a 3rd parameter to .css will automatically
+ // attempt a parseFloat and fallback to a string if the parse fails
+ // so, simple values such as "10px" are parsed to Float.
+ // complex values such as "rotate(1rad)" are returned as is.
+ result = jQuery.css( tween.elem, tween.prop, "" );
+ // Empty strings, null, undefined and "auto" are converted to 0.
+ return !result || result === "auto" ? 0 : result;
+ },
+ set: function( tween ) {
+ // use step hook for back compat - use cssHook if its there - use .style if its
+ // available and use plain properties where available
+ if ( jQuery.fx.step[ tween.prop ] ) {
+ jQuery.fx.step[ tween.prop ]( tween );
+ } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
+ } else {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+ }
+};
+
+// Support: IE9
+// Panic based approach to setting things on disconnected nodes
+
+Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+ set: function( tween ) {
+ if ( tween.elem.nodeType && tween.elem.parentNode ) {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+};
+
+jQuery.easing = {
+ linear: function( p ) {
+ return p;
+ },
+ swing: function( p ) {
+ return 0.5 - Math.cos( p*Math.PI ) / 2;
+ }
+};
+
+jQuery.fx = Tween.prototype.init;
+
+// Back Compat <1.8 extension point
+jQuery.fx.step = {};
+
+});
diff --git a/src/effects/animated-selector.js b/src/effects/animated-selector.js
new file mode 100644
index 000000000..290e32bfa
--- /dev/null
+++ b/src/effects/animated-selector.js
@@ -0,0 +1,11 @@
+define([
+ "../core",
+ "../selector",
+ "../effects",
+], function( jQuery ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}); \ No newline at end of file
diff --git a/src/event.js b/src/event.js
index 9262d1d6d..cd468d2a3 100644
--- a/src/event.js
+++ b/src/event.js
@@ -1,3 +1,15 @@
+define([
+ "./core",
+ "./var/strundefined",
+ "./var/rnotwhite",
+ "./var/hasOwn",
+ "./var/slice",
+ "./data/var/data_priv",
+ "./data/accepts",
+ "./selector",
+ "./support"
+], function( jQuery, strundefined, rnotwhite, hasOwn, slice, data_priv ) {
+
var rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
@@ -57,7 +69,7 @@ jQuery.event = {
eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
- return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
+ return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
undefined;
};
@@ -66,7 +78,7 @@ jQuery.event = {
}
// Handle multiple events separated by a space
- types = ( types || "" ).match( core_rnotwhite ) || [""];
+ types = ( types || "" ).match( rnotwhite ) || [""];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || [];
@@ -148,7 +160,7 @@ jQuery.event = {
}
// Once for each type.namespace in types; type may be omitted
- types = ( types || "" ).match( core_rnotwhite ) || [""];
+ types = ( types || "" ).match( rnotwhite ) || [""];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || [];
@@ -210,8 +222,8 @@ jQuery.event = {
var i, cur, tmp, bubbleType, ontype, handle, special,
eventPath = [ elem || document ],
- type = core_hasOwn.call( event, "type" ) ? event.type : event,
- namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
+ type = hasOwn.call( event, "type" ) ? event.type : event,
+ namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
cur = tmp = elem = elem || document;
@@ -342,7 +354,7 @@ jQuery.event = {
var i, j, ret, matched, handleObj,
handlerQueue = [],
- args = core_slice.call( arguments ),
+ args = slice.call( arguments ),
handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
special = jQuery.event.special[ event.type ] || {};
@@ -827,3 +839,5 @@ jQuery.fn.extend({
}
}
});
+
+});
diff --git a/src/event-alias.js b/src/event/alias.js
index b1a15e840..7e7917508 100644
--- a/src/event-alias.js
+++ b/src/event/alias.js
@@ -1,3 +1,8 @@
+define([
+ "../core",
+ "../event"
+], function( jQuery ) {
+
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
@@ -30,3 +35,5 @@ jQuery.fn.extend({
return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
}
});
+
+});
diff --git a/src/exports/amd.js b/src/exports/amd.js
new file mode 100644
index 000000000..abd874e81
--- /dev/null
+++ b/src/exports/amd.js
@@ -0,0 +1,12 @@
+// Register as a named AMD module, since jQuery can be concatenated with other
+// files that may use define, but not via a proper concatenation script that
+// understands anonymous AMD modules. A named AMD is safest and most robust
+// way to register. Lowercase jquery is used because AMD module names are
+// derived from file names, and jQuery is normally delivered in a lowercase
+// file name. Do this after creating the global so that if an AMD module wants
+// to call noConflict to hide this version of jQuery, it will work.
+if ( typeof define === "function" && define.amd ) {
+ define( "jquery", [], function() {
+ return jQuery;
+ });
+} \ No newline at end of file
diff --git a/src/intro.js b/src/intro.js
index 1d1640aa3..c39d37b34 100644
--- a/src/intro.js
+++ b/src/intro.js
@@ -27,21 +27,7 @@
return factory( w );
};
} else {
- // Execute the factory to produce jQuery
- var jQuery = factory( window );
-
- // Register as a named AMD module, since jQuery can be concatenated with other
- // files that may use define, but not via a proper concatenation script that
- // understands anonymous AMD modules. A named AMD is safest and most robust
- // way to register. Lowercase jquery is used because AMD module names are
- // derived from file names, and jQuery is normally delivered in a lowercase
- // file name. Do this after creating the global so that if an AMD module wants
- // to call noConflict to hide this version of jQuery, it will work.
- if ( typeof define === "function" && define.amd ) {
- define( "jquery", [], function() {
- return jQuery;
- });
- }
+ factory( window );
}
// Pass this, window may not be defined yet
diff --git a/src/jquery.js b/src/jquery.js
new file mode 100644
index 000000000..ce3ad8e2f
--- /dev/null
+++ b/src/jquery.js
@@ -0,0 +1,38 @@
+define([
+ "./core",
+ "./selector",
+ "./callbacks",
+ "./deferred",
+ "./core/ready",
+ "./traversing",
+ "./data",
+ "./queue",
+ "./queue/delay",
+ "./attributes",
+ "./event",
+ "./event/alias",
+ "./manipulation",
+ "./manipulation/_evalUrl",
+ "./wrap",
+ "./css",
+ "./css/hidden-visible-selectors",
+ "./serialize",
+ "./ajax",
+ "./ajax/xhr",
+ "./ajax/script",
+ "./ajax/jsonp",
+ "./ajax/load",
+ "./effects",
+ "./effects/animated-selector",
+ "./offset",
+ "./dimensions",
+ "./support",
+ "./deprecated"
+], function( jQuery ) {
+
+// Expose jQuery and $ identifiers, even in
+// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
+// and CommonJS for browser emulators (#13566)
+return (window.jQuery = window.$ = jQuery);
+
+});
diff --git a/src/manipulation.js b/src/manipulation.js
index 19494ae2d..8eabb1979 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -1,8 +1,20 @@
+define([
+ "./core",
+ "./var/concat",
+ "./var/push",
+ "./manipulation/var/rcheckableType",
+ "./data/var/data_priv",
+ "./data/var/data_user",
+ "./data/accepts",
+ "./selector",
+ "./traversing",
+ "./event"
+], function( jQuery, concat, push, rcheckableType, data_priv, data_user ){
+
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
rtagName = /<([\w:]+)/,
rhtml = /<|&#?\w+;/,
rnoInnerhtml = /<(?:script|style|link)/i,
- manipulation_rcheckableType = /^(?:checkbox|radio)$/i,
// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptType = /^$|\/(?:java|ecma)script/i,
@@ -72,8 +84,7 @@ jQuery.fn.extend({
});
},
- // keepData is for internal use only--do not document
- remove: function( selector, keepData ) {
+ remove: function( selector, keepData /* Internal Use Only */ ) {
var elem,
elems = selector ? jQuery.filter( selector, this ) : this,
i = 0;
@@ -195,7 +206,7 @@ jQuery.fn.extend({
domManip: function( args, callback, allowIntersection ) {
// Flatten any nested arrays
- args = core_concat.apply( [], args );
+ args = concat.apply( [], args );
var fragment, first, scripts, hasScripts, node, doc,
i = 0,
@@ -239,7 +250,7 @@ jQuery.fn.extend({
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
// Support: QtWebKit
- // jQuery.merge because core_push.apply(_, arraylike) throws
+ // jQuery.merge because push.apply(_, arraylike) throws
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
@@ -260,8 +271,10 @@ jQuery.fn.extend({
!data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
if ( node.src ) {
- // Hope ajax is available...
- jQuery._evalUrl( node.src );
+ // Optional AJAX dependency, but won't run scripts if not present
+ if ( jQuery._evalUrl ) {
+ jQuery._evalUrl( node.src );
+ }
} else {
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
}
@@ -294,8 +307,8 @@ jQuery.each({
jQuery( insert[ i ] )[ original ]( elems );
// Support: QtWebKit
- // .get() because core_push.apply(_, arraylike) throws
- core_push.apply( ret, elems.get() );
+ // .get() because push.apply(_, arraylike) throws
+ push.apply( ret, elems.get() );
}
return this.pushStack( ret );
@@ -360,7 +373,7 @@ jQuery.extend({
// Add nodes directly
if ( jQuery.type( elem ) === "object" ) {
// Support: QtWebKit
- // jQuery.merge because core_push.apply(_, arraylike) throws
+ // jQuery.merge because push.apply(_, arraylike) throws
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node
@@ -383,7 +396,7 @@ jQuery.extend({
}
// Support: QtWebKit
- // jQuery.merge because core_push.apply(_, arraylike) throws
+ // jQuery.merge because push.apply(_, arraylike) throws
jQuery.merge( nodes, tmp.childNodes );
// Remember the top-level container
@@ -438,7 +451,7 @@ jQuery.extend({
i = 0;
for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
- if ( Data.accepts( elem ) ) {
+ if ( jQuery.acceptData( elem ) ) {
key = elem[ data_priv.expando ];
if ( key && (data = data_priv.cache[ key ]) ) {
@@ -463,17 +476,6 @@ jQuery.extend({
// Discard any remaining `user` data
delete data_user.cache[ elem[ data_user.expando ] ];
}
- },
-
- _evalUrl: function( url ) {
- return jQuery.ajax({
- url: url,
- type: "GET",
- dataType: "script",
- async: false,
- global: false,
- "throws": true
- });
}
});
@@ -567,7 +569,7 @@ function fixInput( src, dest ) {
var nodeName = dest.nodeName.toLowerCase();
// Fails to persist the checked state of a cloned checkbox or radio button.
- if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
+ if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
dest.checked = src.checked;
// Fails to return the selected option to the default selected state when cloning options
@@ -575,3 +577,4 @@ function fixInput( src, dest ) {
dest.defaultValue = src.defaultValue;
}
}
+});
diff --git a/src/manipulation/_evalUrl.js b/src/manipulation/_evalUrl.js
new file mode 100644
index 000000000..42ec67834
--- /dev/null
+++ b/src/manipulation/_evalUrl.js
@@ -0,0 +1,16 @@
+define([
+ "../ajax"
+], function( jQuery ) {
+ jQuery._evalUrl = function( url ) {
+ return jQuery.ajax({
+ url: url,
+ type: "GET",
+ dataType: "script",
+ async: false,
+ global: false,
+ "throws": true
+ });
+ };
+
+ return jQuery._evalUrl;
+});
diff --git a/src/manipulation/var/rcheckableType.js b/src/manipulation/var/rcheckableType.js
new file mode 100644
index 000000000..29049b3ae
--- /dev/null
+++ b/src/manipulation/var/rcheckableType.js
@@ -0,0 +1,3 @@
+define(function() {
+ return /^(?:checkbox|radio)$/i;
+}); \ No newline at end of file
diff --git a/src/offset.js b/src/offset.js
index b616a49a0..60ceb41ff 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -1,3 +1,12 @@
+define([
+ "./core",
+ "./var/strundefined",
+ "./css",
+ "./selector"
+], function( jQuery, strundefined ) {
+
+var docElem = window.document.documentElement;
+
jQuery.fn.offset = function( options ) {
if ( arguments.length ) {
return options === undefined ?
@@ -25,7 +34,7 @@ jQuery.fn.offset = function( options ) {
// If we don't have gBCR, just use 0,0 rather than error
// BlackBerry 5, iOS 3 (original iPhone)
- if ( typeof elem.getBoundingClientRect !== core_strundefined ) {
+ if ( typeof elem.getBoundingClientRect !== strundefined ) {
box = elem.getBoundingClientRect();
}
win = getWindow( doc );
@@ -136,6 +145,12 @@ jQuery.fn.extend({
}
});
+/**
+ * Gets a window from an element
+ */
+function getWindow( elem ) {
+ return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
+}
// Create scrollLeft and scrollTop methods
jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
@@ -162,6 +177,4 @@ jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( me
};
});
-function getWindow( elem ) {
- return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
-}
+});
diff --git a/src/outro.js b/src/outro.js
index 20cec437c..57d3e4820 100644
--- a/src/outro.js
+++ b/src/outro.js
@@ -1,6 +1 @@
-// Expose jQuery and $ identifiers, even in
-// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
-// and CommonJS for browser emulators (#13566)
-return (window.jQuery = window.$ = jQuery);
-
-}));
+})); \ No newline at end of file
diff --git a/src/queue.js b/src/queue.js
index 1297bc1b4..62f08bf01 100644
--- a/src/queue.js
+++ b/src/queue.js
@@ -1,3 +1,10 @@
+define([
+ "./core",
+ "./data/var/data_priv",
+ "./deferred",
+ "./callbacks"
+], function( jQuery, data_priv ) {
+
jQuery.extend({
queue: function( elem, type, data ) {
var queue;
@@ -96,19 +103,6 @@ jQuery.fn.extend({
jQuery.dequeue( this, type );
});
},
- // Based off of the plugin by Clint Helfers, with permission.
- // http://blindsignals.com/index.php/2009/07/jquery-delay/
- delay: function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
- type = type || "fx";
-
- return this.queue( type, function( next, hooks ) {
- var timeout = setTimeout( next, time );
- hooks.stop = function() {
- clearTimeout( timeout );
- };
- });
- },
clearQueue: function( type ) {
return this.queue( type || "fx", [] );
},
@@ -143,3 +137,5 @@ jQuery.fn.extend({
return defer.promise( obj );
}
});
+
+});
diff --git a/src/queue/delay.js b/src/queue/delay.js
new file mode 100644
index 000000000..4b4498cea
--- /dev/null
+++ b/src/queue/delay.js
@@ -0,0 +1,22 @@
+define([
+ "../core",
+ "../queue",
+ "../effects" // Delay is optional because of this dependency
+], function( jQuery ) {
+
+// Based off of the plugin by Clint Helfers, with permission.
+// http://blindsignals.com/index.php/2009/07/jquery-delay/
+jQuery.fn.delay = function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function( next, hooks ) {
+ var timeout = setTimeout( next, time );
+ hooks.stop = function() {
+ clearTimeout( timeout );
+ };
+ });
+};
+
+return jQuery.fn.delay;
+});
diff --git a/src/selector-native.js b/src/selector-native.js
index 58a0cec41..cec99cef2 100644
--- a/src/selector-native.js
+++ b/src/selector-native.js
@@ -1,3 +1,7 @@
+define([
+ "./core"
+], function( jQuery ) {
+
/*
* Optional (non-Sizzle) selector module for custom builds.
*
@@ -23,7 +27,8 @@
* customize this stub for the project's specific needs.
*/
-var selector_hasDuplicate,
+var docElem = window.document.documentElement,
+ selector_hasDuplicate,
matches = docElem.webkitMatchesSelector ||
docElem.mozMatchesSelector ||
docElem.oMatchesSelector ||
@@ -162,3 +167,5 @@ jQuery.extend( jQuery.find, {
return elem.getAttribute( name );
}
});
+
+});
diff --git a/src/sizzle-jquery.js b/src/selector-sizzle.js
index fa3196543..a2f4787fe 100644
--- a/src/sizzle-jquery.js
+++ b/src/selector-sizzle.js
@@ -1,3 +1,8 @@
+define([
+ "./core",
+ "../bower_components/sizzle/dist/sizzle"
+], function ( jQuery, Sizzle ) {
+
jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors;
jQuery.expr[":"] = jQuery.expr.pseudos;
@@ -5,3 +10,5 @@ jQuery.unique = Sizzle.uniqueSort;
jQuery.text = Sizzle.getText;
jQuery.isXMLDoc = Sizzle.isXML;
jQuery.contains = Sizzle.contains;
+
+});
diff --git a/src/selector.js b/src/selector.js
new file mode 100644
index 000000000..f47632b87
--- /dev/null
+++ b/src/selector.js
@@ -0,0 +1 @@
+define([ "./selector-sizzle" ]); \ No newline at end of file
diff --git a/src/serialize.js b/src/serialize.js
index 65dee4005..369f63e74 100644
--- a/src/serialize.js
+++ b/src/serialize.js
@@ -1,3 +1,10 @@
+define([
+ "./core",
+ "./manipulation/var/rcheckableType",
+ "./traversing", // filter
+ "./attributes/prop"
+], function( jQuery, rcheckableType ) {
+
var r20 = /%20/g,
rbracket = /\[\]$/,
rCRLF = /\r?\n/g,
@@ -19,7 +26,7 @@ jQuery.fn.extend({
// Use .is(":disabled") so that fieldset[disabled] works
return this.name && !jQuery( this ).is( ":disabled" ) &&
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
- ( this.checked || !manipulation_rcheckableType.test( type ) );
+ ( this.checked || !rcheckableType.test( type ) );
})
.map(function( i, elem ){
var val = jQuery( this ).val();
@@ -35,8 +42,8 @@ jQuery.fn.extend({
}
});
-//Serialize an array of form elements or a set of
-//key/values into a query string
+// Serialize an array of form elements or a set of
+// key/values into a query string
jQuery.param = function( a, traditional ) {
var prefix,
s = [],
@@ -97,3 +104,4 @@ function buildParams( prefix, obj, traditional, add ) {
add( prefix, obj );
}
}
+});
diff --git a/src/support.js b/src/support.js
index e46588dd1..a02e97d2e 100644
--- a/src/support.js
+++ b/src/support.js
@@ -1,3 +1,8 @@
+define([
+ "./core",
+ "./core/swap"
+], function( jQuery ) {
+
jQuery.support = (function( support ) {
var input = document.createElement("input"),
fragment = document.createDocumentFragment(),
@@ -111,3 +116,4 @@ jQuery.support = (function( support ) {
return support;
})( {} );
+});
diff --git a/src/traversing.js b/src/traversing.js
index 8e305c289..94378a597 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -1,3 +1,8 @@
+define([
+ "./core",
+ "./var/indexOf",
+ "./selector"
+], function( jQuery, indexOf ) {
var isSimple = /^.[^:#\[\.,]*$/,
rparentsprev = /^(?:parents|prev(?:Until|All))/,
rneedsContext = jQuery.expr.match.needsContext,
@@ -110,11 +115,11 @@ jQuery.fn.extend({
// index in selector
if ( typeof elem === "string" ) {
- return core_indexOf.call( jQuery( elem ), this[ 0 ] );
+ return indexOf.call( jQuery( elem ), this[ 0 ] );
}
// Locate the position of the desired element
- return core_indexOf.call( this,
+ return indexOf.call( this,
// If it receives a jQuery object, the first element is used
elem.jquery ? elem[ 0 ] : elem
@@ -278,6 +283,7 @@ function winnow( elements, qualifier, not ) {
}
return jQuery.grep( elements, function( elem ) {
- return ( core_indexOf.call( qualifier, elem ) >= 0 ) !== not;
+ return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
});
}
+});
diff --git a/src/var/arr.js b/src/var/arr.js
new file mode 100644
index 000000000..39efc6a70
--- /dev/null
+++ b/src/var/arr.js
@@ -0,0 +1,3 @@
+define(function() {
+ return [];
+}); \ No newline at end of file
diff --git a/src/var/class2type.js b/src/var/class2type.js
new file mode 100644
index 000000000..d31b7afcd
--- /dev/null
+++ b/src/var/class2type.js
@@ -0,0 +1,3 @@
+define(function() {
+ return {};
+}); \ No newline at end of file
diff --git a/src/var/concat.js b/src/var/concat.js
new file mode 100644
index 000000000..c95cff5ca
--- /dev/null
+++ b/src/var/concat.js
@@ -0,0 +1,5 @@
+define([
+ "./arr"
+], function( arr ) {
+ return arr.concat;
+}); \ No newline at end of file
diff --git a/src/var/hasOwn.js b/src/var/hasOwn.js
new file mode 100644
index 000000000..2fd59e1f7
--- /dev/null
+++ b/src/var/hasOwn.js
@@ -0,0 +1,5 @@
+define([
+ "./class2type"
+], function( class2type ) {
+ return class2type.hasOwnProperty;
+}); \ No newline at end of file
diff --git a/src/var/indexOf.js b/src/var/indexOf.js
new file mode 100644
index 000000000..8909c1948
--- /dev/null
+++ b/src/var/indexOf.js
@@ -0,0 +1,5 @@
+define([
+ "./arr"
+], function( arr ) {
+ return arr.indexOf;
+}); \ No newline at end of file
diff --git a/src/var/pnum.js b/src/var/pnum.js
new file mode 100644
index 000000000..d1af1e67b
--- /dev/null
+++ b/src/var/pnum.js
@@ -0,0 +1,3 @@
+define(function() {
+ return /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source;
+}); \ No newline at end of file
diff --git a/src/var/push.js b/src/var/push.js
new file mode 100644
index 000000000..bc38c7ed7
--- /dev/null
+++ b/src/var/push.js
@@ -0,0 +1,5 @@
+define([
+ "./arr"
+], function( arr ) {
+ return arr.push;
+}); \ No newline at end of file
diff --git a/src/var/rnotwhite.js b/src/var/rnotwhite.js
new file mode 100644
index 000000000..887c82985
--- /dev/null
+++ b/src/var/rnotwhite.js
@@ -0,0 +1,3 @@
+define(function() {
+ return /\S+/g;
+}); \ No newline at end of file
diff --git a/src/var/slice.js b/src/var/slice.js
new file mode 100644
index 000000000..08503fac2
--- /dev/null
+++ b/src/var/slice.js
@@ -0,0 +1,5 @@
+define([
+ "./arr"
+], function( arr ) {
+ return arr.slice;
+}); \ No newline at end of file
diff --git a/src/var/strundefined.js b/src/var/strundefined.js
new file mode 100644
index 000000000..99a26f44a
--- /dev/null
+++ b/src/var/strundefined.js
@@ -0,0 +1,3 @@
+define(function() {
+ return typeof undefined;
+}); \ No newline at end of file
diff --git a/src/var/toString.js b/src/var/toString.js
new file mode 100644
index 000000000..db39811b6
--- /dev/null
+++ b/src/var/toString.js
@@ -0,0 +1,5 @@
+define([
+ "./class2type"
+], function( class2type ) {
+ return class2type.toString;
+}); \ No newline at end of file
diff --git a/src/var/trim.js b/src/var/trim.js
new file mode 100644
index 000000000..e5d414aca
--- /dev/null
+++ b/src/var/trim.js
@@ -0,0 +1,3 @@
+define(function() {
+ return "".trim;
+}); \ No newline at end of file
diff --git a/src/wrap.js b/src/wrap.js
index 5968adbc6..1859dca11 100644
--- a/src/wrap.js
+++ b/src/wrap.js
@@ -1,3 +1,7 @@
+define([
+ "./core",
+ "./traversing" // parent, contents
+], function( jQuery ) {
jQuery.fn.extend({
wrapAll: function( html ) {
var wrap;
@@ -67,3 +71,4 @@ jQuery.fn.extend({
}).end();
}
});
+});