rails_script 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64a22187ede1845168cb8ad0acddc07dee947b73
|
4
|
+
data.tar.gz: 251b6ec058a974335534d538c12448ba35d91384
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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
|
|
data/lib/rails_script/version.rb
CHANGED
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.
|
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
|