Commit fece552855eec6caad82ad8b1f0b723857b19502
1 parent
93116c6b
Exists in
master
and in
29 other branches
Encapsulate plugins' js code
Showing
2 changed files
with
9 additions
and
6 deletions
Show diff stats
app/helpers/layout_helper.rb
1 | 1 | module LayoutHelper |
2 | 2 | |
3 | 3 | def noosfero_javascript |
4 | - render :file => 'layouts/_javascript' | |
4 | + plugins_javascripts = @plugins.map { |plugin| plugin.js_files.map { |js| plugin.class.public_path(js) } }.flatten | |
5 | + | |
6 | + output = '' | |
7 | + output += render :file => 'layouts/_javascript' | |
8 | + output += javascript_tag 'render_all_jquery_ui_widgets()' | |
9 | + unless plugins_javascripts.empty? | |
10 | + output += javascript_include_tag plugins_javascripts, :cache => "cache/plugins-#{Digest::MD5.hexdigest plugins_javascripts.to_s}" | |
11 | + end | |
12 | + output | |
5 | 13 | end |
6 | 14 | |
7 | 15 | def noosfero_stylesheets | ... | ... |
app/views/layouts/application-ng.rhtml
... | ... | @@ -12,11 +12,6 @@ |
12 | 12 | |
13 | 13 | <%# Add custom tags/styles/etc via content_for %> |
14 | 14 | <%= yield :head %> |
15 | - <%= javascript_tag('render_all_jquery_ui_widgets()') %> | |
16 | - <% | |
17 | - plugins_javascripts = @plugins.map { |plugin| plugin.js_files.map { |js| plugin.class.public_path(js) } }.flatten | |
18 | - %> | |
19 | - <%= javascript_include_tag(plugins_javascripts, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_javascripts.to_s)) unless plugins_javascripts.empty? %> | |
20 | 15 | <%= |
21 | 16 | @plugins.dispatch(:head_ending).collect do |content| |
22 | 17 | content.respond_to?(:call) ? content.call : content | ... | ... |