diff options
author | Kate Arzamastseva <pshns@ukr.net> | 2011-07-10 14:42:10 +0300 |
---|---|---|
committer | Kate Arzamastseva <pshns@ukr.net> | 2011-07-10 14:42:10 +0300 |
commit | abc5e9c041a9f062f4506e4d643d1838a562b460 (patch) | |
tree | 62e3331744130aac11fe2350e666af42e38995f2 /lib/scripts/events.js | |
parent | de11c42f80968ac41dc4164829845c1e5dae25c2 (diff) | |
parent | 0cacf91f96aa51a4c66082fe6c9b034fe61a1290 (diff) | |
download | rpg-abc5e9c041a9f062f4506e4d643d1838a562b460.tar.gz rpg-abc5e9c041a9f062f4506e4d643d1838a562b460.tar.bz2 |
merging
Diffstat (limited to 'lib/scripts/events.js')
-rw-r--r-- | lib/scripts/events.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/scripts/events.js b/lib/scripts/events.js index 95564be39..796d3cc4c 100644 --- a/lib/scripts/events.js +++ b/lib/scripts/events.js @@ -32,9 +32,19 @@ function addInitEvent(func) { * @param mixed - any arguments to be passed to the function * @returns functionref */ -function bind (fnc) { - var args = Array.prototype.slice.call(arguments, 1); - return function() { - return fnc.apply(this, args); +function bind(fnc/*, ... */) { + var Aps = Array.prototype.slice; + // Store passed arguments in this scope. + // Since arguments is no Array nor has an own slice method, + // we have to apply the slice method from the Array.prototype + var static_args = Aps.call(arguments, 1); + + // Return a function evaluating the passed function with the + // given args and optional arguments passed on invocation. + return function (/* ... */) { + // Same here, but we use Array.prototype.slice solely for + // converting arguments to an Array. + return fnc.apply(this, + static_args.concat(Aps.call(arguments, 0))); }; } |