aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ajax.js50
-rw-r--r--src/attributes.js12
-rw-r--r--src/core.js11
-rw-r--r--src/css.js12
-rw-r--r--src/data.js8
-rw-r--r--src/dimensions.js6
-rw-r--r--src/effects.js28
-rw-r--r--src/event.js29
-rw-r--r--src/intro.js2
-rw-r--r--src/manipulation.js42
-rw-r--r--src/offset.js43
-rw-r--r--src/queue.js34
-rw-r--r--src/support.js8
-rw-r--r--src/traversing.js63
14 files changed, 218 insertions, 130 deletions
diff --git a/src/ajax.js b/src/ajax.js
index edb5c54be..0d1dd84cc 100644
--- a/src/ajax.js
+++ b/src/ajax.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 );
});
diff --git a/src/attributes.js b/src/attributes.js
index e7e5d378d..4f5692f57 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -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 );
diff --git a/src/core.js b/src/core.js
index eb67ba19f..faba32a72 100644
--- a/src/core.js
+++ b/src/core.js
@@ -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();
diff --git a/src/css.js b/src/css.js
index 5b6b7b9b6..e52e45330 100644
--- a/src/css.js
+++ b/src/css.js
@@ -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 ) {
diff --git a/src/data.js b/src/data.js
index 69adc1239..e3dc1902a 100644
--- a/src/data.js
+++ b/src/data.js
@@ -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 );
});
}
diff --git a/src/dimensions.js b/src/dimensions.js
index d3c8418db..3acbb1d76 100644
--- a/src/dimensions.js
+++ b/src/dimensions.js
@@ -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;
diff --git a/src/effects.js b/src/effects.js
index 5d656c96c..ff2f145b8 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -17,7 +17,7 @@ jQuery.fn.extend({
return this.animate( genFx("show", 3), speed, callback);
} 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");
this[i].style.display = old || "";
@@ -48,7 +48,7 @@ jQuery.fn.extend({
// Set the display of the elements in a second loop
// 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") || "";
}
@@ -61,16 +61,16 @@ jQuery.fn.extend({
return this.animate( genFx("hide", 3), speed, callback);
} 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");
- if ( !old && old !== "none" ){
+ if ( !old && old !== "none" ) {
jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
}
}
// Set the display of the elements in a second loop
// 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";
}
@@ -88,7 +88,7 @@ jQuery.fn.extend({
this._toggle.apply( this, arguments );
} else if ( fn == null || bool ) {
- this.each(function(){
+ this.each(function() {
var state = bool ? fn : jQuery(this).is(":hidden");
jQuery(this)[ state ? "show" : "hide" ]();
});
@@ -190,14 +190,14 @@ jQuery.fn.extend({
});
},
- stop: function(clearQueue, gotoEnd){
+ stop: function( clearQueue, gotoEnd ) {
var timers = jQuery.timers;
if ( clearQueue ) {
this.queue([]);
}
- this.each(function(){
+ this.each(function() {
// go in reverse order so anything added to the queue during the loop is ignored
for ( var i = timers.length - 1; i >= 0; i-- ) {
if ( timers[i].elem === this ) {
@@ -228,8 +228,8 @@ jQuery.each({
slideToggle: genFx("toggle", 1),
fadeIn: { opacity: "show" },
fadeOut: { opacity: "hide" }
-}, function( name, props ){
- jQuery.fn[ name ] = function( speed, callback ){
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, callback ) {
return this.animate( props, speed, callback );
};
});
@@ -248,7 +248,7 @@ jQuery.extend({
// Queueing
opt.old = opt.complete;
- opt.complete = function(){
+ opt.complete = function() {
if ( opt.queue !== false ) {
jQuery(this).dequeue();
}
@@ -464,8 +464,8 @@ jQuery.extend( jQuery.fx, {
});
if ( jQuery.expr && jQuery.expr.filters ) {
- jQuery.expr.filters.animated = function(elem){
- return jQuery.grep(jQuery.timers, function(fn){
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
return elem === fn.elem;
}).length;
};
@@ -474,7 +474,7 @@ if ( jQuery.expr && jQuery.expr.filters ) {
function genFx( type, num ) {
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;
});
diff --git a/src/event.js b/src/event.js
index 892525aea..3697e4e75 100644
--- a/src/event.js
+++ b/src/event.js
@@ -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.
* Many of the ideas behind this code originated from
@@ -142,7 +148,7 @@ jQuery.event = {
var namespaces = type.split(".");
type = namespaces.shift();
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("\\.(?:.*\\.)?") + "(\\.|$)"),
special = this.special[ type ] || {};
@@ -403,10 +409,15 @@ jQuery.event = {
thisObject = proxy;
proxy = undefined;
}
+
// 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
proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
+
// So proxy can be declared as an argument
return proxy;
},
@@ -462,7 +473,7 @@ jQuery.event = {
}
};
-jQuery.Event = function( src ){
+jQuery.Event = function( src ) {
// Allow instantiation without the 'new' keyword
if ( !this.preventDefault ) {
return new jQuery.Event( src );
@@ -524,7 +535,7 @@ jQuery.Event.prototype = {
// otherwise set the cancelBubble property of the original event to true (IE)
e.cancelBubble = true;
},
- stopImmediatePropagation: function(){
+ stopImmediatePropagation: function() {
this.isImmediatePropagationStopped = returnTrue;
this.stopPropagation();
},
@@ -575,10 +586,10 @@ jQuery.each({
mouseleave: "mouseout"
}, function( orig, fix ) {
jQuery.event.special[ orig ] = {
- setup: function(data){
+ setup: function( data ) {
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 );
}
};
@@ -728,7 +739,7 @@ function trigger( type, elem, args ) {
// Create "bubbling" focus and blur events
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 ] = {
setup: function() {
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 ) {
// Handle object literals
if ( typeof type === "object" ) {
@@ -807,7 +818,7 @@ jQuery.fn.extend({
var args = arguments, i = 1;
// 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++ ] );
}
diff --git a/src/intro.js b/src/intro.js
index adea1b575..19a2c8057 100644
--- a/src/intro.js
+++ b/src/intro.js
@@ -13,5 +13,5 @@
*
* Date:
*/
-(function(window, undefined){
+(function( window, undefined ) {
diff --git a/src/manipulation.js b/src/manipulation.js
index 4f7ee6504..7500730f9 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -5,8 +5,8 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rtagName = /<([\w:]+)/,
rtbody = /<tbody/i,
rhtml = /<|&\w+;/,
- fcloseTag = function(all, front, tag){
- return rselfClosing.test(tag) ?
+ fcloseTag = function( all, front, tag ) {
+ return rselfClosing.test( tag ) ?
all :
front + "></" + tag + ">";
},
@@ -32,7 +32,7 @@ if ( !jQuery.support.htmlSerialize ) {
jQuery.fn.extend({
text: function( text ) {
- if(jQuery.isFunction(text)) {
+ if ( jQuery.isFunction(text) ) {
return this.each(function() {
return jQuery(this).text( text.call(this) );
});
@@ -60,7 +60,7 @@ jQuery.fn.extend({
wrap.insertBefore( this[0] );
}
- wrap.map(function(){
+ wrap.map(function() {
var elem = this;
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
@@ -75,19 +75,19 @@ jQuery.fn.extend({
},
wrapInner: function( html ) {
- return this.each(function(){
+ return this.each(function() {
jQuery( this ).contents().wrapAll( html );
});
},
wrap: function( html ) {
- return this.each(function(){
+ return this.each(function() {
jQuery( this ).wrapAll( html );
});
},
unwrap: function() {
- return this.parent().each(function(){
+ return this.parent().each(function() {
if ( !jQuery.nodeName( this, "body" ) ) {
jQuery( this ).replaceWith( this.childNodes );
}
@@ -95,7 +95,7 @@ jQuery.fn.extend({
},
append: function() {
- return this.domManip(arguments, true, function(elem){
+ return this.domManip(arguments, true, function( elem ) {
if ( this.nodeType === 1 ) {
this.appendChild( elem );
}
@@ -103,7 +103,7 @@ jQuery.fn.extend({
},
prepend: function() {
- return this.domManip(arguments, true, function(elem){
+ return this.domManip(arguments, true, function( elem ) {
if ( this.nodeType === 1 ) {
this.insertBefore( elem, this.firstChild );
}
@@ -112,7 +112,7 @@ jQuery.fn.extend({
before: function() {
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 );
});
} else if ( arguments.length ) {
@@ -124,7 +124,7 @@ jQuery.fn.extend({
after: function() {
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 );
});
} else if ( arguments.length ) {
@@ -136,7 +136,7 @@ jQuery.fn.extend({
clone: function( events ) {
// Do the clone
- var ret = this.map(function(){
+ var ret = this.map(function() {
if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
// IE copies events bound via attachEvent when
// using cloneNode. Calling detachEvent on the
@@ -204,7 +204,7 @@ jQuery.fn.extend({
replaceWith: function( value ) {
if ( this[0] && this[0].parentNode ) {
- return this.each(function(){
+ return this.each(function() {
var next = this.nextSibling, parent = this.parentNode;
jQuery(this).remove();
@@ -278,7 +278,7 @@ jQuery.fn.extend({
function cloneCopyEvent(orig, ret) {
var i = 0;
- ret.each(function(){
+ ret.each(function() {
if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
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;
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",
insertAfter: "after",
replaceAll: "replaceWith"
-}, function(name, original){
+}, function( name, original ) {
jQuery.fn[ name ] = function( selector ) {
var ret = [], insert = jQuery( selector );
@@ -361,8 +361,8 @@ jQuery.each({
this.removeChild( this.firstChild );
}
}
-}, function(name, fn){
- jQuery.fn[ name ] = function(){
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function() {
return this.each( fn, arguments );
};
});
@@ -378,12 +378,14 @@ jQuery.extend({
var ret = [];
- jQuery.each(elems, function(i, elem){
+ jQuery.each(elems, function( i, elem ) {
if ( typeof elem === "number" ) {
elem += '';
}
- if ( !elem ) { return; }
+ if ( !elem ) {
+ return;
+ }
// Convert html string into DOM nodes
if ( typeof elem === "string" && !rhtml.test( elem ) ) {
diff --git a/src/offset.js b/src/offset.js
index 8268ce726..692583900 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -1,12 +1,17 @@
if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.fn.offset = function( options ) {
var elem = this[0];
- if ( !elem || !elem.ownerDocument ) { return null; }
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
if ( options ) {
return this.each(function() {
jQuery.offset.setOffset( this, options );
});
}
+
if ( elem === elem.ownerDocument.body ) {
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,
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;
+
return { top: top, left: left };
};
+
} else {
jQuery.fn.offset = function( options ) {
var elem = this[0];
- if ( !elem || !elem.ownerDocument ) { return null; }
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
if ( options ) {
return this.each(function() {
jQuery.offset.setOffset( this, options );
});
}
+
if ( elem === elem.ownerDocument.body ) {
return jQuery.offset.bodyOffset( elem );
}
@@ -39,7 +51,9 @@ if ( "getBoundingClientRect" in document.documentElement ) {
top = elem.offsetTop, left = elem.offsetLeft;
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;
top -= elem.scrollTop;
@@ -107,7 +121,7 @@ jQuery.offset = {
body.removeChild( container );
body = container = innerDiv = checkDiv = table = td = null;
- jQuery.offset.initialize = function(){};
+ jQuery.offset.initialize = function() {};
},
bodyOffset: function( body ) {
@@ -148,7 +162,9 @@ jQuery.offset = {
jQuery.fn.extend({
position: function() {
- if ( !this[0] ) { return null; }
+ if ( !this[0] ) {
+ return null;
+ }
var elem = this[0],
@@ -177,7 +193,7 @@ jQuery.fn.extend({
},
offsetParent: function() {
- return this.map(function(){
+ return this.map(function() {
var offsetParent = this.offsetParent || document.body;
while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, 'position') === 'static') ) {
offsetParent = offsetParent.offsetParent;
@@ -189,25 +205,30 @@ jQuery.fn.extend({
// Create scrollLeft and scrollTop methods
-jQuery.each( ['Left', 'Top'], function(i, name) {
- var method = 'scroll' + name;
+jQuery.each( ["Left", "Top"], function( i, name ) {
+ var method = "scroll" + name;
jQuery.fn[ method ] = function(val) {
var elem = this[0], win;
- if ( !elem ) { return null; }
+ if ( !elem ) {
+ return null;
+ }
if ( val !== undefined ) {
// Set the scroll offset
return this.each(function() {
win = getWindow( this );
- win ?
+ if ( win ) {
win.scrollTo(
!i ? val : jQuery(win).scrollLeft(),
i ? val : jQuery(win).scrollTop()
- ) :
+ );
+
+ } else {
this[ method ] = val;
+ }
});
} else {
win = getWindow( elem );
diff --git a/src/queue.js b/src/queue.js
index 3770f4d90..e52f37b85 100644
--- a/src/queue.js
+++ b/src/queue.js
@@ -1,41 +1,53 @@
jQuery.extend({
queue: function( elem, type, data ) {
- if ( !elem ) { return; }
+ if ( !elem ) {
+ return;
+ }
type = (type || "fx") + "queue";
var q = jQuery.data( elem, type );
// 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) ) {
q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
} else {
q.push( data );
}
+
return q;
},
- dequeue: function( elem, type ){
+ dequeue: function( elem, type ) {
type = type || "fx";
var queue = jQuery.queue( elem, type ), fn = queue.shift();
// 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 ) {
// Add a progress sentinel to prevent the fx queue from being
// 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({
- queue: function(type, data){
+ queue: function( type, data ) {
if ( typeof type !== "string" ) {
data = type;
type = "fx";
@@ -44,7 +56,7 @@ jQuery.fn.extend({
if ( data === undefined ) {
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 );
if ( type === "fx" && queue[0] !== "inprogress" ) {
@@ -52,8 +64,8 @@ jQuery.fn.extend({
}
});
},
- dequeue: function(type){
- return this.each(function(){
+ dequeue: function( type ) {
+ return this.each(function() {
jQuery.dequeue( this, type );
});
},
@@ -72,7 +84,7 @@ jQuery.fn.extend({
});
},
- clearQueue: function(type){
+ clearQueue: function( type ) {
return this.queue( type || "fx", [] );
}
});
diff --git a/src/support.js b/src/support.js
index ef5f01021..097866c28 100644
--- a/src/support.js
+++ b/src/support.js
@@ -1,4 +1,4 @@
-(function(){
+(function() {
jQuery.support = {};
@@ -56,7 +56,7 @@
script.type = "text/javascript";
try {
script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
- } catch(e){}
+ } catch(e) {}
root.insertBefore( script, root.firstChild );
@@ -71,7 +71,7 @@
root.removeChild( script );
if ( div.attachEvent && div.fireEvent ) {
- div.attachEvent("onclick", function click(){
+ div.attachEvent("onclick", function click() {
// Cloning a node shouldn't copy over any
// bound event handlers (IE does this)
jQuery.support.noCloneEvent = false;
@@ -83,7 +83,7 @@
// Figure out if the W3C box model works as expected
// document.body must exist before we can do this
// TODO: This timeout is temporary until I move ready into core.js.
- jQuery(function(){
+ jQuery(function() {
var div = document.createElement("div");
div.style.width = div.style.paddingLeft = "1px";
diff --git a/src/traversing.js b/src/traversing.js
index 42444c3f2..a09ae1937 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -7,17 +7,17 @@ var runtil = /Until$/,
// Implement the identical functionality for filter and not
var winnow = function( elements, qualifier, keep ) {
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;
});
} else if ( qualifier.nodeType ) {
- return jQuery.grep(elements, function(elem, i) {
+ return jQuery.grep(elements, function( elem, i ) {
return (elem === qualifier) === keep;
});
} else if ( typeof qualifier === "string" ) {
- var filtered = jQuery.grep(elements, function(elem) {
+ var filtered = jQuery.grep(elements, function( elem ) {
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;
});
};
@@ -114,7 +114,7 @@ jQuery.fn.extend({
var pos = jQuery.expr.match.POS.test( selectors ) ?
jQuery( selectors, context || this.context ) : null;
- return this.map(function(i, cur){
+ return this.map(function( i, cur ) {
while ( cur && cur.ownerDocument && cur !== context ) {
if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
return cur;
@@ -157,19 +157,46 @@ jQuery.fn.extend({
});
jQuery.each({
- parent: function(elem){var parent = elem.parentNode; return parent && parent.nodeType !== 11 ? parent : null;},
- parents: function(elem){return jQuery.dir(elem,"parentNode");},
- parentsUntil: function(elem,i,until){return jQuery.dir(elem,"parentNode",until);},
- next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
- 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){
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ 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 ) {
var ret = jQuery.map( this, fn, until );