js-namespace-rails 0.1.0 → 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc5c9aaf90032ca0b2336b6f3e0378cfd17b9c0c
|
4
|
+
data.tar.gz: 29bcbc3fd241d5ae779719fbc95d02a3dda88c29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 874d914cca90bd43ee396685cc658535bdea9e08544ee0c7968afd682ea17917060c9d616e746e5cc9aa186e58499bfaec0d1fda1e1533ca6fc6ca6f7aa5d9bc
|
7
|
+
data.tar.gz: 3ac478149a622ed55ef664810c075130ef84e8fd4ee0301e073174649cad4e8e32df940d6eb6bb7c6e45b769f5c99cac74f8f3d9d95547cf428bbe165a888bf9
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ js-namespace-rails can handle this problem by using it's method to namespace and
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
gem 'js-namespace-rails'
|
13
|
+
gem 'js-namespace-rails'
|
14
14
|
```
|
15
15
|
|
16
16
|
## Setup
|
@@ -18,8 +18,10 @@ gem 'js-namespace-rails', github: 'falm/js-namepsace-rails'
|
|
18
18
|
Require js-namespace-rails file in application.js or other bundle,notice js-namespace-rails depends on jquery so you need require 'jquery' before
|
19
19
|
|
20
20
|
``` js
|
21
|
+
|
21
22
|
//= require jquery
|
22
23
|
//= require js-namespace-rails
|
24
|
+
|
23
25
|
```
|
24
26
|
|
25
27
|
|
@@ -33,7 +35,7 @@ Assume your project have articles_controller
|
|
33
35
|
```
|
34
36
|
And its corresponding js file app/assets/javascripts/articles.js.erb
|
35
37
|
|
36
|
-
then you just need to write
|
38
|
+
then you just need to write below into the js file
|
37
39
|
``` js
|
38
40
|
// app/assets/javascripts/articles.js.erb
|
39
41
|
JsSpace.on('articles', {
|
@@ -46,6 +48,9 @@ then you just need to write blew into the js file
|
|
46
48
|
});
|
47
49
|
```
|
48
50
|
|
51
|
+
## License
|
52
|
+
MIT License.
|
53
|
+
|
49
54
|
|
50
55
|
|
51
56
|
|
@@ -1,21 +1,25 @@
|
|
1
1
|
|
2
2
|
module ActionView::Helpers::AssetTagHelper
|
3
3
|
|
4
|
-
alias_method :
|
4
|
+
alias_method :javascript_include_tag_without_controller, :javascript_include_tag
|
5
5
|
|
6
6
|
def javascript_include_tag(*source)
|
7
7
|
|
8
|
-
origin_result =
|
8
|
+
origin_result = javascript_include_tag_without_controller(*source)
|
9
9
|
|
10
|
-
|
10
|
+
if defined?(controller_path)
|
11
|
+
_controller = controller_path.gsub(/\//,'_')
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
script = <<STRING
|
14
|
+
document.addEventListener('DOMContentLoaded', function() {
|
15
|
+
document.getElementsByTagName('body')[0].setAttribute('data-controller', '#{_controller}');
|
16
|
+
document.getElementsByTagName('body')[0].setAttribute('data-action', '#{action_name}');
|
17
|
+
});
|
17
18
|
STRING
|
18
|
-
|
19
|
+
origin_result + concat(javascript_tag(script, defer: 'defer'))
|
20
|
+
end
|
21
|
+
|
22
|
+
origin_result
|
19
23
|
|
20
24
|
end
|
21
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js-namespace-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Hou
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -80,6 +80,48 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: capybara
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: capybara-webkit
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
83
125
|
description: Namespace and Selectively Execute Javascript
|
84
126
|
email:
|
85
127
|
- hjj1992@gmail.com
|
@@ -95,7 +137,8 @@ files:
|
|
95
137
|
- lib/js_namespace_rails/engine.rb
|
96
138
|
- lib/js_namespace_rails/version.rb
|
97
139
|
homepage: https://github.com/falm/js-namespace-rails
|
98
|
-
licenses:
|
140
|
+
licenses:
|
141
|
+
- MIT
|
99
142
|
metadata: {}
|
100
143
|
post_install_message:
|
101
144
|
rdoc_options: []
|