Module: ButtonHelper

Includes:
ActionView::Helpers, FormatHelper
Included in:
ActionView::Helpers::FormBuilder, DropdownHelper::DropdownCreator
Defined in:
app/helpers/button_helper.rb

Instance Method Summary collapse

Methods included from FormatHelper

#prepend_class, #squeeze_n_strip

Instance Method Details

#button(content_or_options = nil, options = {}, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/button_helper.rb', line 5

def button(content_or_options=nil, options={}, &block)
  content_or_options.is_a?(Hash) ? options = content_or_options : content = content_or_options

  layout = 'btn-block' if options.delete(:layout).try(:to_sym) == :block
  size   = get_btn_size(options.delete(:size))
  type   = get_btn_type(options.delete(:type))
  prepend_class(options, 'btn', type, size, layout)

   :button, options do
    content.presence || capture(&block)
  end
end

#button_group(options = {}, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/button_helper.rb', line 18

def button_group(options={}, &block)
  size   = get_btn_group_size(options.delete(:size))
  layout = if options.delete(:layout).try(:to_sym) == :vertical
             'btn-group-vertical'
           else
             'btn-group'
           end

  prepend_class(options, layout, size)
  options[:role] = 'group'
  options[:data] = (options[:data] || {}).merge({bui: 'btn_group', size: size})

   :div, options, &block
end

#button_toolbar(options = {}, &block) ⇒ Object



33
34
35
36
37
38
# File 'app/helpers/button_helper.rb', line 33

def button_toolbar(options={}, &block)
  prepend_class(options, 'btn-toolbar')
  options[:role] = 'toolbar'

   :div, options, &block
end


40
41
42
43
44
45
# File 'app/helpers/button_helper.rb', line 40

def navbar_button(content_or_options=nil, options={}, &block)
  content_or_options.is_a?(Hash) ? options = content_or_options : content = content_or_options

  prepend_class(options, 'navbar-btn')
  button content, options, &block
end