2021-10-10 00:50:57 +02:00
|
|
|
import { inputDuplicatorCreator } from './input-duplicator';
|
|
|
|
|
2024-03-24 16:44:48 +01:00
|
|
|
function setupInputs() {
|
2021-10-10 00:50:57 +02:00
|
|
|
inputDuplicatorCreator({
|
|
|
|
addButtonSelector: '.js-image-add-source',
|
|
|
|
fieldSelector: '.js-image-source',
|
|
|
|
maxInputCountSelector: '.js-max-source-count',
|
|
|
|
removeButtonSelector: '.js-source-remove',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-03-24 16:44:48 +01:00
|
|
|
function imageSourcesCreator() {
|
|
|
|
setupInputs();
|
|
|
|
document.addEventListener('fetchcomplete', ({ target, detail }) => {
|
|
|
|
const sourceSauce = document.querySelector('.js-sourcesauce');
|
|
|
|
|
|
|
|
if (target.matches('#source-form')) {
|
|
|
|
detail.text().then(text => {
|
|
|
|
sourceSauce.outerHTML = text;
|
|
|
|
setupInputs();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-10-10 00:50:57 +02:00
|
|
|
export { imageSourcesCreator };
|