X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=jquery%2Fjquery.js;h=fafed0ea0b3428f300a296e5b7862f6fcb8fb5ee;hb=894fc4b280b9ea967a4da08ce6b26462837b033f;hp=cfac542b2816ddc529d69d37bbc6eb8208c16371;hpb=f9dbb9f73a7336b826533a6b1d81e2e759380948;p=jquery.git diff --git a/jquery/jquery.js b/jquery/jquery.js index cfac542..fafed0e 100644 --- a/jquery/jquery.js +++ b/jquery/jquery.js @@ -320,12 +320,18 @@ function $(a,c) { (function(){ var b = navigator.userAgent.toLowerCase(); + + // Figure out what browser is being used $.browser = - ( /safari/.test(b) && "safari" ) || + ( /webkit/.test(b) && "safari" ) || ( /opera/.test(b) && "opera" ) || ( /msie/.test(b) && "msie" ) || ( !/compatible/.test(b) && "mozilla" ) || "other"; + + // Check to see if the W3C box model is being used + $.boxModel = ( $.browser != "msie" || + document.compatMode == "CSS1Compat" ); })(); $.apply = function(o,f,a) { @@ -347,10 +353,15 @@ $.apply = function(o,f,a) { $.getCSS = function(e,p) { // Adapted from Prototype 1.4.0 if ( p == 'height' || p == 'width' ) { - var ph = $.browser == "msie" ? 0 : - parseInt($.css(e,"paddingTop")) + parseInt($.css(e,"paddingBottom")); - var pw = $.browser == "msie" ? 0 : - parseInt($.css(e,"paddingLeft")) + parseInt($.css(e,"paddingRight")); + + // Handle extra width/height provided by the W3C box model + var ph = !$.boxModel ? 0 : + parseInt($.css(e,"paddingTop")) + parseInt($.css(e,"paddingBottom")) + + parseInt($.css(e,"borderTop")) + parseInt($.css(e,"borderBottom")); + + var pw = !$.boxModel ? 0 : + parseInt($.css(e,"paddingLeft")) + parseInt($.css(e,"paddingRight")) + + parseInt($.css(e,"borderLeft")) + parseInt($.css(e,"borderRight")); var oHeight, oWidth; @@ -596,8 +607,7 @@ $.attr = function(o,a,v){ 'for': 'htmlFor', 'text': 'cssText', 'class': 'className', - 'float': 'cssFloat', - 'style': 'cssText' + 'float': 'cssFloat' }; a = (fix[a] && fix[a].replace && fix[a]) || a; var r = new RegExp("-([a-z])","ig"); @@ -767,7 +777,12 @@ $.event = {}; // Bind an event to an element // Original by Dean Edwards $.event.add = function(element, type, handler) { - if ( element.location ) { element = window; } // Ughhhhh.... + // For whatever reason, IE has trouble passing the window object + // around, causing it to be cloned in the process + if ( $.browser == "msie" && typeof element.setInterval != "undefined" ) { + element = window; + } + if (!handler.$$guid) { handler.$$guid = $.event.add.guid++; } if (!element.events) { element.events = {}; } var handlers = element.events[type]; @@ -803,7 +818,7 @@ $.event.remove = function(element, type, handler) { }; $.event.trigger = function(element,type,data) { - data = data || [{ type: type }]; + data = data || [ $.event.fix({ type: type }) ]; if ( element && element["on" + type] ) { $.apply( element, element["on" + type], data ); }