Module: PapermillHelper
- Defined in:
- lib/papermill/papermill_helper.rb
Instance Method Summary collapse
-
#papermill_javascript_tag(options = {}) ⇒ Object
Sets all the javascript needed for papermill.
-
#papermill_stylesheet_tag(options = {}) ⇒ Object
Sets the css tags needed for papermill.
Instance Method Details
#papermill_javascript_tag(options = {}) ⇒ Object
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)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/papermill/papermill_helper.rb', line 8 def papermill_javascript_tag( = {}) html = [] if [:with_jquery] || [:with_jqueryui] html << %{<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"</script>} if [:with_jquery] html << %{<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"</script>} if [:with_jquery] || [:with_jqueryui_only] html << %{<script type="text/javascript">jQuery.noConflict();</script>} if [:with_jquery] == "no_conflict" end html << %{<script src="http://swfupload.googlecode.com/svn/swfupload/tags/swfupload_v2.2.0_core/swfupload.js"></script>} 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") 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 |
#papermill_stylesheet_tag(options = {}) ⇒ Object
Sets the css tags needed for papermill.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/papermill/papermill_helper.rb', line 31 def papermill_stylesheet_tag( = {}) 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 |