makandra-navy 0.6.0 → 0.6.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: 042a20d0c59984e62efe693961036f2d1c423066
4
- data.tar.gz: a0087236f413976189fcb476ee5bf07649dc6d1b
3
+ metadata.gz: 7b6fe9ffcfac9fce4076eb3134ee479123c201c7
4
+ data.tar.gz: 153953b1f453894f2daeb4b17852f8a1542847e5
5
5
  SHA512:
6
- metadata.gz: fec0da5f8f3f17cd025fe95260a2fe0467bddf2c5d11c65047283d4af07fdceb1fa81825f3510dbaf6e584af63686734ed778dd2c6bb0d25c967ed0dedf2cb24
7
- data.tar.gz: d74929409cfbb95dfb033b14dfde6ec1299ce83611e48c50a7a4022b109811eb42602262f03f03e542f685f835987a8e39bab8b14de5f5fe3d1148206177f103
6
+ metadata.gz: 39d41688c171d912dcf1098a7674aa07376021ebb4e6803b30fd62195f4f5df61ddf30af33d0bee09832a1823608f799f665d4f6da5bb97976a4e9e7f71c9f2c
7
+ data.tar.gz: 4b197625f5443e335709e7cacb0d40d29583795c6c8074ac2d308d48c20d872ca83693737b8309f9ccc367982bdc8a18cefbda3590727e45c94e2cee23fd4ef7
data/lib/navy/renderer.rb CHANGED
@@ -22,7 +22,7 @@ module Navy
22
22
  def render_navigation(navigation)
23
23
  name = @name || navigation.name
24
24
  html = ''.html_safe
25
- html << render_section_container(navigation, 1)
25
+ html << render_section_container(navigation, navigation.sections(@context), 1)
26
26
  @html_to_append.each do |append|
27
27
  html << append
28
28
  end
@@ -38,16 +38,7 @@ module Navy
38
38
  @html_to_append << html
39
39
  end
40
40
 
41
- def render_section_containers
42
- html = ''.html_safe
43
- while @section_containers_to_render.any?
44
- html << render_section_container(*@section_containers_to_render.shift)
45
- end
46
- html
47
- end
48
-
49
- def render_section_container(section_container, level, parent_id = nil, parent_url = nil)
50
- sections = section_container.sections(@context)
41
+ def render_section_container(section_container, sections, level, parent_id = nil, parent_url = nil)
51
42
  section_classes = ["navy-level-#{level}", "navy-navigation-bar"]
52
43
  section_classes << (section_container.active? ? 'navy-current' : 'navy-hidden')
53
44
  unless sections.size == 0 or (sections.size == 1 and sections.first.url == parent_url)
@@ -82,8 +73,15 @@ module Navy
82
73
  link_classes = ['navy-section', link_to_options.delete(:class)].compact
83
74
  link_classes << 'navy-current navy-active' if section.active?
84
75
  label = ''.html_safe
76
+ url = section.url
85
77
  if section.children?
86
- children_html = render_section_container(section, level + 1, id, section.url)
78
+ children_sections = section.sections(@context)
79
+ if (first_child = children_sections.first)
80
+ url ||= first_child.url
81
+ else
82
+ url ||= '#'
83
+ end
84
+ children_html = render_section_container(section, children_sections, level + 1, id, url)
87
85
  if children_html.present?
88
86
  append(children_html)
89
87
  label << ' <span class="navy-section-expander">▾</span>'.html_safe
@@ -91,7 +89,7 @@ module Navy
91
89
  end
92
90
  label << section.label
93
91
  label = content_tag(:span, label, :class => 'navy-section-inner')
94
- link_to(label, section.url, link_to_options.merge(:class => link_classes.join(' '), :"data-navy-opens" => id, 'data-navy-section' => section.name))
92
+ link_to(label, url, link_to_options.merge(:class => link_classes.join(' '), :"data-navy-opens" => id, 'data-navy-section' => section.name))
95
93
  end
96
94
 
97
95
 
data/lib/navy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Navy
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: makandra-navy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-07 00:00:00.000000000 Z
12
+ date: 2017-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  version: '0'
72
72
  requirements: []
73
73
  rubyforge_project: navy
74
- rubygems_version: 2.6.6
74
+ rubygems_version: 2.5.1
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Comprehensive solution for multi-level horizontal navigation bars.