X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fevent%2Fevent.js;h=4a6331670652f0b52cb698bff6aadefcfaf3fa85;hb=ee0175c4b9d665322ac496dfcc6f8b0cc70b3c35;hp=9b3788b4e695f23874462f49a9bd4e82e94697a1;hpb=c330527318775d32c87954f640c53066e7a732d9;p=jquery.git diff --git a/src/event/event.js b/src/event/event.js index 9b3788b..4a63316 100644 --- a/src/event/event.js +++ b/src/event/event.js @@ -187,32 +187,32 @@ jQuery.fn.extend({ * data as the second paramter (and the handler function as the third), see * second example. * - * @example $("p").bind( "click", function() { + * @example $("p").bind("click", function(){ * alert( $(this).text() ); - * } ) + * }); * @before

Hello

* @result alert("Hello") * - * @example var handler = function(event) { + * @example function handler(event) { * alert(event.data.foo); - * }; - * $("p").bind( "click", {foo: "bar"}, handler) + * } + * $("p").bind("click", {foo: "bar"}, handler) * @result alert("bar") * @desc Pass some additional data to the event handler. * - * @example $("form").bind( "submit", function() { return false; } ) + * @example $("form").bind("submit", function() { return false; }) * @desc Cancel a default action and prevent it from bubbling by returning false * from your function. * - * @example $("form").bind( "submit", function(event) { + * @example $("form").bind("submit", function(event){ * event.preventDefault(); - * } ); + * }); * @desc Cancel only the default action by using the preventDefault method. * * - * @example $("form").bind( "submit", function(event) { + * @example $("form").bind("submit", function(event){ * event.stopPropagation(); - * } ) + * }); * @desc Stop only an event from bubbling by using the stopPropagation method. * * @name bind @@ -241,9 +241,9 @@ jQuery.fn.extend({ * data as the second paramter (and the handler function as the third), see * second example. * - * @example $("p").one( "click", function() { + * @example $("p").one("click", function(){ * alert( $(this).text() ); - * } ) + * }); * @before

Hello

* @result alert("Hello") * @@ -316,10 +316,6 @@ jQuery.fn.extend({ }); }, - // We're overriding the old toggle function, so - // remember it for later - _toggle: jQuery.fn.toggle, - /** * Toggle between two function calls every other click. * Whenever a matched element is clicked, the first specified function @@ -341,9 +337,10 @@ jQuery.fn.extend({ * @cat Events */ toggle: function() { - // save reference to arguments for access in closure + // Save reference to arguments for access in closure var a = arguments; - return typeof a[0] == "function" && typeof a[1] == "function" ? this.click(function(e) { + + return this.click(function(e) { // Figure out which function to execute this.lastToggle = this.lastToggle == 0 ? 1 : 0; @@ -352,10 +349,7 @@ jQuery.fn.extend({ // and execute the function return a[this.lastToggle].apply( this, [e] ) || false; - }) : - - // Otherwise, execute the old toggle function - this._toggle.apply( this, arguments ); + }); }, /** @@ -486,7 +480,7 @@ new function(){ * @name scroll * @type jQuery * @param Function fn A function to bind to the scroll event on each of the matched elements. - * @cat Events/Browser + * @cat Events */ /** @@ -501,7 +495,7 @@ new function(){ * @name submit * @type jQuery * @param Function fn A function to bind to the submit event on each of the matched elements. - * @cat Events/Form + * @cat Events */ /** @@ -516,7 +510,7 @@ new function(){ * * @name submit * @type jQuery - * @cat Events/Form + * @cat Events */ /** @@ -529,7 +523,7 @@ new function(){ * @name focus * @type jQuery * @param Function fn A function to bind to the focus event on each of the matched elements. - * @cat Events/UI + * @cat Events */ /** @@ -545,7 +539,7 @@ new function(){ * * @name focus * @type jQuery - * @cat Events/UI + * @cat Events */ /** @@ -558,7 +552,7 @@ new function(){ * @name keydown * @type jQuery * @param Function fn A function to bind to the keydown event on each of the matched elements. - * @cat Events/Keyboard + * @cat Events */ /** @@ -571,7 +565,7 @@ new function(){ * @name dblclick * @type jQuery * @param Function fn A function to bind to the dblclick event on each of the matched elements. - * @cat Events/Mouse + * @cat Events */ /** @@ -584,7 +578,7 @@ new function(){ * @name keypress * @type jQuery * @param Function fn A function to bind to the keypress event on each of the matched elements. - * @cat Events/Keyboard + * @cat Events */ /** @@ -597,7 +591,7 @@ new function(){ * @name error * @type jQuery * @param Function fn A function to bind to the error event on each of the matched elements. - * @cat Events/Browser + * @cat Events */ /** @@ -610,7 +604,7 @@ new function(){ * @name blur * @type jQuery * @param Function fn A function to bind to the blur event on each of the matched elements. - * @cat Events/UI + * @cat Events */ /** @@ -626,7 +620,7 @@ new function(){ * * @name blur * @type jQuery - * @cat Events/UI + * @cat Events */ /** @@ -639,7 +633,7 @@ new function(){ * @name load * @type jQuery * @param Function fn A function to bind to the load event on each of the matched elements. - * @cat Events/Browser + * @cat Events */ /** @@ -652,7 +646,7 @@ new function(){ * @name select * @type jQuery * @param Function fn A function to bind to the select event on each of the matched elements. - * @cat Events/Form + * @cat Events */ /** @@ -665,7 +659,7 @@ new function(){ * * @name select * @type jQuery - * @cat Events/Form + * @cat Events */ /** @@ -678,7 +672,7 @@ new function(){ * @name mouseup * @type jQuery * @param Function fn A function to bind to the mouseup event on each of the matched elements. - * @cat Events/Mouse + * @cat Events */ /** @@ -691,7 +685,7 @@ new function(){ * @name unload * @type jQuery * @param Function fn A function to bind to the unload event on each of the matched elements. - * @cat Events/Browser + * @cat Events */ /** @@ -704,7 +698,7 @@ new function(){ * @name change * @type jQuery * @param Function fn A function to bind to the change event on each of the matched elements. - * @cat Events/Form + * @cat Events */ /** @@ -717,7 +711,7 @@ new function(){ * @name mouseout * @type jQuery * @param Function fn A function to bind to the mouseout event on each of the matched elements. - * @cat Events/Mouse + * @cat Events */ /** @@ -730,7 +724,7 @@ new function(){ * @name keyup * @type jQuery * @param Function fn A function to bind to the keyup event on each of the matched elements. - * @cat Events/Keyboard + * @cat Events */ /** @@ -743,7 +737,7 @@ new function(){ * @name click * @type jQuery * @param Function fn A function to bind to the click event on each of the matched elements. - * @cat Events/Mouse + * @cat Events */ /** @@ -756,7 +750,7 @@ new function(){ * * @name click * @type jQuery - * @cat Events/Mouse + * @cat Events */ /** @@ -769,7 +763,7 @@ new function(){ * @name resize * @type jQuery * @param Function fn A function to bind to the resize event on each of the matched elements. - * @cat Events/Browser + * @cat Events */ /** @@ -782,7 +776,7 @@ new function(){ * @name mousemove * @type jQuery * @param Function fn A function to bind to the mousemove event on each of the matched elements. - * @cat Events/Mouse + * @cat Events */ /** @@ -795,7 +789,7 @@ new function(){ * @name mousedown * @type jQuery * @param Function fn A function to bind to the mousedown event on each of the matched elements. - * @cat Events/Mouse + * @cat Events */ /** @@ -808,7 +802,7 @@ new function(){ * @name mouseover * @type jQuery * @param Function fn A function to bind to the mousedown event on each of the matched elements. - * @cat Events/Mouse + * @cat Events */ jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + @@ -881,4 +875,4 @@ if (jQuery.browser.msie) jQuery.event.remove(els[i-1], type); while (--i); } - }); \ No newline at end of file + });