Module: BootyboxGridHelper

Defined in:
app/helpers/bootybox_grid_helper.rb

Instance Method Summary collapse

Instance Method Details

#col(w = {:lg => 4}, title = "col", options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/bootybox_grid_helper.rb', line 3

def col(w={:lg => 4}, title ="col", options = {}, &block)
  # fallback for old syntax
  if title.is_a?(Hash)
    options = title
    title = options[:title]
  end

  col_css = [column_classes(w, options[:mode], options[:framework]).strip, options[:class].try(:strip), 'is-bootybox-col'].compact.join(" ")

  if options[:header] != true
    (:div, :class => col_css) do
      capture(&block)
    end
  else
    options[:color] ||= "dark-blue"

    content = options[:inner_content] == true ? (:div, raw(capture(&block)), :class => "inner-content-body") : capture(&block)

    html_content = (:header, (:h3, title), :class => options[:color])
    html_content += (:div, raw(content), :class => "content-body")

    (:div, :class => col_css) do
      (:section, :class => "content-box") do
        raw(html_content)
      end
    end
  end
end

#column_classes(w = {:lg => 4}, mode = nil, framework = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/helpers/bootybox_grid_helper.rb', line 32

def column_classes(w ={:lg => 4}, mode = nil, framework = nil )

  default = case (framework || Bootybox.configuration.css_framework.to_sym)
  when :bootstrap
    :lg
  when :foundation
    :large
  end

  # auto-determine settings if no framework given
  if framework.nil?
    settings = convert_col_settings!(w, framework)
  else
    settings = w
  end

  column_key_values.each do |v|
    if !settings[v.to_sym]
      settings[v.to_sym] = settings[default]
    end
  end

  col_css = case (framework || Bootybox.configuration.css_framework.to_sym)
  when :bootstrap
    [""]
  when :foundation
    ["columns"]
  end

  settings.each do |c,s|
    c = "col-#{c}" if (framework == :bootstrap || Bootybox.configuration.css_framework.to_sym == :bootstrap)
    col_css << [c, mode, s].compact.join("-")
  end

  return col_css.join(" ")
end