Skip to content
Permalink
Browse files

Follow the style guide, lose 72 bytes! Closes gh-840.

  • Loading branch information
mikesherov authored and dmethvin committed Jul 10, 2012
1 parent f30f773 commit 8f01b92b8fd85a66f2cba671f8b9ff6f7095c34b
Showing with 147 additions and 135 deletions.
  1. +39 −42 src/ajax.js
  2. +5 −6 src/ajax/xhr.js
  3. +5 −4 src/attributes.js
  4. +5 −5 src/callbacks.js
  5. +31 −21 src/core.js
  6. +8 −15 src/css.js
  7. +2 −1 src/data.js
  8. +5 −8 src/dimensions.js
  9. +2 −2 src/effects.js
  10. +15 −14 src/event.js
  11. +16 −7 src/manipulation.js
  12. +14 −10 src/traversing.js
@@ -1,4 +1,9 @@
var r20 = /%20/g,
var // Document location
ajaxLocation,
// Document location segments
ajaxLocParts,

r20 = /%20/g,
rbracket = /\[\]$/,
rCRLF = /\r?\n/g,
rhash = /#.*$/,
@@ -35,12 +40,6 @@ var r20 = /%20/g,
*/
transports = {},

// Document location
ajaxLocation,

// Document location segments
ajaxLocParts,

// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
allTypes = ["*/"] + ["*"];

@@ -70,14 +69,12 @@ function addToPrefiltersOrTransports( structure ) {
dataTypeExpression = "*";
}

if ( jQuery.isFunction( func ) ) {
var dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
i = 0,
length = dataTypes.length,
dataType,
list,
placeBefore;
var dataType, list, placeBefore,
dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
i = 0,
length = dataTypes.length;

if ( jQuery.isFunction( func ) ) {
// For each dataType in the dataTypeExpression
for ( ; i < length; i++ ) {
dataType = dataTypes[ i ];
@@ -104,11 +101,11 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX

inspected[ dataType ] = true;

var list = structure[ dataType ],
var selection,
list = structure[ dataType ],
i = 0,
length = list ? list.length : 0,
executeOnly = ( structure === prefilters ),
selection;
executeOnly = ( structure === prefilters );

for ( ; i < length && ( executeOnly || !selection ); i++ ) {
selection = list[ i ]( options, originalOptions, jqXHR );
@@ -383,7 +380,22 @@ jQuery.extend({
// Force options to be an object
options = options || {};

var // Create the final options object
var // ifModified key
ifModifiedKey,
// Response headers
responseHeadersString,
responseHeaders,
// transport
transport,
// timeout handle
timeoutTimer,
// Cross-domain detection vars
parts,
// To know if global events are to be dispatched
fireGlobals,
// Loop variable
i,
// Create the final options object
s = jQuery.ajaxSetup( {}, options ),
// Callbacks context
callbackContext = s.context || s,
@@ -398,26 +410,11 @@ jQuery.extend({
completeDeferred = jQuery.Callbacks( "once memory" ),
// Status-dependent callbacks
statusCode = s.statusCode || {},
// ifModified key
ifModifiedKey,
// Headers (they are sent all at once)
requestHeaders = {},
requestHeadersNames = {},
// Response headers
responseHeadersString,
responseHeaders,
// transport
transport,
// timeout handle
timeoutTimer,
// Cross-domain detection vars
parts,
// The jqXHR state
state = 0,
// To know if global events are to be dispatched
fireGlobals,
// Loop variable
i,
// Default abort message
strAbort = "canceled",
// Fake xhr
@@ -759,7 +756,8 @@ jQuery.extend({
// Serialize an array of form elements or a set of
// key/values into a query string
param: function( a, traditional ) {
var s = [],
var prefix,
s = [],
add = function( key, value ) {
// If value is a function, invoke it and return its value
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
@@ -781,7 +779,7 @@ jQuery.extend({
} else {
// If traditional, encode the "old" way (the way 1.3.2 or older
// did it), otherwise encode params recursively.
for ( var prefix in a ) {
for ( prefix in a ) {
buildParams( prefix, a[ prefix ], traditional, add );
}
}
@@ -792,6 +790,8 @@ jQuery.extend({
});

function buildParams( prefix, obj, traditional, add ) {
var name;

if ( jQuery.isArray( obj ) ) {
// Serialize array item.
jQuery.each( obj, function( i, v ) {
@@ -813,7 +813,7 @@ function buildParams( prefix, obj, traditional, add ) {

} else if ( !traditional && jQuery.type( obj ) === "object" ) {
// Serialize object item.
for ( var name in obj ) {
for ( name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
}

@@ -843,13 +843,10 @@ jQuery.extend({
*/
function ajaxHandleResponses( s, jqXHR, responses ) {

var contents = s.contents,
var ct, type, finalDataType, firstDataType,
contents = s.contents,
dataTypes = s.dataTypes,
responseFields = s.responseFields,
ct,
type,
finalDataType,
firstDataType;
responseFields = s.responseFields;

// Fill responseXXX fields
for ( type in responseFields ) {
@@ -1,12 +1,12 @@
var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
var xhrCallbacks,
// #5280: Internet Explorer will keep connections alive if we don't abort on unload
xhrOnUnloadAbort = window.ActiveXObject ? function() {
// Abort all pending requests
for ( var key in xhrCallbacks ) {
xhrCallbacks[ key ]( 0, 1 );
}
} : false,
xhrId = 0,
xhrCallbacks;
xhrId = 0;

// Functions to create xhrs
function createStandardXHR() {
@@ -57,9 +57,8 @@ if ( jQuery.support.ajax ) {
send: function( headers, complete ) {

// Get a new xhr
var xhr = s.xhr(),
handle,
i;
var handle, i,
xhr = s.xhr();

// Open the socket
// Passing null username, generates a login popup on Opera (#2865)
@@ -1,11 +1,11 @@
var rclass = /[\n\t\r]/g,
var nodeHook, boolHook, fixSpecified,
rclass = /[\n\t\r]/g,
rreturn = /\r/g,
rtype = /^(?:button|input)$/i,
rfocusable = /^(?:button|input|object|select|textarea)$/i,
rclickable = /^a(?:rea)?$/i,
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
getSetAttribute = jQuery.support.getSetAttribute,
nodeHook, boolHook, fixSpecified;
getSetAttribute = jQuery.support.getSetAttribute;

jQuery.fn.extend({
attr: function( name, value ) {
@@ -179,7 +179,8 @@ jQuery.fn.extend({
isFunction = jQuery.isFunction( value );

return this.each(function( i ) {
var self = jQuery(this), val;
var val,
self = jQuery(this);

if ( this.nodeType !== 1 ) {
return;
@@ -40,11 +40,7 @@ jQuery.Callbacks = function( options ) {
( optionsCache[ options ] || createOptions( options ) ) :
jQuery.extend( {}, options );

var // Actual callback list
list = [],
// Stack of fire calls for repeatable lists
stack = !options.once && [],
// Last fire value (for non-forgettable lists)
var // Last fire value (for non-forgettable lists)
memory,
// Flag to know if list was already fired
fired,
@@ -56,6 +52,10 @@ jQuery.Callbacks = function( options ) {
firingLength,
// Index of currently firing callback (modified by remove if needed)
firingIndex,
// Actual callback list
list = [],
// Stack of fire calls for repeatable lists
stack = !options.once && [],
// Fire callbacks
fire = function( data ) {
memory = options.memory && data;
@@ -1,4 +1,10 @@
var
// A central reference to the root jQuery(document)
rootjQuery,

// The deferred used on DOM ready
readyList,

// Use the correct document accordingly with window argument (sandbox)
document = window.document,
location = window.location,
@@ -24,12 +30,6 @@ var
return new jQuery.fn.init( selector, context, rootjQuery );
},

// A central reference to the root jQuery(document)
rootjQuery,

// The deferred used on DOM ready
readyList,

// Used for detecting and trimming whitespace
core_rnotwhite = /\S/,
core_rspace = /\s+/,
@@ -449,7 +449,8 @@ jQuery.extend({
},

isEmptyObject: function( obj ) {
for ( var name in obj ) {
var name;
for ( name in obj ) {
return false;
}
return true;
@@ -560,7 +561,8 @@ jQuery.extend({

// args is for internal usage only
each: function( obj, callback, args ) {
var name, i = 0,
var name,
i = 0,
length = obj.length,
isObj = length === undefined || jQuery.isFunction( obj );

@@ -616,12 +618,13 @@ jQuery.extend({

// results is for internal usage only
makeArray: function( arr, results ) {
var ret = results || [];
var type,
ret = results || [];

if ( arr != null ) {
// The window, strings (and functions) also have 'length'
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
var type = jQuery.type( arr );
type = jQuery.type( arr );

if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
core_push.call( ret, arr );
@@ -656,11 +659,12 @@ jQuery.extend({
},

merge: function( first, second ) {
var i = first.length,
var l = second.length,
i = first.length,
j = 0;

if ( typeof second.length === "number" ) {
for ( var l = second.length; j < l; j++ ) {
if ( typeof l === "number" ) {
for ( ; j < l; j++ ) {
first[ i++ ] = second[ j ];
}

@@ -676,12 +680,15 @@ jQuery.extend({
},

grep: function( elems, callback, inv ) {
var ret = [], retVal;
var retVal,
ret = [],
i = 0,
length = elems.length;
inv = !!inv;

// Go through the array, only saving the items
// that pass the validator function
for ( var i = 0, length = elems.length; i < length; i++ ) {
for ( ; i < length; i++ ) {
retVal = !!callback( elems[ i ], i );
if ( inv !== retVal ) {
ret.push( elems[ i ] );
@@ -693,7 +700,8 @@ jQuery.extend({

// arg is for internal usage only
map: function( elems, callback, arg ) {
var value, key, ret = [],
var value, key,
ret = [],
i = 0,
length = elems.length,
// jquery objects are treated as arrays
@@ -730,8 +738,10 @@ jQuery.extend({
// Bind a function to a context, optionally partially applying any
// arguments.
proxy: function( fn, context ) {
var tmp, args, proxy;

if ( typeof context === "string" ) {
var tmp = fn[ context ];
tmp = fn[ context ];
context = fn;
fn = tmp;
}
@@ -743,10 +753,10 @@ jQuery.extend({
}

// Simulated bind
var args = core_slice.call( arguments, 2 ),
proxy = function() {
return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
};
args = core_slice.call( arguments, 2 );
proxy = function() {
return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
};

// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;

0 comments on commit 8f01b92

Please sign in to comment.
You can’t perform that action at this time.