2017-08-17 22:00:37 +05:30
|
|
|
import DropLab from './droplab/drop_lab';
|
2017-09-10 17:25:29 +05:30
|
|
|
import ISetter from './droplab/plugins/input_setter';
|
|
|
|
|
|
|
|
// Todo: Remove this when fixing issue in input_setter plugin
|
|
|
|
const InputSetter = Object.assign({}, ISetter);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
class CommentTypeToggle {
|
|
|
|
constructor(opts = {}) {
|
|
|
|
this.dropdownTrigger = opts.dropdownTrigger;
|
|
|
|
this.dropdownList = opts.dropdownList;
|
|
|
|
this.noteTypeInput = opts.noteTypeInput;
|
|
|
|
this.submitButton = opts.submitButton;
|
|
|
|
this.closeButton = opts.closeButton;
|
|
|
|
this.reopenButton = opts.reopenButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
initDroplab() {
|
|
|
|
this.droplab = new DropLab();
|
|
|
|
|
|
|
|
const config = this.setConfig();
|
|
|
|
|
|
|
|
this.droplab.init(this.dropdownTrigger, this.dropdownList, [InputSetter], config);
|
|
|
|
}
|
|
|
|
|
|
|
|
setConfig() {
|
|
|
|
const config = {
|
2018-12-13 13:39:08 +05:30
|
|
|
InputSetter: [
|
|
|
|
{
|
|
|
|
input: this.noteTypeInput,
|
|
|
|
valueAttribute: 'data-value',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: this.submitButton,
|
|
|
|
valueAttribute: 'data-submit-text',
|
|
|
|
},
|
|
|
|
],
|
2017-08-17 22:00:37 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
if (this.closeButton) {
|
2018-12-13 13:39:08 +05:30
|
|
|
config.InputSetter.push(
|
|
|
|
{
|
|
|
|
input: this.closeButton,
|
|
|
|
valueAttribute: 'data-close-text',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: this.closeButton,
|
|
|
|
valueAttribute: 'data-close-text',
|
|
|
|
inputAttribute: 'data-alternative-text',
|
|
|
|
},
|
|
|
|
);
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
if (this.reopenButton) {
|
2018-12-13 13:39:08 +05:30
|
|
|
config.InputSetter.push(
|
|
|
|
{
|
|
|
|
input: this.reopenButton,
|
|
|
|
valueAttribute: 'data-reopen-text',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: this.reopenButton,
|
|
|
|
valueAttribute: 'data-reopen-text',
|
|
|
|
inputAttribute: 'data-alternative-text',
|
|
|
|
},
|
|
|
|
);
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default CommentTypeToggle;
|