Notes/src/public/app/widgets/buttons/close_pane_button.js

25 lines
804 B
JavaScript
Raw Normal View History

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")
.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();
widget.triggerCommand("closeThisNoteSplit", { ntxId: widget.getClosestNtxId() });
});
2021-05-24 22:29:49 +02:00
}
}