simple_navigation_renderers 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/simple_navigation_renderers/bootstrap.rb +56 -46
- data/lib/simple_navigation_renderers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3b1c37c5e0b2ef981172bbf81dc7c32a6a5a949
|
4
|
+
data.tar.gz: 3ad07a991af0a78262e0f7a26b390b2fa3522630
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cc6a6757952d15c52a0adea721363ac9a75b653261964a600c8fcadec6eee7feb731ecff1c4e45c516e1a7960de0a7758113994a75aadce0b8576da1bdf9048
|
7
|
+
data.tar.gz: 33908fadd6c3336692d7ee2d5c07182a21b8e8668c22c20ccdc387b5b122728015875481294d2532adf03e223fca7508d9a8babdd9b0a32388af386a8d269572
|
data/CHANGELOG.md
CHANGED
@@ -6,51 +6,47 @@ module SimpleNavigationRenderers
|
|
6
6
|
if (skip_if_empty? && item_container.empty?)
|
7
7
|
''
|
8
8
|
else
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
li_options[:
|
37
|
-
item
|
9
|
+
list_content = with_bootstrap_configs do
|
10
|
+
|
11
|
+
item_container.items.inject([]) do |list, item|
|
12
|
+
li_options = item.html_options
|
13
|
+
|
14
|
+
navbar_text = li_options.delete(:navbar_text)
|
15
|
+
navbar_divider = li_options.delete(:divider)
|
16
|
+
navbar_header = li_options.delete(:header)
|
17
|
+
link_options = li_options.delete(:link) || {}
|
18
|
+
split = li_options.delete(:split)
|
19
|
+
|
20
|
+
if navbar_text
|
21
|
+
list << li_text( item.name, li_options )
|
22
|
+
elsif navbar_divider
|
23
|
+
list << li_divider( item_container.level, li_options )
|
24
|
+
elsif navbar_header && (item_container.level != 1)
|
25
|
+
list << li_header( item.name, li_options )
|
26
|
+
else
|
27
|
+
li_content = if include_sub_navigation?(item)
|
28
|
+
if item_container.level == 1
|
29
|
+
if split
|
30
|
+
main_li_options = li_options.dup
|
31
|
+
main_li_options[:class] = [ main_li_options[:class], "dropdown-split-left" ].flatten.compact.join(' ')
|
32
|
+
list << content_tag(:li, simple_link(item, link_options), main_li_options)
|
33
|
+
li_options[:id] = nil
|
34
|
+
item.sub_navigation.dom_class = [ item.sub_navigation.dom_class, "pull-right" ].flatten.compact.join(' ')
|
35
|
+
end
|
36
|
+
li_options[:class] = [ li_options[:class], "dropdown", (split ? "dropdown-split-right" : nil) ].flatten.compact.join(' ')
|
37
|
+
dropdown_link(item, split, link_options) + render_sub_navigation_for(item)
|
38
|
+
else
|
39
|
+
li_options[:class] = [ li_options[:class], "dropdown-submenu"].flatten.compact.join(' ')
|
40
|
+
simple_link(item, link_options) + render_sub_navigation_for(item)
|
38
41
|
end
|
39
|
-
li_options[:class] = [ li_options[:class], "dropdown", (split ? "dropdown-split-right" : nil) ].flatten.compact.join(' ')
|
40
|
-
dropdown_link(item, split, link_options) + render_sub_navigation_for(item)
|
41
42
|
else
|
42
|
-
|
43
|
-
simple_link(item, link_options) + render_sub_navigation_for(item)
|
43
|
+
simple_link(item, link_options)
|
44
44
|
end
|
45
|
-
|
46
|
-
simple_link(item, link_options)
|
45
|
+
list << content_tag(:li, li_content, li_options)
|
47
46
|
end
|
48
|
-
|
49
|
-
end
|
50
|
-
end.join
|
47
|
+
end.join
|
51
48
|
|
52
|
-
|
53
|
-
SimpleNavigation.config.name_generator = @config_name_generator
|
49
|
+
end
|
54
50
|
|
55
51
|
item_container.dom_class = [ item_container.dom_class,
|
56
52
|
(item_container.level == 1) ? "nav#{(options[:bv] == 2) ? '' : ' navbar-nav'}" :
|
@@ -90,13 +86,27 @@ module SimpleNavigationRenderers
|
|
90
86
|
link_to(link, "#", link_options)
|
91
87
|
end
|
92
88
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
89
|
+
def with_bootstrap_configs
|
90
|
+
config_selected_class = SimpleNavigation.config.selected_class
|
91
|
+
config_name_generator = SimpleNavigation.config.name_generator
|
92
|
+
|
93
|
+
SimpleNavigation.config.selected_class = "active"
|
94
|
+
# name_generator should be proc (not lambda or method) to be compatible with earlier versions of simple-navigation
|
95
|
+
SimpleNavigation.config.name_generator = proc do | name, item |
|
96
|
+
if name.instance_of?(Hash)
|
97
|
+
raise SimpleNavigationRenderers::InvalidHash unless name.keys.include?(:icon) || name.keys.include?(:text)
|
98
|
+
[ (name[:icon] ? content_tag(:span, '', {class: name[:icon]}.merge(name[:title] ? {title: name[:title]} : {}) ) : nil), name[:text] ].compact.join(' ')
|
99
|
+
else
|
100
|
+
config_name_generator.call( name, item )
|
101
|
+
end
|
99
102
|
end
|
103
|
+
|
104
|
+
result = yield
|
105
|
+
|
106
|
+
SimpleNavigation.config.name_generator = config_name_generator
|
107
|
+
SimpleNavigation.config.selected_class = config_selected_class
|
108
|
+
|
109
|
+
result
|
100
110
|
end
|
101
111
|
|
102
112
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_navigation_renderers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Shpak
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.1.
|
137
|
+
rubygems_version: 2.1.11
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: 'simple_navigation_renderers gem adds renderers for Bootstrap 2 and 3. With
|