rails_script 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/generators/rails_script/install/templates/base.js.coffee +3 -3
- data/lib/rails_script/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 466139880f91bff9dc250cfb577db783e2be2c64
|
4
|
+
data.tar.gz: 766488d7eabddc2ead1c10d93e9d30e71f8c1daf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba3c9eaf4c2c040b877a8614750f490c2421ebe265dccef7577a957a7efd4bc54474898d17e142779cfca4326314b0ac6adc585dd5c9f18e0a4b048878f65b18
|
7
|
+
data.tar.gz: 427607b7861accd331d93d9e14f42ad7c839c1b48cdb31b45ad33f6314f1fb9b43f1a65bfe536994d23c768afef89efe5c4d9b5e048a2f28c8b1369bdb31872f
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ RailsScript is a Rails-centric, object oriented, featherweight framework for wri
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'rails_script', '~> 0.
|
9
|
+
gem 'rails_script', '~> 0.4.0'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -64,7 +64,7 @@ class App.Users extends App.Base
|
|
64
64
|
|
65
65
|
### Controller Specific JavaScript
|
66
66
|
|
67
|
-
Executing some JavaScript to run on all controller actions is just a matter of adding it to the class
|
67
|
+
Executing some JavaScript to run on all controller actions is just a matter of adding it to the class constructor. In the below example we will change the background color of the page for all actions in ```UsersController```.
|
68
68
|
|
69
69
|
```
|
70
70
|
# app/assets/javascripts/users.js.coffee
|
@@ -102,7 +102,7 @@ class App.Base
|
|
102
102
|
)
|
103
103
|
```
|
104
104
|
|
105
|
-
In this example we extracted the rollover action into a new function. Doing so will make the class cleaner and easier to maintain as the application grows. Once again note the ```return this``` in the
|
105
|
+
In this example we extracted the rollover action into a new function. Doing so will make the class cleaner and easier to maintain as the application grows. Once again note the ```return this``` in the constructor.
|
106
106
|
|
107
107
|
|
108
108
|
### Utilities
|
@@ -170,7 +170,7 @@ class App.Users extends App.Base
|
|
170
170
|
|
171
171
|
### Elements
|
172
172
|
|
173
|
-
An ```Element``` is a class that describes the
|
173
|
+
An ```Element``` is a class that describes the functionality of a one off element in the application. A Main Menu is a good example of this since there is usually only a single Main Menu.
|
174
174
|
|
175
175
|
First generate the ```Element```
|
176
176
|
|
@@ -282,7 +282,7 @@ class App.MyClassName
|
|
282
282
|
|
283
283
|
### Passing Rails Variables
|
284
284
|
|
285
|
-
To pass data from Rails to JavaScript, just call ```to_javascript``` with your data. This is then converted to a JSON object with ```to_javascript.to_json``` and can be accessed with ```Utility.RailsVars```.
|
285
|
+
To pass data from Rails to JavaScript, just call ```to_javascript``` along with a hash of your data. This is then converted to a JSON object with ```to_javascript.to_json``` and can be accessed with ```Utility.RailsVars```. The ```to_javascript``` helper may be called from multiple points in the application, all data is merged together.
|
286
286
|
|
287
287
|
Here's an example where ```to_javascript``` is used in a ```before_filter``` to pass the current user and their friends:
|
288
288
|
```
|
@@ -30,9 +30,9 @@ class App.Base
|
|
30
30
|
loads, i.e. "$(window).on 'scroll.app', myHandler"
|
31
31
|
###
|
32
32
|
setClearEventHandlers: ->
|
33
|
-
|
33
|
+
jQuery(document).on 'page:before-change', ->
|
34
34
|
for element in [window, document]
|
35
|
-
for event, handlers of (
|
35
|
+
for event, handlers of (jQuery._data(element, 'events') || {})
|
36
36
|
for handler in handlers
|
37
37
|
if handler? && handler.namespace == ''
|
38
|
-
|
38
|
+
jQuery(element).off event, handler.handler
|
data/lib/rails_script/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Pheasey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|