simple_navigation_renderers 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 616b1a87c82cdb976a28aadc839c4be6546a8e78
4
- data.tar.gz: 70eac40e4239df1041b6dc9bc97d32960e8627ca
3
+ metadata.gz: e3b1c37c5e0b2ef981172bbf81dc7c32a6a5a949
4
+ data.tar.gz: 3ad07a991af0a78262e0f7a26b390b2fa3522630
5
5
  SHA512:
6
- metadata.gz: e3f18bdd23db2dcbed7641834dd75da7f2ba9c2816de206a624d2017667925c542f15bef4227a958d649ff11de95582e47d92524785c7224b65d28e28a1371df
7
- data.tar.gz: 29ce774d04e11f5e303d0059de7af07aede50ff521b0a283695ad646097364b2518cbe3a0dd7ab5bad9051b51b09a405eafca9c8efc5e41d91adfe06623cc29d
6
+ metadata.gz: 8cc6a6757952d15c52a0adea721363ac9a75b653261964a600c8fcadec6eee7feb731ecff1c4e45c516e1a7960de0a7758113994a75aadce0b8576da1bdf9048
7
+ data.tar.gz: 33908fadd6c3336692d7ee2d5c07182a21b8e8668c22c20ccdc387b5b122728015875481294d2532adf03e223fca7508d9a8babdd9b0a32388af386a8d269572
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v1.0.1
2
+
3
+ * fix problem with `name_generator` method (appeared after `simple-navigation` changes)
4
+
5
+
1
6
  ## v1.0.0
2
7
 
3
8
  * separate 'divider' Bootstrap element
@@ -6,51 +6,47 @@ module SimpleNavigationRenderers
6
6
  if (skip_if_empty? && item_container.empty?)
7
7
  ''
8
8
  else
9
- config_selected_class = SimpleNavigation.config.selected_class
10
- SimpleNavigation.config.selected_class = "active"
11
- @config_name_generator = SimpleNavigation.config.name_generator
12
- SimpleNavigation.config.name_generator = self.method(:name_generator)
13
-
14
- list_content = item_container.items.inject([]) do |list, item|
15
- li_options = item.html_options
16
-
17
- navbar_text = li_options.delete(:navbar_text)
18
- navbar_divider = li_options.delete(:divider)
19
- navbar_header = li_options.delete(:header)
20
- link_options = li_options.delete(:link) || {}
21
- split = li_options.delete(:split)
22
-
23
- if navbar_text
24
- list << li_text( item.name, li_options )
25
- elsif navbar_divider
26
- list << li_divider( item_container.level, li_options )
27
- elsif navbar_header && (item_container.level != 1)
28
- list << li_header( item.name, li_options )
29
- else
30
- li_content = if include_sub_navigation?(item)
31
- if item_container.level == 1
32
- if split
33
- main_li_options = li_options.dup
34
- main_li_options[:class] = [ main_li_options[:class], "dropdown-split-left" ].flatten.compact.join(' ')
35
- list << content_tag(:li, simple_link(item, link_options), main_li_options)
36
- li_options[:id] = nil
37
- item.sub_navigation.dom_class = [ item.sub_navigation.dom_class, "pull-right" ].flatten.compact.join(' ')
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
- li_options[:class] = [ li_options[:class], "dropdown-submenu"].flatten.compact.join(' ')
43
- simple_link(item, link_options) + render_sub_navigation_for(item)
43
+ simple_link(item, link_options)
44
44
  end
45
- else
46
- simple_link(item, link_options)
45
+ list << content_tag(:li, li_content, li_options)
47
46
  end
48
- list << content_tag(:li, li_content, li_options)
49
- end
50
- end.join
47
+ end.join
51
48
 
52
- SimpleNavigation.config.selected_class = config_selected_class
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 name_generator( name )
94
- if name.instance_of?(Hash)
95
- raise SimpleNavigationRenderers::InvalidHash unless name.keys.include?(:icon) || name.keys.include?(:text)
96
- [ (name[:icon] ? content_tag(:span, '', {class: name[:icon]}.merge(name[:title] ? {title: name[:title]} : {}) ) : nil), name[:text] ].compact.join(' ')
97
- else
98
- @config_name_generator.call(name)
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
@@ -1,3 +1,3 @@
1
1
  module SimpleNavigationRenderers
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  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.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.10
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