Module: JellyHelper
Instance Method Summary
collapse
#jelly_attachment_hash, #jelly_callback_attach_hash, #jelly_callback_hash
Instance Method Details
#application_jelly_files(jelly_files_path_from_javascripts = '', rails_root = RAILS_ROOT) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/jelly/jelly_helper.rb', line 4
def application_jelly_files(jelly_files_path_from_javascripts = '', rails_root = RAILS_ROOT)
rails_root = File.expand_path(rails_root)
(
Dir[File.expand_path("#{rails_root}/public/javascripts/#{jelly_files_path_from_javascripts}/components/**/*.js")] +
Dir[File.expand_path("#{rails_root}/public/javascripts/#{jelly_files_path_from_javascripts}/pages/**/*.js")]
).map do |path|
path.gsub("#{rails_root}/public/javascripts/", "").gsub(/\.js$/, "")
end
end
|
#attach_javascript_component(component_name, *args) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/jelly/jelly_helper.rb', line 40
def attach_javascript_component(component_name, *args)
key = jelly_attachment_hash(component_name, *args)
unless jelly_attachments.include? key
jelly_attachments << key
end
end
|
#attach_javascript_component_javascript_tag(*components) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/jelly/jelly_helper.rb', line 27
def attach_javascript_component_javascript_tag(*components)
components = [components].flatten
javascript_tag <<-JS
$(document).ready(function() {
Jelly.attach.apply(Jelly, #{components.to_json});
});
JS
end
|
#attach_javascript_component_on_ready(component_name, *args) ⇒ Object
47
48
49
50
|
# File 'lib/jelly/jelly_helper.rb', line 47
def attach_javascript_component_on_ready(component_name, *args)
warn "attach_javascript_component_on_ready is deprecated since attach_javascript_component adds components to be attached in a $(document).ready block\n#{puts caller.join("\n\t")}"
attach_javascript_component(component_name, *args)
end
|
#clear_jelly_attached ⇒ Object
36
37
38
|
# File 'lib/jelly/jelly_helper.rb', line 36
def clear_jelly_attached
jelly_attachments.clear
end
|
#jelly_attachments ⇒ Object
52
53
54
|
# File 'lib/jelly/jelly_helper.rb', line 52
def jelly_attachments
@jelly_attachments ||= []
end
|
#spread_jelly ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/jelly/jelly_helper.rb', line 14
def spread_jelly
attach_javascript_component("Jelly.Location")
attach_javascript_component("Jelly.Page", controller.controller_path.camelcase, controller.action_name)
<<-HTML
#{window_token_javascript_tag}
#{attach_javascript_component_javascript_tag(jelly_attachments)}
HTML
end
|
#window_token_javascript_tag ⇒ Object
23
24
25
|
# File 'lib/jelly/jelly_helper.rb', line 23
def window_token_javascript_tag
javascript_tag("window._token = '#{form_authenticity_token}';")
end
|