Skip to content
Browse files

only render javascript if needed

  • Loading branch information...
1 parent e45b653 commit 624e0f0f1d8a5770a88f82afac76264ac8be166c @beaucollins committed Jul 1, 2010
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/power_reviews/view_helpers.rb
View
9 lib/power_reviews/view_helpers.rb
@@ -1,8 +1,10 @@
module PowerReviews
module ViewHelpers
- def power_reviews_javascript_tag
- javascript_include_tag('/system/pwr/engine/js/full')
+ def power_reviews_javascript_tag(path_to_file = '/system/pwr/engine/js/full')
+ unless @power_reviews_javascript_needed.nil?
+ javascript_include_tag(path_to_file)
+ end
end
def power_reviews_javascript_variables(options = {})
@@ -17,6 +19,7 @@ def power_reviews_javascript_variables(options = {})
end
def power_reviews_snippet(page_id, write_review_url, review_anchor = '#ReviewHeader')
+ @power_reviews_javascript_needed = true
javascript_tag do
<<-eos
POWERREVIEWS.display.snippet(document, {
@@ -29,6 +32,7 @@ def power_reviews_snippet(page_id, write_review_url, review_anchor = '#ReviewHea
end
def power_reviews_display(page_id, write_review_url)
+ @power_reviews_javascript_needed = true
javascript_tag do
<<-eos
POWERREVIEWS.display.engine(document, {
@@ -40,6 +44,7 @@ def power_reviews_display(page_id, write_review_url)
end
def power_reviews_form(page_id, options = {})
+ @power_reviews_javascript_needed = true
options = {
:locale => '',
:site_id => PowerReviews::Config.site_id,

0 comments on commit 624e0f0

Please sign in to comment.
Something went wrong with that request. Please try again.