js-namespace-rails 1.0.1 → 1.0.2

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: 03dd3af7647f1ec0adb2184a10be2df1e1c5b4db
4
- data.tar.gz: 9653ea1d9336402cd1b46d145f8ec323285167b3
3
+ metadata.gz: e856175ef86aae61fe8652a9eab0eca6ea5b8be2
4
+ data.tar.gz: 2b3898475d0ab5ee4151ca442841fe8014e553da
5
5
  SHA512:
6
- metadata.gz: df5036638b1133f602a8029a841c2925c3a365266bfa810cdaf3c02f8b0b50a9bb449dfa165e94e74941073671113534440ffbd9816f8644350ae8a0c26e6773
7
- data.tar.gz: e64aa4a4c1bf66008195ea42259b995c7a68a89cfc77b619de990cc377602b5d85266114c26d78b750c78d6c874b6d869a25fb4179a2b5ba6002478f0cdc9df0
6
+ metadata.gz: d8ad6b85b9ee92e81b4e0fce12b8599fc7c90a36ed6eb63deab9ff8fea754228a95dc954550732cba7512cf626620cf5a711e1eca35cd6ca4c8c81157a77e442
7
+ data.tar.gz: 73dcd9281f30f4c9c540127ea01216f751a942ad2c9b886f7f85d7930fea02423b8f7f2adfa8566f2f6f7f31c78267d0d3a3822f08c4d93ec0456e4c6434bb84
@@ -1,5 +1,7 @@
1
1
  document.addEventListener('DOMContentLoaded', function() {
2
- document.getElementsByTagName('body')[0].setAttribute('data-controller', '<%= controller_path.gsub(/\//,'_') %>');
3
- document.getElementsByTagName('body')[0].setAttribute('data-action', '<%= action_name %>');
4
- window.JsSpace.params = <%= raw @js_namespace_rails_params.to_json %>;
2
+ document.body.setAttribute('data-controller', '<%= controller_path.gsub(/\//,'_') %>');
3
+ document.body.setAttribute('data-action', '<%= action_name %>');
4
+ if(window.JsSpace){
5
+ window.JsSpace.params = <%= raw @js_namespace_rails_params.to_json %>;
6
+ }
5
7
  });
@@ -0,0 +1,7 @@
1
+
2
+ <% if request.headers["X-XHR-Referer"].present? %>
3
+ <script type="text/javascript">
4
+ JsSpace.params = <%= raw @js_namespace_rails_params.to_json %>;
5
+ JsSpace.init('<%= controller_path.gsub(/\//,'_')%>', '<%= action_name %>');
6
+ </script>
7
+ <% end %>
@@ -6,6 +6,7 @@ module JsNamespaceRails
6
6
  base.module_eval do
7
7
  helper_method :js_execute
8
8
  helper_method :insert_hook_script
9
+ helper_method :initialize_script
9
10
  end
10
11
  end
11
12
 
@@ -15,11 +16,15 @@ module JsNamespaceRails
15
16
  end
16
17
 
17
18
  def js_execute
18
- view_context.render(partial: 'js_namespace_rails/init')
19
+ view_context.render partial: 'js_namespace_rails/init.js.erb'
19
20
  end
20
21
 
21
22
  def insert_hook_script
22
- view_context.render(partial: 'js_namespace_rails/hook.js.erb')
23
+ view_context.render partial: 'js_namespace_rails/hook.js.erb'
24
+ end
25
+
26
+ def initialize_script
27
+ view_context.render partial: 'js_namespace_rails/initialize_script.html.erb'
23
28
  end
24
29
  end
25
30
  ::ActionController::Base.send :include, ActionControllerExtension
@@ -1,3 +1,3 @@
1
1
  module JsNamespaceRails
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Hou
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -147,6 +147,7 @@ files:
147
147
  - app/assets/javascripts/js-namespace-rails.js
148
148
  - app/views/js_namespace_rails/_hook.js.erb
149
149
  - app/views/js_namespace_rails/_init.js.erb
150
+ - app/views/js_namespace_rails/_initialize_script.html.erb
150
151
  - lib/js-namespace-rails.rb
151
152
  - lib/js_namespace_rails.rb
152
153
  - lib/js_namespace_rails/action_controller_extension.rb
@@ -165,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
166
  requirements:
166
167
  - - ">="
167
168
  - !ruby/object:Gem::Version
168
- version: '0'
169
+ version: '2.0'
169
170
  required_rubygems_version: !ruby/object:Gem::Requirement
170
171
  requirements:
171
172
  - - ">="
@@ -173,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
174
  version: '0'
174
175
  requirements: []
175
176
  rubyforge_project:
176
- rubygems_version: 2.6.6
177
+ rubygems_version: 2.6.8
177
178
  signing_key:
178
179
  specification_version: 4
179
180
  summary: js-namespace-rails let you choose which javascript snippet can execute in