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

36 lines
986 B
JavaScript
Raw Normal View History

2021-05-24 22:29:49 +02:00
import options from "../../services/options.js";
import splitService from "../../services/resizer.js";
2022-12-02 16:46:14 +01:00
import CommandButtonWidget from "./command_button.js";
2021-05-22 21:35:25 +02:00
2022-12-02 16:46:14 +01:00
export default class LeftPaneToggleWidget extends CommandButtonWidget {
constructor() {
super();
2021-05-22 21:35:25 +02:00
2022-12-11 13:20:37 +01:00
this.class("launcher-button");
2022-12-02 16:46:14 +01:00
this.settings.icon = () => options.is('leftPaneVisible')
2021-05-22 21:35:25 +02:00
? "bx-chevrons-left"
: "bx-chevrons-right";
2022-12-02 16:46:14 +01:00
this.settings.title = () => options.is('leftPaneVisible')
? "Hide panel"
: "Open panel";
2021-05-22 21:35:25 +02:00
2022-12-02 16:46:14 +01:00
this.settings.command = () => options.is('leftPaneVisible')
? "hideLeftPane"
: "showLeftPane";
2022-12-02 16:46:14 +01:00
}
2021-05-22 21:35:25 +02:00
2022-12-02 16:46:14 +01:00
refreshIcon() {
2021-05-22 21:35:25 +02:00
super.refreshIcon();
2022-12-02 16:46:14 +01:00
splitService.setupLeftPaneResizer(options.is('leftPaneVisible'));
2021-05-22 21:35:25 +02:00
}
entitiesReloadedEvent({loadResults}) {
if (loadResults.isOptionReloaded("leftPaneVisible")) {
this.refreshIcon();
}
}
}