Commit fece552855eec6caad82ad8b1f0b723857b19502

Authored by Braulio Bhavamitra
1 parent 93116c6b

Encapsulate plugins' js code

app/helpers/layout_helper.rb
1 module LayoutHelper 1 module LayoutHelper
2 2
3 def noosfero_javascript 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 end 13 end
6 14
7 def noosfero_stylesheets 15 def noosfero_stylesheets
app/views/layouts/application-ng.rhtml
@@ -12,11 +12,6 @@ @@ -12,11 +12,6 @@
12 12
13 <%# Add custom tags/styles/etc via content_for %> 13 <%# Add custom tags/styles/etc via content_for %>
14 <%= yield :head %> 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 @plugins.dispatch(:head_ending).collect do |content| 16 @plugins.dispatch(:head_ending).collect do |content|
22 content.respond_to?(:call) ? content.call : content 17 content.respond_to?(:call) ? content.call : content