Module: Transit::AdminHelper

Defined in:
app/helpers/transit/admin_helper.rb

Instance Method Summary collapse

Instance Method Details

#context_field_item(field, form) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'app/helpers/transit/admin_helper.rb', line 4

def context_field_item(field, form)
 idfield = field.new_record? ? "" : form.hidden_field(:id)
 (: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

#file_icon_class(asset) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/transit/admin_helper.rb', line 26

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

#toolbar_button(text, url, attrs) ⇒ Object



18
19
20
21
22
23
24
# File 'app/helpers/transit/admin_helper.rb', line 18

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

#transit_toolbar(model, &block) ⇒ Object



14
15
16
# File 'app/helpers/transit/admin_helper.rb', line 14

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