effective_bootstrap 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_bootstrap_helper.rb +51 -0
- data/lib/effective_bootstrap/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: c15ada27fcf25cd86f4be05939a3fe2f6eac8efa
|
4
|
+
data.tar.gz: 8a30b06554ce24843aafb4a9b3d0fe48f5a95558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d16a0e4831874a52d7494aebe69d35dc8dae64e7abda2b22f1912e98d16bf0b3c44227a1b66ae199fe2dd41d4ae08bd5faa445c541e198b9bb2461db00c32dc
|
7
|
+
data.tar.gz: 9552ed89690370d5c1811bf4d3e91216aa265614f8c21976139b5cfaf5c70415d2bb2be861f67dabc4142a0e8be7f0ee2881b001ce4b5b4272f75bf45864b96e
|
@@ -143,6 +143,57 @@ module EffectiveBootstrapHelper
|
|
143
143
|
content_tag(:div, '', class: 'dropdown-divider')
|
144
144
|
end
|
145
145
|
|
146
|
+
# Tabs DSL
|
147
|
+
# Inserts both the tablist and the tabpanel
|
148
|
+
|
149
|
+
# = tabs do
|
150
|
+
# = tab 'Imports' do
|
151
|
+
# %p Imports
|
152
|
+
|
153
|
+
# = tab 'Exports' do
|
154
|
+
# %p Exports
|
155
|
+
|
156
|
+
# If you pass active 'label' it will make that tab active. Otherwise first.
|
157
|
+
# Unique will make sure the tab html IDs are unique
|
158
|
+
# $('#tab-demographics').tab('show')
|
159
|
+
def tabs(active: nil, unique: false, list: {}, content: {}, &block)
|
160
|
+
raise 'expected a block' unless block_given?
|
161
|
+
|
162
|
+
@_tab_mode = :tablist
|
163
|
+
@_tab_active = (active || :first)
|
164
|
+
@_tab_unique = ''.object_id if unique
|
165
|
+
|
166
|
+
content_tag(:ul, {class: 'nav nav-tabs', role: 'tablist'}.merge(list)) do
|
167
|
+
yield # Yield to tab the first time
|
168
|
+
end +
|
169
|
+
content_tag(:div, {class: 'tab-content'}.merge(content)) do
|
170
|
+
@_tab_mode = :content
|
171
|
+
@_tab_active = (active || :first)
|
172
|
+
yield # Yield to tab the second time
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def tab(label, options = {}, &block)
|
177
|
+
controls = options.delete(:controls) || label.to_s.parameterize.gsub('_', '-')
|
178
|
+
controls = controls[1..-1] if controls[0] == '#'
|
179
|
+
controls = "#{controls}-#{@_tab_unique}" if @_tab_unique
|
180
|
+
|
181
|
+
active = (@_tab_active == :first || @_tab_active == label)
|
182
|
+
|
183
|
+
@_tab_active = nil if @_tab_active == :first
|
184
|
+
|
185
|
+
if @_tab_mode == :tablist # Inserting the label into the tablist top
|
186
|
+
content_tag(:li, class: 'nav-item') do
|
187
|
+
content_tag(:a, label, id: ('tab-' + controls), class: ['nav-link', ('active' if active)].compact.join(' '), href: '#' + controls, 'aria-controls': controls, 'aria-selected': active.to_s, 'data-toggle': 'tab', role: 'tab')
|
188
|
+
end
|
189
|
+
else # Inserting the content into the tab itself
|
190
|
+
classes = ['tab-pane', 'fade', ('show active' if active), options[:class].presence].compact.join(' ')
|
191
|
+
content_tag(:div, id: controls, class: classes, role: 'tabpanel', 'aria-labelledby': ('tab-' + controls)) do
|
192
|
+
yield
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
146
197
|
def merge_class_key(hash, value)
|
147
198
|
return { :class => value } unless hash.kind_of?(Hash)
|
148
199
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|