mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-27 10:01:37 +08:00
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
import AbstractButtonWidget from "./abstract_button.js";
|
|
import { t } from "../../services/i18n.js";
|
|
|
|
export default class OnClickButtonWidget extends AbstractButtonWidget {
|
|
doRender() {
|
|
super.doRender();
|
|
|
|
if (this.settings.onClick) {
|
|
this.$widget.on("click", e => {
|
|
e.stopPropagation();
|
|
this.$widget.tooltip(t("onclick_button.hide"));
|
|
|
|
this.settings.onClick(this, e);
|
|
});
|
|
} else {
|
|
console.warn(t("onclick_button.no_click_handler", { componentId: this.componentId }), this.settings);
|
|
}
|
|
|
|
if (this.settings.onAuxClick) {
|
|
this.$widget.on("auxclick", e => {
|
|
this.$widget.tooltip(t("onclick_button.hide"));
|
|
|
|
this.settings.onAuxClick(this, e);
|
|
});
|
|
}
|
|
}
|
|
|
|
onClick(handler) {
|
|
this.settings.onClick = handler;
|
|
return this;
|
|
}
|
|
|
|
onAuxClick(handler) {
|
|
this.settings.onAuxClick = handler;
|
|
return this;
|
|
}
|
|
}
|