Sha256: eacb2508aacae15610b0857679be447a458aa7412e1dd150d2fbac216a539751

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

module Transit::AdminHelper
  unloadable
  
  def context_field_item(field, form)
   idfield = field.new_record? ? "" : form.hidden_field(:id)
   content_tag(:li, { id:"context_#{field.id.to_s}", class: "field field_#{field.class.to_s.underscore}" }) do
     form.hidden_field(:_type, value: field.class.to_s) <<
     form.hidden_field(:position, rel: 'field_position') <<
     idfield <<
     render(partial: "transit/contexts/#{field.class.to_s.underscore}", locals: { form: form, context: field })
   end.html_safe
  end

  def transit_toolbar(model, &block)
   content_tag(:div, capture(&block), { class: 'ui-widget-header ui-state-default', id: 'transit_toolbar' })
  end

  def toolbar_button(text, url, attrs)
   klasses = attrs[:class].to_s.split(" ").push('transit_toolbar_button')
   if attrs[:icon].present?
     (attrs[:data] ||= {}).merge!("ui-icon" => "ui-icon-#{attrs.delete(:icon)}")
   end
   link_to text.html_safe, url, attrs.merge(class: klasses.join(" ")) 
  end

  def file_icon_class(asset)
   ext = File.extname(asset.file_file_name.to_s.downcase).gsub('.', '')
   extnames = { 
     'powerpoint' => ['ppt','pptx','key'],
     'audio'      => ['mp3', 'wav'],
     'video'      => ['mp4', 'wmv', 'mov', 'mpeg'],
     'flash'      => ['swf', 'flv', 'fla'],
     'pdf'        => ['pdf'],
     'word'       => ['doc', 'docx', 'pages'],
     'excel'      => ['xls', 'csv', 'xlsx', 'numbers'],
     'image'      => ['tiff', 'tif', 'bmp', 'jpeg', 'jpg', 'png', 'gif'],
     'vector'     => ['ai', 'eps']
   }
   choice = 'file'
   extnames.each_pair{ |key, value|  choice = key if value.include?(ext) }
   "file_icon_#{choice}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transit-0.0.2 app/helpers/transit/admin_helper.rb