Module: PapermillHelper

Defined in:
lib/papermill/papermill_helper.rb

Instance Method Summary collapse

Instance Method Details

#papermill_javascript_tag(options = {}) ⇒ Object

Sets all the javascript needed for papermill. If jQuery and JQueryUI (with Sortable) are already loaded, call papermill_javascript_tag If you use some other JS Framework, call papermill_javascript_tag(:with_jquery => “no_conflict”) If you want to rely on this helper to load jQuery and JQueryUI and use them after, call papermill_javascript_tag(:with_jquery => true)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/papermill/papermill_helper.rb', line 10

def papermill_javascript_tag(options = {})
  html = []
  html << %{<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>\
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js" type="text/javascript"></script>} if options[:with_jquery]
  html << %{<script type="text/javascript">}
  html << %{jQuery.noConflict();} if options[:with_jquery].to_s == "no_conflict"
  html << %{</script>}
  html << javascript_include_tag("/facebox/facebox.js", "/jgrowl/jquery.jgrowl_minimized.js", "/Jcrop/jquery.Jcrop.min.js", "/swfupload/swfupload.js", "/papermill/papermill.js", :cache => "papermill")
  unless @content_for_papermill_inline_js.blank?
    html << %{<script type="text/javascript">}
    html << %{jQuery(document).ready(function() {#{@content_for_papermill_inline_js}});}
    html << %{</script>}
  end
  html.join("\n")
end

#papermill_stylesheet_tag(options = {}) ⇒ Object

Sets the css tags needed for papermill.



27
28
29
30
31
32
33
34
35
36
# File 'lib/papermill/papermill_helper.rb', line 27

def papermill_stylesheet_tag(options = {})
  html = []
  html << stylesheet_link_tag("/facebox/facebox.css", "/jgrowl/jquery.jgrowl.css", "/Jcrop/jquery.Jcrop.css", "/papermill/papermill.css", :cache => "papermill")
  unless @content_for_papermill_inline_css.blank?
    html << %{<style type="text/css">}
    html << @content_for_papermill_inline_css
    html << %{</style>}
  end
  html.join("\n")
end