effective_bootstrap 1.14.5 → 1.14.7

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: 3830b85eac4d17ee79fa420b2ed161c4bb395e19a116978cf6b942ce3e11b1ff
4
- data.tar.gz: 7763c6ec3e664a607dced1038438479ebdcaf412dfc9ffe20bfcded55f3e7d88
3
+ metadata.gz: a5dab8378d10d23707e36538dda751cc0a3d8ca0221593f63d1f612b826099d0
4
+ data.tar.gz: 665eae25b98123231859e04b44c88430c68db4e65cf7f0c32328e45b9164ba1f
5
5
  SHA512:
6
- metadata.gz: 32cfd50d13eae43a044af215634ff38c5cd2dd09bf6a05ef415c2312d95c6239c70e41067f8b9295f1040735096b42b45d1e1440c48cd9ab3c462166c32c3cb4
7
- data.tar.gz: 3b7afe371608c0388ff14a38b1a3d260f49e35486db1692da31d490fb04876486565fc87d835ee13fa8c3c77330d96525f93ad2aae6e8b88b6a8b9c95d0db86c
6
+ metadata.gz: 582d4816ada40d49a88b1920ac3b04bdf206ab6f634d1b4b92a2892fdf2c645c860b6bf5228a80abd944715fb0fa0d163c3929667479bd5eb561c6e11f141156
7
+ data.tar.gz: de7c3e442e442af4d9b2689a224644d6065fbdf6d74a99cdef1293ed093cc8978f2fdbec8932cea5e84a80c7fb5cb40aec53c9bf5f5e7567e0ba94876b7760b8
@@ -15,7 +15,12 @@ $(document).on('change', "[data-load-ajax-url][data-load-ajax-div]", function(ev
15
15
  let value = ($input.val() || '');
16
16
  if(value.length == 0) { $container.html(''); return; }
17
17
 
18
- url = (url + '?' + name + '=' + value);
18
+ let joiner = (url.indexOf('?') == -1 ? '?' : '&');
19
+
20
+ let input = {}
21
+ input[name] = value;
22
+
23
+ url = (url + joiner + $.param(input));
19
24
 
20
25
  $container.html("<div class='load-ajax-loading'><p>Loading...</p></div>");
21
26
 
@@ -27,6 +32,7 @@ $(document).on('change', "[data-load-ajax-url][data-load-ajax-div]", function(ev
27
32
  } else {
28
33
  $container.replaceWith($content.children(div));
29
34
  EffectiveBootstrap.initialize();
35
+ $(document).trigger('effective-datatables:initialize');
30
36
  }
31
37
  });
32
38
  });
@@ -1,28 +1,3 @@
1
- $(document).on 'change', '[data-toggle=cards] input[type=radio]', (event) ->
2
- $input = $(event.currentTarget)
3
- return unless $input.is(':checked')
4
-
5
- $card = $input.closest('.card')
6
- return unless $card.length > 0
7
-
8
- $cards = $input.closest('.card-deck').children('.card')
9
- return unless $cards.length > 0
10
-
11
- $cards.removeClass('active').removeClass('border-secondary')
12
- $cards.find('.card-header').removeClass('bg-secondary text-white')
13
-
14
- $card.addClass('active').addClass('border-secondary')
15
- $card.find('.card-header').addClass('bg-secondary text-white')
16
- true
17
-
18
- $(document).on 'click', '[data-toggle=cards] [data-toggle=card]', (event) ->
19
- $card = $(event.currentTarget).closest('.card')
20
- return unless $card.length > 0
21
-
22
- val = $card.find('input:radio').val()
23
- $card.find('input:radio').val([val]).trigger('change')
24
- false
25
-
26
1
  $(document).on 'change', '.effective-radios input', (event) ->
27
2
  $input = $(event.currentTarget)
28
3
  $group = $input.closest('.effective-radios')
@@ -5,25 +5,34 @@ div.btn-group > .btn.first-button {
5
5
 
6
6
  .effective-radios.is-valid {
7
7
  label { border-color: #28a745; }
8
+ .card { border-color: #28a745; }
8
9
  .valid-feedback { display: block; }
9
10
  }
10
11
 
11
12
  .effective-radios.is-invalid {
12
13
  label { border-color: #dc3545; }
14
+ .card { border-color: #dc3545; }
13
15
  .invalid-feedback { display: block; }
14
16
  }
15
17
 
16
- .effective-radios.card-deck {
17
- .card-header { cursor: pointer; }
18
+ .effective-radios.cards {
19
+ .card {
20
+ cursor: pointer;
21
+ }
18
22
 
19
23
  input[type=radio] { display: none; }
20
24
 
21
- .visible-when-selected { display: none; }
22
- .visible-when-unselected { display: block; }
25
+ input:checked + .card {
26
+ box-shadow: 0 0 1px 1px #0b3b61;
27
+ }
23
28
 
24
- .active {
25
- .visible-when-selected { display: block; }
26
- .visible-when-unselected { display: none; }
29
+ input:checked + .card {
30
+ .show-if-checked { display: inherit; }
31
+ .show-if-unchecked { display: none; }
27
32
  }
28
- }
29
33
 
34
+ input:not(:checked) + .card {
35
+ .show-if-checked { display: none; }
36
+ .show-if-unchecked { display: inherit; }
37
+ }
38
+ }
@@ -6,6 +6,11 @@
6
6
  # cards: true
7
7
  # custom: false
8
8
 
9
+ # For cards, you should pass an html collection like
10
+ # [[card('First Item') {...}, 'first item'], [card('Second Item') {...}, 'second item']]
11
+ # or a collection like
12
+ # [['First Item', 'first'], ['Second Item', 'second']]
13
+
9
14
  module Effective
10
15
  module FormInputs
11
16
  class Radios < CollectionInput
@@ -54,7 +59,7 @@ module Effective
54
59
  [
55
60
  'effective-radios',
56
61
  ('btn-group btn-group-toggle' if buttons?),
57
- ('card-deck' if cards?),
62
+ ('cards card-deck' if cards?),
58
63
  ('no-feedback' unless feedback_options),
59
64
  ('is-invalid' if feedback_options && has_error?(name)),
60
65
  ('is-valid' if feedback_options && has_error? && !has_error?(name))
@@ -110,21 +115,21 @@ module Effective
110
115
  builder.label(opts) { builder.radio_button(id: item_id) + builder.text }
111
116
  elsif cards?
112
117
  opts = item_label_options.merge(for: item_id)
113
- opts[:class] = [opts[:class], ('active border-secondary' if active_item?(builder)), ('first-card' if first_item?) ].compact.join(' ')
118
+ opts[:class] = [opts[:class], ('active' if active_item?(builder)), ('first-card' if first_item?) ].compact.join(' ')
114
119
 
115
- if active_item?(builder)
116
- builder.label(opts) { builder.radio_button(id: item_id) + builder.text.sub('card-header', 'card-header bg-secondary text-white').html_safe }
117
- else
118
- builder.label(opts) { builder.radio_button(id: item_id) + builder.text }
119
- end
120
+ builder.label(opts) { builder.radio_button(id: item_id) + build_item_wrap { builder.text } }
120
121
  else
121
122
  build_item_wrap { builder.radio_button(id: item_id) + builder.label(item_label_options.merge(for: item_id)) }
122
123
  end
123
124
  end
124
125
 
125
126
  def build_item_wrap(&block)
126
- if cards?
127
- content_tag(:div, yield, class: 'card')
127
+ if cards? && options_collection_includes_cards?
128
+ yield # Not required.
129
+ elsif cards?
130
+ content_tag(:div, class: 'card') do
131
+ content_tag(:div, yield, class: ('card-body' if card_body?))
132
+ end
128
133
  elsif custom?
129
134
  content_tag(:div, yield, class: 'custom-control custom-radio ' + (inline? ? 'custom-control-inline' : 'form-group'))
130
135
  else
@@ -136,11 +141,16 @@ module Effective
136
141
  options[:input].except(:inline, :custom, :buttons)
137
142
  end
138
143
 
144
+ def options_collection_includes_cards?
145
+ return @options_collection_includes_cards unless @options_collection_includes_cards.nil?
146
+ @options_collection_includes_cards = options_collection.first(3).any? { |text, _| text.to_s.include?("div class=\"card") }
147
+ end
148
+
139
149
  def item_label_options
140
150
  if buttons?
141
151
  { class: 'btn btn-outline-secondary' }
142
152
  elsif cards?
143
- { class: 'card' }
153
+ { class: 'form-card-label' }
144
154
  elsif custom?
145
155
  { class: 'custom-control-label' }
146
156
  else
@@ -158,6 +168,12 @@ module Effective
158
168
  @cards = (options.delete(:cards) || false)
159
169
  end
160
170
 
171
+ def card_body? # default true
172
+ return @card_body unless @card_body.nil?
173
+ value = options.delete(:card_body)
174
+ @card_body = (value == nil ? true : value)
175
+ end
176
+
161
177
  def button_group_id
162
178
  "#{tag_id}_btn_group"
163
179
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '1.14.5'.freeze
2
+ VERSION = '1.14.7'.freeze
3
3
  end
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: 1.14.5
4
+ version: 1.14.7
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: 2023-05-30 00:00:00.000000000 Z
11
+ date: 2023-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -737,7 +737,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
737
737
  - !ruby/object:Gem::Version
738
738
  version: '0'
739
739
  requirements: []
740
- rubygems_version: 3.1.2
740
+ rubygems_version: 3.4.10
741
741
  signing_key:
742
742
  specification_version: 4
743
743
  summary: Everything you need to get set up with bootstrap 4.