Skip to content
Permalink
Browse files

Made a number of spacing changes to bring the code more-inline with t…

…he jQuery Core Style Guideline.
  • Loading branch information
jeresig committed Dec 22, 2009
1 parent 36c99dc commit 61e37d41490aed319a176c6ca7feb95e5505059c
Showing with 218 additions and 130 deletions.
  1. +27 −23 src/ajax.js
  2. +7 −5 src/attributes.js
  3. +7 −4 src/core.js
  4. +9 −3 src/css.js
  5. +4 −4 src/data.js
  6. +3 −3 src/dimensions.js
  7. +14 −14 src/effects.js
  8. +20 −9 src/event.js
  9. +1 −1 src/intro.js
  10. +22 −20 src/manipulation.js
  11. +32 −11 src/offset.js
  12. +23 −11 src/queue.js
  13. +4 −4 src/support.js
  14. +45 −18 src/traversing.js
@@ -52,7 +52,7 @@ jQuery.fn.extend({
dataType: "html",
data: params,
context:this,
complete: function(res, status){
complete: function( res, status ) {
// If successful, inject the HTML into all the matched elements
if ( status === "success" || status === "notmodified" ) {
// See if a selector was specified
@@ -83,31 +83,31 @@ jQuery.fn.extend({
return jQuery.param(this.serializeArray());
},
serializeArray: function() {
return this.map(function(){
return this.map(function() {
return this.elements ? jQuery.makeArray(this.elements) : this;
})
.filter(function(){
.filter(function() {
return this.name && !this.disabled &&
(this.checked || rselectTextarea.test(this.nodeName) ||
rinput.test(this.type));
})
.map(function(i, elem){
.map(function( i, elem ) {
var val = jQuery(this).val();

return val == null ?
null :
jQuery.isArray(val) ?
jQuery.map( val, function(val, i){
return {name: elem.name, value: val};
jQuery.map( val, function( val, i ) {
return { name: elem.name, value: val };
}) :
{name: elem.name, value: val};
{ name: elem.name, value: val };
}).get();
}
});

// Attach a bunch of functions for handling common AJAX events
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function(i,o){
jQuery.fn[o] = function(f){
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
jQuery.fn[o] = function( f ) {
return this.bind(o, f);
};
});
@@ -176,7 +176,7 @@ jQuery.extend({
// Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
// This function can be overriden by calling jQuery.ajaxSetup
xhr: function(){
xhr: function() {
return window.ActiveXObject ?
new ActiveXObject("Microsoft.XMLHTTP") :
new XMLHttpRequest();
@@ -235,13 +235,17 @@ jQuery.extend({
s.dataType = "script";

// Handle JSONP-style loading
window[ jsonp ] = window[ jsonp ] || function(tmp){
window[ jsonp ] = window[ jsonp ] || function( tmp ) {
data = tmp;
success();
complete();
// Garbage collect
window[ jsonp ] = undefined;
try{ delete window[ jsonp ]; } catch(e){}

try {
delete window[ jsonp ];
} catch(e) {}

if ( head ) {
head.removeChild( script );
}
@@ -291,7 +295,7 @@ jQuery.extend({
var done = false;

// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
script.onload = script.onreadystatechange = function() {
if ( !done && (!this.readyState ||
this.readyState === "loaded" || this.readyState === "complete") ) {
done = true;
@@ -356,7 +360,7 @@ jQuery.extend({
xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
s.accepts[ s.dataType ] + ", */*" :
s.accepts._default );
} catch(e){}
} catch(e) {}

// Allow custom headers/mimetypes and early abort
if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
@@ -375,7 +379,7 @@ jQuery.extend({
}

// Wait for a response to come back
var onreadystatechange = function(isTimeout){
var onreadystatechange = function( isTimeout ) {
// The request was aborted, clear the interval and decrement jQuery.active
if ( !xhr || xhr.readyState === 0 ) {
if ( ival ) {
@@ -447,7 +451,7 @@ jQuery.extend({

// Timeout checker
if ( s.timeout > 0 ) {
setTimeout(function(){
setTimeout(function() {
// Check to see if the request is still happening
if ( xhr && !requestDone ) {
onreadystatechange( "timeout" );
@@ -470,7 +474,7 @@ jQuery.extend({
onreadystatechange();
}

function success(){
function success() {
// If a local callback was specified, fire it and pass it the data
if ( s.success ) {
s.success.call( callbackContext, data, status, xhr );
@@ -482,7 +486,7 @@ jQuery.extend({
}
}

function complete(){
function complete() {
// Process result
if ( s.complete ) {
s.complete.call( callbackContext, xhr, status);
@@ -499,7 +503,7 @@ jQuery.extend({
}
}

function trigger(type, args){
function trigger(type, args) {
(s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
}

@@ -530,7 +534,7 @@ jQuery.extend({
// Opera returns 0 when status is 304
( xhr.status >= 200 && xhr.status < 300 ) ||
xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
} catch(e){}
} catch(e) {}

return false;
},
@@ -597,7 +601,7 @@ jQuery.extend({
// Set jQuery.param.traditional to true for jQuery <= 1.3.2 behavior.
traditional = jQuery.param.traditional;

function add( key, value ){
function add( key, value ) {
// If value is a function, invoke it and return its value
value = jQuery.isFunction(value) ? value() : value;
s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
@@ -617,7 +621,7 @@ jQuery.extend({

if ( jQuery.isArray(obj) ) {
// Serialize array item.
jQuery.each( obj, function(i,v){
jQuery.each( obj, function( i, v ) {
if ( traditional ) {
// Treat each array item as a scalar.
add( prefix, v );
@@ -635,7 +639,7 @@ jQuery.extend({

} else if ( !traditional && typeof obj === "object" ) {
// Serialize object item.
jQuery.each( obj, function(k,v){
jQuery.each( obj, function( k, v ) {
buildParams( prefix + "[" + k + "]", v );
});

@@ -142,7 +142,7 @@ jQuery.fn.extend({

var val = value;

return this.each(function(){
return this.each(function() {
if ( jQuery.isFunction(value) ) {
val = value.call(this);

@@ -163,7 +163,7 @@ jQuery.fn.extend({
} else if ( jQuery.nodeName( this, "select" ) ) {
var values = jQuery.makeArray(val);

jQuery( "option", this ).each(function(){
jQuery( "option", this ).each(function() {
this.selected = jQuery.inArray( this.value || this.text, values ) >= 0;
});

@@ -210,10 +210,12 @@ jQuery.each({
this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || "";
}
}
}, function(name, fn){
jQuery.fn[ name ] = function(val, state){
}, function( name, fn ) {
jQuery.fn[ name ] = function( val, state ) {
if ( jQuery.isFunction( val ) ) {
return this.each(function() { jQuery(this)[ name ]( val.call(this), state ); });
return this.each(function() {
jQuery(this)[ name ]( val.call(this), state );
});
}

return this.each( fn, arguments );
@@ -164,7 +164,7 @@ jQuery.fn = jQuery.prototype = {
return this.length;
},

toArray: function(){
toArray: function() {
return slice.call( this, 0 );
},

@@ -258,7 +258,7 @@ jQuery.fn = jQuery.prototype = {
},

map: function( callback ) {
return this.pushStack( jQuery.map(this, function(elem, i){
return this.pushStack( jQuery.map(this, function( elem, i ) {
return callback.call( elem, i, elem );
}));
},
@@ -379,7 +379,10 @@ jQuery.extend({
},

bindReady: function() {
if ( readyBound ) { return; }
if ( readyBound ) {
return;
}

readyBound = true;

// Catch cases where $(document).ready() is called after the
@@ -411,7 +414,7 @@ jQuery.extend({

try {
toplevel = window.frameElement == null;
} catch(e){}
} catch(e) {}

if ( document.documentElement.doScroll && toplevel ) {
doScrollCheck();
@@ -8,11 +8,15 @@ var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
rnumpx = /^-?\d+(?:px)?$/i,
rnum = /^-?\d/,

cssShow = { position: "absolute", visibility: "hidden", display:"block" },
cssWidth = [ "Left", "Right" ],
cssHeight = [ "Top", "Bottom" ],

// cache check for defaultView.getComputedStyle
getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
// normalize float css property
styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
fcamelCase = function(all, letter){
fcamelCase = function( all, letter ) {
return letter.toUpperCase();
};

@@ -78,12 +82,14 @@ jQuery.extend({

css: function( elem, name, force, extra ) {
if ( name === "width" || name === "height" ) {
var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name === "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;

function getWH() {
val = name === "width" ? elem.offsetWidth : elem.offsetHeight;

if ( extra === "border" ) { return; }
if ( extra === "border" ) {
return;
}

jQuery.each( which, function() {
if ( !extra ) {
@@ -100,7 +100,7 @@ jQuery.extend({
});

jQuery.fn.extend({
data: function( key, value ){
data: function( key, value ) {
if ( typeof key === "undefined" && this.length ) {
return jQuery.data( this[0] );

@@ -123,14 +123,14 @@ jQuery.fn.extend({
this.data( parts[0] ) :
data;
} else {
return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
jQuery.data( this, key, value );
});
}
},

removeData: function( key ){
return this.each(function(){
removeData: function( key ) {
return this.each(function() {
jQuery.removeData( this, key );
});
}
@@ -1,17 +1,17 @@
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
jQuery.each([ "Height", "Width" ], function(i, name){
jQuery.each([ "Height", "Width" ], function( i, name ) {

var type = name.toLowerCase();

// innerHeight and innerWidth
jQuery.fn["inner" + name] = function(){
jQuery.fn["inner" + name] = function() {
return this[0] ?
jQuery.css( this[0], type, false, "padding" ) :
null;
};

// outerHeight and outerWidth
jQuery.fn["outer" + name] = function(margin) {
jQuery.fn["outer" + name] = function( margin ) {
return this[0] ?
jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
null;

0 comments on commit 61e37d4

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