Module: Tienda::ApplicationHelper
- Defined in:
- app/helpers/tienda/application_helper.rb
Instance Method Summary collapse
- #attachment_preview(attachment, options = {}) ⇒ Object
- #body_class ⇒ Object
- #navigation_manager_link(item) ⇒ Object
- #settings_field(field, options = {}) ⇒ Object
- #settings_label(field, html_class) ⇒ Object
- #status_tag(status) ⇒ Object
Instance Method Details
#attachment_preview(attachment, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/tienda/application_helper.rb', line 18 def (, = {}) if String.new.tap do |s| if .mounted_as == :image style = "style='background-image:url(#{.url})'" else style = '' end s << "<div class='attachmentPreview #{.mounted_as == :image ? 'image' : 'doc'}'>" s << "<div class='imgContainer'><div class='img' #{style}></div></div>" s << "<div class='desc'>" s << "<span class='filename'>#{link_to File.basename(.path), .url}</span>" # s << "<span class='filename'><a href='#{attachment_path(attachment)}'>#{attachment.file_name}</a></span>" s << "<span class='delete'>" s << link_to(t('helpers.attachment_preview.delete', :default => 'Delete this file?'), (), :method => :delete, :data => {:confirm => t('helpers.attachment_preview.delete_confirm', :default => "Are you sure you wish to remove this attachment?")}) s << "</span>" s << "</div>" s << "</div>" end.html_safe elsif ![:hide_if_blank] "<div class='attachmentPreview'><div class='imgContainer'><div class='img none'></div></div><div class='desc none'>#{t('helpers.attachment_preview.no_attachment')}</div></div>".html_safe end end |
#body_class ⇒ Object
4 5 6 |
# File 'app/helpers/tienda/application_helper.rb', line 4 def body_class "#{params[:controller].gsub('/', '_')}_#{params[:action]}" end |
#navigation_manager_link(item) ⇒ Object
8 9 10 11 12 |
# File 'app/helpers/tienda/application_helper.rb', line 8 def (item) link_to item.url(self), item..merge(class: item.active?(self) ? 'active-menu' : 'inactive') do "<i class='fa #{item.icon}'></i>#{item.description}".html_safe end end |
#settings_field(field, options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/helpers/tienda/application_helper.rb', line 46 def settings_field(field, = {}) default = I18n.t("tienda.settings.defaults")[field.to_sym] value = (params[:settings] && params[:settings][field]) || Tienda.settings[field.to_s] type = I18n.t("tienda.settings.types")[field.to_sym] || 'string' case type when 'boolean' String.new.tap do |s| value = default if value.blank? s << "<div class='radios'>" s << ("settings[#{field}]", 'true', value == true, :id => "settings_#{field}_true") s << label_tag("settings_#{field}_true", t("tienda.settings.options.#{field}.affirmative", :default => 'Yes')) s << ("settings[#{field}]", 'false', value == false, :id => "settings_#{field}_false") s << label_tag("settings_#{field}_false", t("tienda.settings.options.#{field}.negative", :default => 'No')) s << "</div>" end.html_safe else text_field_tag "settings[#{field}]", value, .merge(:placeholder => default, :class => [:class]) end end |
#settings_label(field, html_class) ⇒ Object
42 43 44 |
# File 'app/helpers/tienda/application_helper.rb', line 42 def settings_label(field, html_class) "<label for='settings_#{field}' class='#{html_class}'>#{t("tienda.settings.labels.#{field}")}</label>".html_safe end |
#status_tag(status) ⇒ Object
14 15 16 |
# File 'app/helpers/tienda/application_helper.rb', line 14 def status_tag(status) content_tag :span, t("tienda.orders.statuses.#{status}"), :class => "status-tag #{status}" end |