2021-05-18 22:14:35 +02:00
|
|
|
import BasicWidget from "./basic_widget.js";
|
|
|
|
|
|
|
|
const TPL = `
|
|
|
|
<span class="button-widget"
|
|
|
|
title="">
|
|
|
|
<span class="bx"></span>
|
|
|
|
</span>
|
|
|
|
`;
|
|
|
|
|
|
|
|
export default class ButtonWidget extends BasicWidget {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
2021-05-22 21:35:25 +02:00
|
|
|
this.settings = {};
|
2021-05-18 22:14:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
doRender() {
|
|
|
|
this.$widget = $(TPL);
|
|
|
|
this.overflowing();
|
|
|
|
|
2021-05-22 21:35:25 +02:00
|
|
|
this.$widget.on("click", () => this.triggerCommand(this.settings.command));
|
2021-05-18 22:14:35 +02:00
|
|
|
|
|
|
|
super.doRender();
|
|
|
|
}
|
|
|
|
|
|
|
|
refreshIcon() {
|
2021-05-22 21:35:25 +02:00
|
|
|
this.$widget.attr("title", this.settings.title);
|
2021-05-18 22:14:35 +02:00
|
|
|
this.$widget.find("span.bx")
|
|
|
|
.removeClass()
|
|
|
|
.addClass("bx")
|
2021-05-22 21:35:25 +02:00
|
|
|
.addClass(this.settings.icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
initialRenderCompleteEvent() {
|
|
|
|
this.refreshIcon();
|
2021-05-18 22:14:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
icon(icon) {
|
2021-05-22 21:35:25 +02:00
|
|
|
this.settings.icon = icon;
|
2021-05-18 22:14:35 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
title(title) {
|
2021-05-22 21:35:25 +02:00
|
|
|
this.settings.title = title;
|
2021-05-18 22:14:35 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
command(command) {
|
2021-05-22 21:35:25 +02:00
|
|
|
this.settings.command = command;
|
2021-05-18 22:14:35 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|