rails_script 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5810a9506cef8d97deab52d83d8ffed35153aaa5
4
- data.tar.gz: a5c4f0b4b66a766821236cc6e7b7037cb0d7af74
3
+ metadata.gz: 64a22187ede1845168cb8ad0acddc07dee947b73
4
+ data.tar.gz: 251b6ec058a974335534d538c12448ba35d91384
5
5
  SHA512:
6
- metadata.gz: c3c272f1d89997fade518d9f59000bab07be38ab9ab38c6cf6c1c39804b32893d372a7c53b14b4dd04e042fe76e9d05e4958de8e2a616cce978d6011a2c33355
7
- data.tar.gz: 6838fba7c9d12ffe1ce8cf969da3435619233636c68476e6ddcf552645d3496fc42ce74ae98acbf832ae0e251cca7c2312c6a465a686b792b7f3d5e704e5efd7
6
+ metadata.gz: da8b34691b63e3162e69197afbb81bdcd7037abeae3dbef05c2cb9d844aab665b0faf489bf174463d4bfdddc3299559938746524803f8d40e6628e3656835200
7
+ data.tar.gz: 7725be6085598c6768ca4889d9417d33c3dc0b748265ddd03a3fa4dc927d5df8b2ff7a6a539d89127bf7c853b8d138f349438a87ac2d89ada13a602129efa283
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RailsScript
2
2
 
3
- RailsScript is a Rails-centric, object oriented, featherweight framework for writing CoffeeScript. It is optimized for the [Rails Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html) and is compatible with [TurboLinks](https://github.com/rails/turbolinks). Using Rails controller names and actions to call JavaScript, it has never been easier to write clean, concise, and maintanable page specific JavaScript.
3
+ RailsScript is a Rails-centric, object oriented, featherweight framework for writing CoffeeScript. It is optimized for the [Rails Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html) and is compatible with [TurboLinks](https://github.com/rails/turbolinks). Using Rails controller names and actions to call JavaScript, it has never been easier to write clean, concise, and maintainable page specific JavaScript.
4
4
 
5
5
  ## Installation
6
6
 
@@ -281,6 +281,11 @@ class App.MyClassName
281
281
  ```
282
282
 
283
283
 
284
+ ### Events
285
+
286
+ Since Turbolinks doesn't refresh the page and only replaces the body, event listeners defined on ```window``` and ```document``` carry between page loads. To avoid these event listeners stacking, RailsScript will destroy all event listeners on ```window``` and ```document``` that have a blank namespace, i.e. ```$(window).on 'scroll', myHandler```. If you need an event handler to persist between page changes, then define a namespace, i.e. ```$(window).on 'scroll.namespace', myHandler```.
287
+
288
+
284
289
 
285
290
 
286
291
  ## Contributing
@@ -1,3 +1,6 @@
1
+ window.Utility || (window.Utility = {});
2
+ Utility.RailsVars = #{@to_javascript.nil? ? '{}' : @to_javascript.to_json};
3
+
1
4
  jQuery(function() {
2
5
  window.$this = new (App.#{ controller_path.split(/\/|_/).map(&:capitalize).join('') } || App.Base)();
3
6
  if (typeof $this.#{ action_name } === 'function') {
@@ -3,7 +3,7 @@ module RailsScript
3
3
 
4
4
  def include_rails_script
5
5
  javascript_tag <<-RUBY
6
- jQuery(function(){window.$this=new(App.#{controller_path.split(/\/|_/).map(&:capitalize).join('')}||App.Base);if(typeof $this.#{action_name}==="function"){return $this.#{action_name}.call()}});jQuery(document).on("page:before-change",function(){var e,t,n,r,i,s,o,u;o=[window,document];u=[];for(i=0,s=o.length;i<s;i++){e=o[i];u.push(function(){var i,s;i=jQuery._data(e,"events");s=[];for(r in i){n=i[r];s.push(function(){var i,s,o;o=[];for(i=0,s=n.length;i<s;i++){t=n[i];if(t==null){continue}o.push(t.namespace===""?$(e).off(r,t.handler):void 0)}return o}())}return s}())}return u})
6
+ window.Utility || (window.Utility = {});Utility.RailsVars = #{@to_javascript.nil? ? '{}' : @to_javascript.to_json};jQuery(function(){window.$this=new(App.#{controller_path.split(/\/|_/).map(&:capitalize).join('')}||App.Base);if(typeof $this.#{action_name}==="function"){return $this.#{action_name}.call()}});jQuery(document).on("page:before-change",function(){var e,t,n,r,i,s,o,u;o=[window,document];u=[];for(i=0,s=o.length;i<s;i++){e=o[i];u.push(function(){var i,s;i=jQuery._data(e,"events");s=[];for(r in i){n=i[r];s.push(function(){var i,s,o;o=[];for(i=0,s=n.length;i<s;i++){t=n[i];if(t==null){continue}o.push(t.namespace===""?$(e).off(r,t.handler):void 0)}return o}())}return s}())}return u})
7
7
  RUBY
8
8
  end
9
9
 
@@ -1,3 +1,3 @@
1
1
  module RailsScript
2
- VERSION = '0.1.4'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_script
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Pheasey
@@ -73,7 +73,7 @@ files:
73
73
  - LICENSE.txt
74
74
  - README.md
75
75
  - Rakefile
76
- - include_rails_script.js
76
+ - include_rails_script.js.coffee
77
77
  - lib/generators/rails_script/class/USAGE
78
78
  - lib/generators/rails_script/class/class_generator.rb
79
79
  - lib/generators/rails_script/class/templates/javascript.js.coffee