Class: DropdownHelper::DropdownCreator

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers, ButtonHelper, FormatHelper
Defined in:
app/helpers/dropdown_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ButtonHelper

#button, #button_group, #button_toolbar, #navbar_button

Methods included from FormatHelper

#prepend_class, #squeeze_n_strip

Constructor Details

#initialize(content, list, options) ⇒ DropdownCreator

Returns a new instance of DropdownCreator.



45
46
47
48
49
50
# File 'app/helpers/dropdown_helper.rb', line 45

def initialize(content, list, options)
  @content           = content
  @list              = list
  @options           = options
  @btn_group_options = options.delete(:btn_group_html) || {}
end

Instance Attribute Details

#btn_group_optionsObject

Returns the value of attribute btn_group_options.



42
43
44
# File 'app/helpers/dropdown_helper.rb', line 42

def btn_group_options
  @btn_group_options
end

#contentObject

Returns the value of attribute content.



39
40
41
# File 'app/helpers/dropdown_helper.rb', line 39

def content
  @content
end

#listObject

Returns the value of attribute list.



40
41
42
# File 'app/helpers/dropdown_helper.rb', line 40

def list
  @list
end

#optionsObject

Returns the value of attribute options.



41
42
43
# File 'app/helpers/dropdown_helper.rb', line 41

def options
  @options
end

#output_bufferObject

Returns the value of attribute output_buffer.



43
44
45
# File 'app/helpers/dropdown_helper.rb', line 43

def output_buffer
  @output_buffer
end

Instance Method Details

#renderObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/helpers/dropdown_helper.rb', line 52

def render
  navbar, btn_id, align, direction, size, type = process_dropdown_options(options)

  btn_options  = button_options(content, size, type, btn_id, navbar)
  list_options = list_options(btn_id, align)

  tag = navbar ? :li : :div
  prepend_class(btn_group_options, 'btn-group',
                (direction == :up ? 'dropup' : 'dropdown'))

   tag, btn_group_options do
    (dropdown_button(btn_options.deep_merge(options)) +
      dropdown_list(list, list_options)).html_safe
  end
end