Sha256: b2b6aea6e2136d1ec9df0ad5d8293212da3ab7f8578022837356784f6387332e
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
var __slice = Array.prototype.slice; Shuriken.defineExtension(function(baseNS) { return baseNS.defineMixin('Callbacks', function(mixin) { mixin.callbacks = {}; mixin.defineCallback = function(key) { this[("on" + (key))] = function(callback) { return this.hasCallback(key, callback); }; this[("invoke" + (key))] = function() { var args; args = __slice.call(arguments, 0); return this.invokeCallbacks.apply(this, [key].concat(args)); }; return true; }; mixin.hasCallback = function(name, callback) { var callbacks; callbacks = mixin.callbacks[name] = (typeof mixin.callbacks[name] !== "undefined" && mixin.callbacks[name] !== null) ? mixin.callbacks[name] : []; callbacks.push(callback); return true; }; mixin.callbacksFor = function(name) { var existing; existing = mixin.callbacks[name]; return (typeof existing !== "undefined" && existing !== null) ? existing : []; }; return (mixin.invokeCallbacks = function(name) { var _a, _b, _c, args, callback; args = __slice.call(arguments, 1); _b = mixin.callbacksFor(name); for (_a = 0, _c = _b.length; _a < _c; _a++) { callback = _b[_a]; if (callback.apply(this, args) === false) { return false; } } return true; }); }); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shuriken-0.2.1 | javascripts/shuriken/mixins/callbacks.js |