import MediaPicker from './MediaPicker'; export default class { constructor() { $('.image-picker').on('click', (e) => { this.pickImage(e); }); this.sortable(); this.removeImageEventListener(); } pickImage(e) { let inputName = e.currentTarget.dataset.inputName; let multiple = e.currentTarget.hasAttribute('data-multiple'); let picker = new MediaPicker({ type: 'image', multiple }); picker.on('select', (file) => { this.addImage(inputName, file, multiple, e.currentTarget); }); } addImage(inputName, file, multiple, target) { let html = this.getTemplate(inputName, file); if (multiple) { let multipleImagesWrapper = $(target).next('.multiple-images'); multipleImagesWrapper.find('.image-holder.placeholder').remove(); multipleImagesWrapper.find('.image-list').append(html); } else { $(target).siblings('.single-image').html(html); } } getTemplate(inputName, file) { return $(`