2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
export default class FileTemplateSelector {
|
|
|
|
constructor(mediator) {
|
|
|
|
this.mediator = mediator;
|
|
|
|
this.$dropdown = null;
|
|
|
|
this.$wrapper = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
init() {
|
|
|
|
const cfg = this.config;
|
|
|
|
|
|
|
|
this.$dropdown = $(cfg.dropdown);
|
|
|
|
this.$wrapper = $(cfg.wrapper);
|
|
|
|
this.$loadingIcon = this.$wrapper.find('.fa-chevron-down');
|
|
|
|
this.$dropdownToggleText = this.$wrapper.find('.dropdown-toggle-text');
|
|
|
|
|
|
|
|
this.initDropdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
show() {
|
|
|
|
if (this.$dropdown === null) {
|
|
|
|
this.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$wrapper.removeClass('hidden');
|
|
|
|
}
|
|
|
|
|
|
|
|
hide() {
|
|
|
|
if (this.$dropdown !== null) {
|
|
|
|
this.$wrapper.addClass('hidden');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
isHidden() {
|
|
|
|
return this.$wrapper.hasClass('hidden');
|
|
|
|
}
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
getToggleText() {
|
|
|
|
return this.$dropdownToggleText.text();
|
|
|
|
}
|
|
|
|
|
|
|
|
setToggleText(text) {
|
|
|
|
this.$dropdownToggleText.text(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderLoading() {
|
2018-12-13 13:39:08 +05:30
|
|
|
this.$loadingIcon.addClass('fa-spinner fa-spin').removeClass('fa-chevron-down');
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
renderLoaded() {
|
2018-12-13 13:39:08 +05:30
|
|
|
this.$loadingIcon.addClass('fa-chevron-down').removeClass('fa-spinner fa-spin');
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
reportSelection(options) {
|
|
|
|
const { query, e, data } = options;
|
|
|
|
e.preventDefault();
|
|
|
|
return this.mediator.selectTemplateFile(this, query, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
reportSelectionName(options) {
|
|
|
|
const opts = options;
|
|
|
|
opts.query = options.selectedObj.name;
|
|
|
|
|
|
|
|
this.reportSelection(opts);
|
|
|
|
}
|
|
|
|
}
|