rails-bootstrap-tabs 0.1.1 → 0.2.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/lib/rails-bootstrap-tabs.rb +2 -0
- data/lib/rails-bootstrap-tabs/helpers/tabs_helper.rb +8 -1
- data/lib/rails-bootstrap-tabs/rails/engine.rb +3 -0
- data/lib/rails-bootstrap-tabs/renderers/tabs_bootstrap3_renderer.rb +36 -0
- data/lib/rails-bootstrap-tabs/renderers/tabs_bootstrap4_renderer.rb +43 -0
- data/lib/rails-bootstrap-tabs/renderers/tabs_renderer.rb +22 -12
- data/lib/rails-bootstrap-tabs/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b53b4afa84fd1f6157955b98548c4c013351aaf2
|
4
|
+
data.tar.gz: aa9afc668ceaade23c10a1e0e19bd8de54184535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb500380c7bcd7f18b2bdf30ced28003dcdb10597bea6c6b205c0e100c7a0157d22db0a41c2f21093116d1811751ecbbfdd6d4a616957041445d0d45b0d43fb
|
7
|
+
data.tar.gz: 22e8369fce286b8ac46b385da53f06672a8117b439f1c6db027b2efd0af5a5e57b66c53a3971caa957c64095dad05e8c95b72a647e547e3e9d39a6b62041c994
|
data/lib/rails-bootstrap-tabs.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module RailsBootstrapTabs
|
2
2
|
module Renderers
|
3
3
|
autoload :TabsRenderer, 'rails-bootstrap-tabs/renderers/tabs_renderer'
|
4
|
+
autoload :TabsBootstrap3Renderer, 'rails-bootstrap-tabs/renderers/tabs_bootstrap3_renderer'
|
5
|
+
autoload :TabsBootstrap4Renderer, 'rails-bootstrap-tabs/renderers/tabs_bootstrap4_renderer'
|
4
6
|
end
|
5
7
|
end
|
6
8
|
|
@@ -1,7 +1,14 @@
|
|
1
1
|
module RailsBootstrapTabs::Helpers
|
2
2
|
module TabsHelper
|
3
3
|
def tabs(*args, &block)
|
4
|
-
RailsBootstrapTabs
|
4
|
+
tabs_renderer_class = if RailsBootstrapTabs.bootstrap_version == 3
|
5
|
+
RailsBootstrapTabs::Renderers::TabsBootstrap3Renderer
|
6
|
+
elsif RailsBootstrapTabs.bootstrap_version == 4
|
7
|
+
RailsBootstrapTabs::Renderers::TabsBootstrap4Renderer
|
8
|
+
else
|
9
|
+
raise "Unknown bootstrap version: #{RailsBootstrapTabs.bootstrap_version}!"
|
10
|
+
end
|
11
|
+
tabs_renderer_class.new(self, *args, &block).render
|
5
12
|
end
|
6
13
|
end
|
7
14
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module RailsBootstrapTabs::Renderers
|
2
|
+
class TabsBootstrap3Renderer < TabsRenderer
|
3
|
+
def render_tabs_wrapper
|
4
|
+
content_tag :ul, class: 'nav nav-tabs' do
|
5
|
+
yield
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def render_tab(tab)
|
10
|
+
options = tab.options
|
11
|
+
content_tag :li, class: ('active' if options[:active]) do
|
12
|
+
link_to "##{options[:anchor]}", data: { toggle: 'tab' } do
|
13
|
+
yield
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def render_panes_wrapper(options)
|
19
|
+
content_class = 'tab-content'
|
20
|
+
content_class << " #{options[:content_class]}" if options[:content_class]
|
21
|
+
|
22
|
+
content_tag :div, class: content_class do
|
23
|
+
yield
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def render_pane(tab)
|
28
|
+
options = tab.options
|
29
|
+
pane_class = 'tab-pane'
|
30
|
+
pane_class << ' active' if options[:active]
|
31
|
+
content_tag :div, id: options[:anchor].to_s, class: pane_class do
|
32
|
+
yield
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module RailsBootstrapTabs::Renderers
|
2
|
+
class TabsBootstrap4Renderer < TabsRenderer
|
3
|
+
def render_tabs_wrapper
|
4
|
+
content_tag :ul, class: 'nav nav-tabs' do
|
5
|
+
yield
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def render_tab(tab)
|
10
|
+
options = tab.options
|
11
|
+
link_class = 'nav-link'
|
12
|
+
link_class << ' active' if options[:active]
|
13
|
+
content_tag :li, class: 'nav-item' do
|
14
|
+
link_to "##{options[:anchor]}", data: { toggle: 'tab' }, class: link_class do
|
15
|
+
yield
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_panes_wrapper(options)
|
21
|
+
content_class = 'tab-content'
|
22
|
+
content_class << " #{options[:content_class]}" if options[:content_class]
|
23
|
+
|
24
|
+
content_tag :div, class: content_class do
|
25
|
+
yield
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def render_pane(tab)
|
30
|
+
options = tab.options
|
31
|
+
pane_class = 'tab-pane'
|
32
|
+
pane_class << ' active' if options[:active]
|
33
|
+
if options[:fade_effect]
|
34
|
+
pane_class << ' fade'
|
35
|
+
pane_class << ' show' if options[:active]
|
36
|
+
pane_class << ' in' unless options[:active]
|
37
|
+
end
|
38
|
+
content_tag :div, id: options[:anchor].to_s, class: pane_class, role: 'tabpanel' do
|
39
|
+
yield
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -21,6 +21,7 @@ module RailsBootstrapTabs::Renderers
|
|
21
21
|
def prepare_tabs
|
22
22
|
@tabs.each.with_index do |tab, index|
|
23
23
|
tab.options[:anchor] ||= "tab-#{index}-#{rstr}"
|
24
|
+
tab.options[:fade_effect] ||= RailsBootstrapTabs.fade_effect || @options[:fade_effect]
|
24
25
|
end
|
25
26
|
active_tab = @tabs.find { |t| t.options[:active] }
|
26
27
|
active_tab ||= @tabs.first
|
@@ -29,32 +30,41 @@ module RailsBootstrapTabs::Renderers
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def render_tabs(tabs)
|
32
|
-
|
33
|
+
render_tabs_wrapper do
|
33
34
|
tabs.map do |tab|
|
34
|
-
|
35
|
-
|
36
|
-
link_to tab.name, "##{options[:anchor]}", data: { toggle: 'tab' }
|
35
|
+
render_tab(tab) do
|
36
|
+
tab.name
|
37
37
|
end
|
38
38
|
end.join("\n").html_safe
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
def render_panes(tabs, options)
|
43
|
-
|
44
|
-
content_class << " #{options[:content_class]}" if options[:content_class]
|
45
|
-
|
46
|
-
content_tag :div, class: content_class do
|
43
|
+
render_panes_wrapper(options) do
|
47
44
|
tabs.map do |tab|
|
48
|
-
|
49
|
-
pane_class = 'tab-pane'
|
50
|
-
pane_class << ' active' if options[:active]
|
51
|
-
content_tag :div, id: options[:anchor].to_s, class: pane_class do
|
45
|
+
render_pane(tab) do
|
52
46
|
tab.block.call if tab.block
|
53
47
|
end
|
54
48
|
end.join("\n").html_safe
|
55
49
|
end
|
56
50
|
end
|
57
51
|
|
52
|
+
def render_tabs_wrapper
|
53
|
+
raise "Must be redefined"
|
54
|
+
end
|
55
|
+
|
56
|
+
def render_tab(tab)
|
57
|
+
raise "Must be redefined"
|
58
|
+
end
|
59
|
+
|
60
|
+
def render_panes_wrapper(options)
|
61
|
+
raise "Must be redefined"
|
62
|
+
end
|
63
|
+
|
64
|
+
def render_pane(tab)
|
65
|
+
raise "Must be redefined"
|
66
|
+
end
|
67
|
+
|
58
68
|
def tab(name, options, &block)
|
59
69
|
@tabs << Tab.new(name, options, block)
|
60
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-bootstrap-tabs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Reshetnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -34,6 +34,8 @@ files:
|
|
34
34
|
- lib/rails-bootstrap-tabs.rb
|
35
35
|
- lib/rails-bootstrap-tabs/helpers/tabs_helper.rb
|
36
36
|
- lib/rails-bootstrap-tabs/rails/engine.rb
|
37
|
+
- lib/rails-bootstrap-tabs/renderers/tabs_bootstrap3_renderer.rb
|
38
|
+
- lib/rails-bootstrap-tabs/renderers/tabs_bootstrap4_renderer.rb
|
37
39
|
- lib/rails-bootstrap-tabs/renderers/tabs_renderer.rb
|
38
40
|
- lib/rails-bootstrap-tabs/version.rb
|
39
41
|
homepage: https://github.com/resivalex/rails-bootstrap-tabs
|
@@ -56,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
58
|
version: '0'
|
57
59
|
requirements: []
|
58
60
|
rubyforge_project:
|
59
|
-
rubygems_version: 2.
|
61
|
+
rubygems_version: 2.6.12
|
60
62
|
signing_key:
|
61
63
|
specification_version: 4
|
62
64
|
summary: A Rails plugin to build bootstrap tabs
|