2024-07-31 10:51:35 +08:00
|
|
|
import { t } from "../../services/i18n.js";
|
2022-12-02 16:46:14 +01:00
|
|
|
import OnClickButtonWidget from "./onclick_button.js";
|
2021-05-24 22:29:49 +02:00
|
|
|
|
2022-12-02 16:46:14 +01:00
|
|
|
export default class ClosePaneButton extends OnClickButtonWidget {
|
2021-05-24 22:29:49 +02:00
|
|
|
isEnabled() {
|
|
|
|
|
return super.isEnabled()
|
|
|
|
|
// main note context should not be closeable
|
|
|
|
|
&& this.noteContext && !!this.noteContext.mainNtxId;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 01:53:55 +08:00
|
|
|
async noteContextReorderEvent({ntxIdsInOrder}) {
|
|
|
|
|
this.refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-24 22:29:49 +02:00
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
|
|
|
|
|
this.icon("bx-x")
|
2024-07-31 10:51:35 +08:00
|
|
|
.title(t("close_pane_button.close_this_pane"))
|
2021-05-24 22:29:49 +02:00
|
|
|
.titlePlacement("bottom")
|
2021-10-13 23:27:58 +02:00
|
|
|
.onClick((widget, e) => {
|
|
|
|
|
// to avoid split pane container detecting click within the pane which would try to activate this
|
|
|
|
|
// pane (which is being removed)
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
2022-07-03 23:10:13 +02:00
|
|
|
widget.triggerCommand("closeThisNoteSplit", { ntxId: widget.getClosestNtxId() });
|
2022-12-18 23:53:47 +01:00
|
|
|
})
|
|
|
|
|
.class("icon-action");
|
2021-05-24 22:29:49 +02:00
|
|
|
}
|
|
|
|
|
}
|