Initial commit: is_imageslider out of the box. v2.3.2
This commit is contained in:
35
is_imageslider/views/js/createForm.js
Normal file
35
is_imageslider/views/js/createForm.js
Normal file
@ -0,0 +1,35 @@
|
||||
$(document).ready(function () {
|
||||
handleFileInputChange();
|
||||
|
||||
window.prestashop.component.initComponents(
|
||||
[
|
||||
'TranslatableField',
|
||||
'TinyMCEEditor',
|
||||
'TranslatableInput',
|
||||
],
|
||||
);
|
||||
|
||||
const choiceTree = new window.prestashop.component.ChoiceTree('#image_slider_shop_association');
|
||||
choiceTree.enableAutoCheckChildren();
|
||||
});
|
||||
|
||||
|
||||
function handleFileInputChange() {
|
||||
const $fileInput = $('#image_slider [type="file"]');
|
||||
|
||||
$fileInput.on('change', (e) => {
|
||||
const $input = $(e.currentTarget);
|
||||
const $relatedImage = $(`[data-related-field="${$input.attr('id')}"]`);
|
||||
const files = $input[0].files;
|
||||
|
||||
if (FileReader && files && files.length) {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function () {
|
||||
$relatedImage.attr('src', reader.result)
|
||||
}
|
||||
|
||||
reader.readAsDataURL(files[0]);
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user