adt-js-components 1.6.0 → 1.6.2
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/AjaxSelect/index.js +26 -6
- package/src/Replicator/index.js +8 -4
- package/src/Select2/index.js +1 -1
package/package.json
CHANGED
package/src/AjaxSelect/index.js
CHANGED
|
@@ -107,16 +107,36 @@ function run(options) {
|
|
|
107
107
|
this.$originalElement.select2('destroy');
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
$
|
|
112
|
-
|
|
110
|
+
function applyEventHandlers(el) {
|
|
111
|
+
new AjaxSelect($(el));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const observer = new MutationObserver(mutations => {
|
|
115
|
+
mutations.forEach(mutation => {
|
|
116
|
+
if (mutation.type === "childList") {
|
|
117
|
+
mutation.addedNodes.forEach(node => {
|
|
118
|
+
if (node.nodeType === 1) {
|
|
119
|
+
if (node.hasAttribute("data-adt-ajax-select")) {
|
|
120
|
+
applyEventHandlers(node);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
node.querySelectorAll('[data-adt-ajax-select]').forEach(child => {
|
|
124
|
+
applyEventHandlers(child);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
113
129
|
});
|
|
114
|
-
};
|
|
130
|
+
});
|
|
115
131
|
|
|
116
|
-
|
|
117
|
-
|
|
132
|
+
observer.observe(document.body, {
|
|
133
|
+
childList: true,
|
|
134
|
+
subtree: true,
|
|
118
135
|
});
|
|
119
136
|
|
|
137
|
+
document.querySelectorAll('[data-adt-ajax-select]').forEach(function(el) {
|
|
138
|
+
applyEventHandlers(el);
|
|
139
|
+
});
|
|
120
140
|
}
|
|
121
141
|
|
|
122
142
|
export default { run }
|
package/src/Replicator/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
async function run(options) {
|
|
2
|
-
console.log('xxx');
|
|
3
2
|
function applyEventHandlers(el) {
|
|
4
|
-
console.log('yyy');
|
|
5
3
|
$(el).formReplicator({
|
|
6
4
|
template: $.parseHTML($(el).attr('data-adt-replicator')),
|
|
7
5
|
addStaticButton: $(el).find('[data-adt-replicator-add]'),
|
|
@@ -13,8 +11,14 @@ async function run(options) {
|
|
|
13
11
|
mutations.forEach(mutation => {
|
|
14
12
|
if (mutation.type === "childList") {
|
|
15
13
|
mutation.addedNodes.forEach(node => {
|
|
16
|
-
if (node.nodeType === 1
|
|
17
|
-
|
|
14
|
+
if (node.nodeType === 1) {
|
|
15
|
+
if (node.hasAttribute("data-adt-replicator")) {
|
|
16
|
+
applyEventHandlers(node);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
node.querySelectorAll('[data-adt-replicator]').forEach(child => {
|
|
20
|
+
applyEventHandlers(child);
|
|
21
|
+
});
|
|
18
22
|
}
|
|
19
23
|
});
|
|
20
24
|
}
|
package/src/Select2/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import 'select2/dist/js/i18n/cs'
|
|
|
6
6
|
function run(options) {
|
|
7
7
|
function applyEventHandlers(el) {
|
|
8
8
|
$(el)
|
|
9
|
-
.select2($.extend({theme: 'bootstrap-5', language: "en"}, $(
|
|
9
|
+
.select2($.extend({theme: 'bootstrap-5', language: "en"}, $(el).data('adt-select2') || {}))
|
|
10
10
|
.on('change', function(e) {
|
|
11
11
|
Nette.toggleForm($(e.currentTarget).closest('form')[0], e.currentTarget);
|
|
12
12
|
});
|