bootstrap3_helper 1.0.0 → 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
  SHA256:
3
- metadata.gz: 7690ea3af6632902048f7f389e97a9c2317e007c6dab849b754fabe805a7357e
4
- data.tar.gz: 2c8234630ce566f379f1d1a46d9ab7e47e958c3b1059df4aa41a0003a27700bc
3
+ metadata.gz: 74e356782b2f424f78b9bd3731009d7ba7a1492a392e782c5cade487ea765a26
4
+ data.tar.gz: 7a8fb76f39fa53b9bdcebf6542239c58448e8caa88b725b5f47c4255ad31d80f
5
5
  SHA512:
6
- metadata.gz: d54b3740ae4f7bd45adcea82506ebe65fae16dcca0837c42e83ada33480c67053acaee9112ffe7029283d2d4babe71d0cfbe9183e97b8d30e886527fd2cf70e5
7
- data.tar.gz: 5e42f3ff987c0e32aa5f2b5dd94c744abc7d4afbadeb41ee17da5b1cfd64b5975a123aa4d3d135e9dd2871fa9abd1ee3ec7d6862cd41d53a8bc41ece2e9a6ea8
6
+ metadata.gz: 71bad603e6cf3834f68c6f216e1dcc3c0b0e88f76ef4a44c05bc9f101d4eba4271a9312caee0500ae2e317e35485ee9fdd214dc807c4d42422eb9a4acc090c20
7
+ data.tar.gz: 8f062f014b468ba1b8fb916666556a69b3ddb03cfa9e024738babe7480ffcb4ad55f3507672d69b98abcb55251c4d3ae664f6055bbca1cf2c7de9d21440fb632
@@ -67,16 +67,27 @@ module Bootstrap3Helper
67
67
  #
68
68
  # rubocop:disable Metrics/MethodLength
69
69
  def header(args = {})
70
- id = args.fetch(:id, nil)
71
- klass = args.fetch(:class, '')
72
- data = args.fetch(:data, {})
70
+ id = args.fetch(:id, nil)
71
+ klass = args.fetch(:class, '')
72
+ data = args.fetch(:data, {})
73
73
 
74
74
  data[:toggle] = 'collapse'
75
75
  data[:parent] = "##{@parent_id}"
76
76
 
77
- @header = content_tag :div, id: id, class: 'panel-heading ' + klass do
77
+ @header = content_tag(
78
+ :div,
79
+ id: id,
80
+ role: 'tab',
81
+ class: 'panel-heading ' + klass
82
+ ) do
78
83
  content_tag :h3, class: 'panel-title' do
79
- content_tag :a, href: "##{@collapse_id}", data: data do
84
+ content_tag(
85
+ :a,
86
+ href: "##{@collapse_id}",
87
+ role: 'button',
88
+ data: data,
89
+ aria: { expanded: @expanded, controls: "##{@collapse_id}" }
90
+ ) do
80
91
  content = yield if block_given?
81
92
  content.to_s.html_safe
82
93
  end
@@ -104,19 +115,27 @@ module Bootstrap3Helper
104
115
  # @return [nilClass]
105
116
  #
106
117
  #
118
+ # rubocop:disable Metrics/MethodLength
107
119
  def body(args = {})
108
120
  klass = 'panel-collapse collapse '
109
121
  data = args.fetch(:data, {})
110
122
  klass += args.fetch(:class, '')
111
123
  klass += ' in' if @expanded
112
124
 
113
- @body = content_tag :div, id: @collapse_id, class: klass do
125
+ @body = content_tag(
126
+ :div,
127
+ id: @collapse_id,
128
+ role: 'tabpanel',
129
+ class: klass,
130
+ aria: { labelledby: "##{@collapse_id}" }
131
+ ) do
114
132
  content_tag :div, class: 'panel-body', data: data do
115
133
  content = yield if block_given?
116
134
  content.to_s.html_safe
117
135
  end
118
136
  end
119
137
  end
138
+ # rubocop:enable Metrics/MethodLength
120
139
 
121
140
  # @description
122
141
  # - Creates the footer element for the accordion
@@ -40,10 +40,19 @@ module Bootstrap3Helper
40
40
  # </code>
41
41
  #
42
42
  def item(name, args = {})
43
- data = args.fetch(:data, nil)
44
- klass = args.fetch(:class, '')
43
+ data = args.fetch(:data, nil)
44
+ klass = args.fetch(:class, '')
45
+ active = klass.include? 'active'
45
46
 
46
- content = content_tag :div, id: name, class: 'tab-pane ' + klass, data: data, role: 'tabpanel' do
47
+ content = content_tag(
48
+ :div,
49
+ id: name,
50
+ class: "tab-pane fade #{active ? 'in' : ''} #{klass}",
51
+ aria: { hidden: active },
52
+ data: data,
53
+ role: 'tabpanel',
54
+ tabindex: -1
55
+ ) do
47
56
  yield if block_given?
48
57
  end
49
58
 
@@ -44,19 +44,33 @@ module Bootstrap3Helper
44
44
  # }
45
45
  # </code>
46
46
  #
47
+ # rubocop:disable Metrics/MethodLength
47
48
  def item(name, args = {})
48
- id = args.fetch(:id, nil)
49
- klass = args.fetch(:class, '')
50
- data = args.fetch(:data, nil)
49
+ id = args.fetch(:id, nil)
50
+ klass = args.fetch(:class, '')
51
+ data = args.fetch(:data, nil)
52
+ active = klass.include? 'active'
51
53
 
52
- li = content_tag :li, id: id, class: klass, data: data do
53
- content_tag :a, href: "##{name}", role: 'tab', data: { toggle: 'tab' }, aria: { controls: name, expanded: false } do
54
+ li = content_tag(
55
+ :li,
56
+ id: id,
57
+ class: klass,
58
+ data: data
59
+ ) do
60
+ content_tag(
61
+ :a,
62
+ href: "##{name}",
63
+ role: 'tab',
64
+ data: { toggle: 'tab' },
65
+ aria: { controls: name, expanded: active }
66
+ ) do
54
67
  block_given? ? yield : name.to_s.titleize
55
68
  end
56
69
  end
57
70
 
58
71
  @items.push(li)
59
72
  end
73
+ # rubocop:enable Metrics/MethodLength
60
74
 
61
75
  # @description
62
76
  # - Used to render out the object and get the HTML representation.
@@ -50,19 +50,35 @@ module Bootstrap3Helper
50
50
  # }
51
51
  # </code>
52
52
  #
53
+ # rubocop:disable Metrics/MethodLength
53
54
  def item(name, args = {})
54
- id = args.fetch(:id, nil)
55
- data = args.fetch(:data, nil)
56
- klass = args.fetch(:class, '')
55
+ id = args.fetch(:id, nil)
56
+ data = args.fetch(:data, nil)
57
+ klass = args.fetch(:class, '')
58
+ active = klass.include? 'active'
57
59
 
58
- li = content_tag :li, id: id, class: klass, data: data, role: 'presentation' do
59
- content_tag :a, href: "##{name}", data: { toggle: 'tab' }, aria: { controls: '' } do
60
+ li = content_tag(
61
+ :li,
62
+ id: id,
63
+ class: klass,
64
+ data: data,
65
+ role: 'presentation'
66
+ ) do
67
+ content_tag(
68
+ :a,
69
+ href: "##{name}",
70
+ role: 'tab',
71
+ tabindex: -1,
72
+ data: { toggle: 'tab' },
73
+ aria: { controls: "##{name}", expanded: active, selected: active }
74
+ ) do
60
75
  block_given? ? yield : name.to_s.titleize
61
76
  end
62
77
  end
63
78
 
64
79
  @items.push(li)
65
80
  end
81
+ # rubocop:enable Metrics/MethodLength
66
82
 
67
83
  # @description
68
84
  # - Used to create menu items that are Dropdowns
@@ -1,3 +1,3 @@
1
1
  module Bootstrap3Helper
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
@@ -162,8 +162,8 @@ module Bootstrap3Helper
162
162
  #
163
163
  # @param [String|Symbol] name
164
164
  #
165
- def icon_helper(name = '')
166
- content_tag :span, '', class: 'glyphicon glyphicon-' + name.to_s
165
+ def icon_helper(name)
166
+ content_tag :span, '', class: "glyphicon glyphicon-#{name}"
167
167
  end
168
168
 
169
169
  # @description
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap3_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert David
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-04 00:00:00.000000000 Z
11
+ date: 2019-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -118,7 +118,7 @@ files:
118
118
  - lib/bootstrap3_helper/tabs/menu.rb
119
119
  - lib/bootstrap3_helper/version.rb
120
120
  - lib/tasks/bootstrap3_helper_tasks.rake
121
- homepage: https://github.com/rdavid369/bootstrap3-helper/blob/master/lib/bootstrap3_helper.rb
121
+ homepage: https://github.com/rdavid369/bootstrap3-helper
122
122
  licenses:
123
123
  - MIT
124
124
  metadata: {}