Commit 3f5ff309 authored by Ariel Flesler's avatar Ariel Flesler

jquery: removing unnecessary trailing and leading spaces & tabs.

parent 20a7bff4
jQuery.fn.extend({ jQuery.fn.extend({
// Keep a copy of the old load // Keep a copy of the old load
_load: jQuery.fn.load, _load: jQuery.fn.load,
load: function( url, params, callback ) { load: function( url, params, callback ) {
if ( typeof url != 'string' ) if ( typeof url != 'string' )
return this._load( url ); return this._load( url );
...@@ -71,8 +71,8 @@ jQuery.fn.extend({ ...@@ -71,8 +71,8 @@ jQuery.fn.extend({
jQuery.makeArray(this.elements) : this; jQuery.makeArray(this.elements) : this;
}) })
.filter(function(){ .filter(function(){
return this.name && !this.disabled && return this.name && !this.disabled &&
(this.checked || /select|textarea/i.test(this.nodeName) || (this.checked || /select|textarea/i.test(this.nodeName) ||
/text|hidden|password/i.test(this.type)); /text|hidden|password/i.test(this.type));
}) })
.map(function(i, elem){ .map(function(i, elem){
...@@ -103,7 +103,7 @@ jQuery.extend({ ...@@ -103,7 +103,7 @@ jQuery.extend({
callback = data; callback = data;
data = null; data = null;
} }
return jQuery.ajax({ return jQuery.ajax({
type: "GET", type: "GET",
url: url, url: url,
...@@ -159,7 +159,7 @@ jQuery.extend({ ...@@ -159,7 +159,7 @@ jQuery.extend({
_default: "*/*" _default: "*/*"
} }
}, },
// Last-Modified header cache for next request // Last-Modified header cache for next request
lastModified: {}, lastModified: {},
...@@ -248,7 +248,7 @@ jQuery.extend({ ...@@ -248,7 +248,7 @@ jQuery.extend({
// 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;
success(); success();
...@@ -301,7 +301,7 @@ jQuery.extend({ ...@@ -301,7 +301,7 @@ jQuery.extend({
xml.abort(); xml.abort();
return false; return false;
} }
if ( s.global ) if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]); jQuery.event.trigger("ajaxSend", [xml, s]);
...@@ -310,13 +310,13 @@ jQuery.extend({ ...@@ -310,13 +310,13 @@ jQuery.extend({
// The transfer is complete and the data is available, or the request timed out // The transfer is complete and the data is available, or the request timed out
if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) { if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
requestDone = true; requestDone = true;
// clear poll interval // clear poll interval
if (ival) { if (ival) {
clearInterval(ival); clearInterval(ival);
ival = null; ival = null;
} }
status = isTimeout == "timeout" && "timeout" || status = isTimeout == "timeout" && "timeout" ||
!jQuery.httpSuccess( xml ) && "error" || !jQuery.httpSuccess( xml ) && "error" ||
s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" || s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
...@@ -339,13 +339,13 @@ jQuery.extend({ ...@@ -339,13 +339,13 @@ jQuery.extend({
try { try {
modRes = xml.getResponseHeader("Last-Modified"); modRes = xml.getResponseHeader("Last-Modified");
} catch(e) {} // swallow exception thrown by FF if header is not available } catch(e) {} // swallow exception thrown by FF if header is not available
if ( s.ifModified && modRes ) if ( s.ifModified && modRes )
jQuery.lastModified[s.url] = modRes; jQuery.lastModified[s.url] = modRes;
// JSONP handles its own success callback // JSONP handles its own success callback
if ( !jsonp ) if ( !jsonp )
success(); success();
} else } else
jQuery.handleError(s, xml, status); jQuery.handleError(s, xml, status);
...@@ -357,10 +357,10 @@ jQuery.extend({ ...@@ -357,10 +357,10 @@ jQuery.extend({
xml = null; xml = null;
} }
}; };
if ( s.async ) { if ( s.async ) {
// don't attach the handler to the request, just poll it instead // don't attach the handler to the request, just poll it instead
var ival = setInterval(onreadystatechange, 13); var ival = setInterval(onreadystatechange, 13);
// Timeout checker // Timeout checker
if ( s.timeout > 0 ) if ( s.timeout > 0 )
...@@ -369,20 +369,20 @@ jQuery.extend({ ...@@ -369,20 +369,20 @@ jQuery.extend({
if ( xml ) { if ( xml ) {
// Cancel the request // Cancel the request
xml.abort(); xml.abort();
if( !requestDone ) if( !requestDone )
onreadystatechange( "timeout" ); onreadystatechange( "timeout" );
} }
}, s.timeout); }, s.timeout);
} }
// Send the data // Send the data
try { try {
xml.send(s.data); xml.send(s.data);
} catch(e) { } catch(e) {
jQuery.handleError(s, xml, null, e); jQuery.handleError(s, xml, null, e);
} }
// firefox 1.5 doesn't fire statechange for sync requests // firefox 1.5 doesn't fire statechange for sync requests
if ( !s.async ) if ( !s.async )
onreadystatechange(); onreadystatechange();
...@@ -410,7 +410,7 @@ jQuery.extend({ ...@@ -410,7 +410,7 @@ jQuery.extend({
if ( s.global && ! --jQuery.active ) if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" ); jQuery.event.trigger( "ajaxStop" );
} }
// return XMLHttpRequest to allow aborting the request etc. // return XMLHttpRequest to allow aborting the request etc.
return xml; return xml;
}, },
......
This diff is collapsed.
...@@ -3,23 +3,23 @@ jQuery.each([ "Height", "Width" ], function(i, name){ ...@@ -3,23 +3,23 @@ jQuery.each([ "Height", "Width" ], function(i, name){
var tl = name == "Height" ? "Top" : "Left", // top or left var tl = name == "Height" ? "Top" : "Left", // top or left
br = name == "Height" ? "Bottom" : "Right"; // bottom or right br = name == "Height" ? "Bottom" : "Right"; // bottom or right
// innerHeight and innerWidth // innerHeight and innerWidth
jQuery.fn["inner" + name] = function(){ jQuery.fn["inner" + name] = function(){
return this[ name.toLowerCase() ]() + return this[ name.toLowerCase() ]() +
num(this, "padding" + tl) + num(this, "padding" + tl) +
num(this, "padding" + br); num(this, "padding" + br);
}; };
// outerHeight and outerWidth // outerHeight and outerWidth
jQuery.fn["outer" + name] = function(margin) { jQuery.fn["outer" + name] = function(margin) {
return this["inner" + name]() + return this["inner" + name]() +
num(this, "border" + tl + "Width") + num(this, "border" + tl + "Width") +
num(this, "border" + br + "Width") + num(this, "border" + br + "Width") +
(!!margin ? (!!margin ?
num(this, "margin" + tl) + num(this, "margin" + br) : 0); num(this, "margin" + tl) + num(this, "margin" + br) : 0);
}; };
}); });
function num(elem, prop) { function num(elem, prop) {
......
This diff is collapsed.
...@@ -4,7 +4,7 @@ jQuery.fn.extend({ ...@@ -4,7 +4,7 @@ jQuery.fn.extend({
this.animate({ this.animate({
height: "show", width: "show", opacity: "show" height: "show", width: "show", opacity: "show"
}, speed, callback) : }, speed, callback) :
this.filter(":hidden").each(function(){ this.filter(":hidden").each(function(){
this.style.display = this.oldblock || ""; this.style.display = this.oldblock || "";
if ( jQuery.css(this,"display") == "none" ) { if ( jQuery.css(this,"display") == "none" ) {
...@@ -17,13 +17,13 @@ jQuery.fn.extend({ ...@@ -17,13 +17,13 @@ jQuery.fn.extend({
} }
}).end(); }).end();
}, },
hide: function(speed,callback){ hide: function(speed,callback){
return speed ? return speed ?
this.animate({ this.animate({
height: "hide", width: "hide", opacity: "hide" height: "hide", width: "hide", opacity: "hide"
}, speed, callback) : }, speed, callback) :
this.filter(":visible").each(function(){ this.filter(":visible").each(function(){
this.oldblock = this.oldblock || jQuery.css(this,"display"); this.oldblock = this.oldblock || jQuery.css(this,"display");
this.style.display = "none"; this.style.display = "none";
...@@ -32,7 +32,7 @@ jQuery.fn.extend({ ...@@ -32,7 +32,7 @@ jQuery.fn.extend({
// Save the old toggle function // Save the old toggle function
_toggle: jQuery.fn.toggle, _toggle: jQuery.fn.toggle,
toggle: function( fn, fn2 ){ toggle: function( fn, fn2 ){
return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
this._toggle.apply( this, arguments ) : this._toggle.apply( this, arguments ) :
...@@ -44,11 +44,11 @@ jQuery.fn.extend({ ...@@ -44,11 +44,11 @@ jQuery.fn.extend({
jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ](); jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
}); });
}, },
slideDown: function(speed,callback){ slideDown: function(speed,callback){
return this.animate({height: "show"}, speed, callback); return this.animate({height: "show"}, speed, callback);
}, },
slideUp: function(speed,callback){ slideUp: function(speed,callback){
return this.animate({height: "hide"}, speed, callback); return this.animate({height: "hide"}, speed, callback);
}, },
...@@ -56,19 +56,19 @@ jQuery.fn.extend({ ...@@ -56,19 +56,19 @@ jQuery.fn.extend({
slideToggle: function(speed, callback){ slideToggle: function(speed, callback){
return this.animate({height: "toggle"}, speed, callback); return this.animate({height: "toggle"}, speed, callback);
}, },
fadeIn: function(speed, callback){ fadeIn: function(speed, callback){
return this.animate({opacity: "show"}, speed, callback); return this.animate({opacity: "show"}, speed, callback);
}, },
fadeOut: function(speed, callback){ fadeOut: function(speed, callback){
return this.animate({opacity: "hide"}, speed, callback); return this.animate({opacity: "hide"}, speed, callback);
}, },
fadeTo: function(speed,to,callback){ fadeTo: function(speed,to,callback){
return this.animate({opacity: to}, speed, callback); return this.animate({opacity: to}, speed, callback);
}, },
animate: function( prop, speed, easing, callback ) { animate: function( prop, speed, easing, callback ) {
var optall = jQuery.speed(speed, easing, callback); var optall = jQuery.speed(speed, easing, callback);
...@@ -78,7 +78,7 @@ jQuery.fn.extend({ ...@@ -78,7 +78,7 @@ jQuery.fn.extend({
var opt = jQuery.extend({}, optall), p, var opt = jQuery.extend({}, optall), p,
hidden = jQuery(this).is(":hidden"), self = this; hidden = jQuery(this).is(":hidden"), self = this;
for ( p in prop ) { for ( p in prop ) {
if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
return jQuery.isFunction(opt.complete) && opt.complete.call(this); return jQuery.isFunction(opt.complete) && opt.complete.call(this);
...@@ -96,7 +96,7 @@ jQuery.fn.extend({ ...@@ -96,7 +96,7 @@ jQuery.fn.extend({
this.style.overflow = "hidden"; this.style.overflow = "hidden";
opt.curAnim = jQuery.extend({}, prop); opt.curAnim = jQuery.extend({}, prop);
jQuery.each( prop, function(name, val){ jQuery.each( prop, function(name, val){
var e = new jQuery.fx( self, opt, name ); var e = new jQuery.fx( self, opt, name );
...@@ -131,7 +131,7 @@ jQuery.fn.extend({ ...@@ -131,7 +131,7 @@ jQuery.fn.extend({
return true; return true;
}); });
}, },
queue: function(type, fn){ queue: function(type, fn){
if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) { if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
fn = type; fn = type;
...@@ -146,7 +146,7 @@ jQuery.fn.extend({ ...@@ -146,7 +146,7 @@ jQuery.fn.extend({
queue(this, type, fn); queue(this, type, fn);
else { else {
queue(this, type).push( fn ); queue(this, type).push( fn );
if ( queue(this, type).length == 1 ) if ( queue(this, type).length == 1 )
fn.call(this); fn.call(this);
} }
...@@ -181,11 +181,11 @@ jQuery.fn.extend({ ...@@ -181,11 +181,11 @@ jQuery.fn.extend({
var queue = function( elem, type, array ) { var queue = function( elem, type, array ) {
if ( elem ){ if ( elem ){
type = type || "fx"; type = type || "fx";
var q = jQuery.data( elem, type + "queue" ); var q = jQuery.data( elem, type + "queue" );
if ( !q || array ) if ( !q || array )
q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) ); q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
...@@ -207,19 +207,19 @@ jQuery.fn.dequeue = function(type){ ...@@ -207,19 +207,19 @@ jQuery.fn.dequeue = function(type){
}; };
jQuery.extend({ jQuery.extend({
speed: function(speed, easing, fn) { speed: function(speed, easing, fn) {
var opt = speed && speed.constructor == Object ? speed : { var opt = speed && speed.constructor == Object ? speed : {
complete: fn || !fn && easing || complete: fn || !fn && easing ||
jQuery.isFunction( speed ) && speed, jQuery.isFunction( speed ) && speed,
duration: speed, duration: speed,
easing: fn && easing || easing && easing.constructor != Function && easing easing: fn && easing || easing && easing.constructor != Function && easing
}; };
opt.duration = (opt.duration && opt.duration.constructor == Number ? opt.duration = (opt.duration && opt.duration.constructor == Number ?
opt.duration : opt.duration :
jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def; jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
// Queueing // Queueing
opt.old = opt.complete; opt.old = opt.complete;
opt.complete = function(){ opt.complete = function(){
...@@ -228,10 +228,10 @@ jQuery.extend({ ...@@ -228,10 +228,10 @@ jQuery.extend({
if ( jQuery.isFunction( opt.old ) ) if ( jQuery.isFunction( opt.old ) )
opt.old.call( this ); opt.old.call( this );
}; };
return opt; return opt;
}, },
easing: { easing: {
linear: function( p, n, firstNum, diff ) { linear: function( p, n, firstNum, diff ) {
return firstNum + diff * p; return firstNum + diff * p;
...@@ -240,7 +240,7 @@ jQuery.extend({ ...@@ -240,7 +240,7 @@ jQuery.extend({
return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
} }
}, },
timers: [], timers: [],
timerId: null, timerId: null,
...@@ -300,7 +300,7 @@ jQuery.fx.prototype = { ...@@ -300,7 +300,7 @@ jQuery.fx.prototype = {
if ( jQuery.timerId == null ) { if ( jQuery.timerId == null ) {
jQuery.timerId = setInterval(function(){ jQuery.timerId = setInterval(function(){
var timers = jQuery.timers; var timers = jQuery.timers;
for ( var i = 0; i < timers.length; i++ ) for ( var i = 0; i < timers.length; i++ )
if ( !timers[i]() ) if ( !timers[i]() )
timers.splice(i--, 1); timers.splice(i--, 1);
...@@ -326,7 +326,7 @@ jQuery.fx.prototype = { ...@@ -326,7 +326,7 @@ jQuery.fx.prototype = {
// flash of content // flash of content
if ( this.prop == "width" || this.prop == "height" ) if ( this.prop == "width" || this.prop == "height" )
this.elem.style[this.prop] = "1px"; this.elem.style[this.prop] = "1px";
// Start by showing the element // Start by showing the element
jQuery(this.elem).show(); jQuery(this.elem).show();
}, },
...@@ -361,7 +361,7 @@ jQuery.fx.prototype = { ...@@ -361,7 +361,7 @@ jQuery.fx.prototype = {
if ( this.options.display != null ) { if ( this.options.display != null ) {
// Reset the overflow // Reset the overflow
this.elem.style.overflow = this.options.overflow; this.elem.style.overflow = this.options.overflow;
// Reset the display // Reset the display
this.elem.style.display = this.options.display; this.elem.style.display = this.options.display;
if ( jQuery.css(this.elem, "display") == "none" ) if ( jQuery.css(this.elem, "display") == "none" )
...@@ -403,7 +403,7 @@ jQuery.fx.prototype = { ...@@ -403,7 +403,7 @@ jQuery.fx.prototype = {
jQuery.extend( jQuery.fx, { jQuery.extend( jQuery.fx, {
speeds:{ speeds:{
slow: 600, slow: 600,
fast: 200, fast: 200,
// Default speed // Default speed
def: 400 def: 400
...@@ -412,15 +412,15 @@ jQuery.extend( jQuery.fx, { ...@@ -412,15 +412,15 @@ jQuery.extend( jQuery.fx, {
scrollLeft: function(fx){ scrollLeft: function(fx){
fx.elem.scrollLeft = fx.now; fx.elem.scrollLeft = fx.now;
}, },
scrollTop: function(fx){ scrollTop: function(fx){
fx.elem.scrollTop = fx.now; fx.elem.scrollTop = fx.now;
}, },
opacity: function(fx){ opacity: function(fx){
jQuery.attr(fx.elem.style, "opacity", fx.now); jQuery.attr(fx.elem.style, "opacity", fx.now);
}, },
_default: function(fx){ _default: function(fx){
fx.elem.style[ fx.prop ] = fx.now + fx.unit; fx.elem.style[ fx.prop ] = fx.now + fx.unit;
} }
......
...@@ -3,24 +3,24 @@ ...@@ -3,24 +3,24 @@
// http://jquery.com/plugins/project/dimensions // http://jquery.com/plugins/project/dimensions
jQuery.fn.offset = function() { jQuery.fn.offset = function() {
var left = 0, top = 0, elem = this[0], results; var left = 0, top = 0, elem = this[0], results;
if ( elem ) with ( jQuery.browser ) { if ( elem ) with ( jQuery.browser ) {
var parent = elem.parentNode, var parent = elem.parentNode,
offsetChild = elem, offsetChild = elem,
offsetParent = elem.offsetParent, offsetParent = elem.offsetParent,
doc = elem.ownerDocument, doc = elem.ownerDocument,
safari2 = safari && parseInt(version) < 522 && !/adobeair/i.test(userAgent), safari2 = safari && parseInt(version) < 522 && !/adobeair/i.test(userAgent),
css = jQuery.curCSS, css = jQuery.curCSS,
fixed = css(elem, "position") == "fixed"; fixed = css(elem, "position") == "fixed";
// Use getBoundingClientRect if available // Use getBoundingClientRect if available
if ( elem.getBoundingClientRect ) { if ( elem.getBoundingClientRect ) {
var box = elem.getBoundingClientRect(); var box = elem.getBoundingClientRect();
// Add the document scroll offsets // Add the document scroll offsets
add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft), add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)); box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
// IE adds the HTML element's border, by default it is medium which is 2px // IE adds the HTML element's border, by default it is medium which is 2px
// IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; } // IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
// IE 7 standards mode, the border is always 2px // IE 7 standards mode, the border is always 2px
...@@ -28,54 +28,54 @@ jQuery.fn.offset = function() { ...@@ -28,54 +28,54 @@ jQuery.fn.offset = function() {
// However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS // However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS
// Therefore this method will be off by 2px in IE while in quirksmode // Therefore this method will be off by 2px in IE while in quirksmode
add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop ); add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop );
// Otherwise loop through the offsetParents and parentNodes // Otherwise loop through the offsetParents and parentNodes
} else { } else {
// Initial element offsets // Initial element offsets
add( elem.offsetLeft, elem.offsetTop ); add( elem.offsetLeft, elem.offsetTop );
// Get parent offsets // Get parent offsets
while ( offsetParent ) { while ( offsetParent ) {
// Add offsetParent offsets // Add offsetParent offsets
add( offsetParent.offsetLeft, offsetParent.offsetTop ); add( offsetParent.offsetLeft, offsetParent.offsetTop );
// Mozilla and Safari > 2 does not include the border on offset parents // Mozilla and Safari > 2 does not include the border on offset parents
// However Mozilla adds the border for table or table cells // However Mozilla adds the border for table or table cells
if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 ) if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 )
border( offsetParent ); border( offsetParent );
// Add the document scroll offsets if position is fixed on any offsetParent // Add the document scroll offsets if position is fixed on any offsetParent
if ( !fixed && css(offsetParent, "position") == "fixed" ) if ( !fixed && css(offsetParent, "position") == "fixed" )
fixed = true; fixed = true;
// Set offsetChild to previous offsetParent unless it is the body element // Set offsetChild to previous offsetParent unless it is the body element
offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent; offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
// Get next offsetParent // Get next offsetParent
offsetParent = offsetParent.offsetParent; offsetParent = offsetParent.offsetParent;
} }
// Get parent scroll offsets // Get parent scroll offsets
while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) { while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
// Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
if ( !/^inline|table.*$/i.test(css(parent, "display")) ) if ( !/^inline|table.*$/i.test(css(parent, "display")) )
// Subtract parent scroll offsets // Subtract parent scroll offsets
add( -parent.scrollLeft, -parent.scrollTop ); add( -parent.scrollLeft, -parent.scrollTop );
// Mozilla does not add the border for a parent that has overflow != visible // Mozilla does not add the border for a parent that has overflow != visible
if ( mozilla && css(parent, "overflow") != "visible" ) if ( mozilla && css(parent, "overflow") != "visible" )
border( parent ); border( parent );
// Get next parent // Get next parent
parent = parent.parentNode; parent = parent.parentNode;
} }
// Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild // Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
// Mozilla doubles body offsets with a non-absolutely positioned offsetChild // Mozilla doubles body offsets with a non-absolutely positioned offsetChild
if ( (safari2 && (fixed || css(offsetChild, "position") == "absolute")) || if ( (safari2 && (fixed || css(offsetChild, "position") == "absolute")) ||
(mozilla && css(offsetChild, "position") != "absolute") ) (mozilla && css(offsetChild, "position") != "absolute") )
add( -doc.body.offsetLeft, -doc.body.offsetTop ); add( -doc.body.offsetLeft, -doc.body.offsetTop );
// Add the document scroll offsets if position is fixed // Add the document scroll offsets if position is fixed
if ( fixed ) if ( fixed )
add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft), add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
...@@ -102,33 +102,33 @@ jQuery.fn.offset = function() { ...@@ -102,33 +102,33 @@ jQuery.fn.offset = function() {
jQuery.fn.extend({ jQuery.fn.extend({
position: function() { position: function() {
var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results; var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;
if (elem) { if (elem) {
// Get *real* offsetParent // Get *real* offsetParent
offsetParent = this.offsetParent(); offsetParent = this.offsetParent();
// Get correct offsets // Get correct offsets
offset = this.offset(); offset = this.offset();
parentOffset = offsetParent.offset(); parentOffset = offsetParent.offset();
// Subtract element margins // Subtract element margins
offset.top -= parseInt( jQuery.curCSS(elem, 'marginTop', true) ) || 0; offset.top -= parseInt( jQuery.curCSS(elem, 'marginTop', true) ) || 0;
offset.left -= parseInt( jQuery.curCSS(elem, 'marginLeft', true) ) || 0; offset.left -= parseInt( jQuery.curCSS(elem, 'marginLeft', true) ) || 0;
// Add offsetParent borders // Add offsetParent borders
parentOffset.top += parseInt( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0; parentOffset.top += parseInt( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0;
parentOffset.left += parseInt( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0; parentOffset.left += parseInt( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0;
// Subtract the two offsets // Subtract the two offsets
results = { results = {
top: offset.top - parentOffset.top, top: offset.top - parentOffset.top,
left: offset.left - parentOffset.left left: offset.left - parentOffset.left
}; };
} }
return results; return results;
}, },
offsetParent: function() { offsetParent: function() {
var offsetParent = this[0].offsetParent; var offsetParent = this[0].offsetParent;
while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') ) while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') )
...@@ -142,19 +142,19 @@ jQuery.fn.extend({ ...@@ -142,19 +142,19 @@ jQuery.fn.extend({
jQuery.each( ['Left', 'Top'], function(i, name) { jQuery.each( ['Left', 'Top'], function(i, name) {
jQuery.fn[ 'scroll' + name ] = function(val) { jQuery.fn[ 'scroll' + name ] = function(val) {
if (!this[0]) return; if (!this[0]) return;
return val != undefined ? return val != undefined ?
// Set the scroll offset // Set the scroll offset
this.each(function() { this.each(function() {
this == window || this == document ? this == window || this == document ?
window.scrollTo( window.scrollTo(
name == 'Left' ? val : jQuery(window)[ 'scrollLeft' ](), name == 'Left' ? val : jQuery(window)[ 'scrollLeft' ](),
name == 'Top' ? val : jQuery(window)[ 'scrollTop' ]() name == 'Top' ? val : jQuery(window)[ 'scrollTop' ]()
) : ) :
this[ 'scroll' + name ] = val; this[ 'scroll' + name ] = val;
}) : }) :
// Return the scroll offset // Return the scroll offset
this[0] == window || this[0] == document ? this[0] == window || this[0] == document ?
self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] || self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
......
...@@ -64,7 +64,7 @@ jQuery.extend({ ...@@ -64,7 +64,7 @@ jQuery.extend({
animated: function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;} animated: function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}
} }
}, },
// The regular expressions that power the parsing engine // The regular expressions that power the parsing engine
parse: [ parse: [
// Match: [@value='test'], [@foo] // Match: [@value='test'], [@foo]
...@@ -118,7 +118,7 @@ jQuery.extend({ ...@@ -118,7 +118,7 @@ jQuery.extend({
// An attempt at speeding up child selectors that // An attempt at speeding up child selectors that
// point to a specific element tag // point to a specific element tag
re = quickChild, re = quickChild,
m = re.exec(t); m = re.exec(t);
if ( m ) { if ( m ) {
...@@ -151,12 +151,12 @@ jQuery.extend({ ...@@ -151,12 +151,12 @@ jQuery.extend({
var id = jQuery.data(n); var id = jQuery.data(n);
if ( m == "~" && merge[id] ) break; if ( m == "~" && merge[id] ) break;
if (!nodeName || n.nodeName.toUpperCase() == nodeName ) { if (!nodeName || n.nodeName.toUpperCase() == nodeName ) {
if ( m == "~" ) merge[id] = true; if ( m == "~" ) merge[id] = true;
r.push( n ); r.push( n );
} }
if ( m == "+" ) break; if ( m == "+" ) break;
} }
} }
...@@ -190,7 +190,7 @@ jQuery.extend({ ...@@ -190,7 +190,7 @@ jQuery.extend({
// Optimize for the case nodeName#idName // Optimize for the case nodeName#idName
var re2 = quickID; var re2 = quickID;
var m = re2.exec(t); var m = re2.exec(t);
// Re-organize the results, so that they're consistent // Re-organize the results, so that they're consistent
if ( m ) { if ( m ) {
m = [ 0, m[2], m[3], m[1] ]; m = [ 0, m[2], m[3], m[1] ];
...@@ -210,7 +210,7 @@ jQuery.extend({ ...@@ -210,7 +210,7 @@ jQuery.extend({
if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) { if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
// Optimization for HTML document case // Optimization for HTML document case
var oid = elem.getElementById(m[2]); var oid = elem.getElementById(m[2]);
// Do a quick check for the existence of the actual ID attribute // Do a quick check for the existence of the actual ID attribute
// to avoid selecting by the name attribute in IE // to avoid selecting by the name attribute in IE
// also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
...@@ -332,10 +332,10 @@ jQuery.extend({ ...@@ -332,10 +332,10 @@ jQuery.extend({
else if ( m[1] == "[" ) { else if ( m[1] == "[" ) {
var tmp = [], type = m[3]; var tmp = [], type = m[3];
for ( var i = 0, rl = r.length; i < rl; i++ ) { for ( var i = 0, rl = r.length; i < rl; i++ ) {
var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ]; var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
if ( z == null || /href|src|selected/.test(m[2]) ) if ( z == null || /href|src|selected/.test(m[2]) )
z = jQuery.attr(a,m[2]) || ''; z = jQuery.attr(a,m[2]) || '';
...@@ -347,7 +347,7 @@ jQuery.extend({ ...@@ -347,7 +347,7 @@ jQuery.extend({
(type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not ) (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
tmp.push( a ); tmp.push( a );
} }
r = tmp; r = tmp;
// We can get a speed boost by handling nth-child here // We can get a speed boost by handling nth-child here
...@@ -359,7 +359,7 @@ jQuery.extend({ ...@@ -359,7 +359,7 @@ jQuery.extend({
!/\D/.test(m[3]) && "0n+" + m[3] || m[3]), !/\D/.test(m[3]) && "0n+" + m[3] || m[3]),
// calculate the numbers (first)n+(last) including if they are negative // calculate the numbers (first)n+(last) including if they are negative
first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0; first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0;
// loop through all the elements left in the jQuery object // loop through all the elements left in the jQuery object
for ( var i = 0, rl = r.length; i < rl; i++ ) { for ( var i = 0, rl = r.length; i < rl; i++ ) {
var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode); var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
...@@ -419,7 +419,7 @@ jQuery.extend({ ...@@ -419,7 +419,7 @@ jQuery.extend({
} }
return matched; return matched;
}, },
nth: function(cur,result,dir,elem){ nth: function(cur,result,dir,elem){
result = result || 1; result = result || 1;
var num = 0; var num = 0;
...@@ -430,7 +430,7 @@ jQuery.extend({ ...@@ -430,7 +430,7 @@ jQuery.extend({
return cur; return cur;
}, },
sibling: function( n, elem ) { sibling: function( n, elem ) {
var r = []; var r = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment