Comparing version 0.7.1 to 0.7.2
@@ -8,3 +8,3 @@ /*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */ | ||
* Author: Miller Medeiros | ||
* Version: 0.7.1 - Build: 244 (2011/11/29 12:33 PM) | ||
* Version: 0.7.2 - Build: 248 (2012/01/12 10:39 PM) | ||
*/ | ||
@@ -24,3 +24,3 @@ | ||
*/ | ||
VERSION : '0.7.1' | ||
VERSION : '0.7.2' | ||
}; | ||
@@ -219,3 +219,3 @@ | ||
* @param {boolean} isOnce | ||
* @param {Object} [scope] | ||
* @param {Object} [listenerContext] | ||
* @param {Number} [priority] | ||
@@ -225,3 +225,3 @@ * @return {SignalBinding} | ||
*/ | ||
_registerListener : function (listener, isOnce, scope, priority) { | ||
_registerListener : function (listener, isOnce, listenerContext, priority) { | ||
@@ -231,3 +231,3 @@ var prevIndex = this._indexOfListener(listener), | ||
if (prevIndex !== -1) { //avoid creating a new Binding for same listener if already added to list | ||
if (prevIndex !== -1 && this._bindings[prevIndex].context === listenerContext) { | ||
binding = this._bindings[prevIndex]; | ||
@@ -238,3 +238,3 @@ if (binding.isOnce() !== isOnce) { | ||
} else { | ||
binding = new SignalBinding(this, listener, isOnce, scope, priority); | ||
binding = new SignalBinding(this, listener, isOnce, listenerContext, priority); | ||
this._addBinding(binding); | ||
@@ -288,9 +288,9 @@ } | ||
* @param {Function} listener Signal handler function. | ||
* @param {Object} [scope] Context on which listener will be executed (object that should represent the `this` variable inside listener function). | ||
* @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). | ||
* @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) | ||
* @return {SignalBinding} An Object representing the binding between the Signal and listener. | ||
*/ | ||
add : function (listener, scope, priority) { | ||
add : function (listener, listenerContext, priority) { | ||
validateListener(listener, 'add'); | ||
return this._registerListener(listener, false, scope, priority); | ||
return this._registerListener(listener, false, listenerContext, priority); | ||
}, | ||
@@ -301,9 +301,9 @@ | ||
* @param {Function} listener Signal handler function. | ||
* @param {Object} [scope] Context on which listener will be executed (object that should represent the `this` variable inside listener function). | ||
* @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). | ||
* @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) | ||
* @return {SignalBinding} An Object representing the binding between the Signal and listener. | ||
*/ | ||
addOnce : function (listener, scope, priority) { | ||
addOnce : function (listener, listenerContext, priority) { | ||
validateListener(listener, 'addOnce'); | ||
return this._registerListener(listener, true, scope, priority); | ||
return this._registerListener(listener, true, listenerContext, priority); | ||
}, | ||
@@ -310,0 +310,0 @@ |
@@ -6,9 +6,9 @@ /* | ||
Author: Miller Medeiros | ||
Version: 0.7.1 - Build: 244 (2011/11/29 12:33 PM) | ||
Version: 0.7.2 - Build: 248 (2012/01/12 10:39 PM) | ||
*/ | ||
(function(g){function f(a,b,d,h,c){this._listener=b;this._isOnce=d;this.context=h;this._signal=a;this._priority=c||0}function e(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}var c={VERSION:"0.7.1"};f.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());return b},detach:function(){return this.isBound()? | ||
this._signal.remove(this._listener):null},isBound:function(){return!!this._signal&&!!this._listener},getListener:function(){return this._listener},_destroy:function(){delete this._signal;delete this._listener;delete this.context},isOnce:function(){return this._isOnce},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};c.Signal=function(){this._bindings=[];this._prevParams=null};c.Signal.prototype={memorize:!1,_shouldPropagate:!0, | ||
active:!0,_registerListener:function(a,b,d,c){var e=this._indexOfListener(a);if(e!==-1){if(a=this._bindings[e],a.isOnce()!==b)throw Error("You cannot add"+(b?"":"Once")+"() then add"+(!b?"":"Once")+"() the same listener without removing the relationship first.");}else a=new f(this,a,b,d,c),this._addBinding(a);this.memorize&&this._prevParams&&a.execute(this._prevParams);return a},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority); | ||
this._bindings.splice(b+1,0,a)},_indexOfListener:function(a){for(var b=this._bindings.length;b--;)if(this._bindings[b]._listener===a)return b;return-1},has:function(a){return this._indexOfListener(a)!==-1},add:function(a,b,d){e(a,"add");return this._registerListener(a,!1,b,d)},addOnce:function(a,b,d){e(a,"addOnce");return this._registerListener(a,!0,b,d)},remove:function(a){e(a,"remove");var b=this._indexOfListener(a);b!==-1&&(this._bindings[b]._destroy(),this._bindings.splice(b,1));return a},removeAll:function(){for(var a= | ||
this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(a){if(this.active){var b=Array.prototype.slice.call(arguments),d=this._bindings.length,c;if(this.memorize)this._prevParams=b;if(d){c=this._bindings.slice();this._shouldPropagate=!0;do d--;while(c[d]&&this._shouldPropagate&&c[d].execute(b)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(); | ||
delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};typeof define==="function"&&define.amd?define("signals",[],c):typeof module!=="undefined"&&module.exports?module.exports=c:g.signals=c})(this); | ||
(function(g){function f(a,b,c,h,d){this._listener=b;this._isOnce=c;this.context=h;this._signal=a;this._priority=d||0}function e(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}var d={VERSION:"0.7.2"};f.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());return b},detach:function(){return this.isBound()? | ||
this._signal.remove(this._listener):null},isBound:function(){return!!this._signal&&!!this._listener},getListener:function(){return this._listener},_destroy:function(){delete this._signal;delete this._listener;delete this.context},isOnce:function(){return this._isOnce},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};d.Signal=function(){this._bindings=[];this._prevParams=null};d.Signal.prototype={memorize:!1,_shouldPropagate:!0, | ||
active:!0,_registerListener:function(a,b,c,d){var e=this._indexOfListener(a);if(e!==-1&&this._bindings[e].context===c){if(a=this._bindings[e],a.isOnce()!==b)throw Error("You cannot add"+(b?"":"Once")+"() then add"+(!b?"":"Once")+"() the same listener without removing the relationship first.");}else a=new f(this,a,b,c,d),this._addBinding(a);this.memorize&&this._prevParams&&a.execute(this._prevParams);return a},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<= | ||
this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a){for(var b=this._bindings.length;b--;)if(this._bindings[b]._listener===a)return b;return-1},has:function(a){return this._indexOfListener(a)!==-1},add:function(a,b,c){e(a,"add");return this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){e(a,"addOnce");return this._registerListener(a,!0,b,c)},remove:function(a){e(a,"remove");var b=this._indexOfListener(a);b!==-1&&(this._bindings[b]._destroy(),this._bindings.splice(b, | ||
1));return a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(a){if(this.active){var b=Array.prototype.slice.call(arguments),c=this._bindings.length,d;if(this.memorize)this._prevParams=b;if(c){d=this._bindings.slice();this._shouldPropagate=!0;do c--;while(d[c]&&this._shouldPropagate&&d[c].execute(b)!==!1)}}},forget:function(){this._prevParams= | ||
null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};typeof define==="function"&&define.amd?define("signals",[],d):typeof module!=="undefined"&&module.exports?module.exports=d:g.signals=d})(this); |
@@ -6,3 +6,3 @@ { | ||
"homepage" : "http://millermedeiros.github.com/js-signals/", | ||
"version" : "0.7.1", | ||
"version" : "0.7.2", | ||
"author" : { | ||
@@ -9,0 +9,0 @@ "name" : "Miller Medeiros", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
157786
583