diff --git a/eve.js b/eve.js index c8eb5c4f..f8bc0deb 100644 --- a/eve.js +++ b/eve.js @@ -183,24 +183,26 @@ * eve.f [ method ] ** - * Returns function that will fire given event with optional arguments. - * Arguments that will be passed to the result function will be also - * concated to the list of final arguments. - | el.onclick = eve.f("click", 1, 2); - | eve.on("click", function (a, b, c) { - | console.log(a, b, c); // 1, 2, [event object] - | }); + * Returns function that will fire event with given `name`, `scope` and optional arguments. + * Arguments that are be passed to the result function will also be concatenated to the list of final arguments. + | el.onclick = eve.f("click", 1, 2); + | eve.on("click", function (a, b, c) { + | console.log(a, b, c); // 1, 2, [event object] + | }); > Arguments - - event (string) event name - - varargs (…) and any other arguments - = (function) possible event handler function + ** + - name (string) name of the *event*, dot (`.`) or slash (`/`) separated + - scope (object) context for the event handlers + - varargs (...) the rest of arguments will be sent to event handlers + ** + = (function) possible event handler function \*/ - eve.f = function (event) { - var attrs = [].slice.call(arguments, 1); - return function () { - eve.apply(null, [event, null].concat(attrs).concat([].slice.call(arguments, 0))); - }; - }; + eve.f = function (name, scope) { + var fargs = [name, scope].concat([].slice.call(arguments, 2)); + return function () { + eve.apply(null, fargs.concat([].slice.call(arguments, 0))); + }; + }; /*\ * eve.stop [ method ]