jssignals-rails 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # js-signals for Rails [![Build Status][travis_ci_build_status]][travis_ci][![Dependency Status][gemnasium_dependency_status]][gemnasium]
2
2
 
3
- Provides js-signals (0.8.1) for use with Rails 3
3
+ Provides js-signals (0.9.0) for use with Rails 3
4
4
 
5
5
  [RubyGems][ruby_gems] | [Ruby Toolbox][ruby_toolbox] | [GitHub][github] | [Travis CI][travis_ci] | [Gemnasium][gemnasium] | [RubyDoc][ruby_doc]
6
6
 
@@ -1,6 +1,6 @@
1
1
  module Jssignals
2
2
  module Rails
3
- VERSION = "1.1.1"
4
- JSSIGNALS_VERSION = "0.8.1";
3
+ VERSION = "1.2.0"
4
+ JSSIGNALS_VERSION = "0.9.0";
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Jssignals::Rails do
4
- it { Jssignals::Rails::VERSION.should == "1.1.1" }
5
- it { Jssignals::Rails::JSSIGNALS_VERSION.should == "0.8.1" }
4
+ it { Jssignals::Rails::VERSION.should == "1.2.0" }
5
+ it { Jssignals::Rails::JSSIGNALS_VERSION.should == "0.9.0" }
6
6
  end
@@ -5,7 +5,7 @@
5
5
  * JS Signals <http://millermedeiros.github.com/js-signals/>
6
6
  * Released under the MIT license
7
7
  * Author: Miller Medeiros
8
- * Version: 0.8.1 - Build: 266 (2012/07/31 03:33 PM)
8
+ * Version: 0.9.0 - Build: 267 (2012/10/31 12:25 PM)
9
9
  */
10
10
 
11
11
  (function(global){
@@ -114,6 +114,13 @@
114
114
  return (!!this._signal && !!this._listener);
115
115
  },
116
116
 
117
+ /**
118
+ * @return {boolean} If SignalBinding will only be executed once.
119
+ */
120
+ isOnce : function () {
121
+ return this._isOnce;
122
+ },
123
+
117
124
  /**
118
125
  * @return {Function} Handler function bound to the signal.
119
126
  */
@@ -121,6 +128,13 @@
121
128
  return this._listener;
122
129
  },
123
130
 
131
+ /**
132
+ * @return {Signal} Signal that listener is currently bound to.
133
+ */
134
+ getSignal : function () {
135
+ return this._signal;
136
+ },
137
+
124
138
  /**
125
139
  * Delete instance properties
126
140
  * @private
@@ -131,13 +145,6 @@
131
145
  delete this.context;
132
146
  },
133
147
 
134
- /**
135
- * @return {boolean} If SignalBinding will only be executed once.
136
- */
137
- isOnce : function () {
138
- return this._isOnce;
139
- },
140
-
141
148
  /**
142
149
  * @return {string} String representation of the object.
143
150
  */
@@ -173,6 +180,12 @@
173
180
  */
174
181
  this._bindings = [];
175
182
  this._prevParams = null;
183
+
184
+ // enforce dispatch to aways work on same context (#47)
185
+ var self = this;
186
+ this.dispatch = function(){
187
+ Signal.prototype.dispatch.apply(self, arguments);
188
+ };
176
189
  }
177
190
 
178
191
  Signal.prototype = {
@@ -182,7 +195,7 @@
182
195
  * @type String
183
196
  * @const
184
197
  */
185
- VERSION : '0.8.1',
198
+ VERSION : '0.9.0',
186
199
 
187
200
  /**
188
201
  * If Signal should keep record of previously dispatched parameters and
@@ -3,11 +3,12 @@
3
3
  JS Signals <http://millermedeiros.github.com/js-signals/>
4
4
  Released under the MIT license
5
5
  Author: Miller Medeiros
6
- Version: 0.8.1 - Build: 266 (2012/07/31 03:33 PM)
6
+ Version: 0.9.0 - Build: 267 (2012/10/31 12:25 PM)
7
7
  */
8
- (function(h){function g(a,b,c,e,d){this._listener=b;this._isOnce=c;this.context=e;this._signal=a;this._priority=d||0}function f(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}function d(){this._bindings=[];this._prevParams=null}g.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());
9
- return b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):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.prototype={VERSION:"0.8.1",memorize:!1,_shouldPropagate:!0,
10
- active:!0,_registerListener:function(a,b,c,e){var d=this._indexOfListener(a,c);if(d!==-1){if(a=this._bindings[d],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 g(this,a,b,c,e),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);
11
- this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c=this._bindings.length,d;c--;)if(d=this._bindings[c],d._listener===a&&d.context===b)return c;return-1},has:function(a,b){return this._indexOfListener(a,b)!==-1},add:function(a,b,c){f(a,"add");return this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){f(a,"addOnce");return this._registerListener(a,!0,b,c)},remove:function(a,b){f(a,"remove");var c=this._indexOfListener(a,b);c!==-1&&(this._bindings[c]._destroy(),this._bindings.splice(c,
12
- 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=
13
- null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};d.Signal=d;typeof define==="function"&&define.amd?define(function(){return d}):typeof module!=="undefined"&&module.exports?module.exports=d:h.signals=d})(this);
8
+ (function(i){function h(a,b,c,d,e){this._listener=b;this._isOnce=c;this.context=d;this._signal=a;this._priority=e||0}function g(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}function e(){this._bindings=[];this._prevParams=null;var a=this;this.dispatch=function(){e.prototype.dispatch.apply(a,arguments)}}h.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):
9
+ a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());return b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal;delete this._listener;delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+
10
+ ", isBound:"+this.isBound()+", active:"+this.active+"]"}};e.prototype={VERSION:"0.9.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(a,b,c,d){var e=this._indexOfListener(a,c);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 h(this,a,b,c,d),this._addBinding(a);this.memorize&&this._prevParams&&a.execute(this._prevParams);return a},
11
+ _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,b){for(var c=this._bindings.length,d;c--;)if(d=this._bindings[c],d._listener===a&&d.context===b)return c;return-1},has:function(a,b){return this._indexOfListener(a,b)!==-1},add:function(a,b,c){g(a,"add");return this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){g(a,"addOnce");return this._registerListener(a,
12
+ !0,b,c)},remove:function(a,b){g(a,"remove");var c=this._indexOfListener(a,b);c!==-1&&(this._bindings[c]._destroy(),this._bindings.splice(c,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=
13
+ 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()+"]"}};var f=e;f.Signal=e;typeof define==="function"&&define.amd?define(function(){return f}):typeof module!=="undefined"&&module.exports?module.exports=f:i.signals=
14
+ f})(this);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jssignals-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-02 00:00:00.000000000 Z
12
+ date: 2012-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties