* });
* @desc Executes the function when the DOM is ready to be used.
*
+ * @example jQuery(function($) {
+ * // Your code using failsafe $ alias here...
+ * });
+ * @desc Uses both the shortcut for $(document).ready() and the argument
+ * to write failsafe jQuery code using the $ alias, without relying on the
+ * global alias.
+ *
* @name $
* @param Function fn The function to execute when the DOM is ready.
* @cat Core
* @type jQuery
+ * @see ready(Function)
*/
jQuery.fn = jQuery.prototype = {
for ( var prop in obj )
jQuery.attr(
type ? this.style : this,
- prop, jQuery.prop(this, obj[prop])
+ prop, jQuery.prop(this, obj[prop], type)
);
});
},
/**
* Set a single style property to a value, on all matched elements.
+ * If a number is provided, it is automatically converted into a pixel value.
*
* @example $("p").css("color","red");
* @before <p>Test Paragraph.</p>
* @result <p style="color:red;">Test Paragraph.</p>
* @desc Changes the color of all paragraphs to red
*
+ * @example $("p").css("left",30);
+ * @before <p>Test Paragraph.</p>
+ * @result <p style="left:30px;">Test Paragraph.</p>
+ * @desc Changes the left of all paragraphs to "30px"
+ *
* @name css
* @type jQuery
* @param String key The name of the property to set.
- * @param Object value The value to set the property to.
+ * @param String|Number value The value to set the property to.
* @cat CSS
*/
css: function( key, value ) {
"textContent" : "innerText";
return e == undefined ?
- this.length && this[0][ type ] :
+ jQuery.map(this, function(a){ return a[ type ]; }).join('') :
this.each(function(){ this[ type ] = e; });
},
*
* @name clone
* @type jQuery
+ * @param Boolean deep (Optional) Set to false if you don't want to clone all descendant nodes, in addition to the element itself.
* @cat DOM/Manipulation
*/
clone: function(deep) {
* match the specified expression(s). This method is used to narrow down
* the results of a search.
*
- * Provide a String array of expressions to apply multiple filters at once.
+ * Provide a comma-separated list of expressions to apply multiple filters at once.
*
* @example $("p").filter(".selected")
* @before <p class="selected">Hello</p><p>How are you?</p>
* @result [ <p class="selected">Hello</p> ]
* @desc Selects all paragraphs and removes those without a class "selected".
*
- * @example $("p").filter([".selected", ":first"])
+ * @example $("p").filter(".selected, :first")
* @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
* @result [ <p>Hello</p>, <p class="selected">And Again</p> ]
* @desc Selects all paragraphs and removes those without class "selected" and being the first one.
*
* @name filter
* @type jQuery
- * @param String|Array<String> expression Expression(s) to search with.
+ * @param String expression Expression(s) to search with.
* @cat DOM/Traversing
*/
*/
filter: function(t) {
return this.pushStack(
- t.constructor == Array &&
- jQuery.map(this,function(a){
- for ( var i = 0, tl = t.length; i < tl; i++ )
- if ( jQuery.filter(t[i],[a]).r.length )
- return a;
- return null;
+ t.constructor == Function &&
+ jQuery.grep(this, function(el, index){
+ return t.apply(el, [index])
}) ||
- t.constructor == Boolean &&
- ( t ? this.get() : [] ) ||
-
- typeof t == "function" &&
- jQuery.grep( this, function(el, index) { return t.apply(el, [index]) }) ||
-
- jQuery.filter(t,this).r );
+ jQuery.multiFilter(t,this) );
},
/**
* @param String expr An expression with which to remove matching elements
* @cat DOM/Traversing
*/
+
+ /**
+ * Removes any elements inside the array of elements from the set
+ * of matched elements. This method is used to remove one or more
+ * elements from a jQuery object.
+ *
+ * @example $("p").not( $("div p.selected") )
+ * @before <div><p>Hello</p><p class="selected">Hello Again</p></div>
+ * @result [ <p>Hello</p> ]
+ * @desc Removes all elements that match "div p.selected" from the total set of all paragraphs.
+ *
+ * @name not
+ * @type jQuery
+ * @param Array|jQuery elems A set of elements to remove from the jQuery set of matched elements.
+ * @cat DOM/Traversing
+ */
not: function(t) {
- return this.pushStack( typeof t == "string" ?
- jQuery.filter(t,this,true).r :
- jQuery.grep(this,function(a){ return a != t; }) );
+ return this.pushStack(
+ t.constructor == String &&
+ jQuery.multiFilter(t,this,true) ||
+
+ jQuery.grep(this,function(a){
+ if ( t.constructor == Array || t.jquery )
+ return jQuery.inArray( t, a ) < 0;
+ else
+ return a != t;
+ }) );
},
/**
* @cat DOM/Attributes
*/
val: function( val ) {
- return val == undefined ?\r ( this.length ? this[0].value : null ) :\r this.attr( "value", val );
+ return val == undefined ?
+ ( this.length ? this[0].value : null ) :
+ this.attr( "value", val );
},
/**
* @cat DOM/Attributes
*/
html: function( val ) {
- return val == undefined ?\r ( this.length ? this[0].innerHTML : null ) :\r this.empty().append( val );
+ return val == undefined ?
+ ( this.length ? this[0].innerHTML : null ) :
+ this.empty().append( val );
},
/**
return obj;
},
- prop: function(elem, value){
- // Handle executable functions
- return value.constructor == Function &&
- value.call( elem ) || value;
+ prop: function(elem, value, type){
+ // Handle executable functions
+ if ( value.constructor == Function )
+ return value.call( elem );
+
+ // Handle passing in a number to a CSS property
+ if ( value.constructor == Number && type == "css" )
+ return value + "px";
+
+ return value;
},
className: {
clean: function(a) {
var r = [];
-
+
for ( var i = 0, al = a.length; i < al; i++ ) {
var arg = a[i];
arg = div.childNodes;
}
- if ( arg.nodeType )
+ if ( arg[0] == undefined )
r.push( arg );
else
r = jQuery.merge( r, arg );
jQuery.fn[ i ] = function(a) {
var ret = jQuery.map(this,n);
if ( a && typeof a == "string" )
- ret = jQuery.filter(a,ret).r;
+ ret = jQuery.multiFilter(a,ret);
return this.pushStack( ret );
};
});