js_hooks 0.0.3 → 0.0.4
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 +4 -4
- data/lib/js_hooks/controller.rb +14 -1
- data/lib/js_hooks/helpers.rb +1 -0
- data/lib/js_hooks/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: e44f33d61860583889ff81d254d23e6f704b9dd5
|
|
4
|
+
data.tar.gz: 2530881e8a52aad465ea7be1d552ce8ee3c80632
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3093586057e1e0f15f6d4d716ff63ca3976abf8e8087c4d2b923fe102911a4c92f5084572cb4037be697dde6430b0aaee0f7eecad76c7f00a05c772f89ee736b
|
|
7
|
+
data.tar.gz: d2443eb2d2748f75a5c1c781be278ec1fe75b4b00b6b858927012d5f066c3cf25ec097c354c026fc1dcf53317ad84d1a360c38973056e4859dfa223fe3777009
|
data/lib/js_hooks/controller.rb
CHANGED
|
@@ -11,7 +11,7 @@ module JsHooks
|
|
|
11
11
|
|
|
12
12
|
include JsHooks::Controller::LocalInstanceMethods
|
|
13
13
|
|
|
14
|
-
helper_method :js_hooks, :add_js_hook
|
|
14
|
+
helper_method :js_hooks, :add_js_hook, :js_hooks_initializers, :add_js_hook_initializer
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -21,6 +21,10 @@ module JsHooks
|
|
|
21
21
|
@js_hooks ||= {}
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def js_hooks_initializers
|
|
25
|
+
@js_hooks_initializers ||= []
|
|
26
|
+
end
|
|
27
|
+
|
|
24
28
|
# Add javascript components to execute inside a document ready jquery closure before the body close tag in your
|
|
25
29
|
# templates. For each hook added, an object with the same name is searched and the init method is called.
|
|
26
30
|
# A suffix can be used with the init method to refine the initialization process:
|
|
@@ -73,6 +77,15 @@ module JsHooks
|
|
|
73
77
|
end
|
|
74
78
|
end
|
|
75
79
|
|
|
80
|
+
# Adds JS code to execute after all hooks are defined but before they are initialized.
|
|
81
|
+
#
|
|
82
|
+
# <% add_js_hook_initializer do %>
|
|
83
|
+
# window.JsHooks.Users.myInitMethod();
|
|
84
|
+
# <% end %>
|
|
85
|
+
def add_js_hook_initializer(initializer)
|
|
86
|
+
self.js_hooks_initializers << initializer if initializer
|
|
87
|
+
end
|
|
88
|
+
|
|
76
89
|
private
|
|
77
90
|
def add_default_js_hooks
|
|
78
91
|
add_js_hook :application
|
data/lib/js_hooks/helpers.rb
CHANGED
data/lib/js_hooks/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: js_hooks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Francisco R. Santos
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|