rocket_navigation 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -2
- data/lib/rocket_navigation/renderer/bootstrap.rb +36 -6
- data/lib/rocket_navigation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 104c3a6dfd7bc95f49b6c3c5933e8062e5148729a603f8d8ff43ce763be547d2
|
4
|
+
data.tar.gz: e530d9a3ebf80dde0e3e1a9c7893c34448e35bf5953cc9633a1487ce37a3950c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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(
|
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
|
-
|
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.
|
78
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2018-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|