*/\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
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[args.length-1];\r
+ var fn2 = args && 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
* 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