2018-03-09 20:18:59 +00:00
|
|
|
import $ from 'jquery';
|
|
|
|
|
2017-04-03 17:54:40 +00:00
|
|
|
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-03-31 11:10:16 +00:00
|
|
|
isHidden() {
|
|
|
|
return this.$wrapper.hasClass('hidden');
|
|
|
|
}
|
|
|
|
|
2017-04-03 17:54:40 +00:00
|
|
|
getToggleText() {
|
|
|
|
return this.$dropdownToggleText.text();
|
|
|
|
}
|
|
|
|
|
|
|
|
setToggleText(text) {
|
|
|
|
this.$dropdownToggleText.text(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderLoading() {
|
2018-10-10 06:09:55 +00:00
|
|
|
this.$loadingIcon.addClass('fa-spinner fa-spin').removeClass('fa-chevron-down');
|
2017-04-03 17:54:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderLoaded() {
|
2018-10-10 06:09:55 +00:00
|
|
|
this.$loadingIcon.addClass('fa-chevron-down').removeClass('fa-spinner fa-spin');
|
2017-04-03 17:54:40 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 20:55:36 +00:00
|
|
|
reportSelection(options) {
|
|
|
|
const { query, e, data } = options;
|
2017-04-03 17:54:40 +00:00
|
|
|
e.preventDefault();
|
|
|
|
return this.mediator.selectTemplateFile(this, query, data);
|
|
|
|
}
|
2017-05-04 20:55:36 +00:00
|
|
|
|
|
|
|
reportSelectionName(options) {
|
|
|
|
const opts = options;
|
|
|
|
opts.query = options.selectedObj.name;
|
|
|
|
|
|
|
|
this.reportSelection(opts);
|
|
|
|
}
|
2017-04-03 17:54:40 +00:00
|
|
|
}
|