first upload all files
This commit is contained in:
41
Modules/Slider/Resources/assets/admin/js/Slide.js
Normal file
41
Modules/Slider/Resources/assets/admin/js/Slide.js
Normal file
@@ -0,0 +1,41 @@
|
||||
export default class {
|
||||
constructor(data) {
|
||||
this.slidePanelHtml = this.getSlidePanelHtml(data);
|
||||
}
|
||||
|
||||
getSlidePanelHtml(data) {
|
||||
data.slide.options = data.slide.options || this.getDefaultOptions();
|
||||
|
||||
let template = _.template($('#slide-template').html());
|
||||
|
||||
return $(template(data));
|
||||
}
|
||||
|
||||
getDefaultOptions() {
|
||||
return { caption_1: {}, caption_2: {}, direction: 'left', call_to_action: {} };
|
||||
}
|
||||
|
||||
render() {
|
||||
this.attachEventListeners();
|
||||
this.showSelectedOptionBlock();
|
||||
|
||||
return this.slidePanelHtml;
|
||||
}
|
||||
|
||||
attachEventListeners() {
|
||||
this.slidePanelHtml.find('.delete-slide').on('click', () => {
|
||||
this.slidePanelHtml.remove();
|
||||
});
|
||||
|
||||
this.slidePanelHtml.find('.change-option-block').on('change', (e) => {
|
||||
this.slidePanelHtml.find('.slide-options').hide();
|
||||
this.slidePanelHtml.find(`.${e.currentTarget.value}`).show();
|
||||
});
|
||||
}
|
||||
|
||||
showSelectedOptionBlock() {
|
||||
setTimeout(() => {
|
||||
this.slidePanelHtml.find('.change-option-block').trigger('change');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user