2021-05-24 22:29:49 +02:00
|
|
|
import options from "../../services/options.js";
|
2021-06-05 14:01:21 +02:00
|
|
|
import splitService from "../../services/resizer.js";
|
2022-12-02 16:46:14 +01:00
|
|
|
import CommandButtonWidget from "./command_button.js";
|
2024-08-01 14:18:21 +08:00
|
|
|
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 {
|
2024-11-23 00:07:40 +02:00
|
|
|
constructor(isHorizontalLayout) {
|
2022-12-02 16:46:14 +01:00
|
|
|
super();
|
2021-05-22 21:35:25 +02:00
|
|
|
|
2024-11-30 01:20:47 +02:00
|
|
|
this.class(isHorizontalLayout ? "toggle-button" : "launcher-button");
|
2022-12-11 13:20:37 +01:00
|
|
|
|
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')
|
2024-08-01 14:18:21 +08:00
|
|
|
? 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')
|
2021-10-12 19:29:42 +02:00
|
|
|
? "hideLeftPane"
|
|
|
|
: "showLeftPane";
|
2024-11-23 00:07:40 +02:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|