mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-05 00:57:59 +01:00
28 lines
779 B
TypeScript
28 lines
779 B
TypeScript
import { assertNotNull } from './utils/assert';
|
|
import { $ } from './utils/dom';
|
|
import { inputDuplicatorCreator } from './input-duplicator';
|
|
import '../types/ujs';
|
|
|
|
function setupInputs() {
|
|
inputDuplicatorCreator({
|
|
addButtonSelector: '.js-image-add-source',
|
|
fieldSelector: '.js-image-source',
|
|
maxInputCountSelector: '.js-max-source-count',
|
|
removeButtonSelector: '.js-source-remove',
|
|
});
|
|
}
|
|
|
|
export function imageSourcesCreator() {
|
|
setupInputs();
|
|
|
|
document.addEventListener('fetchcomplete', ({ target, detail }) => {
|
|
if (target.matches('#source-form')) {
|
|
const sourceSauce = assertNotNull($<HTMLElement>('.js-sourcesauce'));
|
|
|
|
detail.text().then(text => {
|
|
sourceSauce.outerHTML = text;
|
|
setupInputs();
|
|
});
|
|
}
|
|
});
|
|
}
|