Module: TransitHelper

Includes:
Transit::FormHelper, Transit::PackageHelper, Transit::PaginationHelper
Defined in:
app/helpers/transit_helper.rb

Instance Method Summary collapse

Methods included from Transit::FormHelper

#form_for

Methods included from Transit::PaginationHelper

#paginate

Methods included from Transit::PackageHelper

#deliver, #deliver_content, #deliver_rss

Instance Method Details

#audio_player(source, html_attrs = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/transit_helper.rb', line 31

def audio_player(source, html_attrs = {})
  attrs = { 
    id: "audio_player_#{Time.now.to_i}",
    class: 'audio_player' 
  }
  wrapper = html_attrs.delete(:wrapper) || :div
  data_attrs = { source: source }
  html_attrs.reverse_merge!( attrs.merge!(data: { context_attributes: Base64.encode64s(data_attrs.to_json) }) )
  (wrapper, "", html_attrs)
end

#transit_assetsObject



8
9
10
11
12
13
# File 'app/helpers/transit_helper.rb', line 8

def transit_assets
  return '' unless controller.class.name.match(/Transit/)
  stylesheet_link_tag('transit') <<
  javascript_include_tag('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js') <<
  javascript_include_tag('transit/admin')
end

#video_player(source, html_attrs = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/transit_helper.rb', line 15

def video_player(source, html_attrs = {})
  attrs = { 
    id: "video_player_#{Time.now.to_i}",
    class: 'video_player' 
  }
  wrapper    = html_attrs.delete(:wrapper) || :div
  data_attrs = { source: source, ext: File.extname(source).sub('.','') };
  
  if img = html_attrs.delete(:image)
    data_attrs.merge!(image: img)      
  end
  
  html_attrs.reverse_merge!( attrs.merge!(data: { context_attributes: Base64.encode64s(data_attrs.to_json) } ))
  (wrapper, "", html_attrs)
end