simple-navigation-bootstrap 1.0.0 → 1.0.2
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 +15 -0
- data/README.md +30 -5
- data/lib/simple-navigation-bootstrap.rb +1 -0
- data/lib/simple-navigation-bootstrap/version.rb +1 -1
- data/lib/simple_navigation/core_ext/item_container.rb +6 -0
- data/lib/simple_navigation/rendering/renderer/bootstrap.rb +20 -12
- data/simple-navigation-bootstrap.gemspec +1 -1
- metadata +12 -19
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmY2ZmNlODIyOTU5YTRlZDcyMmI5ZTRmMjJjOWI1NTIyMDVhZjMzNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDQ0Yzg1Njk5YTkyNGEzMDNhNmI5MTQ3NTE4MzFhMGQ5NzhlNjc1NQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OTg2ZjA4YWNiNzc3NDU2NzI4YzE1OWM3YTcyZjkxZDg5NmZmNjA0ZWY4OWIx
|
10
|
+
MTZjYmMwOGRkNDk1M2MxMzA4NDYwOWE1YzY0ZjYyZWQzN2FkYmM1ZDJlYjEx
|
11
|
+
NjJmNDhjNDZkZmJjNzU4MmFhZDZkZTE2Y2FjZGQzMTdmZjY4OGU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MDBkMGEyYWE4ZGM4NmZiZGE5OGUwYWY0OWJiNDA4MmUyNDU0ZjMzMWZmMDJi
|
14
|
+
NWIyOTY1Zjg4MmFiZTI0MTExMGY0NWNlZjMwNTEwNzM4N2YyNGJkZGYyODcy
|
15
|
+
NWI5YmEwZWM1NjQzZjM4MDYwOGNlMDg3Njg1NTJkMmNlMDNmNDU=
|
data/README.md
CHANGED
@@ -18,16 +18,30 @@ To use the Bootstrap renderer, specify it in your view:
|
|
18
18
|
render_navigation :expand_all => true, :renderer => :bootstrap
|
19
19
|
```
|
20
20
|
|
21
|
+
And the minimal navigation config you need is:
|
22
|
+
```ruby
|
23
|
+
SimpleNavigation::Configuration.run do |navigation|
|
24
|
+
navigation.items do |primary|
|
25
|
+
primary.dom_class = 'nav'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
See below for a more complete example.
|
31
|
+
|
21
32
|
## Additional Functionality
|
33
|
+
### Icons
|
22
34
|
In addition to generating Bootstrap-comptible list markup, you may specify
|
23
35
|
an `:icon` attribute on your navigation items, either as an array
|
24
36
|
or string, containing Bootstrap [icon classes](http://twitter.github.com/bootstrap/base-css.html#icons), to add an icon to the item.
|
25
37
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
38
|
+
### Split navigation
|
39
|
+
For items with sub-navigation, you may specify `:split => true` on an item to
|
40
|
+
enable a split dropdown. Split dropdowns allow using an url on the primary
|
41
|
+
navigation item, as well as having a dropdown containing sub-navigation. If
|
42
|
+
you plan on using this feature, in your `application.css` or equivalent you
|
43
|
+
must require the `bootstrap_navbar_split_dropdowns` stylesheet after
|
44
|
+
requiring Bootstrap.
|
31
45
|
|
32
46
|
For example:
|
33
47
|
```css
|
@@ -37,6 +51,15 @@ For example:
|
|
37
51
|
*/
|
38
52
|
```
|
39
53
|
|
54
|
+
You may also enable split navigation for all children by setting the `split`
|
55
|
+
attribute of the container to `true` (defaults to `false`).
|
56
|
+
|
57
|
+
### Dropdowns
|
58
|
+
If you wish to disable dropdown attributes for some reason (eg -you don't use the
|
59
|
+
JavaScript, or have custom handling), you may specify `:dropdown => false` on an
|
60
|
+
item, or set the `dropdown` attribute on the container to `false` (defaults to
|
61
|
+
`true`).
|
62
|
+
|
40
63
|
## Examples
|
41
64
|
To create a navigation menu, you might do something like this:
|
42
65
|
```ruby
|
@@ -52,6 +75,8 @@ SimpleNavigation::Configuration.run do |navigation|
|
|
52
75
|
books.item :history, 'History', books_history_path
|
53
76
|
end
|
54
77
|
primary.dom_class = 'nav'
|
78
|
+
primary.dropdown = true
|
79
|
+
primary.split = false
|
55
80
|
end
|
56
81
|
end
|
57
82
|
```
|
@@ -2,13 +2,17 @@ module SimpleNavigation
|
|
2
2
|
module Renderer
|
3
3
|
class Bootstrap < SimpleNavigation::Renderer::Base
|
4
4
|
def render(item_container)
|
5
|
+
return '' if respond_to?(:skip_if_empty?) && skip_if_empty? && item_container.empty?
|
5
6
|
config_selected_class = SimpleNavigation.config.selected_class
|
6
7
|
SimpleNavigation.config.selected_class = 'active'
|
7
8
|
list_content = item_container.items.inject([]) do |list, item|
|
8
9
|
li_options = item.html_options.reject {|k, v| k == :link}
|
9
10
|
icon = li_options.delete(:icon)
|
10
|
-
|
11
|
-
|
11
|
+
dropdown = item_container.dropdown.nil? ? true : item_container.dropdown
|
12
|
+
split = item_container.split
|
13
|
+
split = (include_sub_navigation?(item) and li_options.delete(:split)) if li_options.include?(:split)
|
14
|
+
dropdown = (include_sub_navigation?(item) and li_options.delete(:dropdown)) if li_options.include?(:dropdown)
|
15
|
+
li_content = tag_for(item, item.name, icon, split, dropdown)
|
12
16
|
if include_sub_navigation?(item)
|
13
17
|
if split
|
14
18
|
lio = li_options.dup
|
@@ -18,23 +22,25 @@ module SimpleNavigation
|
|
18
22
|
li_options[:id] = nil
|
19
23
|
li_content = tag_for(item)
|
20
24
|
end
|
21
|
-
item.sub_navigation.dom_class = [item.sub_navigation.dom_class, 'dropdown-menu', split ? 'pull-right' : nil].flatten.compact.join(' ')
|
25
|
+
item.sub_navigation.dom_class = [item.sub_navigation.dom_class, dropdown ? 'dropdown-menu' : nil, split ? 'pull-right' : nil].flatten.compact.join(' ')
|
22
26
|
li_content << render_sub_navigation_for(item)
|
23
|
-
li_options[:class] = [li_options[:class], 'dropdown', split ? 'dropdown-split-right' : nil].flatten.compact.join(' ')
|
27
|
+
li_options[:class] = [li_options[:class], dropdown ? 'dropdown' : nil, split ? 'dropdown-split-right' : nil].flatten.compact.join(' ')
|
24
28
|
end
|
25
29
|
list << content_tag(:li, li_content, li_options)
|
26
30
|
end.join
|
27
31
|
SimpleNavigation.config.selected_class = config_selected_class
|
28
|
-
if
|
29
|
-
|
30
|
-
else
|
31
|
-
|
32
|
+
if item_container.respond_to?(:dom_attributes)
|
33
|
+
dom_attributes = item_container.dom_attributes
|
34
|
+
else
|
35
|
+
# supports simple-navigation before the ItemContainer#dom_attributes
|
36
|
+
dom_attributes = {:id => item_container.dom_id, :class => item_container.dom_class}
|
32
37
|
end
|
38
|
+
content_tag(:ul, list_content, dom_attributes)
|
33
39
|
end
|
34
40
|
|
35
41
|
protected
|
36
42
|
|
37
|
-
def tag_for(item, name = '', icon = nil, split = false)
|
43
|
+
def tag_for(item, name = '', icon = nil, split = false, dropdown = false)
|
38
44
|
unless item.url or include_sub_navigation?(item)
|
39
45
|
return item.name
|
40
46
|
end
|
@@ -47,9 +53,11 @@ module SimpleNavigation
|
|
47
53
|
item_options[:link] = Hash.new if item_options[:link].nil?
|
48
54
|
item_options[:link][:class] = Array.new if item_options[:link][:class].nil?
|
49
55
|
unless split
|
50
|
-
|
51
|
-
|
52
|
-
|
56
|
+
if dropdown
|
57
|
+
item_options[:link][:class] << 'dropdown-toggle'
|
58
|
+
item_options[:link][:'data-toggle'] = 'dropdown'
|
59
|
+
item_options[:link][:'data-target'] = '#'
|
60
|
+
end
|
53
61
|
link << content_tag(:b, '', :class => 'caret')
|
54
62
|
end
|
55
63
|
item.html_options = item_options
|
@@ -18,6 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
|
19
19
|
# specify any dependencies here; for example:
|
20
20
|
s.add_development_dependency "rake"
|
21
|
-
s.add_runtime_dependency "simple-navigation", ">= 3.7.0"
|
21
|
+
s.add_runtime_dependency "simple-navigation", ">= 3.7.0", "< 4.0.0"
|
22
22
|
s.add_runtime_dependency "railties", ">= 3.1"
|
23
23
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-navigation-bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Peter Fern
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,23 +27,26 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: simple-navigation
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 3.7.0
|
34
|
+
- - <
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 4.0.0
|
38
37
|
type: :runtime
|
39
38
|
prerelease: false
|
40
39
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
40
|
requirements:
|
43
41
|
- - ! '>='
|
44
42
|
- !ruby/object:Gem::Version
|
45
43
|
version: 3.7.0
|
44
|
+
- - <
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 4.0.0
|
46
47
|
- !ruby/object:Gem::Dependency
|
47
48
|
name: railties
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
50
|
requirements:
|
51
51
|
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
@@ -54,7 +54,6 @@ dependencies:
|
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
57
|
requirements:
|
59
58
|
- - ! '>='
|
60
59
|
- !ruby/object:Gem::Version
|
@@ -75,38 +74,32 @@ files:
|
|
75
74
|
- lib/simple-navigation-bootstrap.rb
|
76
75
|
- lib/simple-navigation-bootstrap/engine.rb
|
77
76
|
- lib/simple-navigation-bootstrap/version.rb
|
77
|
+
- lib/simple_navigation/core_ext/item_container.rb
|
78
78
|
- lib/simple_navigation/rendering/renderer/bootstrap.rb
|
79
79
|
- simple-navigation-bootstrap.gemspec
|
80
80
|
- vendor/assets/stylesheets/bootstrap_navbar_split_dropdowns.css
|
81
81
|
homepage: https://github.com/pdf/simple-navigation-bootstrap
|
82
82
|
licenses: []
|
83
|
+
metadata: {}
|
83
84
|
post_install_message:
|
84
85
|
rdoc_options: []
|
85
86
|
require_paths:
|
86
87
|
- lib
|
87
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
89
|
requirements:
|
90
90
|
- - ! '>='
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
hash: 4218250063998013409
|
96
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
94
|
requirements:
|
99
95
|
- - ! '>='
|
100
96
|
- !ruby/object:Gem::Version
|
101
97
|
version: '0'
|
102
|
-
segments:
|
103
|
-
- 0
|
104
|
-
hash: 4218250063998013409
|
105
98
|
requirements: []
|
106
99
|
rubyforge_project:
|
107
|
-
rubygems_version:
|
100
|
+
rubygems_version: 2.4.7
|
108
101
|
signing_key:
|
109
|
-
specification_version:
|
102
|
+
specification_version: 4
|
110
103
|
summary: simple-navigation-bootstrap is a simple-navigation renderer for twitter-bootstrap
|
111
104
|
navigation and dropdowns.
|
112
105
|
test_files: []
|