Class: MenuBar
Defined Under Namespace
Classes: AbstractContent, AbstractItem, Menu, MenuBarContent, MenuBarGroup, MenuBarInput, MenuBarItem, MenuBarTrigger, MenuContent, MenuGroup, MenuItem
Constant Summary
EasyMenu::Configuration::Bootstrap, EasyMenu::Configuration::Default
EasyMenu::Helpers::HTML_OPTIONS
Instance Attribute Summary collapse
Instance Method Summary
collapse
included
#config_name, #css_class, #html_option_keys, #merge_class, #wrap_content, #wrapper_element
Constructor Details
#initialize(template, options = {}) {|_self| ... } ⇒ MenuBar
Returns a new instance of MenuBar.
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/menu_bar.rb', line 11
def initialize(template, options = {})
@template = template
@options = options.reverse_merge(:theme => config[:default_theme_class], :remove_dangling_separators => true)
config.merge! options[:config] if options[:config] config[:template] = @template
@content = []
@groups = []
yield self if block_given?
end
|
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
9
10
11
|
# File 'lib/menu_bar.rb', line 9
def content
@content
end
|
#groups ⇒ Object
Returns the value of attribute groups.
9
10
11
|
# File 'lib/menu_bar.rb', line 9
def groups
@groups
end
|
Instance Method Details
#empty? ⇒ Boolean
23
24
25
|
# File 'lib/menu_bar.rb', line 23
def empty?
@content.blank?
end
|
#group(options = {}) {|mbg| ... } ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/menu_bar.rb', line 27
def group(options = {})
initialize_options(options)
mbg = MenuBarGroup.new(@template, options.merge(@options.slice(:config)))
mbc = MenuBarContent.new(config, mbg, options[:menu_bar_content])
yield mbg if block_given?
(mbc, options)
@groups << mbg
return mbg
end
|
#html_safe? ⇒ Boolean
117
118
119
|
# File 'lib/menu_bar.rb', line 117
def html_safe?
true
end
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/menu_bar.rb', line 81
def (button_text, options = {})
initialize_options(options)
arrow = @template.content_tag(:span, '', :class => config[:menu_bar_item_arrow_class])
m = Menu.new(config, options)
mbt = MenuBarTrigger.new(config, button_text.html_safe + ' ' + arrow, m, options[:menu_bar_item])
yield m if block_given?
mbc = MenuBarContent.new(config, mbt, merge_class(options[:menu_bar_content], config[:menu_bar_content_with_menu_class]))
(mbc, options)
return m
end
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/menu_bar.rb', line 41
def (content = nil, options = {}, &block)
initialize_options(options)
if block_given?
options = content || options
content = block.call
end
mbc = MenuBarContent.new(config, content, options)
(mbc, options)
return mbc
end
|
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/menu_bar.rb', line 69
def (content, options = {})
initialize_options(options)
mbin = MenuBarInput.new config, content, options
mbi = MenuBarItem.new config, mbin, options[:menu_bar_item]
mbc = MenuBarContent.new(config, mbi, options[:menu_bar_content])
(mbc, options)
return mbi
end
|
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/menu_bar.rb', line 56
def (content, options = {})
initialize_options(options)
raise if config[:template].is_a?(Hash) || config[:template].nil?
mbi = MenuBarItem.new config, content, options
mbc = MenuBarContent.new(config, mbi, options[:menu_bar_content])
(mbc, options)
return mbi
end
|
#separator(options = {}) ⇒ Object
99
100
101
102
103
104
105
106
|
# File 'lib/menu_bar.rb', line 99
def separator(options = {})
s = @template.content_tag :div, '', :class => config[:menu_bar_separator_class]
mbc = MenuBarContent.new(config, s, options.reverse_merge(:remove_if_dangling => @options[:remove_dangling_separators]))
(mbc, options)
return s
end
|
#to_s ⇒ Object
108
109
110
111
|
# File 'lib/menu_bar.rb', line 108
def to_s
@content.pop if @content.last && @content.last.options[:remove_if_dangling]
wrap_content(@content.join.html_safe)
end
|
#to_str ⇒ Object
113
114
115
|
# File 'lib/menu_bar.rb', line 113
def to_str
to_s
end
|