Sha256: 9e258f87a01807a66bedd9b745e366ad8cd8e59d696b540a9a7d083e9ce7eaaf

Contents?: true

Size: 1.23 KB

Versions: 18

Compression:

Stored size: 1.23 KB

Contents

module DocumentsHelper
  #size can be any of the names that the document has size for
  def thumb_for(document, size)
    image_tag thumb_file_for(document, size)
  end

  def thumb_file_for(document, size)
    style = document.class.attachment_definitions[:file][:styles]

    format = style.respond_to?('[]') && style[:format] || document.format

    polymorphic_path(document, format: format, style: size)
  end

  # Return the right icon based on {#document}'s mime type
  def icon document, size = 50
    "<i class=\"icon_file_#{ size }-#{ icon_mime_type document }\"></i>".html_safe
  end

  # Find the right class for the icon of this document, based on its format
  def icon_mime_type document
    if SocialStream::Documents.icon_mime_types[:subtypes].include?(document.format)
      document.format
    elsif SocialStream::Documents.icon_mime_types[:types].include?(document.mime_type_type_sym)
      document.mime_type_type_sym
    else
      SocialStream::Documents.icon_mime_types[:default]
    end
  end
  
  def document_details_tab_class(document, tab)
    editing = document && document.errors.present?

    case tab
    when :edit
      editing ? 'active' : ''
    when :info
      editing ? '' : 'active'
    else
      ''
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
social_stream-2.2.2 documents/app/helpers/documents_helper.rb
social_stream-documents-2.2.1 app/helpers/documents_helper.rb
social_stream-2.2.1 documents/app/helpers/documents_helper.rb
social_stream-2.2.0 documents/app/helpers/documents_helper.rb
social_stream-documents-2.2.0 app/helpers/documents_helper.rb
social_stream-2.1.1 documents/app/helpers/documents_helper.rb
social_stream-2.1.0 documents/app/helpers/documents_helper.rb
social_stream-documents-2.1.0 app/helpers/documents_helper.rb
social_stream-2.0.4 documents/app/helpers/documents_helper.rb
social_stream-documents-2.0.4 app/helpers/documents_helper.rb
social_stream-2.0.3 documents/app/helpers/documents_helper.rb
social_stream-documents-2.0.3 app/helpers/documents_helper.rb
social_stream-2.0.2 documents/app/helpers/documents_helper.rb
social_stream-documents-2.0.2 app/helpers/documents_helper.rb
social_stream-2.0.1 documents/app/helpers/documents_helper.rb
social_stream-documents-2.0.1 app/helpers/documents_helper.rb
social_stream-2.0.0 documents/app/helpers/documents_helper.rb
social_stream-documents-2.0.0 app/helpers/documents_helper.rb