rails-bootstrap-tabs 0.2.1 → 0.2.6

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: aa6a1a3802a03c8201ffc5ac76374c4f4ab348ca
4
- data.tar.gz: 47c52dc3612df4bb555abf7c30083963f6a24c8b
2
+ SHA256:
3
+ metadata.gz: a6f78efb3cdc927ca42ae910a5210f8899da6ab8e4061ce34adb916b4d35f561
4
+ data.tar.gz: de1b46a7967da3780826e6c2e5d0b57cf364ed73beee6cfd1d15fac97467e65e
5
5
  SHA512:
6
- metadata.gz: 86855c5dfa0aad5caae3aeb4f56f469f61f43fd40a6478cb861293cbc336320ab612ab3b7019df36351d9c79b81cb810e34bde97c921687a27a4306026b759e2
7
- data.tar.gz: e80dd1b445b0bb76633cb0476ce29cb79a73fca3bce0fdb2627808fc1646036951f60f3b3a7b88ee42a3d7050d66116c960a90a30f6537e11e9b71c9be4d74ae
6
+ metadata.gz: 16fb29aec485fba4df89f9531323a054c9d772e4171b3c2559deab8d261eb8e24da503377c5068da359710dbc7918da8de74d28306ba2b79c8e68569b2aa771b
7
+ data.tar.gz: b1532b2c22b7e3a1e32e0d5f7fa2ff752c01a4dc49f0c065bdbcecc57d8e1a02f28a350c4abb60a1a825d5df08a77ce42b43bf041576eb6ef2d70a8e4c07b73e
@@ -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]}", class: "#{options[:link_class]}", 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,19 @@ 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
14
- link_to "##{options[:anchor]}", class: "#{options[:link_class]}", data: { toggle: 'tab' }, class: link_class do
19
+ link_class << " #{options[:link_class]}" if options[:link_class]
20
+ li_class = 'nav-item'
21
+ li_class << ' active' if options[:active]
22
+ if options[:nav_markup]
23
+ link_to "##{options[:anchor]}", data: { toggle: 'tab' }, class: link_class do
15
24
  yield
16
25
  end
26
+ else
27
+ content_tag :li, class: li_class do
28
+ link_to "##{options[:anchor]}", data: { toggle: 'tab' }, class: link_class do
29
+ yield
30
+ end
31
+ end
17
32
  end
18
33
  end
19
34
 
@@ -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.1'.freeze
2
+ VERSION = '0.2.6'.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.1
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Reshetnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-08 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.11
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