X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=jquery%2Fjquery.js;h=a0146c3721dd886c4e668c15cae98bcc1ed162e5;hb=6a47e28340e3cd9e8be73872767e6dbebd1a28f5;hp=01b56f6cc8e485609b4892747c03f6344e2e7ca8;hpb=efe0fef88082eebf66e9b7c250a6a072a5aa1966;p=jquery.git diff --git a/jquery/jquery.js b/jquery/jquery.js index 01b56f6..a0146c3 100644 --- a/jquery/jquery.js +++ b/jquery/jquery.js @@ -91,6 +91,7 @@ jQuery.fn = jQuery.prototype = { * @property * @name jquery * @type String + * @cat Core */ jquery: "$Rev$", @@ -104,6 +105,7 @@ jQuery.fn = jQuery.prototype = { * @property * @name length * @type Number + * @cat Core */ /** @@ -115,6 +117,7 @@ jQuery.fn = jQuery.prototype = { * * @name size * @type Number + * @cat Core */ size: function() { return this.length; @@ -131,11 +134,12 @@ jQuery.fn = jQuery.prototype = { * * @name get * @type Array + * @cat Core */ /** - * Access a single matched element. num is used to access the - * numth element matched. + * Access a single matched element. num is used to access the + * Nth element matched. * * @example $("img").get(1); * @before @@ -143,7 +147,8 @@ jQuery.fn = jQuery.prototype = { * * @name get * @type Element - * @param Number num Access the element in the numth position. + * @param Number num Access the element in the Nth position. + * @cat Core */ /** @@ -156,6 +161,7 @@ jQuery.fn = jQuery.prototype = { * @name get * @type jQuery * @param Elements elems An array of elements + * @cat Core */ get: function( num ) { // Watch for when an array (of elements) is passed in @@ -194,15 +200,10 @@ jQuery.fn = jQuery.prototype = { * @name each * @type jQuery * @param Function fn A function to execute + * @cat Core */ each: function( fn, args ) { - // Iterate through all of the matched elements - for ( var i = 0; i < this.length; i++ ) - - // Execute the function within the context of each element - fn.apply( this[i], args || [i] ); - - return this; + return jQuery.each( this, fn, args ); }, /** @@ -217,6 +218,7 @@ jQuery.fn = jQuery.prototype = { * @name attr * @type Object * @param String name The name of the property to access. + * @cat DOM */ /** @@ -231,6 +233,7 @@ jQuery.fn = jQuery.prototype = { * @name attr * @type jQuery * @param Hash prop A set of key/value pairs to set as object properties. + * @cat DOM */ /** @@ -244,10 +247,11 @@ jQuery.fn = jQuery.prototype = { * @type jQuery * @param String key The name of the property to set. * @param Object value The value to set the property to. + * @cat DOM */ attr: function( key, value, type ) { // Check to see if we're setting style values - return key.constructor != String || value ? + return key.constructor != String || value != undefined ? this.each(function(){ // See if we're setting a hash of styles if ( value == undefined ) @@ -282,6 +286,7 @@ jQuery.fn = jQuery.prototype = { * @name css * @type Object * @param String name The name of the property to access. + * @cat CSS */ /** @@ -296,6 +301,7 @@ jQuery.fn = jQuery.prototype = { * @name css * @type jQuery * @param Hash prop A set of key/value pairs to set as style properties. + * @cat CSS */ /** @@ -309,6 +315,7 @@ jQuery.fn = jQuery.prototype = { * @type jQuery * @param String key The name of the property to set. * @param Object value The value to set the property to. + * @cat CSS */ css: function( key, value ) { return this.attr( key, value, "curCSS" ); @@ -325,6 +332,7 @@ jQuery.fn = jQuery.prototype = { * * @name text * @type String + * @cat DOM */ text: function(e) { e = e || this; @@ -358,6 +366,7 @@ jQuery.fn = jQuery.prototype = { * @any Element elem A DOM element that will be wrapped. * @any Array elems An array of elements, the first of which will be wrapped. * @any Object obj Any object, converted to a string, then a text node. + * @cat DOM/Manipulation */ wrap: function() { // The elements to wrap the target around @@ -382,7 +391,7 @@ jQuery.fn = jQuery.prototype = { /** * Append any number of elements to the inside of all matched elements. - * This operation is similar to doing an appendChild to all the + * This operation is similar to doing an appendChild to all the * specified elements, adding them into the document. * * @example $("p").append("Hello"); @@ -395,6 +404,7 @@ jQuery.fn = jQuery.prototype = { * @any Element elem A DOM element that will be appended. * @any Array elems An array of elements, all of which will be appended. * @any Object obj Any object, converted to a string, then a text node. + * @cat DOM/Manipulation */ append: function() { return this.domManip(arguments, true, 1, function(a){ @@ -417,6 +427,7 @@ jQuery.fn = jQuery.prototype = { * @any Element elem A DOM element that will be prepended. * @any Array elems An array of elements, all of which will be prepended. * @any Object obj Any object, converted to a string, then a text node. + * @cat DOM/Manipulation */ prepend: function() { return this.domManip(arguments, true, -1, function(a){ @@ -437,6 +448,7 @@ jQuery.fn = jQuery.prototype = { * @any Element elem A DOM element that will beinserted. * @any Array elems An array of elements, all of which will be inserted. * @any Object obj Any object, converted to a string, then a text node. + * @cat DOM/Manipulation */ before: function() { return this.domManip(arguments, false, 1, function(a){ @@ -457,6 +469,7 @@ jQuery.fn = jQuery.prototype = { * @any Element elem A DOM element that will beinserted. * @any Array elems An array of elements, all of which will be inserted. * @any Object obj Any object, converted to a string, then a text node. + * @cat DOM/Manipulation */ after: function() { return this.domManip(arguments, false, -1, function(a){ @@ -475,6 +488,7 @@ jQuery.fn = jQuery.prototype = { * * @name end * @type jQuery + * @cat DOM/Traversing */ end: function() { return this.get( this.stack.pop() ); @@ -495,6 +509,7 @@ jQuery.fn = jQuery.prototype = { * @name find * @type jQuery * @param String expr An expression to search with. + * @cat DOM/Traversing */ find: function(t) { return this.pushStack( jQuery.map( this, function(a){ @@ -517,6 +532,7 @@ jQuery.fn = jQuery.prototype = { * @name filter * @type jQuery * @param String expr An expression to search with. + * @cat DOM/Traversing */ /** @@ -535,6 +551,7 @@ jQuery.fn = jQuery.prototype = { * @name filter * @type jQuery * @param Array exprs A set of expressions to evaluate against + * @cat DOM/Traversing */ filter: function(t) { return this.pushStack( @@ -565,6 +582,7 @@ jQuery.fn = jQuery.prototype = { * @name not * @type jQuery * @param Element el An element to remove from the set + * @cat DOM/Traversing */ /** @@ -579,6 +597,7 @@ jQuery.fn = jQuery.prototype = { * @name not * @type jQuery * @param String expr An expression with which to remove matching elements + * @cat DOM/Traversing */ not: function(t) { return this.pushStack( t.constructor == String ? @@ -597,6 +616,7 @@ jQuery.fn = jQuery.prototype = { * @name add * @type jQuery * @param String expr An expression whose matched elements are added + * @cat DOM/Traversing */ /** @@ -610,6 +630,7 @@ jQuery.fn = jQuery.prototype = { * @name add * @type jQuery * @param Array els An array of Elements to add + * @cat jQuery */ /** @@ -623,6 +644,7 @@ jQuery.fn = jQuery.prototype = { * @name add * @type jQuery * @param Element el An Element to add + * @cat jQuery */ add: function(t) { return this.pushStack( jQuery.merge( this, t.constructor == String ? @@ -637,6 +659,7 @@ jQuery.fn = jQuery.prototype = { * @member jQuery * @param {String} expr The expression with which to filter * @type Boolean + * @cat jQuery */ is: function(expr) { return expr ? jQuery.filter(expr,this).r.length > 0 : this.length > 0; @@ -669,11 +692,10 @@ jQuery.fn = jQuery.prototype = { } else obj = tbody[0]; } - //alert( obj ); + for ( var i = ( dir < 0 ? a.length - 1 : 0 ); i != ( dir < 0 ? dir : a.length ); i += dir ) { fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] ); - //alert( fn ); } }); }, @@ -706,6 +728,26 @@ jQuery.fn = jQuery.prototype = { } }; +/** + * + * + * @private + * @name extend + * @param Object obj + * @param Object prop + * @type Object + */ + +/** + * Extend one object with another, returning the original, + * modified, object. This is a great utility for simple inheritance. + * + * @name $.extend + * @param Object obj The object to extend + * @param Object prop The object that will be merged into the first. + * @type Object + * @cat Javascript + */ jQuery.extend = jQuery.fn.extend = function(obj,prop) { if ( !prop ) { prop = obj; obj = this; } for ( var i in prop ) obj[i] = prop[i]; @@ -713,60 +755,86 @@ jQuery.extend = jQuery.fn.extend = function(obj,prop) { }; jQuery.extend({ + /** + * + * + * @private + * @name init + * @type undefined + */ init: function(){ jQuery.initDone = true; - for ( var i in jQuery.macros.axis ) new function(){ - var t = jQuery.macros.axis[i]; - + jQuery.each( jQuery.macros.axis, function(i,n){ jQuery.fn[ i ] = function(a) { - var ret = jQuery.map(this,t); + var ret = jQuery.map(this,n); if ( a && a.constructor == String ) ret = jQuery.filter(a,ret).r; return this.pushStack( ret, arguments ); }; - }; - - // appendTo, prependTo, beforeTo, afterTo + }); - for ( var i = 0; i < jQuery.macros.to.length; i++ ) new function(){ - var n = jQuery.macros.to[i]; - jQuery.fn[ n + "To" ] = function(){ + jQuery.each( jQuery.macros.to, function(i,n){ + jQuery.fn[ i ] = function(){ var a = arguments; return this.each(function(){ - for ( var i = 0; i < a.length; i++ ) - $(a[i])[n]( this ); + for ( var j = 0; j < a.length; j++ ) + $(a[j])[n]( this ); }); }; - }; + }); - for ( var i in jQuery.macros.each ) new function() { - var n = jQuery.macros.each[i]; + jQuery.each( jQuery.macros.each, function(i,n){ jQuery.fn[ i ] = function() { return this.each( n, arguments ); }; - }; + }); + + jQuery.each( jQuery.macros.filter, function(i,n){ + jQuery.fn[ n ] = function(num,fn) { + return this.filter( ":" + n + "(" + num + ")", fn ); + }; + }); - for ( var i in jQuery.macros.attr ) new function() { - var n = jQuery.macros.attr[i] || i; + jQuery.each( jQuery.macros.attr, function(i,n){ + n = n || i; jQuery.fn[ i ] = function(h) { return h == undefined ? this.length ? this[0][n] : null : this.attr( n, h ); }; - }; + }); - for ( var i = 0; i < jQuery.macros.css.length; i++ ) new function() { - var n = jQuery.macros.css[i]; + jQuery.each( jQuery.macros.css, function(i,n){ jQuery.fn[ i ] = function(h) { return h == undefined ? ( this.length ? jQuery.css( this[0], n ) : null ) : this.css( n, h ); }; - }; + }); }, + /** + * A generic iterator function, which can be used to seemlessly + * iterate over both objects and arrays. + * + * @name $.each + * @param Object obj The object, or array, to iterate over. + * @param Object fn The function that will be executed on every object. + * @type Object + * @cat Javascript + */ + each: function( obj, fn, args ) { + if ( obj.length == undefined ) + for ( var i in obj ) + fn.apply( obj[i], args || [i, obj[i]] ); + else + for ( var i = 0; i < obj.length; i++ ) + fn.apply( obj[i], args || [i, obj[i]] ); + return obj; + }, + className: { add: function(o,c){ if (jQuery.className.has(o,c)) return; @@ -1425,19 +1493,523 @@ new function() { }; jQuery.macros = { - to: ["append","prepend","before","after"], + to: { + /** + * Append all of the matched elements to another, specified, set of elements. + * This operation is, essentially, the reverse of doing a regular + * $(A).append(B), in that instead of appending B to A, you're appending + * A to B. + * + * @example $("p").appendTo("#foo"); + * @before

I would like to say:

+ * @result

I would like to say:

+ * + * @name appendTo + * @type jQuery + * @param String expr A jQuery expression of elements to match. + * @cat DOM/Manipulation + */ + appendTo: "append", + + /** + * Prepend all of the matched elements to another, specified, set of elements. + * This operation is, essentially, the reverse of doing a regular + * $(A).prepend(B), in that instead of prepending B to A, you're prepending + * A to B. + * + * @example $("p").prependTo("#foo"); + * @before

I would like to say:

Hello
+ * @result

I would like to say:

Hello
+ * + * @name prependTo + * @type jQuery + * @param String expr A jQuery expression of elements to match. + * @cat DOM/Manipulation + */ + prependTo: "prepend", + + /** + * Insert all of the matched elements before another, specified, set of elements. + * This operation is, essentially, the reverse of doing a regular + * $(A).before(B), in that instead of inserting B before A, you're inserting + * A before B. + * + * @example $("p").insertBefore("#foo"); + * @before
Hello

I would like to say:

+ * @result

I would like to say:

Hello
+ * + * @name insertBefore + * @type jQuery + * @param String expr A jQuery expression of elements to match. + * @cat DOM/Manipulation + */ + insertBefore: "before", + + /** + * Insert all of the matched elements after another, specified, set of elements. + * This operation is, essentially, the reverse of doing a regular + * $(A).after(B), in that instead of inserting B after A, you're inserting + * A after B. + * + * @example $("p").insertAfter("#foo"); + * @before

I would like to say:

Hello
+ * @result
Hello

I would like to say:

+ * + * @name insertAfter + * @type jQuery + * @param String expr A jQuery expression of elements to match. + * @cat DOM/Manipulation + */ + insertAfter: "after" + }, + + /** + * Get the current CSS width of the first matched element. + * + * @example $("p").width(); + * @before

This is just a test.

+ * @result "300px" + * + * @name width + * @type String + * @cat CSS + */ + + /** + * Set the CSS width of every matched element. Be sure to include + * the "px" (or other unit of measurement) after the number that you + * specify, otherwise you might get strange results. + * + * @example $("p").width("20px"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name width + * @type jQuery + * @param String val Set the CSS property to the specified value. + * @cat CSS + */ + + /** + * Get the current CSS height of the first matched element. + * + * @example $("p").height(); + * @before

This is just a test.

+ * @result "14px" + * + * @name height + * @type String + * @cat CSS + */ + + /** + * Set the CSS height of every matched element. Be sure to include + * the "px" (or other unit of measurement) after the number that you + * specify, otherwise you might get strange results. + * + * @example $("p").height("20px"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name height + * @type jQuery + * @param String val Set the CSS property to the specified value. + * @cat CSS + */ + + /** + * Get the current CSS top of the first matched element. + * + * @example $("p").top(); + * @before

This is just a test.

+ * @result "0px" + * + * @name top + * @type String + * @cat CSS + */ + + /** + * Set the CSS top of every matched element. Be sure to include + * the "px" (or other unit of measurement) after the number that you + * specify, otherwise you might get strange results. + * + * @example $("p").top("20px"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name top + * @type jQuery + * @param String val Set the CSS property to the specified value. + * @cat CSS + */ + + /** + * Get the current CSS left of the first matched element. + * + * @example $("p").left(); + * @before

This is just a test.

+ * @result "0px" + * + * @name left + * @type String + * @cat CSS + */ + + /** + * Set the CSS left of every matched element. Be sure to include + * the "px" (or other unit of measurement) after the number that you + * specify, otherwise you might get strange results. + * + * @example $("p").left("20px"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name left + * @type jQuery + * @param String val Set the CSS property to the specified value. + * @cat CSS + */ + + /** + * Get the current CSS position of the first matched element. + * + * @example $("p").position(); + * @before

This is just a test.

+ * @result "static" + * + * @name position + * @type String + * @cat CSS + */ + + /** + * Set the CSS position of every matched element. + * + * @example $("p").position("relative"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name position + * @type jQuery + * @param String val Set the CSS property to the specified value. + * @cat CSS + */ + + /** + * Get the current CSS float of the first matched element. + * + * @example $("p").float(); + * @before

This is just a test.

+ * @result "none" + * + * @name float + * @type String + * @cat CSS + */ + + /** + * Set the CSS float of every matched element. + * + * @example $("p").float("left"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name float + * @type jQuery + * @param String val Set the CSS property to the specified value. + * @cat CSS + */ + + /** + * Get the current CSS overflow of the first matched element. + * + * @example $("p").overflow(); + * @before

This is just a test.

+ * @result "none" + * + * @name overflow + * @type String + * @cat CSS + */ + + /** + * Set the CSS overflow of every matched element. + * + * @example $("p").overflow("auto"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name overflow + * @type jQuery + * @param String val Set the CSS property to the specified value. + * @cat CSS + */ + + /** + * Get the current CSS color of the first matched element. + * + * @example $("p").color(); + * @before

This is just a test.

+ * @result "black" + * + * @name color + * @type String + * @cat CSS + */ + + /** + * Set the CSS color of every matched element. + * + * @example $("p").color("blue"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name color + * @type jQuery + * @param String val Set the CSS property to the specified value. + * @cat CSS + */ + + /** + * Get the current CSS background of the first matched element. + * + * @example $("p").background(); + * @before

This is just a test.

+ * @result "" + * + * @name background + * @type String + * @cat CSS + */ + + /** + * Set the CSS background of every matched element. + * + * @example $("p").background("blue"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name background + * @type jQuery + * @param String val Set the CSS property to the specified value. + * @cat CSS + */ + css: "width,height,top,left,position,float,overflow,color,background".split(","), + + filter: [ "eq", "lt", "gt", "contains" ], + attr: { + /** + * Get the current value of the first matched element. + * + * @example $("input").val(); + * @before + * @result "some text" + * + * @name val + * @type String + * @cat DOM/Attributes + */ + + /** + * Set the value of every matched element. + * + * @example $("input").value("test"); + * @before + * @result + * + * @name val + * @type jQuery + * @param String val Set the property to the specified value. + * @cat DOM/Attributes + */ val: "value", + + /** + * Get the html contents of the first matched element. + * + * @example $("div").html(); + * @before
+ * @result + * + * @name html + * @type String + * @cat DOM/Attributes + */ + + /** + * Set the html contents of every matched element. + * + * @example $("div").html("new stuff"); + * @before
+ * @result
new stuff
+ * + * @name html + * @type jQuery + * @param String val Set the html contents to the specified value. + * @cat DOM/Attributes + */ html: "innerHTML", - value: null, + + /** + * Get the current id of the first matched element. + * + * @example $("input").id(); + * @before + * @result "test" + * + * @name id + * @type String + * @cat DOM/Attributes + */ + + /** + * Set the id of every matched element. + * + * @example $("input").id("newid"); + * @before + * @result + * + * @name id + * @type jQuery + * @param String val Set the property to the specified value. + * @cat DOM/Attributes + */ id: null, + + /** + * Get the current title of the first matched element. + * + * @example $("img").title(); + * @before + * @result "my image" + * + * @name title + * @type String + * @cat DOM/Attributes + */ + + /** + * Set the title of every matched element. + * + * @example $("img").title("new title"); + * @before + * @result + * + * @name title + * @type jQuery + * @param String val Set the property to the specified value. + * @cat DOM/Attributes + */ title: null, + + /** + * Get the current name of the first matched element. + * + * @example $("input").name(); + * @before + * @result "username" + * + * @name name + * @type String + * @cat DOM/Attributes + */ + + /** + * Set the name of every matched element. + * + * @example $("input").name("user"); + * @before + * @result + * + * @name name + * @type jQuery + * @param String val Set the property to the specified value. + * @cat DOM/Attributes + */ name: null, + + /** + * Get the current href of the first matched element. + * + * @example $("a").href(); + * @before my link + * @result "test.html" + * + * @name href + * @type String + * @cat DOM/Attributes + */ + + /** + * Set the href of every matched element. + * + * @example $("a").href("test2.html"); + * @before my link + * @result my link + * + * @name href + * @type jQuery + * @param String val Set the property to the specified value. + * @cat DOM/Attributes + */ href: null, + + /** + * Get the current src of the first matched element. + * + * @example $("img").src(); + * @before + * @result "test.jpg" + * + * @name src + * @type String + * @cat DOM/Attributes + */ + + /** + * Set the src of every matched element. + * + * @example $("img").src("test2.jpg"); + * @before + * @result + * + * @name src + * @type jQuery + * @param String val Set the property to the specified value. + * @cat DOM/Attributes + */ src: null, + + /** + * Get the current rel of the first matched element. + * + * @example $("a").rel(); + * @before my link + * @result "nofollow" + * + * @name rel + * @type String + * @cat DOM/Attributes + */ + + /** + * Set the rel of every matched element. + * + * @example $("a").rel("nofollow"); + * @before my link + * @result my link + * + * @name rel + * @type jQuery + * @param String val Set the property to the specified value. + * @cat DOM/Attributes + */ rel: null }, + axis: { /** * Get a set of elements containing the unique parents of the matched @@ -1449,6 +2021,7 @@ jQuery.macros = { * * @name parent * @type jQuery + * @cat DOM/Traversing */ /** @@ -1462,6 +2035,7 @@ jQuery.macros = { * @name parent * @type jQuery * @param String expr An expression to filter the parents with + * @cat DOM/Traversing */ parent: "a.parentNode", @@ -1475,6 +2049,7 @@ jQuery.macros = { * * @name ancestors * @type jQuery + * @cat DOM/Traversing */ /** @@ -1488,11 +2063,35 @@ jQuery.macros = { * @name ancestors * @type jQuery * @param String expr An expression to filter the ancestors with + * @cat DOM/Traversing */ ancestors: jQuery.parents, /** - * A synonym for ancestors + * Get a set of elements containing the unique ancestors of the matched + * set of elements. + * + * @example $("span").ancestors() + * @before

Hello

Hello Again
+ * @result [ ...,
...
,

Hello

] + * + * @name parents + * @type jQuery + * @cat DOM/Traversing + */ + + /** + * Get a set of elements containing the unique ancestors of the matched + * set of elements, and filtered by an expression. + * + * @example $("span").ancestors("p") + * @before

Hello

Hello Again
+ * @result [

Hello

] + * + * @name parents + * @type jQuery + * @param String expr An expression to filter the ancestors with + * @cat DOM/Traversing */ parents: jQuery.parents, @@ -1508,6 +2107,7 @@ jQuery.macros = { * * @name next * @type jQuery + * @cat DOM/Traversing */ /** @@ -1523,6 +2123,7 @@ jQuery.macros = { * @name next * @type jQuery * @param String expr An expression to filter the next Elements with + * @cat DOM/Traversing */ next: "jQuery.sibling(a).next", @@ -1538,6 +2139,7 @@ jQuery.macros = { * * @name prev * @type jQuery + * @cat DOM/Traversing */ /** @@ -1546,13 +2148,14 @@ jQuery.macros = { * * It only returns the immediately previous sibling, not all previous siblings. * - * @example $("p").previous("selected") + * @example $("p").previous(".selected") * @before
Hello

Hello Again

And Again

* @result [
Hello
] * * @name prev * @type jQuery * @param String expr An expression to filter the previous Elements with + * @cat DOM/Traversing */ prev: "jQuery.sibling(a).prev", @@ -1566,21 +2169,52 @@ jQuery.macros = { * * @name siblings * @type jQuery + * @cat DOM/Traversing */ /** * Get a set of elements containing all of the unique siblings of each of the * matched set of elements, and filtered by an expression. * - * @example $("div").siblings("selected") + * @example $("div").siblings(".selected") * @before
Hello

Hello Again

And Again

* @result [

Hello Again

] * * @name siblings * @type jQuery * @param String expr An expression to filter the sibling Elements with + * @cat DOM/Traversing */ - siblings: jQuery.sibling + siblings: jQuery.sibling, + + + /** + * Get a set of elements containing all of the unique children of each of the + * matched set of elements. + * + * @example $("div").children() + * @before

Hello

Hello Again

And Again

+ * @result [ Hello Again ] + * + * @name children + * @type jQuery + * @cat DOM/Traversing + */ + + /** + * Get a set of elements containing all of the unique children of each of the + * matched set of elements, and filtered by an expression. + * + * @example $("div").children(".selected") + * @before
Hello

Hello Again

And Again

+ * @result [

Hello Again

] + * + * @name children + * @type jQuery + * @param String expr An expression to filter the child Elements with + * @cat DOM/Traversing + */ + children: "a.childNodes" }, each: { @@ -1593,8 +2227,9 @@ jQuery.macros = { * * @name show * @type jQuery + * @cat Effects */ - show: function(){ + _show: function(){ this.style.display = this.oldblock ? this.oldblock : ""; if ( jQuery.css(this,"display") == "none" ) this.style.display = "block"; @@ -1609,9 +2244,10 @@ jQuery.macros = { * * @name hide * @type jQuery + * @cat Effects */ - hide: function(){ - this.oldblock = jQuery.css(this,"display"); + _hide: function(){ + this.oldblock = this.oldblock || jQuery.css(this,"display"); if ( this.oldblock == "none" ) this.oldblock = "block"; this.style.display = "none"; @@ -1628,8 +2264,9 @@ jQuery.macros = { * * @name toggle * @type jQuery + * @cat Effects */ - toggle: function(){ + _toggle: function(){ var d = jQuery.css(this,"display"); $(this)[ !d || d == "none" ? "show" : "hide" ](); }, @@ -1637,52 +2274,78 @@ jQuery.macros = { /** * Adds the specified class to each of the set of matched elements. * - * @example ("p").addClass("selected") + * @example $("p").addClass("selected") * @before

Hello

* @result [

Hello

] * * @name addClass * @type jQuery * @param String class A CSS class to add to the elements + * @cat DOM */ addClass: function(c){ jQuery.className.add(this,c); }, /** - * The opposite of addClass. Removes the specified class from the - * set of matched elements. + * Removes the specified class from the set of matched elements. * - * @example ("p").removeClass("selected") + * @example $("p").removeClass("selected") * @before

Hello

* @result [

Hello

] * * @name removeClass * @type jQuery * @param String class A CSS class to remove from the elements + * @cat DOM */ removeClass: function(c){ jQuery.className.remove(this,c); }, /** - * Adds the specified class if it is present. Remove it if it is + * Adds the specified class if it is present, removes it if it is * not present. * - * @example ("p").toggleClass("selected") + * @example $("p").toggleClass("selected") * @before

Hello

Hello Again

* @result [

Hello

,

Hello Again

] * * @name toggleClass * @type jQuery * @param String class A CSS class with which to toggle the elements + * @cat DOM */ toggleClass: function( c ){ jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c); }, /** - * TODO: Document + * Removes all matched elements from the DOM. This does NOT remove them from the + * jQuery object, allowing you to use the matched elements further. + * + * @example $("p").remove(); + * @before

Hello

how are

you?

+ * @result how are + * + * @name remove + * @type jQuery + * @cat DOM/Manipulation + */ + + /** + * Removes only elements (out of the list of matched elements) that match + * the specified jQuery expression. This does NOT remove them from the + * jQuery object, allowing you to use the matched elements further. + * + * @example $("p").remove(".hello"); + * @before

Hello

how are

you?

+ * @result how are

you?

+ * + * @name remove + * @type jQuery + * @param String expr A jQuery expression to filter elements by. + * @cat DOM/Manipulation */ remove: function(a){ if ( !a || jQuery.filter( [this], a ).r ) @@ -1692,12 +2355,13 @@ jQuery.macros = { /** * Removes all child nodes from the set of matched elements. * - * @example ("p").empty() + * @example $("p").empty() * @before

Hello, Person and person

* @result [

] * * @name empty * @type jQuery + * @cat DOM/Manipulation */ empty: function(){ while ( this.firstChild ) @@ -1728,6 +2392,7 @@ jQuery.macros = { * @type jQuery * @param String type An event type * @param Function fn A function to bind to the event on each of the set of matched elements + * @cat Events */ bind: function( type, fn ) { if ( fn.constructor == String ) @@ -1736,36 +2401,64 @@ jQuery.macros = { }, /** - * The opposite of bind. Removes a bound event from each of a set of matched + * The opposite of bind, removes a bound event from each of the matched * elements. You must pass the identical function that was used in the original * bind method. * * @example $("p").unbind( "click", function() { alert("Hello"); } ) - * @before

Hello

+ * @before

Hello

* @result [

Hello

] * * @name unbind * @type jQuery * @param String type An event type * @param Function fn A function to unbind from the event on each of the set of matched elements + * @cat Events + */ + + /** + * Removes all bound events of a particular type from each of the matched + * elements. + * + * @example $("p").unbind( "click" ) + * @before

Hello

+ * @result [

Hello

] + * + * @name unbind + * @type jQuery + * @param String type An event type + * @cat Events + */ + + /** + * Removes all bound events from each of the matched elements. + * + * @example $("p").unbind() + * @before

Hello

+ * @result [

Hello

] + * + * @name unbind + * @type jQuery + * @cat Events */ unbind: function( type, fn ) { jQuery.event.remove( this, type, fn ); }, /** - * Trigger a particular event. + * Trigger a type of event on every matched element. * * @example $("p").trigger("click") - * @before

Hello

- * @result [

Hello

] + * @before

Hello

+ * @result alert('hello') * * @name trigger * @type jQuery - * @param String type An event type + * @param String type An event type to trigger. + * @cat Events */ trigger: function( type, data ) { jQuery.event.trigger( type, data, this ); } } -}; \ No newline at end of file +};