rocket_navigation 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bcc5a6383962ab18b75a89f3de3478557fccd07a9a52336f2a38b58525be39c
4
- data.tar.gz: 16a24f2943f043a3da683d4a8b9aa0a0dafbaa97dbb3332b01878160be07c1f0
3
+ metadata.gz: 104c3a6dfd7bc95f49b6c3c5933e8062e5148729a603f8d8ff43ce763be547d2
4
+ data.tar.gz: e530d9a3ebf80dde0e3e1a9c7893c34448e35bf5953cc9633a1487ce37a3950c
5
5
  SHA512:
6
- metadata.gz: 7200edb138f28b055089e9cc4855a119111e6284774382aa83766cebba10fa1022848cf59cf2a3ca9ee48bf784402b9e7d55eaabdc7fa5c92210a3c6df44cd0f
7
- data.tar.gz: 8d18d67a5b807c8c6350da559c6bae68b6487267d6324cc5a951ad83a47d10c7c2023842a9b4518d3bce25e7800e605f49bec9248c3aa68e7ec9adce337cdfc6
6
+ metadata.gz: f0e0b2a732b3962bb9973a22c7216e64adb74e5ecae5726986c62ef57ecfec1401cbfb58ed325d3c1beb0e3b866a4f9c1cd171604be498528fecc9aa1e74d07e
7
+ data.tar.gz: 96da5e101d0a76bf2fadc921773b01bac05c6a275f2d86d481712254da28b210a322f4f8e0dd22680e0edd870e782f96fa942be1293c20afc90e1ec9ca8ded67
data/README.md CHANGED
@@ -35,7 +35,7 @@ Changes include:
35
35
  10. All css classes are managed in renderers and can be easily overriden from them
36
36
  11. Added [breadcrumbs_on_rails](https://github.com/weppos/breadcrumbs_on_rails) integration
37
37
  12. expand_all defaults to true, as pretty much all menus are js-based now.
38
- 13. Includes bootstrap 4 renderer
38
+ 13. Includes bootstrap 4 renderer, with optional superfish support for multilevel menu
39
39
 
40
40
  ## Installation
41
41
 
@@ -139,7 +139,6 @@ end
139
139
  helper_method :navigation
140
140
  ```
141
141
 
142
-
143
142
  HTML options priority - item, renderer, default
144
143
 
145
144
  ## BreadcrumbsOnRails integration
@@ -152,6 +151,29 @@ Should be called before ```= render_breadcrumbs```, i.e. in controller
152
151
  render_navigation renderer: :breadcrumbs_on_rails, &navigation(:main)
153
152
  ```
154
153
 
154
+ ## Bootstrap example with superfish
155
+
156
+ required js:
157
+
158
+ ```
159
+ $(function() {
160
+ $('ul.navbar-nav').superfish();
161
+ })
162
+ ```
163
+
164
+ required sass:
165
+
166
+ ```
167
+ .dropdown-menu
168
+ margin-top: 0
169
+ ```
170
+
171
+ rendering:
172
+
173
+ ```
174
+ = render_navigation container_html: {class: "nav navbar-nav"}, renderer: :bootstrap, superfish: true, &navigation(:main)
175
+ ```
176
+
155
177
  ## Development
156
178
 
157
179
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -9,17 +9,24 @@ module RocketNavigation
9
9
  super(container, options)
10
10
  end
11
11
 
12
+ def list_tag
13
+ options[:ordered] ? :ol : :ul
14
+ end
15
+
12
16
  def render(item_container)
13
17
  if skip_if_empty? && item_container.empty?
14
18
  ''.html_safe
15
19
  else
16
20
  if item_container.level > 1
17
21
  content = list_content(item_container)
18
- content_tag(:div, content, {class: "dropdown-menu"})
22
+ if options[:superfish]
23
+ content_tag(list_tag, content, {class: "dropdown-menu"})
24
+ else
25
+ content_tag(:div, content, {class: "dropdown-menu"})
26
+ end
19
27
  else
20
- tag = options[:ordered] ? :ol : :ul
21
28
  content = list_content(item_container)
22
- content_tag(tag, content, container_html)
29
+ content_tag(list_tag, content, container_html)
23
30
  end
24
31
  end
25
32
  end
@@ -32,7 +39,17 @@ module RocketNavigation
32
39
  end
33
40
  content_tag(:li, li_content, item_options(item))
34
41
  else
35
- tag_for(item)
42
+ if include_sub_navigation?(item)
43
+ content = tag_for(item)
44
+ content << render_sub_navigation_for(item)
45
+ if options[:superfish]
46
+ content_tag(:li, content, class: "dropdown")
47
+ else
48
+ content_tag(:div, content, class: "dropdown")
49
+ end
50
+ else
51
+ tag_for(item)
52
+ end
36
53
  end
37
54
  end
38
55
 
@@ -74,8 +91,21 @@ module RocketNavigation
74
91
  end
75
92
 
76
93
  def tag_for(item)
77
- if item.level == 1 && item.sub_navigation
78
- link_to(item.name, item.url, {class: "nav-link dropdown-toggle", 'data-toggle' => "dropdown"})
94
+ if item.sub_navigation
95
+ cl = ""
96
+ if item.level == 1
97
+ cl = "nav-link"
98
+ else
99
+ cl = "dropdown-item"
100
+ end
101
+ opt = {
102
+ class: cl
103
+ }
104
+ opt[:class] += " dropdown-toggle"
105
+ unless options[:superfish]
106
+ opt['data-toggle'] = "dropdown"
107
+ end
108
+ link_to(item.name, item.url, opt)
79
109
  else
80
110
  super(item)
81
111
  end
@@ -1,3 +1,3 @@
1
1
  module RocketNavigation
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocket_navigation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Tv
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport