X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=04b9ca5c1bfbfc802655f58935b363295e4114e7;hb=33662cd713c28b2db0adccec170ffe93b35f098a;hp=3b0f82e31531262472cd3ea8dd23198a3ec773fb;hpb=458d427c0e4af4502e14400110b5327aa2513781;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 3b0f82e..04b9ca5 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -365,7 +365,7 @@ jQuery.fn = jQuery.prototype = { * @name attr * @type Object * @param String name The name of the property to access. - * @cat DOM + * @cat DOM/Attributes */ /** @@ -382,7 +382,7 @@ jQuery.fn = jQuery.prototype = { * @name attr * @type jQuery * @param Map properties Key/value pairs to set as object properties. - * @cat DOM + * @cat DOM/Attributes */ /** @@ -401,7 +401,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 DOM + * @cat DOM/Attributes */ attr: function( key, value, type ) { // Check to see if we're setting style values @@ -496,7 +496,7 @@ jQuery.fn = jQuery.prototype = { * * @name text * @type String - * @cat DOM + * @cat DOM/Attributes */ /** @@ -511,7 +511,7 @@ jQuery.fn = jQuery.prototype = { * @name text * @type String * @param String val The text value to set the contents of the element to. - * @cat DOM + * @cat DOM/Attributes */ text: function(e) { // A surprisingly high number of people expect the @@ -742,7 +742,7 @@ jQuery.fn = jQuery.prototype = { * @example $("p").find("span").end(); * @before

Hello, how are you?

* @result [

...

] - * desc Selects all paragraphs, finds span elements inside these, and reverts the + * @desc Selects all paragraphs, finds span elements inside these, and reverts the * selection back to the paragraphs. * * @name end @@ -1098,7 +1098,7 @@ jQuery.fn = jQuery.prototype = { * @param Object prop1 The object that will be merged into the first. * @param Object propN (optional) More objects to merge into the first * @type Object - * @cat Javascript + * @cat JavaScript */ jQuery.extend = jQuery.fn.extend = function() { // copy reference to target object @@ -1165,21 +1165,27 @@ jQuery.extend({ * as $().each() - which is used to iterate, exclusively, over a jQuery * object. This function can be used to iterate over anything. * - * @example $.each( [0,1,2], function(i){ - * alert( "Item #" + i + ": " + this ); + * The callback has two arguments:the key (objects) or index (arrays) as first + * the first, and the value as the second. + * + * @example $.each( [0,1,2], function(i, n){ + * alert( "Item #" + i + ": " + n ); * }); - * @desc Iterates over the items in an array, accessing both the current item and its index. + * @desc This is an example of iterating over the items in an array, + * accessing both the current item and its index. * - * @example $.each( { name: "John", lang: "JS" }, function(i){ - * alert( "Name: " + i + ", Value: " + this ); + * @example $.each( { name: "John", lang: "JS" }, function(i, n){ + * alert( "Name: " + i + ", Value: " + n ); * }); - * @desc Iterates over the properties in an Object, accessing both the current item and its key. + * + * @desc This is an example of iterating over the properties in an + * Object, accessing both the current item and its key. * * @name $.each * @param Object obj The object, or array, to iterate over. * @param Function fn The function that will be executed on every object. * @type Object - * @cat Javascript + * @cat JavaScript */ // args is for internal usage only each: function( obj, fn, args ) { @@ -1420,7 +1426,7 @@ jQuery.extend({ * @name $.trim * @type String * @param String str The string to trim. - * @cat Javascript + * @cat JavaScript */ trim: function(t){ return t.replace(/^\s+|\s+$/g, ""); @@ -1463,7 +1469,7 @@ jQuery.extend({ * @type Array * @param Array first The first array to merge. * @param Array second The second array to merge. - * @cat Javascript + * @cat JavaScript */ merge: function(first, second) { var r = [].slice.call( first, 0 ); @@ -1498,7 +1504,7 @@ jQuery.extend({ * @param Array array The Array to find items in. * @param Function fn The function to process each item against. * @param Boolean inv Invert the selection - select the opposite of the function. - * @cat Javascript + * @cat JavaScript */ grep: function(elems, fn, inv) { // If a string is passed in for the function, make a function @@ -1552,7 +1558,7 @@ jQuery.extend({ * @type Array * @param Array array The Array to translate. * @param Function fn The function to process each item against. - * @cat Javascript + * @cat JavaScript */ map: function(elems, fn) { // If a string is passed in for the function, make a function @@ -1573,7 +1579,7 @@ jQuery.extend({ } } - var r = [ result[0] ]; + var r = result.length ? [ result[0] ] : []; check: for ( var i = 1, rl = result.length; i < rl; i++ ) { for ( var j = 0; j < i; j++ ) @@ -1608,7 +1614,7 @@ jQuery.extend({ * @property * @name $.browser * @type Boolean - * @cat Javascript + * @cat JavaScript */ /* @@ -1617,7 +1623,7 @@ jQuery.extend({ * @property * @name $.boxModel * @type Boolean - * @cat Javascript + * @cat JavaScript */ new function() { var b = navigator.userAgent.toLowerCase(); @@ -1878,7 +1884,7 @@ jQuery.each({ * @name removeAttr * @type jQuery * @param String name The name of the attribute to remove. - * @cat DOM + * @cat DOM/Attributes */ /** @@ -1935,7 +1941,7 @@ jQuery.each({ * @name addClass * @type jQuery * @param String class A CSS class to add to the elements - * @cat DOM + * @cat DOM/Attributes * @see removeClass(String) */ @@ -1953,7 +1959,7 @@ jQuery.each({ * @name removeClass * @type jQuery * @param String class (optional) A CSS class to remove from the elements - * @cat DOM + * @cat DOM/Attributes * @see addClass(String) */ @@ -1968,7 +1974,7 @@ jQuery.each({ * @name toggleClass * @type jQuery * @param String class A CSS class with which to toggle the elements - * @cat DOM + * @cat DOM/Attributes */ /** @@ -2106,4 +2112,4 @@ jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){ jQuery.fn[ n ] = function(num,fn) { return this.filter( ":" + n + "(" + num + ")", fn ); }; -}); \ No newline at end of file +});