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

45 lines
1.3 KiB
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";
import { t } from "../../services/i18n.js";
2021-05-22 21:35:25 +02:00
2022-12-02 16:46:14 +01:00
export default class LeftPaneToggleWidget extends CommandButtonWidget {
constructor(isHorizontalLayout) {
2022-12-02 16:46:14 +01:00
super();
2021-05-22 21:35:25 +02:00
this.class(isHorizontalLayout ? "toggle-button" : "launcher-button");
2022-12-11 13:20:37 +01:00
this.settings.icon = () => {
if (options.get("layoutOrientation") === "horizontal") {
return "bx-sidebar";
}
return (options.is('leftPaneVisible') ? "bx-chevrons-left" : "bx-chevrons-right");
};
2021-05-22 21:35:25 +02:00
2022-12-02 16:46:14 +01:00
this.settings.title = () => options.is('leftPaneVisible')
? t("left_pane_toggle.hide_panel")
: t("left_pane_toggle.show_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";
if (isHorizontalLayout) {
this.settings.titlePlacement = "bottom";
}
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();
}
}
}