Module: Shoppe::ShoppeHelper

Defined in:
app/helpers/shoppe/shoppe_helper.rb

Instance Method Summary collapse

Instance Method Details

#attachment_preview(attachment) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/shoppe/shoppe_helper.rb', line 7

def attachment_preview(attachment)
  if attachment
    String.new.tap do |s|
      if attachment.image?
        style = "style='background-image:url(#{attachment.path})'"
      else
        style = ''
      end
      s << "<div class='attachmentPreview #{attachment.image? ? 'image' : 'doc'}'>"
      s << "<div class='imgContainer'><div class='img' #{style}></div></div>"
      s << "<div class='desc'>"
      s << "<span class='filename'><a href='#{attachment_path(attachment)}'>#{attachment.file_name}</a></span>"
      s << "<span class='delete'>"
      s << link_to("Delete this file?", attachment_path(attachment), :method => :delete, :data => {:confirm => "Are you sure you wish to remove this attachment?"})
      s << "</span>"
      s << "</div>"
      s << "</div>"
    end.html_safe
  else
    "<div class='attachmentPreview'><div class='imgContainer'><div class='img none'></div></div><div class='desc none'>No attachment</div></div>".html_safe
  end
end

#status_tag(status) ⇒ Object



3
4
5
# File 'app/helpers/shoppe/shoppe_helper.rb', line 3

def status_tag(status)
   :span, status, :class => "status-tag #{status}"
end