bootstrap-navbar 1.0.0.pre8 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a32dd31868e0ace9697468bd0705c163ee94265e
4
- data.tar.gz: 87c339d440b1fff10aa4a0540b6089f42b67bb62
3
+ metadata.gz: 0486f20fd1cce816f2193140268cecc4d586e043
4
+ data.tar.gz: 2b581e4521985b728f3b72ae5341d219459529d9
5
5
  SHA512:
6
- metadata.gz: 526f6c444e4a3a4a89b924ea8702c28de5138891d0f9608c760339ca5e64f1e691c1210e3c831f464ea28f5ba9e090b1e4b98bb3d029b0f8339cd4c3ca8d0c12
7
- data.tar.gz: 9db4133c32ad30c4d7ab29bea5ebd3c7faf9943f1d200aac4248d5b236a525acd06b1176b053676e955a5cf0f677548e898e27cf1f253bb515d323585782ecc3
6
+ metadata.gz: 53f00d99073df7999fd2e7f4e2ce02029730d964d5e647a6c0968d93e7cf068bc362b2a6421c3a61a0ec2519c08bd7b0ce5d5058565019777331eb7e8fb6ebfc
7
+ data.tar.gz: 8c6a54de102d5777e22e692fbbdcbc102358c329797cdb2f012297d43e5a2110b3a38a11dd2dc05865a21a1371a108bee3dce66a0bb615383c6e77b4db34acfd
@@ -2,7 +2,7 @@ module BootstrapNavbar::Helpers::Bootstrap3
2
2
  def navbar(options = {}, &block)
3
3
  container = options.has_key?(:container) ? options[:container] : true
4
4
  navbar_content =
5
- header(options[:brand], options[:brand_link]) <<
5
+ header(options.delete(:brand), options.delete(:brand_link)) <<
6
6
  collapsable(&block)
7
7
  wrapper options do
8
8
  if container
@@ -15,7 +15,8 @@ module BootstrapNavbar::Helpers::Bootstrap3
15
15
 
16
16
  def navbar_group(options = {}, &block)
17
17
  css_classes = %w(nav navbar-nav).tap do |css_classes|
18
- css_classes << "navbar-#{options[:align]}" if options.has_key?(:align)
18
+ css_classes << "navbar-#{options.delete(:align)}" if options.has_key?(:align)
19
+ css_classes << options.delete(:class) if options.has_key?(:class)
19
20
  end
20
21
  attributes = attributes_for_tag({ class: css_classes.join(' ') }.merge(options))
21
22
  prepare_html <<-HTML.chomp!
@@ -25,35 +26,38 @@ module BootstrapNavbar::Helpers::Bootstrap3
25
26
  HTML
26
27
  end
27
28
 
28
- def navbar_item(text, url)
29
- attributes = {}
30
- attributes[:class] = 'active' if current_url?(url)
31
- attributes = attributes_for_tag(attributes)
32
- prepare_html <<-HTML.chomp!
33
- <li#{attributes}>
34
- <a href="#{url}">#{text}</a>
35
- </li>
36
- HTML
37
- end
29
+ def navbar_item(text, url = nil, list_item_options = nil, link_options = nil, &block)
30
+ text, url, list_item_options, link_options = capture(&block), text, list_item_options if block_given?
31
+ url ||= '#'
32
+ list_item_options ||= {}
33
+ link_options ||= {}
38
34
 
39
- def navbar_dropdown(text, &block)
35
+ list_item_css_classes = [].tap do |css_classes|
36
+ css_classes << 'active' if current_url?(url)
37
+ css_classes << list_item_options.delete(:class) if list_item_options.has_key?(:class)
38
+ end
39
+ list_item_attributes = attributes_for_tag(
40
+ { class: list_item_css_classes.join(' ') }
41
+ .delete_if { |k, v| v.empty? }
42
+ .merge(list_item_options)
43
+ )
44
+ link_attributes = attributes_for_tag(link_options)
40
45
  prepare_html <<-HTML.chomp!
41
- <li class="dropdown">
42
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">#{text} <b class="caret"></b></a>
43
- <ul class="dropdown-menu">
44
- #{capture(&block) if block_given?}
45
- </ul>
46
+ <li#{list_item_attributes}>
47
+ <a href="#{url}"#{link_attributes}>
48
+ #{text}
49
+ </a>
46
50
  </li>
47
51
  HTML
48
52
  end
49
53
 
50
54
  def navbar_form(options = {}, &block)
51
55
  css_classes = %w(navbar-form).tap do |css_classes|
52
- css_classes << "navbar-#{options[:align]}" if options.has_key?(:align)
56
+ css_classes << "navbar-#{options.delete(:align)}" if options.has_key?(:align)
57
+ css_classes << options.delete(:class) if options.has_key?(:class)
53
58
  end
54
- role = options[:role] || 'form'
55
- attribute_hash = { class: css_classes.join(' '), role: role }
56
- attributes = attributes_for_tag(attribute_hash)
59
+ role = options.delete(:role) || 'form'
60
+ attributes = attributes_for_tag({ class: css_classes.join(' '), role: role }.merge(options))
57
61
  prepare_html <<-HTML.chomp!
58
62
  <form#{attributes}>
59
63
  #{capture(&block) if block_given?}
@@ -61,31 +65,54 @@ HTML
61
65
  HTML
62
66
  end
63
67
 
64
- def navbar_divider
65
- prepare_html <<-HTML.chomp!
66
- <li class="divider"></li>
67
- HTML
68
- end
69
-
70
- def navbar_text(text = nil, &block)
68
+ def navbar_text(text = nil, options = {}, &block)
71
69
  raise StandardError, 'Please provide either the "text" parameter or a block.' if (text.nil? && !block_given?) || (!text.nil? && block_given?)
72
70
  text ||= capture(&block)
71
+ css_classes = %w(navbar-text).tap do |css_classes|
72
+ css_classes << options.delete(:class) if options.has_key?(:class)
73
+ end
74
+ attributes = attributes_for_tag({ class: css_classes.join(' ') }.merge(options))
73
75
  prepare_html <<-HTML.chomp!
74
- <p class="navbar-text">#{text}</p>
76
+ <p#{attributes}>#{text}</p>
75
77
  HTML
76
78
  end
77
79
 
78
80
  def navbar_button(text, options = {})
79
81
  css_classes = %w(btn navbar-btn).tap do |css_classes|
80
- css_classes << options[:class] if options.has_key?(:class)
82
+ css_classes << options.delete(:class) if options.has_key?(:class)
81
83
  end
82
- attribute_hash = { class: css_classes.join(' '), type: 'button' }
83
- attributes = attributes_for_tag(attribute_hash)
84
+ type = options.delete(:type) || 'button'
85
+ attributes = attributes_for_tag({ class: css_classes.join(' '), type: type }.merge(options))
84
86
  prepare_html <<-HTML.chomp!
85
87
  <button#{attributes}>#{text}</button>
86
88
  HTML
87
89
  end
88
90
 
91
+ def navbar_dropdown(text, &block)
92
+ prepare_html <<-HTML.chomp!
93
+ <li class="dropdown">
94
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">#{text} <b class="caret"></b></a>
95
+ <ul class="dropdown-menu">
96
+ #{capture(&block) if block_given?}
97
+ </ul>
98
+ </li>
99
+ HTML
100
+ end
101
+
102
+ def navbar_dropdown_header(text)
103
+ prepare_html <<-HTML.chomp!
104
+ <li class="dropdown-header">
105
+ #{text}
106
+ </li>
107
+ HTML
108
+ end
109
+
110
+ def navbar_dropdown_divider
111
+ prepare_html <<-HTML.chomp!
112
+ <li class="divider"></li>
113
+ HTML
114
+ end
115
+
89
116
  private
90
117
 
91
118
  def container(content)
@@ -105,7 +132,7 @@ HTML
105
132
  <span class="icon-bar"></span>
106
133
  <span class="icon-bar"></span>
107
134
  </button>
108
- #{brand_link brand, brand_link}
135
+ #{brand_link brand, brand_link unless brand.nil?}
109
136
  </div>
110
137
  HTML
111
138
  end
@@ -119,19 +146,24 @@ HTML
119
146
  end
120
147
 
121
148
  def brand_link(name, url = nil)
122
- prepare_html %(<a href="#{url || '/'}" class="navbar-brand">#{name}</a>)
149
+ url ||= '/'
150
+ prepare_html <<-HTML.chomp!
151
+ <a href="#{url}" class="navbar-brand">
152
+ #{name}
153
+ </a>
154
+ HTML
123
155
  end
124
156
 
125
157
  def wrapper(options, &block)
126
- style = options[:inverse] ? 'inverse' : 'default'
158
+ style = options.delete(:inverse) ? 'inverse' : 'default'
127
159
  css_classes = %w(navbar).tap do |css_classes|
128
- css_classes << "navbar-fixed-#{options[:fixed]}" if options.has_key?(:fixed)
129
- css_classes << 'navbar-static-top' if options[:static]
130
- css_classes << 'navbar-inverse' if options[:inverse]
160
+ css_classes << "navbar-fixed-#{options.delete(:fixed)}" if options.has_key?(:fixed)
161
+ css_classes << 'navbar-static-top' if options.delete(:static)
162
+ css_classes << 'navbar-inverse' if options.delete(:inverse)
131
163
  css_classes << "navbar-#{style}"
132
164
  end
133
- attribute_hash = { class: css_classes.join(' '), role: 'navigation' }
134
- attributes = attributes_for_tag(attribute_hash)
165
+ role = options.delete(:role) || 'navigation'
166
+ attributes = attributes_for_tag({ class: css_classes.join(' '), role: role }.merge(options))
135
167
  prepare_html <<-HTML.chomp!
136
168
  <nav#{attributes}>
137
169
  #{capture(&block) if block_given?}
@@ -1,3 +1,3 @@
1
1
  module BootstrapNavbar
2
- VERSION = '1.0.0.pre8'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -40,7 +40,6 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
40
40
  with_tag :span, with: { class: 'icon-bar' }
41
41
  end
42
42
  end
43
- with_tag :a, with: { class: 'navbar-brand', href: '/' }
44
43
  end
45
44
  with_tag :div, with: { class: 'collapse navbar-collapse', id: 'navbar-collapsable' }, text: /foo/
46
45
  end
@@ -92,7 +91,6 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
92
91
  with_all_3_dot_x_versions do
93
92
  expect(renderer.navbar(brand: 'foo')).to have_tag(:a, with: { href: '/', class: 'navbar-brand' }, text: /foo/)
94
93
  expect(renderer.navbar(brand: 'foo', brand_link: 'http://google.com')).to have_tag(:a, with: { href: 'http://google.com', class: 'navbar-brand' }, text: /foo/)
95
- expect(renderer.navbar(brand_link: 'http://google.com')).to have_tag(:a, with: { href: 'http://google.com', class: 'navbar-brand' })
96
94
  end
97
95
  end
98
96
  end
@@ -215,14 +213,6 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
215
213
  end
216
214
  end
217
215
 
218
- describe '#navbar_divider' do
219
- it 'generates the correct HTML' do
220
- with_all_3_dot_x_versions do
221
- expect(renderer.navbar_divider).to have_tag(:li, with: { class: 'divider' })
222
- end
223
- end
224
- end
225
-
226
216
  describe '#navbar_text' do
227
217
  context 'without parameters' do
228
218
  it 'raises an error' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-navbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre8
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Meurer
@@ -132,9 +132,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - '>'
135
+ - - '>='
136
136
  - !ruby/object:Gem::Version
137
- version: 1.3.1
137
+ version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
140
  rubygems_version: 2.1.5