smart_navigation 0.1.2 → 0.1.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 +5 -2
- data/lib/smart_navigation/renderer.rb +16 -4
- data/lib/smart_navigation/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: 996a81e56bb9faf73440df7a823e7b03835dcf72
|
4
|
+
data.tar.gz: a1e1117851effcccef0856527a46d2179c289012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4ca51e4c127ae1da7fe4255982da51defb8132293dacda0183c51bf4f68d6ca6fa5483fd06b02196a6cf35a7ceb4354124017797fe99e4832a1f7f007b749f2
|
7
|
+
data.tar.gz: cd5fc22b7391a718974b7b80e291d278bcfc7ced41015c74d3dd3bb1165b2211f2c0b670e7a8ffb2c473274e067522b67d73536bfe78ed8acf88170ca24cfc06
|
data/README.md
CHANGED
@@ -76,6 +76,7 @@ There are a number of options you can use to customize the navigation. The defau
|
|
76
76
|
options = {
|
77
77
|
menu_class: 'menu',
|
78
78
|
menu_html: {},
|
79
|
+
menu_icons: true,
|
79
80
|
separator_class: 'separator',
|
80
81
|
submenu_parent_class: 'has-submenu',
|
81
82
|
submenu_class: 'submenu',
|
@@ -84,7 +85,9 @@ options = {
|
|
84
85
|
submenu_icons: false,
|
85
86
|
submenu_toggle: nil,
|
86
87
|
icon_prefix: 'icon icon-',
|
87
|
-
|
88
|
+
icon_default: 'missing',
|
89
|
+
icon_position: 'left',
|
90
|
+
keep_defaults: true
|
88
91
|
}
|
89
92
|
|
90
93
|
smart_navigation_for(@items, options)
|
@@ -104,4 +107,4 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
104
107
|
|
105
108
|
## Code of Conduct
|
106
109
|
|
107
|
-
Everyone interacting in the
|
110
|
+
Everyone interacting in the SmartNavigation project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hardpixel/smart-navigation/blob/master/CODE_OF_CONDUCT.md).
|
@@ -4,12 +4,12 @@ module SmartNavigation
|
|
4
4
|
def initialize(view_context, items, options={})
|
5
5
|
@context = view_context
|
6
6
|
@items = sort_items items
|
7
|
-
@options =
|
7
|
+
@options = merge_options options
|
8
8
|
end
|
9
9
|
|
10
10
|
# Render menu
|
11
11
|
def render
|
12
|
-
menu_tag @items.map { |k, v| item_tag(v,
|
12
|
+
menu_tag @items.map { |k, v| item_tag(v, @options[:menu_icons]) }.join
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -19,6 +19,7 @@ module SmartNavigation
|
|
19
19
|
{
|
20
20
|
menu_class: 'menu',
|
21
21
|
menu_html: {},
|
22
|
+
menu_icons: true,
|
22
23
|
separator_class: 'separator',
|
23
24
|
submenu_parent_class: 'has-submenu',
|
24
25
|
submenu_class: 'submenu',
|
@@ -27,10 +28,21 @@ module SmartNavigation
|
|
27
28
|
submenu_icons: false,
|
28
29
|
submenu_toggle: nil,
|
29
30
|
icon_prefix: 'icon icon-',
|
30
|
-
|
31
|
+
icon_default: 'missing',
|
32
|
+
icon_position: 'left',
|
33
|
+
keep_defaults: true
|
31
34
|
}
|
32
35
|
end
|
33
36
|
|
37
|
+
# Get merged options
|
38
|
+
def merge_options(options)
|
39
|
+
if @options[:keep_defaults].present?
|
40
|
+
default_options.merge(options)
|
41
|
+
else
|
42
|
+
options
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
34
46
|
# Sort items by order
|
35
47
|
def sort_items(items)
|
36
48
|
items.sort_by { |_k, v| v[:order] }.to_h
|
@@ -77,7 +89,7 @@ module SmartNavigation
|
|
77
89
|
|
78
90
|
# Create menu icon
|
79
91
|
def icon_tag(name, label=nil)
|
80
|
-
icon = tag :i, nil, class: "#{@options[:icon_prefix]}#{name}"
|
92
|
+
icon = tag :i, nil, class: "#{@options[:icon_prefix]}#{name || @options[:icon_default]}"
|
81
93
|
|
82
94
|
if @options[:icon_position] == 'left'
|
83
95
|
"#{icon}#{label}".html_safe
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonian Guveli
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|