Sha256: d49cf927cd42afdc7f32556d17047812fd90d7074dc031028ba7a0a98dc3befc

Contents?: true

Size: 1.68 KB

Versions: 23

Compression:

Stored size: 1.68 KB

Contents

module Tenon
  module TenonContentHelper
    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

    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 += content_tag(:p, "#{title}")
    end

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

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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
tenon-1.1.4 app/helpers/tenon/tenon_content_helper.rb
tenon-1.1.3 app/helpers/tenon/tenon_content_helper.rb
tenon-1.1.2 app/helpers/tenon/tenon_content_helper.rb
tenon-1.1.1 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.76 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.75 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.74 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.73 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.72 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.71 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.70 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.69 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.68 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.67 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.66 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.65 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.64 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.63 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.62 app/helpers/tenon/tenon_content_helper.rb
tenon-1.0.61 app/helpers/tenon/tenon_content_helper.rb