X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=e12245c05616bd63af54e03f4f5313e1de0319b8;hb=68313e77488d98d7419e87c7090d4ec9b9d4882b;hp=f2e9c1816e1c32e9467534ef9cf74589e257f30e;hpb=7cc550727c4e0bcd93c5d435f0799f568fc74dfa;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index f2e9c18..e12245c 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -42,7 +42,7 @@ var jQuery = function(a,c) { return new jQuery(a,c); // Handle HTML strings - if ( a.constructor == String ) { + if ( typeof a == "string" ) { var m = /^[^<]*(<.+>)[^>]*$/.exec(a); if ( m ) a = jQuery.clean( [ m[1] ] ); } @@ -68,6 +68,9 @@ var jQuery = function(a,c) { // Map over the $ in case of overwrite if ( typeof $ != "undefined" ) jQuery._$ = $; + +// Map the jQuery namespace to the '$' one +var $ = jQuery; /** * This function accepts a string containing a CSS selector, @@ -181,9 +184,6 @@ if ( typeof $ != "undefined" ) * @type jQuery */ -// Map the jQuery namespace to the '$' one -var $ = jQuery; - jQuery.fn = jQuery.prototype = { /** * The current version of jQuery. @@ -863,7 +863,7 @@ jQuery.fn = jQuery.prototype = { for ( var i = 0; i < t.length; i++ ) if ( jQuery.filter(t[i],[a]).r.length ) return a; - return false; + return null; }) || t.constructor == Boolean && @@ -904,7 +904,7 @@ jQuery.fn = jQuery.prototype = { * @cat DOM/Traversing */ not: function(t) { - return this.pushStack( t.constructor == String ? + return this.pushStack( typeof t == "string" ? jQuery.filter(t,this,false).r : jQuery.grep(this,function(a){ return a != t; }), arguments ); }, @@ -951,7 +951,7 @@ jQuery.fn = jQuery.prototype = { * @cat DOM/Traversing */ add: function(t) { - return this.pushStack( jQuery.merge( this, t.constructor == String ? + return this.pushStack( jQuery.merge( this, typeof t == "string" ? jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments ); }, @@ -1121,7 +1121,7 @@ jQuery.extend({ jQuery.each( jQuery.macros.axis, function(i,n){ jQuery.fn[ i ] = function(a) { var ret = jQuery.map(this,n); - if ( a && a.constructor == String ) + if ( a && typeof a == "string" ) ret = jQuery.filter(a,ret).r; return this.pushStack( ret, arguments ); }; @@ -1324,7 +1324,7 @@ jQuery.extend({ var r = []; for ( var i = 0; i < a.length; i++ ) { var arg = a[i]; - if ( arg.constructor == String ) { // Convert html string into DOM nodes + if ( typeof arg == "string" ) { // Convert html string into DOM nodes // Trim whitespace, otherwise indexOf won't work as expected var s = jQuery.trim(arg), div = document.createElement("div"), wrap = [0,"",""]; @@ -1401,7 +1401,7 @@ jQuery.extend({ image: "a.type=='image'", reset: "a.type=='reset'", button: "a.type=='button'", - input: "a.nodeName.toLowerCase().match(/input|select|textarea|button/)" + input: "/input|select|textarea|button/i.test(a.nodeName)" }, ".": "jQuery.className.has(a,m[2])", "@": { @@ -1777,7 +1777,7 @@ jQuery.extend({ grep: function(elems, fn, inv) { // If a string is passed in for the function, make a function // for it (a handy shortcut) - if ( fn.constructor == String ) + if ( typeof fn == "string" ) fn = new Function("a","i","return " + fn); var result = []; @@ -1823,7 +1823,7 @@ jQuery.extend({ map: function(elems, fn) { // If a string is passed in for the function, make a function // for it (a handy shortcut) - if ( fn.constructor == String ) + if ( typeof fn == "string" ) fn = new Function("a","return " + fn); var result = []; @@ -1959,9 +1959,16 @@ jQuery.extend({ fix: function(event) { // check IE if(jQuery.browser.msie) { - // fix target property - event.target = event.srcElement; - + // fix target property, if available + // check prevents overwriting of fake target coming from trigger + if(event.srcElement) + event.target = event.srcElement; + + // calculate pageX/Y + var e = document.documentElement, b = document.body; + event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft); + event.pageY = event.clientY + (e.scrollTop || b.scrollTop); + // check safari and if target is a textnode } else if(jQuery.browser.safari && event.target.nodeType == 3) { // target is readonly, clone the event object @@ -1980,7 +1987,7 @@ jQuery.extend({ event.stopPropagation = function() { this.cancelBubble = true; }; - + return event; } } @@ -3010,8 +3017,6 @@ jQuery.macros = { * @cat Events */ bind: function( type, fn ) { - if ( fn.constructor == String ) - fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn); jQuery.event.add( this, type, fn ); },