Made a number of spacing changes to bring the code more-inline with the jQuery Core Style Guideline.

This commit is contained in:
jeresig 2009-12-21 19:58:13 -05:00
parent 36c99dc0c7
commit 61e37d4149
14 changed files with 218 additions and 130 deletions

View file

@ -52,7 +52,7 @@ jQuery.fn.extend({
dataType: "html", dataType: "html",
data: params, data: params,
context:this, context:this,
complete: function(res, status){ complete: function( res, status ) {
// If successful, inject the HTML into all the matched elements // If successful, inject the HTML into all the matched elements
if ( status === "success" || status === "notmodified" ) { if ( status === "success" || status === "notmodified" ) {
// See if a selector was specified // See if a selector was specified
@ -83,31 +83,31 @@ jQuery.fn.extend({
return jQuery.param(this.serializeArray()); return jQuery.param(this.serializeArray());
}, },
serializeArray: function() { serializeArray: function() {
return this.map(function(){ return this.map(function() {
return this.elements ? jQuery.makeArray(this.elements) : this; return this.elements ? jQuery.makeArray(this.elements) : this;
}) })
.filter(function(){ .filter(function() {
return this.name && !this.disabled && return this.name && !this.disabled &&
(this.checked || rselectTextarea.test(this.nodeName) || (this.checked || rselectTextarea.test(this.nodeName) ||
rinput.test(this.type)); rinput.test(this.type));
}) })
.map(function(i, elem){ .map(function( i, elem ) {
var val = jQuery(this).val(); var val = jQuery(this).val();
return val == null ? return val == null ?
null : null :
jQuery.isArray(val) ? jQuery.isArray(val) ?
jQuery.map( val, function(val, i){ jQuery.map( val, function( val, i ) {
return {name: elem.name, value: val}; return { name: elem.name, value: val };
}) : }) :
{name: elem.name, value: val}; { name: elem.name, value: val };
}).get(); }).get();
} }
}); });
// Attach a bunch of functions for handling common AJAX events // Attach a bunch of functions for handling common AJAX events
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function(i,o){ jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
jQuery.fn[o] = function(f){ jQuery.fn[o] = function( f ) {
return this.bind(o, f); return this.bind(o, f);
}; };
}); });
@ -176,7 +176,7 @@ jQuery.extend({
// Create the request object; Microsoft failed to properly // Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
// This function can be overriden by calling jQuery.ajaxSetup // This function can be overriden by calling jQuery.ajaxSetup
xhr: function(){ xhr: function() {
return window.ActiveXObject ? return window.ActiveXObject ?
new ActiveXObject("Microsoft.XMLHTTP") : new ActiveXObject("Microsoft.XMLHTTP") :
new XMLHttpRequest(); new XMLHttpRequest();
@ -235,13 +235,17 @@ jQuery.extend({
s.dataType = "script"; s.dataType = "script";
// Handle JSONP-style loading // Handle JSONP-style loading
window[ jsonp ] = window[ jsonp ] || function(tmp){ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
data = tmp; data = tmp;
success(); success();
complete(); complete();
// Garbage collect // Garbage collect
window[ jsonp ] = undefined; window[ jsonp ] = undefined;
try{ delete window[ jsonp ]; } catch(e){}
try {
delete window[ jsonp ];
} catch(e) {}
if ( head ) { if ( head ) {
head.removeChild( script ); head.removeChild( script );
} }
@ -291,7 +295,7 @@ jQuery.extend({
var done = false; var done = false;
// Attach handlers for all browsers // Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){ script.onload = script.onreadystatechange = function() {
if ( !done && (!this.readyState || if ( !done && (!this.readyState ||
this.readyState === "loaded" || this.readyState === "complete") ) { this.readyState === "loaded" || this.readyState === "complete") ) {
done = true; done = true;
@ -356,7 +360,7 @@ jQuery.extend({
xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
s.accepts[ s.dataType ] + ", */*" : s.accepts[ s.dataType ] + ", */*" :
s.accepts._default ); s.accepts._default );
} catch(e){} } catch(e) {}
// Allow custom headers/mimetypes and early abort // Allow custom headers/mimetypes and early abort
if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) { if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
@ -375,7 +379,7 @@ jQuery.extend({
} }
// Wait for a response to come back // 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 // The request was aborted, clear the interval and decrement jQuery.active
if ( !xhr || xhr.readyState === 0 ) { if ( !xhr || xhr.readyState === 0 ) {
if ( ival ) { if ( ival ) {
@ -447,7 +451,7 @@ jQuery.extend({
// Timeout checker // Timeout checker
if ( s.timeout > 0 ) { if ( s.timeout > 0 ) {
setTimeout(function(){ setTimeout(function() {
// Check to see if the request is still happening // Check to see if the request is still happening
if ( xhr && !requestDone ) { if ( xhr && !requestDone ) {
onreadystatechange( "timeout" ); onreadystatechange( "timeout" );
@ -470,7 +474,7 @@ jQuery.extend({
onreadystatechange(); onreadystatechange();
} }
function success(){ function success() {
// If a local callback was specified, fire it and pass it the data // If a local callback was specified, fire it and pass it the data
if ( s.success ) { if ( s.success ) {
s.success.call( callbackContext, data, status, xhr ); s.success.call( callbackContext, data, status, xhr );
@ -482,7 +486,7 @@ jQuery.extend({
} }
} }
function complete(){ function complete() {
// Process result // Process result
if ( s.complete ) { if ( s.complete ) {
s.complete.call( callbackContext, xhr, status); 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); (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
} }
@ -530,7 +534,7 @@ jQuery.extend({
// Opera returns 0 when status is 304 // Opera returns 0 when status is 304
( xhr.status >= 200 && xhr.status < 300 ) || ( xhr.status >= 200 && xhr.status < 300 ) ||
xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
} catch(e){} } catch(e) {}
return false; return false;
}, },
@ -597,7 +601,7 @@ jQuery.extend({
// Set jQuery.param.traditional to true for jQuery <= 1.3.2 behavior. // Set jQuery.param.traditional to true for jQuery <= 1.3.2 behavior.
traditional = jQuery.param.traditional; traditional = jQuery.param.traditional;
function add( key, value ){ function add( key, value ) {
// If value is a function, invoke it and return its value // If value is a function, invoke it and return its value
value = jQuery.isFunction(value) ? value() : value; value = jQuery.isFunction(value) ? value() : value;
s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
@ -617,7 +621,7 @@ jQuery.extend({
if ( jQuery.isArray(obj) ) { if ( jQuery.isArray(obj) ) {
// Serialize array item. // Serialize array item.
jQuery.each( obj, function(i,v){ jQuery.each( obj, function( i, v ) {
if ( traditional ) { if ( traditional ) {
// Treat each array item as a scalar. // Treat each array item as a scalar.
add( prefix, v ); add( prefix, v );
@ -635,7 +639,7 @@ jQuery.extend({
} else if ( !traditional && typeof obj === "object" ) { } else if ( !traditional && typeof obj === "object" ) {
// Serialize object item. // Serialize object item.
jQuery.each( obj, function(k,v){ jQuery.each( obj, function( k, v ) {
buildParams( prefix + "[" + k + "]", v ); buildParams( prefix + "[" + k + "]", v );
}); });

View file

@ -142,7 +142,7 @@ jQuery.fn.extend({
var val = value; var val = value;
return this.each(function(){ return this.each(function() {
if ( jQuery.isFunction(value) ) { if ( jQuery.isFunction(value) ) {
val = value.call(this); val = value.call(this);
@ -163,7 +163,7 @@ jQuery.fn.extend({
} else if ( jQuery.nodeName( this, "select" ) ) { } else if ( jQuery.nodeName( this, "select" ) ) {
var values = jQuery.makeArray(val); 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; 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__" ) || ""; this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || "";
} }
} }
}, function(name, fn){ }, function( name, fn ) {
jQuery.fn[ name ] = function(val, state){ jQuery.fn[ name ] = function( val, state ) {
if ( jQuery.isFunction( val ) ) { 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 ); return this.each( fn, arguments );

View file

@ -164,7 +164,7 @@ jQuery.fn = jQuery.prototype = {
return this.length; return this.length;
}, },
toArray: function(){ toArray: function() {
return slice.call( this, 0 ); return slice.call( this, 0 );
}, },
@ -258,7 +258,7 @@ jQuery.fn = jQuery.prototype = {
}, },
map: function( callback ) { 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 ); return callback.call( elem, i, elem );
})); }));
}, },
@ -379,7 +379,10 @@ jQuery.extend({
}, },
bindReady: function() { bindReady: function() {
if ( readyBound ) { return; } if ( readyBound ) {
return;
}
readyBound = true; readyBound = true;
// Catch cases where $(document).ready() is called after the // Catch cases where $(document).ready() is called after the
@ -411,7 +414,7 @@ jQuery.extend({
try { try {
toplevel = window.frameElement == null; toplevel = window.frameElement == null;
} catch(e){} } catch(e) {}
if ( document.documentElement.doScroll && toplevel ) { if ( document.documentElement.doScroll && toplevel ) {
doScrollCheck(); doScrollCheck();

View file

@ -8,11 +8,15 @@ var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
rnumpx = /^-?\d+(?:px)?$/i, rnumpx = /^-?\d+(?:px)?$/i,
rnum = /^-?\d/, rnum = /^-?\d/,
cssShow = { position: "absolute", visibility: "hidden", display:"block" },
cssWidth = [ "Left", "Right" ],
cssHeight = [ "Top", "Bottom" ],
// cache check for defaultView.getComputedStyle // cache check for defaultView.getComputedStyle
getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
// normalize float css property // normalize float css property
styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
fcamelCase = function(all, letter){ fcamelCase = function( all, letter ) {
return letter.toUpperCase(); return letter.toUpperCase();
}; };
@ -78,12 +82,14 @@ jQuery.extend({
css: function( elem, name, force, extra ) { css: function( elem, name, force, extra ) {
if ( name === "width" || name === "height" ) { 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() { function getWH() {
val = name === "width" ? elem.offsetWidth : elem.offsetHeight; val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
if ( extra === "border" ) { return; } if ( extra === "border" ) {
return;
}
jQuery.each( which, function() { jQuery.each( which, function() {
if ( !extra ) { if ( !extra ) {

View file

@ -100,7 +100,7 @@ jQuery.extend({
}); });
jQuery.fn.extend({ jQuery.fn.extend({
data: function( key, value ){ data: function( key, value ) {
if ( typeof key === "undefined" && this.length ) { if ( typeof key === "undefined" && this.length ) {
return jQuery.data( this[0] ); return jQuery.data( this[0] );
@ -123,14 +123,14 @@ jQuery.fn.extend({
this.data( parts[0] ) : this.data( parts[0] ) :
data; data;
} else { } 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 ); jQuery.data( this, key, value );
}); });
} }
}, },
removeData: function( key ){ removeData: function( key ) {
return this.each(function(){ return this.each(function() {
jQuery.removeData( this, key ); jQuery.removeData( this, key );
}); });
} }

View file

@ -1,17 +1,17 @@
// Create innerHeight, innerWidth, outerHeight and outerWidth methods // 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(); var type = name.toLowerCase();
// innerHeight and innerWidth // innerHeight and innerWidth
jQuery.fn["inner" + name] = function(){ jQuery.fn["inner" + name] = function() {
return this[0] ? return this[0] ?
jQuery.css( this[0], type, false, "padding" ) : jQuery.css( this[0], type, false, "padding" ) :
null; null;
}; };
// outerHeight and outerWidth // outerHeight and outerWidth
jQuery.fn["outer" + name] = function(margin) { jQuery.fn["outer" + name] = function( margin ) {
return this[0] ? return this[0] ?
jQuery.css( this[0], type, false, margin ? "margin" : "border" ) : jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
null; null;

28
src/effects.js vendored
View file

@ -17,7 +17,7 @@ jQuery.fn.extend({
return this.animate( genFx("show", 3), speed, callback); return this.animate( genFx("show", 3), speed, callback);
} else { } else {
for ( var i = 0, l = this.length; i < l; i++ ){ for ( var i = 0, l = this.length; i < l; i++ ) {
var old = jQuery.data(this[i], "olddisplay"); var old = jQuery.data(this[i], "olddisplay");
this[i].style.display = old || ""; this[i].style.display = old || "";
@ -48,7 +48,7 @@ jQuery.fn.extend({
// Set the display of the elements in a second loop // Set the display of the elements in a second loop
// to avoid the constant reflow // to avoid the constant reflow
for ( var j = 0, k = this.length; j < k; j++ ){ for ( var j = 0, k = this.length; j < k; j++ ) {
this[j].style.display = jQuery.data(this[j], "olddisplay") || ""; this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
} }
@ -61,16 +61,16 @@ jQuery.fn.extend({
return this.animate( genFx("hide", 3), speed, callback); return this.animate( genFx("hide", 3), speed, callback);
} else { } else {
for ( var i = 0, l = this.length; i < l; i++ ){ for ( var i = 0, l = this.length; i < l; i++ ) {
var old = jQuery.data(this[i], "olddisplay"); var old = jQuery.data(this[i], "olddisplay");
if ( !old && old !== "none" ){ if ( !old && old !== "none" ) {
jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display")); jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
} }
} }
// Set the display of the elements in a second loop // Set the display of the elements in a second loop
// to avoid the constant reflow // to avoid the constant reflow
for ( var j = 0, k = this.length; j < k; j++ ){ for ( var j = 0, k = this.length; j < k; j++ ) {
this[j].style.display = "none"; this[j].style.display = "none";
} }
@ -88,7 +88,7 @@ jQuery.fn.extend({
this._toggle.apply( this, arguments ); this._toggle.apply( this, arguments );
} else if ( fn == null || bool ) { } else if ( fn == null || bool ) {
this.each(function(){ this.each(function() {
var state = bool ? fn : jQuery(this).is(":hidden"); var state = bool ? fn : jQuery(this).is(":hidden");
jQuery(this)[ state ? "show" : "hide" ](); jQuery(this)[ state ? "show" : "hide" ]();
}); });
@ -190,14 +190,14 @@ jQuery.fn.extend({
}); });
}, },
stop: function(clearQueue, gotoEnd){ stop: function( clearQueue, gotoEnd ) {
var timers = jQuery.timers; var timers = jQuery.timers;
if ( clearQueue ) { if ( clearQueue ) {
this.queue([]); this.queue([]);
} }
this.each(function(){ this.each(function() {
// go in reverse order so anything added to the queue during the loop is ignored // go in reverse order so anything added to the queue during the loop is ignored
for ( var i = timers.length - 1; i >= 0; i-- ) { for ( var i = timers.length - 1; i >= 0; i-- ) {
if ( timers[i].elem === this ) { if ( timers[i].elem === this ) {
@ -228,8 +228,8 @@ jQuery.each({
slideToggle: genFx("toggle", 1), slideToggle: genFx("toggle", 1),
fadeIn: { opacity: "show" }, fadeIn: { opacity: "show" },
fadeOut: { opacity: "hide" } fadeOut: { opacity: "hide" }
}, function( name, props ){ }, function( name, props ) {
jQuery.fn[ name ] = function( speed, callback ){ jQuery.fn[ name ] = function( speed, callback ) {
return this.animate( props, speed, callback ); return this.animate( props, speed, callback );
}; };
}); });
@ -248,7 +248,7 @@ jQuery.extend({
// Queueing // Queueing
opt.old = opt.complete; opt.old = opt.complete;
opt.complete = function(){ opt.complete = function() {
if ( opt.queue !== false ) { if ( opt.queue !== false ) {
jQuery(this).dequeue(); jQuery(this).dequeue();
} }
@ -464,8 +464,8 @@ jQuery.extend( jQuery.fx, {
}); });
if ( jQuery.expr && jQuery.expr.filters ) { if ( jQuery.expr && jQuery.expr.filters ) {
jQuery.expr.filters.animated = function(elem){ jQuery.expr.filters.animated = function( elem ) {
return jQuery.grep(jQuery.timers, function(fn){ return jQuery.grep(jQuery.timers, function( fn ) {
return elem === fn.elem; return elem === fn.elem;
}).length; }).length;
}; };
@ -474,7 +474,7 @@ if ( jQuery.expr && jQuery.expr.filters ) {
function genFx( type, num ) { function genFx( type, num ) {
var obj = {}; var obj = {};
jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function(){ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
obj[ this ] = type; obj[ this ] = type;
}); });

View file

@ -1,3 +1,9 @@
var fcleanup = function( nm ) {
return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
return "\\" + ch;
});
};
/* /*
* A number of helper functions used for managing events. * A number of helper functions used for managing events.
* Many of the ideas behind this code originated from * Many of the ideas behind this code originated from
@ -142,7 +148,7 @@ jQuery.event = {
var namespaces = type.split("."); var namespaces = type.split(".");
type = namespaces.shift(); type = namespaces.shift();
var all = !namespaces.length, var all = !namespaces.length,
cleaned = jQuery.map( namespaces.slice(0).sort() , function(nm){ return nm.replace(/[^\w\s\.\|`]/g, function(ch){return "\\"+ch; }); }), cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"), namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
special = this.special[ type ] || {}; special = this.special[ type ] || {};
@ -403,10 +409,15 @@ jQuery.event = {
thisObject = proxy; thisObject = proxy;
proxy = undefined; proxy = undefined;
} }
// FIXME: Should proxy be redefined to be applied with thisObject if defined? // FIXME: Should proxy be redefined to be applied with thisObject if defined?
proxy = proxy || function() { return fn.apply( thisObject !== undefined ? thisObject : this, arguments ); }; proxy = proxy || function() {
return fn.apply( thisObject !== undefined ? thisObject : this, arguments );
};
// Set the guid of unique handler to the same of original handler, so it can be removed // 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 || this.guid++; proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
// So proxy can be declared as an argument // So proxy can be declared as an argument
return proxy; return proxy;
}, },
@ -462,7 +473,7 @@ jQuery.event = {
} }
}; };
jQuery.Event = function( src ){ jQuery.Event = function( src ) {
// Allow instantiation without the 'new' keyword // Allow instantiation without the 'new' keyword
if ( !this.preventDefault ) { if ( !this.preventDefault ) {
return new jQuery.Event( src ); return new jQuery.Event( src );
@ -524,7 +535,7 @@ jQuery.Event.prototype = {
// otherwise set the cancelBubble property of the original event to true (IE) // otherwise set the cancelBubble property of the original event to true (IE)
e.cancelBubble = true; e.cancelBubble = true;
}, },
stopImmediatePropagation: function(){ stopImmediatePropagation: function() {
this.isImmediatePropagationStopped = returnTrue; this.isImmediatePropagationStopped = returnTrue;
this.stopPropagation(); this.stopPropagation();
}, },
@ -575,10 +586,10 @@ jQuery.each({
mouseleave: "mouseout" mouseleave: "mouseout"
}, function( orig, fix ) { }, function( orig, fix ) {
jQuery.event.special[ orig ] = { jQuery.event.special[ orig ] = {
setup: function(data){ setup: function( data ) {
jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
}, },
teardown: function(data){ teardown: function( data ) {
jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
} }
}; };
@ -728,7 +739,7 @@ function trigger( type, elem, args ) {
// Create "bubbling" focus and blur events // Create "bubbling" focus and blur events
if ( document.addEventListener ) { if ( document.addEventListener ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ){ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
jQuery.event.special[ fix ] = { jQuery.event.special[ fix ] = {
setup: function() { setup: function() {
this.addEventListener( orig, handler, true ); this.addEventListener( orig, handler, true );
@ -746,7 +757,7 @@ if ( document.addEventListener ) {
}); });
} }
jQuery.each(["bind", "one"], function(i, name) { jQuery.each(["bind", "one"], function( i, name ) {
jQuery.fn[ name ] = function( type, data, fn, thisObject ) { jQuery.fn[ name ] = function( type, data, fn, thisObject ) {
// Handle object literals // Handle object literals
if ( typeof type === "object" ) { if ( typeof type === "object" ) {
@ -807,7 +818,7 @@ jQuery.fn.extend({
var args = arguments, i = 1; var args = arguments, i = 1;
// link all the functions, so any of them can unbind this click handler // link all the functions, so any of them can unbind this click handler
while( i < args.length ) { while ( i < args.length ) {
jQuery.event.proxy( fn, args[ i++ ] ); jQuery.event.proxy( fn, args[ i++ ] );
} }

View file

@ -13,5 +13,5 @@
* *
* Date: * Date:
*/ */
(function(window, undefined){ (function( window, undefined ) {

View file

@ -5,8 +5,8 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rtagName = /<([\w:]+)/, rtagName = /<([\w:]+)/,
rtbody = /<tbody/i, rtbody = /<tbody/i,
rhtml = /<|&\w+;/, rhtml = /<|&\w+;/,
fcloseTag = function(all, front, tag){ fcloseTag = function( all, front, tag ) {
return rselfClosing.test(tag) ? return rselfClosing.test( tag ) ?
all : all :
front + "></" + tag + ">"; front + "></" + tag + ">";
}, },
@ -32,7 +32,7 @@ if ( !jQuery.support.htmlSerialize ) {
jQuery.fn.extend({ jQuery.fn.extend({
text: function( text ) { text: function( text ) {
if(jQuery.isFunction(text)) { if ( jQuery.isFunction(text) ) {
return this.each(function() { return this.each(function() {
return jQuery(this).text( text.call(this) ); return jQuery(this).text( text.call(this) );
}); });
@ -60,7 +60,7 @@ jQuery.fn.extend({
wrap.insertBefore( this[0] ); wrap.insertBefore( this[0] );
} }
wrap.map(function(){ wrap.map(function() {
var elem = this; var elem = this;
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
@ -75,19 +75,19 @@ jQuery.fn.extend({
}, },
wrapInner: function( html ) { wrapInner: function( html ) {
return this.each(function(){ return this.each(function() {
jQuery( this ).contents().wrapAll( html ); jQuery( this ).contents().wrapAll( html );
}); });
}, },
wrap: function( html ) { wrap: function( html ) {
return this.each(function(){ return this.each(function() {
jQuery( this ).wrapAll( html ); jQuery( this ).wrapAll( html );
}); });
}, },
unwrap: function() { unwrap: function() {
return this.parent().each(function(){ return this.parent().each(function() {
if ( !jQuery.nodeName( this, "body" ) ) { if ( !jQuery.nodeName( this, "body" ) ) {
jQuery( this ).replaceWith( this.childNodes ); jQuery( this ).replaceWith( this.childNodes );
} }
@ -95,7 +95,7 @@ jQuery.fn.extend({
}, },
append: function() { append: function() {
return this.domManip(arguments, true, function(elem){ return this.domManip(arguments, true, function( elem ) {
if ( this.nodeType === 1 ) { if ( this.nodeType === 1 ) {
this.appendChild( elem ); this.appendChild( elem );
} }
@ -103,7 +103,7 @@ jQuery.fn.extend({
}, },
prepend: function() { prepend: function() {
return this.domManip(arguments, true, function(elem){ return this.domManip(arguments, true, function( elem ) {
if ( this.nodeType === 1 ) { if ( this.nodeType === 1 ) {
this.insertBefore( elem, this.firstChild ); this.insertBefore( elem, this.firstChild );
} }
@ -112,7 +112,7 @@ jQuery.fn.extend({
before: function() { before: function() {
if ( this[0] && this[0].parentNode ) { if ( this[0] && this[0].parentNode ) {
return this.domManip(arguments, false, function(elem){ return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this ); this.parentNode.insertBefore( elem, this );
}); });
} else if ( arguments.length ) { } else if ( arguments.length ) {
@ -124,7 +124,7 @@ jQuery.fn.extend({
after: function() { after: function() {
if ( this[0] && this[0].parentNode ) { if ( this[0] && this[0].parentNode ) {
return this.domManip(arguments, false, function(elem){ return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this.nextSibling ); this.parentNode.insertBefore( elem, this.nextSibling );
}); });
} else if ( arguments.length ) { } else if ( arguments.length ) {
@ -136,7 +136,7 @@ jQuery.fn.extend({
clone: function( events ) { clone: function( events ) {
// Do the clone // Do the clone
var ret = this.map(function(){ var ret = this.map(function() {
if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
// IE copies events bound via attachEvent when // IE copies events bound via attachEvent when
// using cloneNode. Calling detachEvent on the // using cloneNode. Calling detachEvent on the
@ -204,7 +204,7 @@ jQuery.fn.extend({
replaceWith: function( value ) { replaceWith: function( value ) {
if ( this[0] && this[0].parentNode ) { if ( this[0] && this[0].parentNode ) {
return this.each(function(){ return this.each(function() {
var next = this.nextSibling, parent = this.parentNode; var next = this.nextSibling, parent = this.parentNode;
jQuery(this).remove(); jQuery(this).remove();
@ -278,7 +278,7 @@ jQuery.fn.extend({
function cloneCopyEvent(orig, ret) { function cloneCopyEvent(orig, ret) {
var i = 0; var i = 0;
ret.each(function(){ ret.each(function() {
if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) { if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
return; return;
} }
@ -287,7 +287,7 @@ function cloneCopyEvent(orig, ret) {
}); });
} }
function buildFragment(args, nodes, scripts){ function buildFragment( args, nodes, scripts ) {
var fragment, cacheable, cached, cacheresults, doc; var fragment, cacheable, cached, cacheresults, doc;
if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) { if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
@ -322,7 +322,7 @@ jQuery.each({
insertBefore: "before", insertBefore: "before",
insertAfter: "after", insertAfter: "after",
replaceAll: "replaceWith" replaceAll: "replaceWith"
}, function(name, original){ }, function( name, original ) {
jQuery.fn[ name ] = function( selector ) { jQuery.fn[ name ] = function( selector ) {
var ret = [], insert = jQuery( selector ); var ret = [], insert = jQuery( selector );
@ -361,8 +361,8 @@ jQuery.each({
this.removeChild( this.firstChild ); this.removeChild( this.firstChild );
} }
} }
}, function(name, fn){ }, function( name, fn ) {
jQuery.fn[ name ] = function(){ jQuery.fn[ name ] = function() {
return this.each( fn, arguments ); return this.each( fn, arguments );
}; };
}); });
@ -378,12 +378,14 @@ jQuery.extend({
var ret = []; var ret = [];
jQuery.each(elems, function(i, elem){ jQuery.each(elems, function( i, elem ) {
if ( typeof elem === "number" ) { if ( typeof elem === "number" ) {
elem += ''; elem += '';
} }
if ( !elem ) { return; } if ( !elem ) {
return;
}
// Convert html string into DOM nodes // Convert html string into DOM nodes
if ( typeof elem === "string" && !rhtml.test( elem ) ) { if ( typeof elem === "string" && !rhtml.test( elem ) ) {

View file

@ -1,12 +1,17 @@
if ( "getBoundingClientRect" in document.documentElement ) { if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.fn.offset = function( options ) { jQuery.fn.offset = function( options ) {
var elem = this[0]; var elem = this[0];
if ( !elem || !elem.ownerDocument ) { return null; }
if ( !elem || !elem.ownerDocument ) {
return null;
}
if ( options ) { if ( options ) {
return this.each(function() { return this.each(function() {
jQuery.offset.setOffset( this, options ); jQuery.offset.setOffset( this, options );
}); });
} }
if ( elem === elem.ownerDocument.body ) { if ( elem === elem.ownerDocument.body ) {
return jQuery.offset.bodyOffset( elem ); return jQuery.offset.bodyOffset( elem );
} }
@ -15,17 +20,24 @@ if ( "getBoundingClientRect" in document.documentElement ) {
clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
return { top: top, left: left }; return { top: top, left: left };
}; };
} else { } else {
jQuery.fn.offset = function( options ) { jQuery.fn.offset = function( options ) {
var elem = this[0]; var elem = this[0];
if ( !elem || !elem.ownerDocument ) { return null; }
if ( !elem || !elem.ownerDocument ) {
return null;
}
if ( options ) { if ( options ) {
return this.each(function() { return this.each(function() {
jQuery.offset.setOffset( this, options ); jQuery.offset.setOffset( this, options );
}); });
} }
if ( elem === elem.ownerDocument.body ) { if ( elem === elem.ownerDocument.body ) {
return jQuery.offset.bodyOffset( elem ); return jQuery.offset.bodyOffset( elem );
} }
@ -39,7 +51,9 @@ if ( "getBoundingClientRect" in document.documentElement ) {
top = elem.offsetTop, left = elem.offsetLeft; top = elem.offsetTop, left = elem.offsetLeft;
while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { break; } if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
break;
}
computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle; computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
top -= elem.scrollTop; top -= elem.scrollTop;
@ -107,7 +121,7 @@ jQuery.offset = {
body.removeChild( container ); body.removeChild( container );
body = container = innerDiv = checkDiv = table = td = null; body = container = innerDiv = checkDiv = table = td = null;
jQuery.offset.initialize = function(){}; jQuery.offset.initialize = function() {};
}, },
bodyOffset: function( body ) { bodyOffset: function( body ) {
@ -148,7 +162,9 @@ jQuery.offset = {
jQuery.fn.extend({ jQuery.fn.extend({
position: function() { position: function() {
if ( !this[0] ) { return null; } if ( !this[0] ) {
return null;
}
var elem = this[0], var elem = this[0],
@ -177,7 +193,7 @@ jQuery.fn.extend({
}, },
offsetParent: function() { offsetParent: function() {
return this.map(function(){ return this.map(function() {
var offsetParent = this.offsetParent || document.body; var offsetParent = this.offsetParent || document.body;
while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, 'position') === 'static') ) { while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, 'position') === 'static') ) {
offsetParent = offsetParent.offsetParent; offsetParent = offsetParent.offsetParent;
@ -189,25 +205,30 @@ jQuery.fn.extend({
// Create scrollLeft and scrollTop methods // Create scrollLeft and scrollTop methods
jQuery.each( ['Left', 'Top'], function(i, name) { jQuery.each( ["Left", "Top"], function( i, name ) {
var method = 'scroll' + name; var method = "scroll" + name;
jQuery.fn[ method ] = function(val) { jQuery.fn[ method ] = function(val) {
var elem = this[0], win; var elem = this[0], win;
if ( !elem ) { return null; } if ( !elem ) {
return null;
}
if ( val !== undefined ) { if ( val !== undefined ) {
// Set the scroll offset // Set the scroll offset
return this.each(function() { return this.each(function() {
win = getWindow( this ); win = getWindow( this );
win ? if ( win ) {
win.scrollTo( win.scrollTo(
!i ? val : jQuery(win).scrollLeft(), !i ? val : jQuery(win).scrollLeft(),
i ? val : jQuery(win).scrollTop() i ? val : jQuery(win).scrollTop()
) : );
} else {
this[ method ] = val; this[ method ] = val;
}
}); });
} else { } else {
win = getWindow( elem ); win = getWindow( elem );

View file

@ -1,41 +1,53 @@
jQuery.extend({ jQuery.extend({
queue: function( elem, type, data ) { queue: function( elem, type, data ) {
if ( !elem ) { return; } if ( !elem ) {
return;
}
type = (type || "fx") + "queue"; type = (type || "fx") + "queue";
var q = jQuery.data( elem, type ); var q = jQuery.data( elem, type );
// Speed up dequeue by getting out quickly if this is just a lookup // Speed up dequeue by getting out quickly if this is just a lookup
if ( !data ) { return q || []; } if ( !data ) {
return q || [];
}
if ( !q || jQuery.isArray(data) ) { if ( !q || jQuery.isArray(data) ) {
q = jQuery.data( elem, type, jQuery.makeArray(data) ); q = jQuery.data( elem, type, jQuery.makeArray(data) );
} else { } else {
q.push( data ); q.push( data );
} }
return q; return q;
}, },
dequeue: function( elem, type ){ dequeue: function( elem, type ) {
type = type || "fx"; type = type || "fx";
var queue = jQuery.queue( elem, type ), fn = queue.shift(); var queue = jQuery.queue( elem, type ), fn = queue.shift();
// If the fx queue is dequeued, always remove the progress sentinel // If the fx queue is dequeued, always remove the progress sentinel
if ( fn === "inprogress" ) { fn = queue.shift(); } if ( fn === "inprogress" ) {
fn = queue.shift();
}
if ( fn ) { if ( fn ) {
// Add a progress sentinel to prevent the fx queue from being // Add a progress sentinel to prevent the fx queue from being
// automatically dequeued // automatically dequeued
if ( type === "fx" ) { queue.unshift("inprogress"); } if ( type === "fx" ) {
queue.unshift("inprogress");
}
fn.call(elem, function() { jQuery.dequeue(elem, type); }); fn.call(elem, function() {
jQuery.dequeue(elem, type);
});
} }
} }
}); });
jQuery.fn.extend({ jQuery.fn.extend({
queue: function(type, data){ queue: function( type, data ) {
if ( typeof type !== "string" ) { if ( typeof type !== "string" ) {
data = type; data = type;
type = "fx"; type = "fx";
@ -44,7 +56,7 @@ jQuery.fn.extend({
if ( data === undefined ) { if ( data === undefined ) {
return jQuery.queue( this[0], type ); return jQuery.queue( this[0], type );
} }
return this.each(function(i, elem){ return this.each(function( i, elem ) {
var queue = jQuery.queue( this, type, data ); var queue = jQuery.queue( this, type, data );
if ( type === "fx" && queue[0] !== "inprogress" ) { if ( type === "fx" && queue[0] !== "inprogress" ) {
@ -52,8 +64,8 @@ jQuery.fn.extend({
} }
}); });
}, },
dequeue: function(type){ dequeue: function( type ) {
return this.each(function(){ return this.each(function() {
jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
}); });
}, },
@ -72,7 +84,7 @@ jQuery.fn.extend({
}); });
}, },
clearQueue: function(type){ clearQueue: function( type ) {
return this.queue( type || "fx", [] ); return this.queue( type || "fx", [] );
} }
}); });

View file

@ -1,4 +1,4 @@
(function(){ (function() {
jQuery.support = {}; jQuery.support = {};
@ -56,7 +56,7 @@
script.type = "text/javascript"; script.type = "text/javascript";
try { try {
script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
} catch(e){} } catch(e) {}
root.insertBefore( script, root.firstChild ); root.insertBefore( script, root.firstChild );
@ -71,7 +71,7 @@
root.removeChild( script ); root.removeChild( script );
if ( div.attachEvent && div.fireEvent ) { if ( div.attachEvent && div.fireEvent ) {
div.attachEvent("onclick", function click(){ div.attachEvent("onclick", function click() {
// Cloning a node shouldn't copy over any // Cloning a node shouldn't copy over any
// bound event handlers (IE does this) // bound event handlers (IE does this)
jQuery.support.noCloneEvent = false; jQuery.support.noCloneEvent = false;
@ -83,7 +83,7 @@
// Figure out if the W3C box model works as expected // Figure out if the W3C box model works as expected
// document.body must exist before we can do this // document.body must exist before we can do this
// TODO: This timeout is temporary until I move ready into core.js. // TODO: This timeout is temporary until I move ready into core.js.
jQuery(function(){ jQuery(function() {
var div = document.createElement("div"); var div = document.createElement("div");
div.style.width = div.style.paddingLeft = "1px"; div.style.width = div.style.paddingLeft = "1px";

View file

@ -7,17 +7,17 @@ var runtil = /Until$/,
// Implement the identical functionality for filter and not // Implement the identical functionality for filter and not
var winnow = function( elements, qualifier, keep ) { var winnow = function( elements, qualifier, keep ) {
if ( jQuery.isFunction( qualifier ) ) { if ( jQuery.isFunction( qualifier ) ) {
return jQuery.grep(elements, function(elem, i) { return jQuery.grep(elements, function( elem, i ) {
return !!qualifier.call( elem, i, elem ) === keep; return !!qualifier.call( elem, i, elem ) === keep;
}); });
} else if ( qualifier.nodeType ) { } else if ( qualifier.nodeType ) {
return jQuery.grep(elements, function(elem, i) { return jQuery.grep(elements, function( elem, i ) {
return (elem === qualifier) === keep; return (elem === qualifier) === keep;
}); });
} else if ( typeof qualifier === "string" ) { } else if ( typeof qualifier === "string" ) {
var filtered = jQuery.grep(elements, function(elem) { var filtered = jQuery.grep(elements, function( elem ) {
return elem.nodeType === 1; return elem.nodeType === 1;
}); });
@ -28,7 +28,7 @@ var winnow = function( elements, qualifier, keep ) {
} }
} }
return jQuery.grep(elements, function(elem, i) { return jQuery.grep(elements, function( elem, i ) {
return (jQuery.inArray( elem, qualifier ) >= 0) === keep; return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
}); });
}; };
@ -114,7 +114,7 @@ jQuery.fn.extend({
var pos = jQuery.expr.match.POS.test( selectors ) ? var pos = jQuery.expr.match.POS.test( selectors ) ?
jQuery( selectors, context || this.context ) : null; jQuery( selectors, context || this.context ) : null;
return this.map(function(i, cur){ return this.map(function( i, cur ) {
while ( cur && cur.ownerDocument && cur !== context ) { while ( cur && cur.ownerDocument && cur !== context ) {
if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) { if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
return cur; return cur;
@ -157,19 +157,46 @@ jQuery.fn.extend({
}); });
jQuery.each({ jQuery.each({
parent: function(elem){var parent = elem.parentNode; return parent && parent.nodeType !== 11 ? parent : null;}, parent: function( elem ) {
parents: function(elem){return jQuery.dir(elem,"parentNode");}, var parent = elem.parentNode;
parentsUntil: function(elem,i,until){return jQuery.dir(elem,"parentNode",until);}, return parent && parent.nodeType !== 11 ? parent : null;
next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, },
prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, parents: function( elem ) {
nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, return jQuery.dir( elem, "parentNode" );
prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, },
nextUntil: function(elem,i,until){return jQuery.dir(elem,"nextSibling",until);}, parentsUntil: function( elem, i, until ) {
prevUntil: function(elem,i,until){return jQuery.dir(elem,"previousSibling",until);}, return jQuery.dir( elem, "parentNode", until );
siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, },
children: function(elem){return jQuery.sibling(elem.firstChild);}, next: function( elem ) {
contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} return jQuery.nth( elem, 2, "nextSibling" );
}, function(name, fn){ },
prev: function( elem ) {
return jQuery.nth( elem, 2, "previousSibling" );
},
nextAll: function( elem ) {
return jQuery.dir( elem, "nextSibling" );
},
prevAll: function( elem ) {
return jQuery.dir( elem, "previousSibling" );
},
nextUntil: function( elem, i, until ) {
return jQuery.dir( elem, "nextSibling", until );
},
prevUntil: function( elem, i, until ) {
return jQuery.dir( elem, "previousSibling", until );
},
siblings: function( elem ) {
return jQuery.sibling( elem.parentNode.firstChild, elem );
},
children: function( elem ) {
return jQuery.sibling( elem.firstChild );
},
contents: function( elem ) {
return jQuery.nodeName( elem, "iframe" ) ?
elem.contentDocument || elem.contentWindow.document :
jQuery.makeArray( elem.childNodes );
}
}, function( name, fn ) {
jQuery.fn[ name ] = function( until, selector ) { jQuery.fn[ name ] = function( until, selector ) {
var ret = jQuery.map( this, fn, until ); var ret = jQuery.map( this, fn, until );