rails-bootstrap-tabs 0.2.0 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b53b4afa84fd1f6157955b98548c4c013351aaf2
4
- data.tar.gz: aa9afc668ceaade23c10a1e0e19bd8de54184535
2
+ SHA256:
3
+ metadata.gz: 0c51419b342fc09fc1fbdbf5fe3eeafff572dda98651851d699cd9a6f5c9ae30
4
+ data.tar.gz: 0b1b7d81087af4f222e417f985acd3ad94ce6bec2b0d7f58df95bb880f15ca7e
5
5
  SHA512:
6
- metadata.gz: 1bb500380c7bcd7f18b2bdf30ced28003dcdb10597bea6c6b205c0e100c7a0157d22db0a41c2f21093116d1811751ecbbfdd6d4a616957041445d0d45b0d43fb
7
- data.tar.gz: 22e8369fce286b8ac46b385da53f06672a8117b439f1c6db027b2efd0af5a5e57b66c53a3971caa957c64095dad05e8c95b72a647e547e3e9d39a6b62041c994
6
+ metadata.gz: '0555693dc97f1a3a98d80861f37ef837a62a1372adbc7bbc08dea44b8f6ea1757e30aea3488cf58bb8611759a75581d52e43a98db4dcfe35081ae542f210b4ab'
7
+ data.tar.gz: 6e7113b6ef0fccef9fca7c7d9d04ffa12b66b40c9086932e1c6df90df8e6cc6fe95655701265d9f16a7b347a6039c72f088c8d11bb9cf40e4ed61b98d4d85f2d
@@ -3,6 +3,7 @@ require 'rails-bootstrap-tabs/helpers/tabs_helper'
3
3
  module RailsBootstrapTabs
4
4
  mattr_accessor :bootstrap_version do; 3; end
5
5
  mattr_accessor :fade_effect do; false; end
6
+ mattr_accessor :nav_markup do; false; end
6
7
 
7
8
  module Rails
8
9
  class Engine < ::Rails::Engine
@@ -9,7 +9,7 @@ module RailsBootstrapTabs::Renderers
9
9
  def render_tab(tab)
10
10
  options = tab.options
11
11
  content_tag :li, class: ('active' if options[:active]) do
12
- link_to "##{options[:anchor]}", data: { toggle: 'tab' } do
12
+ link_to "##{options[:anchor]}", class: (options[:link_class] if options[:link_class]), data: { toggle: 'tab' } do
13
13
  yield
14
14
  end
15
15
  end
@@ -1,8 +1,14 @@
1
1
  module RailsBootstrapTabs::Renderers
2
2
  class TabsBootstrap4Renderer < TabsRenderer
3
3
  def render_tabs_wrapper
4
- content_tag :ul, class: 'nav nav-tabs' do
5
- yield
4
+ if @options[:nav_markup]
5
+ content_tag :nav, class: 'nav nav-tabs' do
6
+ yield
7
+ end
8
+ else
9
+ content_tag :ul, class: 'nav nav-tabs' do
10
+ yield
11
+ end
6
12
  end
7
13
  end
8
14
 
@@ -10,10 +16,17 @@ module RailsBootstrapTabs::Renderers
10
16
  options = tab.options
11
17
  link_class = 'nav-link'
12
18
  link_class << ' active' if options[:active]
13
- content_tag :li, class: 'nav-item' do
19
+ link_class << " #{options[:link_class]}" if options[:link_class]
20
+ if options[:nav_markup]
14
21
  link_to "##{options[:anchor]}", data: { toggle: 'tab' }, class: link_class do
15
22
  yield
16
23
  end
24
+ else
25
+ content_tag :li, class: 'nav-item' do
26
+ link_to "##{options[:anchor]}", data: { toggle: 'tab' }, class: link_class do
27
+ yield
28
+ end
29
+ end
17
30
  end
18
31
  end
19
32
 
@@ -8,8 +8,9 @@ module RailsBootstrapTabs::Renderers
8
8
  @tabs = []
9
9
  end
10
10
 
11
- def rstr
12
- (0...8).map { ('a'.ord + rand(26)).chr }.join
11
+ def rstr(seed)
12
+ rnd = Random.new(seed)
13
+ (0...8).map { ('a'.ord + rnd.rand(26)).chr }.join
13
14
  end
14
15
 
15
16
  def render
@@ -20,8 +21,21 @@ module RailsBootstrapTabs::Renderers
20
21
 
21
22
  def prepare_tabs
22
23
  @tabs.each.with_index do |tab, index|
23
- tab.options[:anchor] ||= "tab-#{index}-#{rstr}"
24
- tab.options[:fade_effect] ||= RailsBootstrapTabs.fade_effect || @options[:fade_effect]
24
+ tab.options[:anchor] ||= "tab-#{index}-#{rstr(index)}"
25
+ if tab.options[:fade_effect].nil?
26
+ if @options.key?(:fade_effect)
27
+ tab.options[:fade_effect] = @options[:fade_effect]
28
+ else
29
+ tab.options[:fade_effect] = RailsBootstrapTabs.fade_effect
30
+ end
31
+ end
32
+ if tab.options[:nav_markup].nil?
33
+ if @options.key?(:nav_markup)
34
+ tab.options[:nav_markup] = @options[:nav_markup]
35
+ else
36
+ tab.options[:nav_markup] = RailsBootstrapTabs.nav_markup
37
+ end
38
+ end
25
39
  end
26
40
  active_tab = @tabs.find { |t| t.options[:active] }
27
41
  active_tab ||= @tabs.first
@@ -1,3 +1,3 @@
1
1
  module RailsBootstrapTabs
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.5'.freeze
3
3
  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.2.0
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Reshetnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-29 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,26 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.11
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.6.0
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.6.0
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: 3.6.0
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 3.6.0
27
47
  description: A Rails plugin to build bootstrap tabs
28
48
  email:
29
49
  - resivalex@gmail.com
@@ -58,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
78
  version: '0'
59
79
  requirements: []
60
80
  rubyforge_project:
61
- rubygems_version: 2.6.12
81
+ rubygems_version: 2.7.7
62
82
  signing_key:
63
83
  specification_version: 4
64
84
  summary: A Rails plugin to build bootstrap tabs