* @type jQuery
*/
-/**
- * A means of creating a cloned copy of a jQuery object. This function
- * copies the set of matched elements from one jQuery object and creates
- * another, new, jQuery object containing the same elements.
- *
- * @example var div = $("div");
- * $( div ).find("p");
- * @desc Locates all p elements with all div elements, without disrupting the original jQuery object contained in 'div' (as would normally be the case if a simple div.find("p") was done).
- *
- * @name $
- * @param jQuery obj The jQuery object to be cloned.
- * @cat Core
- * @type jQuery
- */
-
jQuery.fn = jQuery.prototype = {
/**
* The current version of jQuery.
* Set the jQuery object to an array of elements, while maintaining
* the stack.
*
- * @example $("img").set([ document.body ]);
- * @result $("img").set() == [ document.body ]
+ * @example $("img").pushStack([ document.body ]);
+ * @result $("img").pushStack() == [ document.body ]
*
* @private
- * @name set
+ * @name pushStack
* @type jQuery
* @param Elements elems An array of elements
* @cat Core
*/
- set: function( a ) {
+ pushStack: function( a ) {
var ret = jQuery(this);
ret.prevObject = this;
return ret.setArray( a );
/**
* Set the jQuery object to an array of elements. This operation is
- * completely destructive - be sure to use .set() if you wish to maintain
+ * completely destructive - be sure to use .pushStack() if you wish to maintain
* the jQuery stack.
*
* @example $("img").setArray([ document.body ]);
for ( var prop in obj )
jQuery.attr(
type ? this.style : this,
- prop, jQuery.prop(this, prop, obj[prop], type)
+ prop, jQuery.prop(this, obj[prop])
);
});
},
* @cat DOM/Traversing
*/
find: function(t) {
- return this.set( jQuery.map( this, function(a){
+ return this.pushStack( jQuery.map( this, function(a){
return jQuery.find(t,a);
}) );
},
* @cat DOM/Manipulation
*/
clone: function(deep) {
- return this.set( jQuery.map( this, function(a){
+ return this.pushStack( jQuery.map( this, function(a){
return a.cloneNode( deep != undefined ? deep : true );
}) );
},
* @cat DOM/Traversing
*/
filter: function(t) {
- return this.set(
+ return this.pushStack(
t.constructor == Array &&
jQuery.map(this,function(a){
for ( var i = 0, tl = t.length; i < tl; i++ )
* @cat DOM/Traversing
*/
not: function(t) {
- return this.set( typeof t == "string" ?
+ return this.pushStack( typeof t == "string" ?
jQuery.filter(t,this,true).r :
jQuery.grep(this,function(a){ return a != t; }) );
},
* @param String expr An expression whose matched elements are added
* @cat DOM/Traversing
*/
+
+ /**
+ * Adds the on the fly created elements to the jQuery object.
+ *
+ * @example $("p").add("<span>Again</span>")
+ * @before <p>Hello</p>
+ * @result [ <p>Hello</p>, <span>Again</span> ]
+ *
+ * @name add
+ * @type jQuery
+ * @param String html A string of HTML to create on the fly.
+ * @cat DOM/Traversing
+ */
/**
* Adds one or more Elements to the set of matched elements.
* @cat DOM/Traversing
*/
add: function(t) {
- return this.set( jQuery.merge(
- this.get(), typeof t == "string" ?
- jQuery.find(t) :
- t.constructor == Array ? t : [t] ) );
+ return this.pushStack( jQuery.merge(
+ this.get(),
+ typeof t == "string" ? jQuery(t).get() : t )
+ );
},
/**
return obj;
},
- prop: function(elem, key, value){
+ prop: function(elem, value){
// Handle executable functions
return value.constructor == Function &&
value.call( elem ) || value;
elem.className += ( elem.className ? " " : "" ) + cur;
});
},
+
// internal only, use removeClass("class")
remove: function( elem, c ){
- elem.className = c ?
- jQuery.grep( elem.className.split(/\s+/), function(cur){
- return !jQuery.className.has( c, cur );
- }).join(' ') : "";
+ elem.className = c ?
+ jQuery.grep( elem.className.split(/\s+/), function(cur){
+ return !jQuery.className.has( c, cur );
+ }).join(' ') : "";
},
+
// internal only, use is(".class")
has: function( t, c ) {
t = t.className || t;
var wrap =
// option or optgroup
- !s.indexOf("<opt") && [1, "<select>", "</select>"] ||
+ !s.indexOf("<opt") &&
+ [1, "<select>", "</select>"] ||
- !s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot") &&
+ (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
[1, "<table>", "</table>"] ||
!s.indexOf("<tr") &&
[2, "<table><tbody>", "</tbody></table>"] ||
// <thead> matched above
- !s.indexOf("<td") || !s.indexOf("<th") &&
+ (!s.indexOf("<td") || !s.indexOf("<th")) &&
[3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
[0,"",""];
r.push( arg );
else
r = jQuery.merge( r, arg );
+
}
return r;
var ret = jQuery.map(this,n);
if ( a && typeof a == "string" )
ret = jQuery.filter(a,ret).r;
- return this.set( ret );
+ return this.pushStack( ret );
};
});
*
* @name appendTo
* @type jQuery
- * @param String expr A jQuery expression of elements to match.
+ * @param <Content> content Content to append to the selected element to.
* @cat DOM/Manipulation
+ * @see append(<Content>)
*/
/**
*
* @name prependTo
* @type jQuery
- * @param String expr A jQuery expression of elements to match.
+ * @param <Content> content Content to prepend to the selected element to.
* @cat DOM/Manipulation
+ * @see prepend(<Content>)
*/
/**
*
* @name insertBefore
* @type jQuery
- * @param String expr A jQuery expression of elements to match.
+ * @param <Content> content Content to insert the selected element before.
* @cat DOM/Manipulation
+ * @see before(<Content>)
*/
/**
*
* @name insertAfter
* @type jQuery
- * @param String expr A jQuery expression of elements to match.
+ * @param <Content> content Content to insert the selected element after.
* @cat DOM/Manipulation
+ * @see after(<Content>)
*/
jQuery.each({
*/
/**
- * Displays each of the set of matched elements if they are hidden.
- *
- * @example $("p").show()
- * @before <p style="display: none">Hello</p>
- * @result [ <p style="display: block">Hello</p> ]
- *
- * @name show
- * @type jQuery
- * @cat Effects
- */
-
-/**
- * Hides each of the set of matched elements if they are shown.
- *
- * @example $("p").hide()
- * @before <p>Hello</p>
- * @result [ <p style="display: none">Hello</p> ]
- *
- * var pass = true, div = $("div");
- * div.hide().each(function(){
- * if ( this.style.display != "none" ) pass = false;
- * });
- * ok( pass, "Hide" );
- *
- * @name hide
- * @type jQuery
- * @cat Effects
- */
-
-/**
- * Toggles each of the set of matched elements. If they are shown,
- * toggle makes them hidden. If they are hidden, toggle
- * makes them shown.
- *
- * @example $("p").toggle()
- * @before <p>Hello</p><p style="display: none">Hello Again</p>
- * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
- *
- * @name toggle
- * @type jQuery
- * @cat Effects
- */
-
-/**
- * Adds the specified class to each of the set of matched elements.
+ * Adds the specified class(es) to each of the set of matched elements.
*
* @example $("p").addClass("selected")
* @before <p>Hello</p>
* @result [ <p class="selected">Hello</p> ]
*
+ * @example $("p").addClass("selected highlight")
+ * @before <p>Hello</p>
+ * @result [ <p class="selected highlight">Hello</p> ]
+ *
* @name addClass
* @type jQuery
- * @param String class A CSS class to add to the elements
+ * @param String class One or more CSS classes to add to the elements
* @cat DOM/Attributes
* @see removeClass(String)
*/
/**
- * Removes all or the specified class from the set of matched elements.
+ * Removes all or the specified class(es) from the set of matched elements.
*
* @example $("p").removeClass()
* @before <p class="selected">Hello</p>
* @before <p class="selected first">Hello</p>
* @result [ <p class="first">Hello</p> ]
*
+ * @example $("p").removeClass("selected highlight")
+ * @before <p class="highlight selected first">Hello</p>
+ * @result [ <p class="first">Hello</p> ]
+ *
* @name removeClass
* @type jQuery
- * @param String class (optional) A CSS class to remove from the elements
+ * @param String class (optional) One or more CSS classes to remove from the elements
* @cat DOM/Attributes
* @see addClass(String)
*/
jQuery.attr( this, key, "" );
this.removeAttribute( key );
},
- show: function(){
- this.style.display = this.oldblock ? this.oldblock : "";
- if ( jQuery.css(this,"display") == "none" )
- this.style.display = "block";
- },
- hide: function(){
- this.oldblock = this.oldblock || jQuery.css(this,"display");
- if ( this.oldblock == "none" )
- this.oldblock = "block";
- this.style.display = "none";
- },
- toggle: function(){
- jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
- },
addClass: function(c){
jQuery.className.add(this,c);
},
jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
},
remove: function(a){
- if ( !a || jQuery.filter( a, [this] ).r )
+ if ( !a || jQuery.filter( a, [this] ).r.length )
this.parentNode.removeChild( this );
},
empty: function() {