Sha256: ba53cb752468a827ef4a1f73be1e0336b42a5f32fed16f4e9373cc57a0e602bb

Contents?: true

Size: 1.95 KB

Versions: 8

Compression:

Stored size: 1.95 KB

Contents

module PapermillHelper
  
  # Sets all the javascript needed for papermill.
  # If you already loaded jQuery and JQueryUI, call papermill_javascript_tag
  # If you don't use jQuery or use some other library, call papermill_javascript_tag(:with_jquery => "no_conflict")
  # If you want to rely on this helper to load jQuery/jQueryUI and use it, call papermill_javascript_tag(:with_jquery => true)
  # If you loaded jQuery and need to load only jQueryUI, call papermill_javascript_tag(:with_jqueryui_only => true)
  def papermill_javascript_tag(options = {})
    html = []
    if options[:with_jquery] || options[:with_jqueryui]
      html << %{<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"</script>} if options[:with_jquery]
      html << %{<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"</script>} if options[:with_jquery] || options[:with_jqueryui_only]
      html << %{<script type="text/javascript">jQuery.noConflict();</script>} if options[:with_jquery] == "no_conflict"
    end
    html << %{<script type="text/javascript">}
    ["SWFUPLOAD_PENDING", "SWFUPLOAD_LOADING", "SWFUPLOAD_ERROR"].each do |js_constant|
      html << %{var #{js_constant} = "#{I18n.t(js_constant, :scope => "papermill")}";}
    end
    html << %{</script>}
    html << javascript_include_tag("/papermill/papermill", "/papermill/swfupload")
    unless @content_for_papermill_inline_js.blank?
      html << '<script type="text/javascript">jQuery(document).ready(function() {'
      html << @content_for_papermill_inline_js
      html << '});</script>'
    end
    html.join("\n")
  end
  
  # Sets the css tags needed for papermill.
  def papermill_stylesheet_tag(options = {})
    html = []
    html << stylesheet_link_tag("/papermill/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
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
papermill-0.13.2 lib/papermill/papermill_helper.rb
papermill-0.13.1 lib/papermill/papermill_helper.rb
papermill-0.13.0 lib/papermill/papermill_helper.rb
papermill-0.12.2 lib/papermill/papermill_helper.rb
papermill-0.12.1 lib/papermill/papermill_helper.rb
papermill-0.12.0 lib/papermill/papermill_helper.rb
papermill-0.11.0 lib/papermill/papermill_helper.rb
papermill-0.10.4 lib/papermill/papermill_helper.rb