Module: ApplicationHelper
- Defined in:
- lib/redmine_plugin_asset_pipeline/application_helper_patch.rb
Instance Method Summary collapse
- #image_tag(source, options = {}) ⇒ Object
- #include_calendar_headers_tags ⇒ Object
- #javascript_include_tag(*sources) ⇒ Object
- #stylesheet_link_tag(*sources) ⇒ Object
Instance Method Details
#image_tag(source, options = {}) ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/redmine_plugin_asset_pipeline/application_helper_patch.rb', line 82 def image_tag(source, ={}) if plugin = .delete(:plugin) source = "#{plugin}/images/#{source}" elsif current_theme && current_theme.images.include?(source) source = current_theme.image_path(source) elsif source[0] != '/' source = "images/#{source}" end super source, end |
#include_calendar_headers_tags ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/redmine_plugin_asset_pipeline/application_helper_patch.rb', line 93 def unless @calendar_headers_tags_included @calendar_headers_tags_included = true content_for :header_tags do start_of_week = Setting.start_of_week start_of_week = l(:general_first_day_of_week, default: '1') if start_of_week.blank? # Redmine uses 1..7 (monday..sunday) in settings and locales # JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0 start_of_week = start_of_week.to_i % 7 = javascript_tag( "var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " + "showOn: 'button', buttonImageOnly: true, buttonImage: '" + path_to_image('images/calendar.png') + "', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};") jquery_locale = l('jquery.locale', default: current_language.to_s) unless jquery_locale == 'en' << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js") end end end end |
#javascript_include_tag(*sources) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/redmine_plugin_asset_pipeline/application_helper_patch.rb', line 45 def javascript_include_tag(*sources) = sources.last.is_a?(Hash) ? sources.pop : {} plugin = .delete(:plugin) debug = .key?(:debug) ? .delete(:debug) : debug_assets? body = .key?(:body) ? .delete(:body) : false digest = .key?(:digest) ? .delete(:digest) : digest_assets? sources.map! do |source| if plugin "#{plugin}/javascripts/#{source}" else # NOTE: bugfix aka crutch for asset from gem ["javascripts/#{source}", source]. find{|s| asset_for(s, 'js').present?} || "javascripts/#{source}" end end sources.collect do |source| asset = asset_for(source, 'js') if debug && asset asset.to_a.map do |dep| single_asset_path = asset_path(dep, ext: 'js', body: true, digest: digest) # TODO: here we must try to make more pretty solution next if single_asset_path.blank? super(dep.pathname.to_s, { src: single_asset_path }.merge!()) end.compact else single_asset_path = asset_path(source, ext: 'js', body: body, digest: digest) # TODO: here we must try to make more pretty solution next if single_asset_path.blank? super(source.to_s, { src: single_asset_path }.merge!()) end end.compact.uniq.join("\n").html_safe end |
#stylesheet_link_tag(*sources) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/redmine_plugin_asset_pipeline/application_helper_patch.rb', line 4 def stylesheet_link_tag(*sources) = sources. plugin = .delete(:plugin) debug = .key?(:debug) ? .delete(:debug) : debug_assets? body = .key?(:body) ? .delete(:body) : false digest = .key?(:digest) ? .delete(:digest) : digest_assets? sources.map! do |source| if plugin "#{plugin}/stylesheets/#{source}" elsif current_theme && current_theme.stylesheets.include?(source) current_theme.stylesheet_path(source) else # NOTE: bugfix aka crutch for asset from gem ["stylesheets/#{source}", source]. find{|s| asset_for(s, 'css').present?} || "stylesheets/#{source}" end end sources.collect do |source| asset = asset_for(source, 'css') if debug && asset asset.to_a.map do |dep| single_asset_path = asset_path(dep, ext: 'css', body: true, protocol: :request, digest: digest) # TODO: here we must try to make more pretty solution next if single_asset_path.blank? super(dep.pathname.to_s, { href: single_asset_path }.merge!()) end.compact else single_asset_path = asset_path(source, ext: 'css', body: body, protocol: :request, digest: digest) # TODO: here we must try to make more pretty solution next if single_asset_path.blank? super(source.to_s, { href: single_asset_path }.merge!()) end end.compact.uniq.join("\n").html_safe end |