effective_bootstrap 1.21.10 → 1.21.12
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/app/assets/javascripts/effective_bootstrap/form.js.coffee +15 -1
- data/app/assets/javascripts/effective_bootstrap/load_ajax.js +21 -4
- data/app/assets/javascripts/effective_checks/initialize.js.coffee +6 -0
- data/app/assets/stylesheets/effective_checks/input.scss +4 -0
- data/app/models/effective/form_inputs/checks.rb +1 -0
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '098b79e69adfe45fcc2671c1e161140af169be00107334cfefb192ecb91c6c80'
|
|
4
|
+
data.tar.gz: c6edeb24c66ade6cc2c3b7f0f7fc20d1e5e5896c97a8366b61c0eecd7e69143d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 31c88afee8a96797991413c9b244aee65574246e6776cbd5611cc1570a817cadc155e2851b897ae2c80bfdc1677894de805ee1f523ad654e4d50a42fc48578ec
|
|
7
|
+
data.tar.gz: 8b8de48fbf71006eb9a369c9c7cbcb5f9757e82be458a33a2c968123be803e3ff7d30aa50049655452bb90431fbac199eb6fd1abfad4349056ba0b6631732b0f
|
|
@@ -7,8 +7,8 @@ this.EffectiveForm ||= new class
|
|
|
7
7
|
remote_form_redirect: '' # String containing the redirect path (optional)
|
|
8
8
|
|
|
9
9
|
validate: (form) ->
|
|
10
|
-
valid = form.checkValidity()
|
|
11
10
|
$form = $(form)
|
|
11
|
+
valid = form.checkValidity() && @allChecksValid($form)
|
|
12
12
|
|
|
13
13
|
@clearFlash()
|
|
14
14
|
@reset($form) if $form.hasClass('was-validated')
|
|
@@ -16,6 +16,14 @@ this.EffectiveForm ||= new class
|
|
|
16
16
|
if valid then @submitting($form) else @invalidate($form)
|
|
17
17
|
valid
|
|
18
18
|
|
|
19
|
+
allChecksValid: ($form) ->
|
|
20
|
+
valid = true
|
|
21
|
+
|
|
22
|
+
$form.find('.effective-checks-required').each ->
|
|
23
|
+
valid = false unless $(@).find('input:checked').length > 0
|
|
24
|
+
|
|
25
|
+
valid
|
|
26
|
+
|
|
19
27
|
submitting: ($form) ->
|
|
20
28
|
$form.addClass('form-is-valid').removeClass('form-is-invalid')
|
|
21
29
|
@spin()
|
|
@@ -34,6 +42,12 @@ this.EffectiveForm ||= new class
|
|
|
34
42
|
$form.find('.effective-radios:not(.no-feedback),.effective-checks:not(.no-feedback)').each ->
|
|
35
43
|
$(@).addClass(if $(@).find('input:invalid').length > 0 then 'is-invalid' else 'is-valid')
|
|
36
44
|
|
|
45
|
+
$form.find('.effective-checks-required').each ->
|
|
46
|
+
if $(@).find('input:checked').length > 0
|
|
47
|
+
$(@).addClass('is-valid').removeClass('is-invalid')
|
|
48
|
+
else
|
|
49
|
+
$(@).addClass('is-invalid').removeClass('is-valid')
|
|
50
|
+
|
|
37
51
|
@flash($form, 'danger')
|
|
38
52
|
|
|
39
53
|
disable: ($form) ->
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Implements the jQuery load div pattern
|
|
2
2
|
// See effective_reports admin screen
|
|
3
|
-
|
|
4
|
-
let $input = $(
|
|
3
|
+
function loadEffectiveAjax(target) {
|
|
4
|
+
let $input = $(target);
|
|
5
5
|
|
|
6
6
|
let url = $input.data('load-ajax-url');
|
|
7
7
|
let div = $input.data('load-ajax-div');
|
|
@@ -42,9 +42,26 @@ $(document).on('change', "[data-load-ajax-url][data-load-ajax-div]", function(ev
|
|
|
42
42
|
if(status == 'error') {
|
|
43
43
|
$container.append("<div class='load-ajax-error'><p>Error: please refresh the page and try again.</p></div>");
|
|
44
44
|
} else {
|
|
45
|
-
$container.replaceWith($content.children(div));
|
|
45
|
+
$container.replaceWith($content.children(div).first());
|
|
46
46
|
EffectiveBootstrap.initialize();
|
|
47
47
|
$(document).trigger('effective-datatables:initialize');
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function delayChange(callback, ms) {
|
|
53
|
+
var timer = 0;
|
|
54
|
+
|
|
55
|
+
return function() {
|
|
56
|
+
var context = this;
|
|
57
|
+
var args = arguments;
|
|
58
|
+
clearTimeout(timer);
|
|
59
|
+
timer = setTimeout(function() { callback.apply(context, args); }, ms || 0);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
$(document).on('change', "select[data-load-ajax-url][data-load-ajax-div]", function(event) { loadEffectiveAjax(event.currentTarget); });
|
|
64
|
+
$(document).on('reload', "[data-load-ajax-url][data-load-ajax-div]", function(event) { loadEffectiveAjax(event.currentTarget); });
|
|
65
|
+
|
|
66
|
+
$(document).on('keyup', "[data-load-ajax-url][data-load-ajax-div]", delayChange(function(event) { loadEffectiveAjax(event.target); }, 400));
|
|
67
|
+
$(document).on('paste', "[data-load-ajax-url][data-load-ajax-div]", delayChange(function(event) { loadEffectiveAjax(event.target); }, 100));
|
|
@@ -5,3 +5,9 @@ $(document).on 'click', '[data-effective-checks-all]', (event) ->
|
|
|
5
5
|
$(document).on 'click', '[data-effective-checks-none]', (event) ->
|
|
6
6
|
$(event.currentTarget).closest('.effective-checks').find('input:checkbox:enabled:not([readonly])').prop('checked', false)
|
|
7
7
|
false
|
|
8
|
+
|
|
9
|
+
$(document).on 'change', '.was-validated .effective-checks-required', (event) ->
|
|
10
|
+
if $(@).find('input:checked').length > 0
|
|
11
|
+
$(@).addClass('is-valid').removeClass('is-invalid')
|
|
12
|
+
else
|
|
13
|
+
$(@).addClass('is-invalid').removeClass('is-valid')
|
|
@@ -26,6 +26,7 @@ module Effective
|
|
|
26
26
|
def wrapper_options
|
|
27
27
|
{ class: [
|
|
28
28
|
'form-group effective-checks',
|
|
29
|
+
('effective-checks-required' if required?(name) || options[:required]),
|
|
29
30
|
('no-feedback' unless feedback_options),
|
|
30
31
|
tag_id,
|
|
31
32
|
('is-invalid' if feedback_options && has_error?(name)),
|
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.21.
|
|
4
|
+
version: 1.21.12
|
|
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:
|
|
11
|
+
date: 2026-01-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|