simple_navigation_renderers 0.0.3 → 1.0.0
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +20 -16
- data/lib/simple_navigation_renderers/bootstrap.rb +59 -45
- data/lib/simple_navigation_renderers/version.rb +1 -1
- data/simple_navigation_renderers.gemspec +2 -2
- data/spec/lib/simple_navigation_renderers/bootstrap_spec.rb +50 -12
- data/spec/lib/simple_navigation_renderers_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -18
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 616b1a87c82cdb976a28aadc839c4be6546a8e78
|
|
4
|
+
data.tar.gz: 70eac40e4239df1041b6dc9bc97d32960e8627ca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3f18bdd23db2dcbed7641834dd75da7f2ba9c2816de206a624d2017667925c542f15bef4227a958d649ff11de95582e47d92524785c7224b65d28e28a1371df
|
|
7
|
+
data.tar.gz: 29ce774d04e11f5e303d0059de7af07aede50ff521b0a283695ad646097364b2518cbe3a0dd7ab5bad9051b51b09a405eafca9c8efc5e41d91adfe06623cc29d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ For now, it is include renderers for:
|
|
|
5
5
|
* [Bootstrap 2 navigation](http://getbootstrap.com/components/#navbar)
|
|
6
6
|
* [Bootstrap 3 navigation](http://getbootstrap.com/2.3.2/components.html#navbar)
|
|
7
7
|
|
|
8
|
-
With these renderers you will be able create **any bootstrap navigation elements**, such as: **
|
|
8
|
+
With these renderers you will be able create **any bootstrap navigation elements**, such as: **submenu**, **navbar-text**, **divider**, **header**. As well as add **icons** to menu elements, such as: gliphicons, font-awesome icons, even custom icons. Also you have **split** option for main menu containing submenu.
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -63,20 +63,23 @@ Lets look at the example:
|
|
|
63
63
|
SimpleNavigation::Configuration.run do |navigation|
|
|
64
64
|
navigation.renderer = SimpleNavigationRenderers::Bootstrap3
|
|
65
65
|
navigation.items do |primary|
|
|
66
|
-
primary.item :news, {icon: "fa fa-fw fa-bullhorn", text: "News"}, news_index_path
|
|
67
|
-
primary.item :concerts, "Concerts", concerts_path
|
|
68
|
-
primary.item :video, "Video", videos_path
|
|
69
|
-
primary.item :
|
|
66
|
+
primary.item :news, {icon: "fa fa-fw fa-bullhorn", text: "News"}, news_index_path
|
|
67
|
+
primary.item :concerts, "Concerts", concerts_path
|
|
68
|
+
primary.item :video, "Video", videos_path
|
|
69
|
+
primary.item :divider_before_info, '#', divider: true
|
|
70
|
+
primary.item :info, {icon: "fa fa-fw fa-book", title: "Info"}, info_index_path, split: true do |info_nav|
|
|
70
71
|
info_nav.item :main_info_page, "Main info page", info_path(:main_info_page)
|
|
71
72
|
info_nav.item :about_info_page, "About", info_path(:about_info_page)
|
|
72
|
-
info_nav.item :misc_info_pages, "Misc."
|
|
73
|
+
info_nav.item :misc_info_pages, "Misc." do |misc_page|
|
|
73
74
|
misc_page.item :header_misc_pages, "Misc. Pages", header: true
|
|
74
75
|
Info.all.each do |info_page|
|
|
75
76
|
misc_page.item :"#{info_page.permalink}", info_page.title, info_path(info_page)
|
|
76
77
|
end
|
|
77
78
|
end
|
|
78
|
-
info_nav.item :
|
|
79
|
+
info_nav.item :divider_before_contact_info_page, '#', divider: true
|
|
80
|
+
info_nav.item :contact_info_page, "Contact", info_path(:contact_info_page)
|
|
79
81
|
end
|
|
82
|
+
primary.item :singed_in, "Signed in as Pavel Shpak", navbar_text: true
|
|
80
83
|
end
|
|
81
84
|
end
|
|
82
85
|
```
|
|
@@ -86,8 +89,9 @@ end
|
|
|
86
89
|
Specific options used in the example:
|
|
87
90
|
|
|
88
91
|
* `:split` - Use it to split first level item link with caret. If you add `split: true` option to item, then caret itself will toggle first level submenu and link will have standard behaviour, instead of toggle submenu. You can use `:split` only with first level items, for the rest it will not do anything.
|
|
89
|
-
* `:
|
|
90
|
-
* `:
|
|
92
|
+
* `:navbar_text` - Use it as `navbar_text: true` to add Bootstrap 'navbar-text'.
|
|
93
|
+
* `:divider` - Use it to add Bootstrap menu divider. if you add `divider: true` option to first level item, then it will create li-tag with `divider-vertical` Bootstrap 2 class. (You can add `divider-vertical` class to Bootstrap 3 - see below). For the second level item and deeper it will create li-tag with class `divider` (which exists in both, Bootstrap 2 and 3).
|
|
94
|
+
* `:header` - Use it as `header: true` to add Bootstrap menu header. You can use `:header` only with submenus, for the first level items it will not do anything.
|
|
91
95
|
* `:name hash` - Use it in place of `:name` if you want. Hash can have three keys: `:text`, `:icon` and `:title`, which is only recognized. You can use it together or separatly, but at least one of `:text` and `:icon` parameters should be provided. For example:
|
|
92
96
|
* `{text: "News", icon: "fa fa-fw fa-bullhorn"}` will create Font Awesome icon and add text after it (name of the item)
|
|
93
97
|
* `{icon: "glyphicon glyphicon-book", title: "Info"}` will create Bootstrap icon with title without any text after it
|
|
@@ -124,13 +128,13 @@ Thus, above example will produce something like following code:
|
|
|
124
128
|
|
|
125
129
|
```html
|
|
126
130
|
<ul class="nav navbar-nav">
|
|
127
|
-
<li class="active simple-navigation-active-leaf"
|
|
131
|
+
<li id="news" class="active simple-navigation-active-leaf">
|
|
128
132
|
<a href="/news_index_path"><span class="fa fa-fw fa-bullhorn"></span> News</a>
|
|
129
133
|
</li>
|
|
130
134
|
<li id="concerts"><a href="/concerts_path">Concerts</a></li>
|
|
131
135
|
<li id="video"><a href="/videos_path">Video</a></li>
|
|
132
|
-
<li class="divider-vertical"></li>
|
|
133
|
-
<li class="dropdown-split-left"
|
|
136
|
+
<li id="divider_before_info" class="divider-vertical"></li>
|
|
137
|
+
<li id="info" class="dropdown-split-left">
|
|
134
138
|
<a href="/info_index_path"><span class="fa fa-fw fa-book" title="Info"></span></a>
|
|
135
139
|
</li>
|
|
136
140
|
<li class="dropdown dropdown-split-right">
|
|
@@ -138,19 +142,19 @@ Thus, above example will produce something like following code:
|
|
|
138
142
|
<ul class="pull-right dropdown-menu">
|
|
139
143
|
<li id="main_info_page"><a href="/info/main_info_page">Main info page</a></li>
|
|
140
144
|
<li id="about_info_page"><a href="/info/about_info_page">About</a></li>
|
|
141
|
-
<li class="
|
|
142
|
-
<li class="dropdown-submenu" id="misc_info_pages">
|
|
145
|
+
<li id="misc_info_pages" class="dropdown-submenu">
|
|
143
146
|
<a href="#">Misc.</a>
|
|
144
147
|
<ul class="dropdown-menu">
|
|
145
|
-
<li class="dropdown-header">Misc. Pages</li>
|
|
148
|
+
<li id="header_misc_pages" class="dropdown-header">Misc. Pages</li>
|
|
146
149
|
<li id="page1"><a href="/info/page1">Page1</a></li>
|
|
147
150
|
<li id="page2"><a href="/info/page2">Page2</a></li>
|
|
148
151
|
</ul>
|
|
149
152
|
</li>
|
|
150
|
-
<li class="divider"></li>
|
|
153
|
+
<li id="divider_before_contact_info_page" class="divider"></li>
|
|
151
154
|
<li id="contact_info_page"><a href="/info/contact_info_page">Contact</a></li>
|
|
152
155
|
</ul>
|
|
153
156
|
</li>
|
|
157
|
+
<li id="singed_in"><p class="navbar-text">Signed in as Pavel Shpak</p></li>
|
|
154
158
|
</ul>
|
|
155
159
|
```
|
|
156
160
|
|
|
@@ -3,65 +3,79 @@ module SimpleNavigationRenderers
|
|
|
3
3
|
module Bootstrap
|
|
4
4
|
|
|
5
5
|
def render( item_container )
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
list << content_tag(:li, '', {class: "divider"})
|
|
21
|
-
else
|
|
22
|
-
list << content_tag(:li, '', {class: "divider-vertical"})
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
if li_options.delete(:header) && (item_container.level != 1)
|
|
27
|
-
list << content_tag(:li, item.name, { class: ((options[:bv] == 2) ? "nav-header" : "dropdown-header") })
|
|
28
|
-
else
|
|
29
|
-
|
|
6
|
+
if (skip_if_empty? && item_container.empty?)
|
|
7
|
+
''
|
|
8
|
+
else
|
|
9
|
+
config_selected_class = SimpleNavigation.config.selected_class
|
|
10
|
+
SimpleNavigation.config.selected_class = "active"
|
|
11
|
+
@config_name_generator = SimpleNavigation.config.name_generator
|
|
12
|
+
SimpleNavigation.config.name_generator = self.method(:name_generator)
|
|
13
|
+
|
|
14
|
+
list_content = item_container.items.inject([]) do |list, item|
|
|
15
|
+
li_options = item.html_options
|
|
16
|
+
|
|
17
|
+
navbar_text = li_options.delete(:navbar_text)
|
|
18
|
+
navbar_divider = li_options.delete(:divider)
|
|
19
|
+
navbar_header = li_options.delete(:header)
|
|
30
20
|
link_options = li_options.delete(:link) || {}
|
|
31
21
|
split = li_options.delete(:split)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
|
|
23
|
+
if navbar_text
|
|
24
|
+
list << li_text( item.name, li_options )
|
|
25
|
+
elsif navbar_divider
|
|
26
|
+
list << li_divider( item_container.level, li_options )
|
|
27
|
+
elsif navbar_header && (item_container.level != 1)
|
|
28
|
+
list << li_header( item.name, li_options )
|
|
29
|
+
else
|
|
30
|
+
li_content = if include_sub_navigation?(item)
|
|
31
|
+
if item_container.level == 1
|
|
32
|
+
if split
|
|
33
|
+
main_li_options = li_options.dup
|
|
34
|
+
main_li_options[:class] = [ main_li_options[:class], "dropdown-split-left" ].flatten.compact.join(' ')
|
|
35
|
+
list << content_tag(:li, simple_link(item, link_options), main_li_options)
|
|
36
|
+
li_options[:id] = nil
|
|
37
|
+
item.sub_navigation.dom_class = [ item.sub_navigation.dom_class, "pull-right" ].flatten.compact.join(' ')
|
|
38
|
+
end
|
|
39
|
+
li_options[:class] = [ li_options[:class], "dropdown", (split ? "dropdown-split-right" : nil) ].flatten.compact.join(' ')
|
|
40
|
+
dropdown_link(item, split, link_options) + render_sub_navigation_for(item)
|
|
41
|
+
else
|
|
42
|
+
li_options[:class] = [ li_options[:class], "dropdown-submenu"].flatten.compact.join(' ')
|
|
43
|
+
simple_link(item, link_options) + render_sub_navigation_for(item)
|
|
40
44
|
end
|
|
41
|
-
li_options[:class] = [ li_options[:class], "dropdown", (split ? "dropdown-split-right" : nil) ].flatten.compact.join(' ')
|
|
42
|
-
dropdown_link(item, split, link_options) + render_sub_navigation_for(item)
|
|
43
45
|
else
|
|
44
|
-
|
|
45
|
-
simple_link(item, link_options) + render_sub_navigation_for(item)
|
|
46
|
+
simple_link(item, link_options)
|
|
46
47
|
end
|
|
47
|
-
|
|
48
|
-
simple_link(item, link_options)
|
|
48
|
+
list << content_tag(:li, li_content, li_options)
|
|
49
49
|
end
|
|
50
|
-
|
|
50
|
+
end.join
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
SimpleNavigation.config.selected_class = config_selected_class
|
|
56
|
-
SimpleNavigation.config.name_generator = @config_name_generator
|
|
52
|
+
SimpleNavigation.config.selected_class = config_selected_class
|
|
53
|
+
SimpleNavigation.config.name_generator = @config_name_generator
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
item_container.dom_class = [ item_container.dom_class,
|
|
56
|
+
(item_container.level == 1) ? "nav#{(options[:bv] == 2) ? '' : ' navbar-nav'}" :
|
|
57
|
+
"dropdown-menu" ].flatten.compact.join(' ')
|
|
59
58
|
content_tag(:ul, list_content, {id: item_container.dom_id, class: item_container.dom_class})
|
|
59
|
+
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
protected
|
|
64
64
|
|
|
65
|
+
def li_text( text, li_options )
|
|
66
|
+
content_tag(:li, content_tag(:p, text, {class: 'navbar-text'}), li_options)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def li_divider( level, li_options )
|
|
70
|
+
li_options[:class] = [ li_options[:class], ((level == 1) ? "divider-vertical" : "divider") ].flatten.compact.join(' ')
|
|
71
|
+
content_tag(:li, '', li_options)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def li_header( text, li_options )
|
|
75
|
+
li_options[:class] = [ li_options[:class], ((options[:bv] == 2) ? "nav-header" : "dropdown-header") ].flatten.compact.join(' ')
|
|
76
|
+
content_tag(:li, text, li_options)
|
|
77
|
+
end
|
|
78
|
+
|
|
65
79
|
def simple_link( item, link_options )
|
|
66
80
|
link_options[:method] ||= item.method
|
|
67
81
|
link_to(item.name, (item.url || "#"), link_options)
|
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.version = SimpleNavigationRenderers::VERSION
|
|
9
9
|
spec.authors = ["Pavel Shpak"]
|
|
10
10
|
spec.email = ["shpakvel@gmail.com"]
|
|
11
|
-
spec.description = %q{simple_navigation_renderers gem adds renderers for Bootstrap 2 and 3. With these renderers you will be able create any bootstrap navigation elements, such as:
|
|
12
|
-
spec.summary = %q{simple_navigation_renderers gem adds renderers for Bootstrap 2 and 3. With these renderers you will be able create any bootstrap navigation elements, such as:
|
|
11
|
+
spec.description = %q{simple_navigation_renderers gem adds renderers for Bootstrap 2 and 3. With these renderers you will be able create any bootstrap navigation elements, such as: submenu, navbar-text, divider, header. As well as add icons to menu elements, such as: gliphicons, font-awesome icons, even custom icons. Also you have split option for main menu containing submenu. }
|
|
12
|
+
spec.summary = %q{simple_navigation_renderers gem adds renderers for Bootstrap 2 and 3. With these renderers you will be able create any bootstrap navigation elements, such as: submenu, navbar-text, divider, header. As well as add icons to menu elements, such as: gliphicons, font-awesome icons, even custom icons. Also you have split option for main menu containing submenu. }
|
|
13
13
|
spec.homepage = "http://github.com/ShPakvel/simple_navigation_renderers"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
@@ -5,12 +5,33 @@ describe SimpleNavigationRenderers::Bootstrap do
|
|
|
5
5
|
|
|
6
6
|
describe '.render' do
|
|
7
7
|
|
|
8
|
+
# tested navigation content
|
|
9
|
+
def fill_in( primary )
|
|
10
|
+
primary.item :news, {icon: "fa fa-fw fa-bullhorn", text: "News"}, "news_index_path"
|
|
11
|
+
primary.item :concerts, "Concerts", "concerts_path", class: "to_check_header", header: true
|
|
12
|
+
primary.item :video, "Video", "videos_path", class: "to_check_split", split: true
|
|
13
|
+
primary.item :divider_before_info_index_path, '#', divider: true
|
|
14
|
+
primary.item :info, {icon: "fa fa-fw fa-book", title: "Info"}, "info_index_path", split: true do |info_nav|
|
|
15
|
+
info_nav.item :main_info_page, "Main info page", "main_info_page"
|
|
16
|
+
info_nav.item :about_info_page, "About", "about_info_page"
|
|
17
|
+
info_nav.item :divider_before_misc_info_pages, '#', divider: true
|
|
18
|
+
info_nav.item :misc_info_pages, "Misc.", "misc_info_pages", split: true do |misc_nav|
|
|
19
|
+
misc_nav.item :header_misc_pages, "Misc. Pages", class: "to_check_header2", header: true
|
|
20
|
+
misc_nav.item :page1, "Page1", "page1"
|
|
21
|
+
misc_nav.item :page2, "Page2", "page2"
|
|
22
|
+
end
|
|
23
|
+
info_nav.item :divider_before_contact_info_page, '#', divider: true
|
|
24
|
+
info_nav.item :contact_info_page, "Contact", "contact_info_page"
|
|
25
|
+
end
|
|
26
|
+
primary.item :singed_in, "Signed in as Pavel Shpak", class: "to_check_navbar_text", navbar_text: true
|
|
27
|
+
end
|
|
28
|
+
|
|
8
29
|
# 'bv' is bootstrap version
|
|
9
30
|
# 'stub_name' neads to check raising error when invalid 'Item name hash' provided
|
|
10
31
|
def render_result( bv=3, stub_name=false )
|
|
11
32
|
SimpleNavigation::Configuration.instance.renderer = (bv == 3) ? SimpleNavigationRenderers::Bootstrap3 : SimpleNavigationRenderers::Bootstrap2
|
|
12
33
|
|
|
13
|
-
SimpleNavigation.stub(adapter: (
|
|
34
|
+
SimpleNavigation.stub( adapter: (SimpleNavigation::Adapters::Rails.new(double(:context, view_context: ActionView::Base.new))) )
|
|
14
35
|
|
|
15
36
|
SimpleNavigation::Item.any_instance.stub( selected?: false, selected_by_condition?: false )
|
|
16
37
|
primary_navigation = SimpleNavigation::ItemContainer.new(1)
|
|
@@ -111,15 +132,32 @@ describe SimpleNavigationRenderers::Bootstrap do
|
|
|
111
132
|
|
|
112
133
|
|
|
113
134
|
|
|
135
|
+
context "when ':navbar_text' option provided" do
|
|
136
|
+
it "creates p-tag with class 'navbar-text' and item 'name' as a content instead of link-tag for the item (standard item)" do
|
|
137
|
+
HTML::Selector.new('ul > li.to_check_navbar_text > a').select(render_result).should have(0).entries
|
|
138
|
+
HTML::Selector.new('ul > li.to_check_navbar_text > a').select(render_result(2)).should have(0).entries
|
|
139
|
+
HTML::Selector.new('ul > li.to_check_navbar_text > p.navbar-text').select(render_result)[0].children[0].to_s.should == "Signed in as Pavel Shpak"
|
|
140
|
+
HTML::Selector.new('ul > li.to_check_navbar_text > p.navbar-text').select(render_result(2))[0].children[0].to_s.should == "Signed in as Pavel Shpak"
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
114
146
|
context "when ':divider' option provided" do
|
|
147
|
+
it "does not create link-tag for the item (standard item)" do
|
|
148
|
+
HTML::Selector.new('ul > li.divider-vertical + li > a[href="divider_before_info_index_path"]').select(render_result).should have(0).entries
|
|
149
|
+
HTML::Selector.new('ul.dropdown-menu > li.divider + li > a[href="divider_before_misc_info_pages"]').select(render_result).should have(0).entries
|
|
150
|
+
HTML::Selector.new('ul.dropdown-menu > li.divider + li > a[href="divider_before_contact_info_page"]').select(render_result).should have(0).entries
|
|
151
|
+
end
|
|
152
|
+
|
|
115
153
|
context "for the first level item" do
|
|
116
|
-
it "adds li-tag with class 'divider-vertical'
|
|
154
|
+
it "adds li-tag with class 'divider-vertical'" do
|
|
117
155
|
HTML::Selector.new('ul > li.divider-vertical + li > a[href="info_index_path"]').select(render_result).should have(1).entries
|
|
118
156
|
end
|
|
119
157
|
end
|
|
120
158
|
|
|
121
159
|
context "for the second level item and deeper" do
|
|
122
|
-
it "adds li-tag with class 'divider'
|
|
160
|
+
it "adds li-tag with class 'divider'" do
|
|
123
161
|
HTML::Selector.new('ul.dropdown-menu > li.divider + li > a[href="misc_info_pages"]').select(render_result).should have(1).entries
|
|
124
162
|
HTML::Selector.new('ul.dropdown-menu > li.divider + li > a[href="contact_info_page"]').select(render_result).should have(1).entries
|
|
125
163
|
end
|
|
@@ -130,9 +168,9 @@ describe SimpleNavigationRenderers::Bootstrap do
|
|
|
130
168
|
|
|
131
169
|
context "when ':header' option provided" do
|
|
132
170
|
context "for the first level item" do
|
|
133
|
-
it "does not set up 'dropdown-header' class on li-tag" do
|
|
171
|
+
it "does not set up 'dropdown-header' or 'nav-header' class on li-tag" do
|
|
134
172
|
HTML::Selector.new('ul.nav.navbar-nav > li.to_check_header.dropdown-header').select(render_result).should have(0).entries
|
|
135
|
-
HTML::Selector.new('ul.nav > li.to_check_header.
|
|
173
|
+
HTML::Selector.new('ul.nav > li.to_check_header.nav-header').select(render_result(2)).should have(0).entries
|
|
136
174
|
end
|
|
137
175
|
|
|
138
176
|
it "creates link-tag for the item (standard item)" do
|
|
@@ -144,21 +182,21 @@ describe SimpleNavigationRenderers::Bootstrap do
|
|
|
144
182
|
context "for the second level item and deeper" do
|
|
145
183
|
context "for 'bootstrap3' renderer" do
|
|
146
184
|
it "sets up 'dropdown-header' class on li-tag" do
|
|
147
|
-
HTML::Selector.new('ul.dropdown-menu > li.dropdown-header').select(render_result).should have(1).entries
|
|
185
|
+
HTML::Selector.new('ul.dropdown-menu > li.to_check_header2.dropdown-header').select(render_result).should have(1).entries
|
|
148
186
|
end
|
|
149
187
|
end
|
|
150
188
|
|
|
151
189
|
context "for 'bootstrap2' renderer" do
|
|
152
190
|
it "sets up 'nav-header' class on li-tag" do
|
|
153
|
-
HTML::Selector.new('ul.dropdown-menu > li.nav-header').select(render_result(2)).should have(1).entries
|
|
191
|
+
HTML::Selector.new('ul.dropdown-menu > li.to_check_header2.nav-header').select(render_result(2)).should have(1).entries
|
|
154
192
|
end
|
|
155
193
|
end
|
|
156
194
|
|
|
157
|
-
it "does not create link-tag for the item (puts only item name
|
|
158
|
-
HTML::Selector.new('ul.dropdown-menu > li.dropdown-header > a').select(render_result).should have(0).entries
|
|
159
|
-
HTML::Selector.new('ul.dropdown-menu > li.nav-header > a').select(render_result(2)).should have(0).entries
|
|
160
|
-
HTML::Selector.new('ul.dropdown-menu > li.dropdown-header').select(render_result)[0].children[0].to_s.should == "Misc. Pages"
|
|
161
|
-
HTML::Selector.new('ul.dropdown-menu > li.nav-header').select(render_result(2))[0].children[0].to_s.should == "Misc. Pages"
|
|
195
|
+
it "does not create link-tag for the item (standard item), but puts only item 'name'" do
|
|
196
|
+
HTML::Selector.new('ul.dropdown-menu > li.to_check_header2.dropdown-header > a').select(render_result).should have(0).entries
|
|
197
|
+
HTML::Selector.new('ul.dropdown-menu > li.to_check_header2.nav-header > a').select(render_result(2)).should have(0).entries
|
|
198
|
+
HTML::Selector.new('ul.dropdown-menu > li.to_check_header2.dropdown-header').select(render_result)[0].children[0].to_s.should == "Misc. Pages"
|
|
199
|
+
HTML::Selector.new('ul.dropdown-menu > li.to_check_header2.nav-header').select(render_result(2))[0].children[0].to_s.should == "Misc. Pages"
|
|
162
200
|
end
|
|
163
201
|
end
|
|
164
202
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe SimpleNavigationRenderers do
|
|
4
|
-
it "
|
|
4
|
+
it "registers 'bootstrap2' renderer" do
|
|
5
5
|
SimpleNavigation.registered_renderers[:bootstrap2].should == SimpleNavigationRenderers::Bootstrap2
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
it "
|
|
8
|
+
it "registers 'bootstrap3' renderer" do
|
|
9
9
|
SimpleNavigation.registered_renderers[:bootstrap3].should == SimpleNavigationRenderers::Bootstrap3
|
|
10
10
|
end
|
|
11
11
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -8,21 +8,4 @@ end unless defined? Rails
|
|
|
8
8
|
RAILS_ROOT = './' unless defined?(RAILS_ROOT)
|
|
9
9
|
RAILS_ENV = 'test' unless defined?(RAILS_ENV)
|
|
10
10
|
|
|
11
|
-
require "simple_navigation_renderers"
|
|
12
|
-
|
|
13
|
-
# helper method
|
|
14
|
-
def fill_in( primary )
|
|
15
|
-
primary.item :news, {icon: "fa fa-fw fa-bullhorn", text: "News"}, "news_index_path"
|
|
16
|
-
primary.item :concerts, "Concerts", "concerts_path", class: "to_check_header", header: true
|
|
17
|
-
primary.item :video, "Video", "videos_path", class: "to_check_split", split: true
|
|
18
|
-
primary.item :info, {icon: "fa fa-fw fa-book", title: "Info"}, "info_index_path", divider: true, split: true do |info_nav|
|
|
19
|
-
info_nav.item :main_info_page, "Main info page", "main_info_page"
|
|
20
|
-
info_nav.item :about_info_page, "About", "about_info_page"
|
|
21
|
-
info_nav.item :misc_info_pages, "Misc.", "misc_info_pages", divider: true, split: true do |misc_nav|
|
|
22
|
-
misc_nav.item :header_misc_pages, "Misc. Pages", header: true
|
|
23
|
-
misc_nav.item :page1, "Page1", "page1"
|
|
24
|
-
misc_nav.item :page2, "Page2", "page2"
|
|
25
|
-
end
|
|
26
|
-
info_nav.item :contact_info_page, "Contact", "contact_info_page", divider: true
|
|
27
|
-
end
|
|
28
|
-
end
|
|
11
|
+
require "simple_navigation_renderers"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_navigation_renderers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pavel Shpak
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2014-03-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: simple-navigation
|
|
@@ -82,9 +82,9 @@ dependencies:
|
|
|
82
82
|
version: '0'
|
|
83
83
|
description: 'simple_navigation_renderers gem adds renderers for Bootstrap 2 and 3.
|
|
84
84
|
With these renderers you will be able create any bootstrap navigation elements,
|
|
85
|
-
such as:
|
|
86
|
-
as: gliphicons, font-awesome icons, even custom icons. Also you have split
|
|
87
|
-
for main menu containing submenu. '
|
|
85
|
+
such as: submenu, navbar-text, divider, header. As well as add icons to menu elements,
|
|
86
|
+
such as: gliphicons, font-awesome icons, even custom icons. Also you have split
|
|
87
|
+
option for main menu containing submenu. '
|
|
88
88
|
email:
|
|
89
89
|
- shpakvel@gmail.com
|
|
90
90
|
executables: []
|
|
@@ -139,9 +139,9 @@ signing_key:
|
|
|
139
139
|
specification_version: 4
|
|
140
140
|
summary: 'simple_navigation_renderers gem adds renderers for Bootstrap 2 and 3. With
|
|
141
141
|
these renderers you will be able create any bootstrap navigation elements, such
|
|
142
|
-
as:
|
|
143
|
-
gliphicons, font-awesome icons, even custom icons. Also you have split
|
|
144
|
-
main menu containing submenu.'
|
|
142
|
+
as: submenu, navbar-text, divider, header. As well as add icons to menu elements,
|
|
143
|
+
such as: gliphicons, font-awesome icons, even custom icons. Also you have split
|
|
144
|
+
option for main menu containing submenu.'
|
|
145
145
|
test_files:
|
|
146
146
|
- spec/lib/simple_navigation_renderers/bootstrap_spec.rb
|
|
147
147
|
- spec/lib/simple_navigation_renderers/exceptions_spec.rb
|