Module: Shoppe::ApplicationHelper
- Defined in:
- app/helpers/shoppe/application_helper.rb
Instance Method Summary collapse
- #attachment_preview(attachment, options = {}) ⇒ Object
- #settings_field(field, options = {}) ⇒ Object
- #settings_label(field) ⇒ Object
- #status_tag(status) ⇒ Object
Instance Method Details
#attachment_preview(attachment, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/shoppe/application_helper.rb', line 8 def (, = {}) if String.new.tap do |s| if .image? style = "style='background-image:url(#{.path})'" else style = '' end s << "<div class='attachmentPreview #{.image? ? 'image' : 'doc'}'>" s << "<div class='imgContainer'><div class='img' #{style}></div></div>" s << "<div class='desc'>" s << "<span class='filename'><a href='#{()}'>#{.file_name}</a></span>" s << "<span class='delete'>" s << link_to(t('shoppe.helpers.attachment_preview.delete', :default => 'Delete this file?'), (), :method => :delete, :data => {:confirm => t('shoppe.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'>No attachment</div></div>".html_safe end end |
#settings_field(field, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/shoppe/application_helper.rb', line 35 def settings_field(field, = {}) default = t("shoppe.settings.defaults")[field.to_sym] value = (params[:settings] && params[:settings][field]) || Shoppe.settings[field.to_s] type = t("shoppe.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("shoppe.settings.options.#{field}.affirmative", :default => 'Yes')) s << ("settings[#{field}]", 'false', value == false, :id => "settings_#{field}_false") s << label_tag("settings_#{field}_false", t("shoppe.settings.options.#{field}.negative", :default => 'No')) s << "</div>" end.html_safe else text_field_tag "settings[#{field}]", value, .merge(:placeholder => default, :class => 'text') end end |
#settings_label(field) ⇒ Object
31 32 33 |
# File 'app/helpers/shoppe/application_helper.rb', line 31 def settings_label(field) "<label for='settings_#{field}'>#{t("shoppe.settings.labels.#{field}")}</label>".html_safe end |
#status_tag(status) ⇒ Object
4 5 6 |
# File 'app/helpers/shoppe/application_helper.rb', line 4 def status_tag(status) content_tag :span, status, :class => "status-tag #{status}" end |