*/\r
var jQuery = function(a,c) {\r
\r
- // Shortcut for document ready (because $(document).each() is silly)\r
+ // Shortcut for document ready\r
if ( a && typeof a == "function" && jQuery.fn.ready && !a.nodeType && a[0] == undefined ) // Safari reports typeof on DOM NodeLists as a function\r
return jQuery(document).ready(a);\r
\r
// Find the matching elements and save them for later\r
jQuery.find( a, c ) );\r
\r
+ // See if an extra function was provided\r
+ var fn = arguments[ arguments.length - 1 ];\r
+\r
+ // If so, execute it in context\r
+ if ( fn && typeof fn == "function" )\r
+ this.each(fn);\r
+\r
return this;\r
};\r
\r
*/\r
attr: function( key, value, type ) {\r
// Check to see if we're setting style values\r
- return key.constructor != String || value != undefined ?\r
+ return typeof key != "string" || value != undefined ?\r
this.each(function(){\r
// See if we're setting a hash of styles\r
if ( value == undefined )\r
find: function(t) {\r
return this.pushStack( jQuery.map( this, function(a){\r
return jQuery.find(t,a);\r
- }));\r
+ }), arguments );\r
},\r
\r
/**\r
clone: function(deep) {\r
return this.pushStack( jQuery.map( this, function(a){\r
return a.cloneNode( deep != undefined ? deep : true );\r
- }));\r
+ }), arguments );\r
},\r
\r
/**\r
typeof t == "function" &&\r
jQuery.grep( this, t ) ||\r
\r
- jQuery.filter(t,this).r );\r
+ jQuery.filter(t,this).r, arguments );\r
},\r
\r
/**\r
not: function(t) {\r
return this.pushStack( typeof t == "string" ?\r
jQuery.filter(t,this,false).r :\r
- jQuery.grep(this,function(a){ return a != t; }) );\r
+ jQuery.grep(this,function(a){ return a != t; }), arguments );\r
},\r
\r
/**\r
*/\r
add: function(t) {\r
return this.pushStack( jQuery.merge( this, typeof t == "string" ?\r
- jQuery.find(t) : t.constructor == Array ? t : [t] ) );\r
+ jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments );\r
},\r
\r
/**\r
* @type jQuery\r
* @cat Core\r
*/\r
- pushStack: function(a) {\r
- if ( !this.stack )\r
- this.stack = [];\r
- this.stack.push( this.get() );\r
- return this.set( a );\r
+ pushStack: function(a,args) {\r
+ var fn = args && args.length > 1 && args[args.length-1];\r
+ var fn2 = args && args.length > 2 && args[args.length-2];\r
+ \r
+ if ( fn && fn.constructor != Function ) fn = null;\r
+ if ( fn2 && fn2.constructor != Function ) fn2 = null;\r
+\r
+ if ( !fn ) {\r
+ if ( !this.stack ) this.stack = [];\r
+ this.stack.push( this.get() );\r
+ this.set( a );\r
+ } else {\r
+ var old = this.get();\r
+ this.set( a );\r
+\r
+ if ( fn2 && a.length || !fn2 )\r
+ this.each( fn2 || fn ).set( old );\r
+ else\r
+ this.set( old ).each( fn );\r
+ }\r
+\r
+ return this;\r
}\r
};\r
\r
\r
ret = elem.style[prop];\r
\r
- } else if (elem.currentStyle) {\r
-\r
- var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});\r
- ret = elem.currentStyle[prop] || elem.currentStyle[newProp];\r
-\r
} else if (document.defaultView && document.defaultView.getComputedStyle) {\r
\r
if (prop == "cssFloat" || prop == "styleFloat")\r
ret = c && c.getPropertyValue(prop) || '';\r
});\r
\r
+ } else if (elem.currentStyle) {\r
+\r
+ var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});\r
+ ret = elem.currentStyle[prop] || elem.currentStyle[newProp];\r
+ \r
}\r
\r
return ret;\r
// Set the correct context (if none is provided)\r
context = context || document;\r
\r
- if ( t.constructor != String ) return [t];\r
+ if ( typeof t != "string" ) return [t];\r
\r
if ( !t.indexOf("//") ) {\r
context = context.documentElement;\r
// Otherwise, find the expression to execute\r
else {\r
var f = jQuery.expr[m[1]];\r
- if ( f.constructor != String )\r
+ if ( typeof f != "string" )\r
f = jQuery.expr[m[1]][m[2]];\r
\r
// Build a custom macro to enclose it\r
* This property is available before the DOM is ready, therefore you can\r
* use it to add ready events only for certain browsers.\r
*\r
+ * There are situations where object detections is not reliable enough, in that\r
+ * cases it makes sense to use browser detection. Simply try to avoid both!\r
+ *\r
+ * A combination of browser and object detection yields quite reliable results.\r
+ *\r
* @example $.browser.msie\r
* @desc Returns true if the current useragent is some version of microsoft's internet explorer\r
*\r