* Applied patch for #204

* Removed references to $ within dimensions.js
This commit is contained in:
Brandon Aaron 2006-10-07 20:06:52 +00:00
parent 7b2c84ddbe
commit c26ae24a1b
3 changed files with 97 additions and 87 deletions

View File

@ -9,21 +9,21 @@
* If used on window, returns the viewport's (window) height * If used on window, returns the viewport's (window) height
* *
* @example $("#testdiv").height() * @example $("#testdiv").height()
* @result "200px" * @result "200px"
* *
* @example $(document).height(); * @example $(document).height();
* @result 800 * @result 800
* *
* @example $(window).height(); * @example $(window).height();
* @result 400 * @result 400
* *
* @name height * @name height
* @type Object * @type Object
* @cat Dimensions * @cat Dimensions
*/ */
$.fn.height = function() { jQuery.fn.height = function() {
if ( this.get(0) == window ) if ( this.get(0) == window )
return self.innerHeight || return self.innerHeight ||
jQuery.boxModel && document.documentElement.clientHeight || jQuery.boxModel && document.documentElement.clientHeight ||
document.body.clientHeight; document.body.clientHeight;
@ -31,7 +31,7 @@ $.fn.height = function() {
return Math.max( document.body.scrollHeight, document.body.offsetHeight ); return Math.max( document.body.scrollHeight, document.body.offsetHeight );
return this.css("height"); return this.css("height");
}; };
/** /**
* Returns the css width value for the first matched element. * Returns the css width value for the first matched element.
@ -39,21 +39,21 @@ $.fn.height = function() {
* If used on window, returns the viewport's (window) width * If used on window, returns the viewport's (window) width
* *
* @example $("#testdiv").width() * @example $("#testdiv").width()
* @result "200px" * @result "200px"
* *
* @example $(document).width(); * @example $(document).width();
* @result 800 * @result 800
* *
* @example $(window).width(); * @example $(window).width();
* @result 400 * @result 400
* *
* @name width * @name width
* @type Object * @type Object
* @cat Dimensions * @cat Dimensions
*/ */
$.fn.width = function() { jQuery.fn.width = function() {
if ( this.get(0) == window ) if ( this.get(0) == window )
return self.innerWidth || return self.innerWidth ||
jQuery.boxModel && document.documentElement.clientWidth || jQuery.boxModel && document.documentElement.clientWidth ||
document.body.clientWidth; document.body.clientWidth;
@ -61,7 +61,7 @@ $.fn.width = function() {
return Math.max( document.body.scrollWidth, document.body.offsetWidth ); return Math.max( document.body.scrollWidth, document.body.offsetWidth );
return this.css("width"); return this.css("width");
}; };
/** /**
* Returns the inner height value (without border) for the first matched element. * Returns the inner height value (without border) for the first matched element.
@ -75,11 +75,11 @@ $.fn.width = function() {
* @type Number * @type Number
* @cat Dimensions * @cat Dimensions
*/ */
$.fn.innerHeight = function() { jQuery.fn.innerHeight = function() {
return this.get(0) == window || this.get(0) == document ? return this.get(0) == window || this.get(0) == document ?
this.height() : this.height() :
this.get(0).offsetHeight - parseInt(this.css("borderTop") || 0) - parseInt(this.css("borderBottom") || 0); this.get(0).offsetHeight - parseInt(this.css("borderTop") || 0) - parseInt(this.css("borderBottom") || 0);
}; };
/** /**
* Returns the inner width value (without border) for the first matched element. * Returns the inner width value (without border) for the first matched element.
@ -93,11 +93,11 @@ $.fn.innerHeight = function() {
* @type Number * @type Number
* @cat Dimensions * @cat Dimensions
*/ */
$.fn.innerWidth = function() { jQuery.fn.innerWidth = function() {
return this.get(0) == window || this.get(0) == document ? return this.get(0) == window || this.get(0) == document ?
this.width() : this.width() :
this.get(0).offsetWidth - parseInt(this.css("borderLeft") || 0) - parseInt(this.css("borderRight") || 0); this.get(0).offsetWidth - parseInt(this.css("borderLeft") || 0) - parseInt(this.css("borderRight") || 0);
}; };
/** /**
* Returns the outer height value (including border) for the first matched element. * Returns the outer height value (including border) for the first matched element.
@ -110,11 +110,11 @@ $.fn.innerWidth = function() {
* @type Number * @type Number
* @cat Dimensions * @cat Dimensions
*/ */
$.fn.outerHeight = function() { jQuery.fn.outerHeight = function() {
return this.get(0) == window || this.get(0) == document ? return this.get(0) == window || this.get(0) == document ?
this.height() : this.height() :
this.get(0).offsetHeight; this.get(0).offsetHeight;
}; };
/** /**
* Returns the outer width value (including border) for the first matched element. * Returns the outer width value (including border) for the first matched element.
@ -127,11 +127,11 @@ $.fn.outerHeight = function() {
* @type Number * @type Number
* @cat Dimensions * @cat Dimensions
*/ */
$.fn.outerWidth = function() { jQuery.fn.outerWidth = function() {
return this.get(0) == window || this.get(0) == document ? return this.get(0) == window || this.get(0) == document ?
this.width() : this.width() :
this.get(0).offsetWidth; this.get(0).offsetWidth;
}; };
/** /**
* Returns how many pixels the user has scrolled to the right (scrollLeft). * Returns how many pixels the user has scrolled to the right (scrollLeft).
@ -144,14 +144,14 @@ $.fn.outerWidth = function() {
* @type Number * @type Number
* @cat Dimensions * @cat Dimensions
*/ */
$.fn.scrollLeft = function() { jQuery.fn.scrollLeft = function() {
if ( this.get(0) == window || this.get(0) == document ) if ( this.get(0) == window || this.get(0) == document )
return self.pageXOffset || return self.pageXOffset ||
jQuery.boxModel && document.documentElement.scrollLeft || jQuery.boxModel && document.documentElement.scrollLeft ||
document.body.scrollLeft; document.body.scrollLeft;
return this.get(0).scrollLeft; return this.get(0).scrollLeft;
}; };
/** /**
* Returns how many pixels the user has scrolled to the bottom (scrollTop). * Returns how many pixels the user has scrolled to the bottom (scrollTop).
@ -164,20 +164,15 @@ $.fn.scrollLeft = function() {
* @type Number * @type Number
* @cat Dimensions * @cat Dimensions
*/ */
$.fn.scrollTop = function() { jQuery.fn.scrollTop = function() {
if ( this.get(0) == window || this.get(0) == document ) if ( this.get(0) == window || this.get(0) == document )
return self.pageYOffset || return self.pageYOffset ||
jQuery.boxModel && document.documentElement.scrollTop || jQuery.boxModel && document.documentElement.scrollTop ||
document.body.scrollTop; document.body.scrollTop;
return this.get(0).scrollTop; return this.get(0).scrollTop;
}; };
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*/
/** /**
* This returns an object with top, left, width, height, borderLeft, * This returns an object with top, left, width, height, borderLeft,
* borderTop, marginLeft, marginTop, scrollLeft, scrollTop, * borderTop, marginLeft, marginTop, scrollLeft, scrollTop,
@ -253,24 +248,24 @@ $.fn.scrollTop = function() {
* @cat Dimensions * @cat Dimensions
* @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net) * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
*/ */
$.fn.offset = function(refElem) { jQuery.fn.offset = function(refElem) {
if (!this[0]) throw '$.fn.offset requires an element.'; if (!this[0]) throw 'jQuery.fn.offset requires an element.';
refElem = (refElem) ? $(refElem)[0] : null; refElem = (refElem) ? jQuery(refElem)[0] : null;
var x = 0, y = 0, elm = this[0], parent = this[0], pos = null, borders = [0,0], isElm = true, sl = 0, st = 0; var x = 0, y = 0, elm = this[0], parent = this[0], pos = null, borders = [0,0], isElm = true, sl = 0, st = 0;
do { do {
if (parent.tagName == 'BODY' || parent.tagName == 'HTML') { if (parent.tagName == 'BODY' || parent.tagName == 'HTML') {
// Safari and IE don't add margin for static and relative // Safari and IE don't add margin for static and relative
if (($.browser.safari || $.browser.msie) && pos != 'absolute') { if ((jQuery.browser.safari || jQuery.browser.msie) && pos != 'absolute') {
x += parseInt($.css(parent, 'marginLeft')) || 0; x += parseInt(jQuery.css(parent, 'marginLeft')) || 0;
y += parseInt($.css(parent, 'marginTop')) || 0; y += parseInt(jQuery.css(parent, 'marginTop')) || 0;
} }
break; break;
} }
pos = $.css(parent, 'position'); pos = jQuery.css(parent, 'position');
border = [parseInt($.css(parent, 'borderLeftWidth')) || 0, border = [parseInt(jQuery.css(parent, 'borderLeftWidth')) || 0,
parseInt($.css(parent, 'borderTopWidth')) || 0]; parseInt(jQuery.css(parent, 'borderTopWidth')) || 0];
sl = parent.scrollLeft; sl = parent.scrollLeft;
st = parent.scrollTop; st = parent.scrollTop;
@ -278,7 +273,7 @@ $.fn.offset = function(refElem) {
y += (parent.offsetTop || 0) + border[1] - st; y += (parent.offsetTop || 0) + border[1] - st;
// Safari and Opera include the border already for parents with position = absolute|relative // Safari and Opera include the border already for parents with position = absolute|relative
if (($.browser.safari || $.browser.opera) && !isElm && (pos == 'absolute' || pos == 'relative')) { if ((jQuery.browser.safari || jQuery.browser.opera) && !isElm && (pos == 'absolute' || pos == 'relative')) {
x -= border[0]; x -= border[0];
y -= border[1]; y -= border[1];
} }
@ -288,7 +283,7 @@ $.fn.offset = function(refElem) {
} while(parent); } while(parent);
if (refElem) { if (refElem) {
var offset = $(refElem).offset(); var offset = jQuery(refElem).offset();
x = x - offset.left; x = x - offset.left;
y = y - offset.top; y = y - offset.top;
sl = sl - offset.scrollLeft; sl = sl - offset.scrollLeft;
@ -300,10 +295,10 @@ $.fn.offset = function(refElem) {
left: x, left: x,
width: elm.offsetWidth, width: elm.offsetWidth,
height: elm.offsetHeight, height: elm.offsetHeight,
borderTop: parseInt($.css(elm, 'borderTopWidth')) || 0, borderTop: parseInt(jQuery.css(elm, 'borderTopWidth')) || 0,
borderLeft: parseInt($.css(elm, 'borderLeftWidth')) || 0, borderLeft: parseInt(jQuery.css(elm, 'borderLeftWidth')) || 0,
marginTop: parseInt($.css(elm, 'marginTopWidth')) || 0, marginTop: parseInt(jQuery.css(elm, 'marginTopWidth')) || 0,
marginLeft: parseInt($.css(elm, 'marginLeftWidth')) || 0, marginLeft: parseInt(jQuery.css(elm, 'marginLeftWidth')) || 0,
scrollTop: st, scrollTop: st,
scrollLeft: sl, scrollLeft: sl,
pageYOffset: window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0, pageYOffset: window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0,

View File

@ -447,16 +447,10 @@ jQuery.extend({
z.a = function(){ z.a = function(){
if ( options.step ) if ( options.step )
options.step.apply( elem, [ z.now ] ); options.step.apply( elem, [ z.now ] );
if ( prop == "opacity" ) { if ( prop == "opacity" )
if (jQuery.browser.mozilla && z.now == 1) z.now = 0.9999; jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
if (window.ActiveXObject) else if ( parseInt(z.now) ) // My hate for IE will never die
y.filter = "alpha(opacity=" + z.now*100 + ")";
else
y.opacity = z.now;
// My hate for IE will never die
} else if ( parseInt(z.now) )
y[prop] = parseInt(z.now) + "px"; y[prop] = parseInt(z.now) + "px";
y.display = "block"; y.display = "block";
@ -490,8 +484,12 @@ jQuery.extend({
// Remember where we started, so that we can go back to it later // Remember where we started, so that we can go back to it later
z.el.orig[prop] = this.cur(); z.el.orig[prop] = this.cur();
z.custom( 0, z.el.orig[prop] ); // Begin the animation
if (prop == "opacity")
z.custom(z.el.orig[prop], 1);
else
z.custom(0, z.el.orig[prop]);
// Stupid IE, look what you made me do // Stupid IE, look what you made me do
if ( prop != "opacity" ) if ( prop != "opacity" )
@ -511,10 +509,6 @@ jQuery.extend({
z.custom(z.el.orig[prop], 0); z.custom(z.el.orig[prop], 0);
}; };
// IE has trouble with opacity if it does not have layout
if ( jQuery.browser.msie && !z.el.currentStyle.hasLayout )
y.zoom = "1";
// Remember the overflow of the element // Remember the overflow of the element
if ( !z.el.oldOverlay ) if ( !z.el.oldOverlay )
z.el.oldOverflow = jQuery.css( z.el, "overflow" ); z.el.oldOverflow = jQuery.css( z.el, "overflow" );
@ -552,7 +546,10 @@ jQuery.extend({
// Reset the property, if the item has been hidden // Reset the property, if the item has been hidden
if ( z.o.hide ) { if ( z.o.hide ) {
for ( var p in z.el.curAnim ) { for ( var p in z.el.curAnim ) {
y[ p ] = z.el.orig[p] + ( p == "opacity" ? "" : "px" ); if (p == "opacity" && jQuery.browser.msie)
jQuery.attr(y, p, z.el.orig[p]);
else
y[ p ] = z.el.orig[p] + "px";
// set its height and/or width to auto // set its height and/or width to auto
if ( p == 'height' || p == 'width' ) if ( p == 'height' || p == 'width' )

24
src/jquery/jquery.js vendored
View File

@ -98,7 +98,7 @@ if ( typeof $ != "undefined" )
* @desc Creates a div element (and all of its contents) dynamically, * @desc Creates a div element (and all of its contents) dynamically,
* and appends it to the element with the ID of body. Internally, an * and appends it to the element with the ID of body. Internally, an
* element is created and it's innerHTML property set to the given markup. * element is created and it's innerHTML property set to the given markup.
* It is therefore both quite flexible and limited. * It is therefore both quite flexible and limited.
* *
* @name $ * @name $
* @param String expr An expression to search with, or a string of HTML to create on the fly. * @param String expr An expression to search with, or a string of HTML to create on the fly.
@ -1451,14 +1451,16 @@ jQuery.extend({
}); });
return p == "height" ? oHeight : oWidth; return p == "height" ? oHeight : oWidth;
} else if ( p == "opacity" && jQuery.browser.msie ) }
return parseFloat( jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
return jQuery.curCSS( e, p ); return jQuery.curCSS( e, p );
}, },
curCSS: function(elem, prop, force) { curCSS: function(elem, prop, force) {
var ret; var ret;
if (prop == 'opacity' && jQuery.browser.msie)
return jQuery.attr(elem.style, 'opacity');
if (!force && elem.style[prop]) { if (!force && elem.style[prop]) {
@ -1829,6 +1831,22 @@ jQuery.extend({
disabled: "disabled", disabled: "disabled",
checked: "checked" checked: "checked"
}; };
// IE actually uses filters for opacity ... elem is actually elem.style
if (name == "opacity" && jQuery.browser.msie && value != undefined) {
// IE has trouble with opacity if it does not have layout
// Would prefer to check element.hasLayout first but don't have access to the element here
elem['zoom'] = 1;
if (value == 1) // Remove filter to avoid more IE weirdness
return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"");
else
return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")";
} else if (name == "opacity" && jQuery.browser.msie) {
return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1;
}
// Mozilla doesn't play well with opacity 1
if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999;
if ( fix[name] ) { if ( fix[name] ) {
if ( value != undefined ) elem[fix[name]] = value; if ( value != undefined ) elem[fix[name]] = value;