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;
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.icon("bx-x")
|
|
|
|
.title("Close this pane")
|
|
|
|
.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() });
|
2021-10-13 23:27:58 +02:00
|
|
|
});
|
2021-05-24 22:29:49 +02:00
|
|
|
}
|
|
|
|
}
|