Module: Tenon::TenonContentHelper

Defined in:
app/helpers/tenon/tenon_content_helper.rb

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/tenon/tenon_content_helper.rb', line 3

def row_link(title, row_type, field, f)
  opts = {
    'data-association-insertion-node' => "##{field}-tenon-content",
    'data-association-insertion-method' => 'append',
    'data-searchable-title' => title.downcase,
    :partial => 'tenon/tenon_content/row',
    :render_options => {
      locals: {
        row_partial: "tenon/tenon_content/row_types/form/#{row_type.to_s.underscore}",
        field: field,
        title: title
      }
    },
    :wrap_object => proc do |row|
      row.set_row_type(row_type)
      row.decorate
    end
  }
  link_to_add_association row_link_content(title, row_type), f, "#{field}_tenon_content_rows".to_sym, opts
end


24
25
26
27
# File 'app/helpers/tenon/tenon_content_helper.rb', line 24

def row_link_content(title, row_type)
  link = image_tag("tenon/tenon-content/#{row_type}.png", id: row_type, data: { :'row-type' => row_type })
  link += (:p, "#{title}")
end

#size_for_breakpoint(breakpoint) ⇒ Object



39
40
41
42
43
44
# File 'app/helpers/tenon/tenon_content_helper.rb', line 39

def size_for_breakpoint(breakpoint)
  content_cols = Tenon.config.front_end[:content_columns][:default]
  gutter_width = Tenon.config.front_end[:gutter]
  columns = Tenon.config.front_end[:columns]
  (((breakpoint + gutter_width) / columns.to_f) * content_cols) - gutter_width
end

#tenon_content_sizesObject



29
30
31
32
33
34
35
36
37
# File 'app/helpers/tenon/tenon_content_helper.rb', line 29

def tenon_content_sizes
  links = []
  Tenon.config.front_end[:breakpoints].each do |name, size|
    links << link_to(name.to_s.titleize, '#', class: 'btn btn-white', data: { size: size_for_breakpoint(size) })
  end
  last = Tenon.config.front_end[:breakpoints].values.last
  links << link_to('Mobile', '#', class: 'btn btn-white', data: { size: 320, mobile: true })
  links.join('').html_safe
end