adt-js-components 1.3.2 → 1.3.4
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.
- package/package.json +1 -1
- package/src/ComponentLoader.js +2 -2
- package/src/Select2/index.js +4 -0
- package/src/SubmitForm/index.js +17 -14
package/package.json
CHANGED
package/src/ComponentLoader.js
CHANGED
|
@@ -21,12 +21,12 @@ const init = (selector, path) => {
|
|
|
21
21
|
|
|
22
22
|
if (path.includes('/')) {
|
|
23
23
|
import('JsComponents/' + path + '/index.js').then(component => {
|
|
24
|
-
component.default.run(componentsConfig[selector] || {}
|
|
24
|
+
component.default.run(componentsConfig[selector] || {});
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
} else {
|
|
28
28
|
import('adt-js-components/src/' + path + '/index.js').then(component => {
|
|
29
|
-
component.default.run(componentsConfig[selector] || {}
|
|
29
|
+
component.default.run(componentsConfig[selector] || {});
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
});
|
package/src/Select2/index.js
CHANGED
|
@@ -10,6 +10,10 @@ function run(options) {
|
|
|
10
10
|
// musí zde být defaultní jazyk "en", pokud zde nebyl a byla importována čeština.. tak se i bez poslání json params nastavila čeština
|
|
11
11
|
$(this).select2($.extend({theme: 'bootstrap-5', language: "en"}, $(this).data('adt-select2') || {}));
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
$el.find('[data-adt-select2]').on('change', function(e) {
|
|
15
|
+
Nette.toggleForm($(e.currentTarget).closest('form')[0], e.currentTarget);
|
|
16
|
+
});
|
|
13
17
|
});
|
|
14
18
|
}
|
|
15
19
|
|
package/src/SubmitForm/index.js
CHANGED
|
@@ -21,10 +21,9 @@ function scrollToFirstError(form) {
|
|
|
21
21
|
scrollParent.scrollBy({top: el.getBoundingClientRect().top - 100, behavior: 'smooth'});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function run(options) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
$el.find('input, textarea, select').on('input', function(e) {
|
|
24
|
+
function run(options, $el) {
|
|
25
|
+
function applyEventHandlers(el) {
|
|
26
|
+
$(this).find('input, textarea, select').on('input', function(e) {
|
|
28
27
|
this.classList.remove('is-invalid');
|
|
29
28
|
if (isList(this)) {
|
|
30
29
|
$(this).parent().parent().find('.is-invalid').removeClass('is-invalid');
|
|
@@ -32,19 +31,23 @@ function run(options) {
|
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
$.nette.ext('live').after(function($el) {
|
|
35
|
+
$el.find('[data-adt-submit-form]').each(function(e) {
|
|
36
|
+
const observer = new MutationObserver(function(mutationsList, observer) {
|
|
37
|
+
mutationsList.forEach(function(mutation) {
|
|
38
|
+
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
|
|
39
|
+
$(mutation.addedNodes).each(function() {
|
|
40
|
+
applyEventHandlers(this);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
40
43
|
});
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
+
});
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
observer.observe(this, { childList: true, subtree: true });
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
applyEventHandlers(this);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
48
51
|
|
|
49
52
|
if (typeof Nette !== "undefined") {
|
|
50
53
|
Nette.showFormErrors = function(form, errors) {
|