2021-03-28 22:24:24 +02:00
|
|
|
import options from "../../services/options.js";
|
2020-02-07 22:19:35 +01:00
|
|
|
import FlexContainer from "./flex_container.js";
|
2025-01-18 12:56:00 +02:00
|
|
|
import appContext, { type EventData } from "../../components/app_context.js";
|
|
|
|
import type Component from "../../components/component.js";
|
2020-02-04 22:46:17 +01:00
|
|
|
|
2025-01-18 12:56:00 +02:00
|
|
|
export default class LeftPaneContainer extends FlexContainer<Component> {
|
2025-05-18 10:22:49 +08:00
|
|
|
private currentLeftPaneVisible: boolean;
|
|
|
|
|
2021-05-22 21:35:25 +02:00
|
|
|
constructor() {
|
2025-01-09 18:07:02 +02:00
|
|
|
super("column");
|
2020-02-04 22:46:17 +01:00
|
|
|
|
2025-05-18 10:22:49 +08:00
|
|
|
this.currentLeftPaneVisible = options.is("leftPaneVisible");
|
|
|
|
|
2025-01-09 18:07:02 +02:00
|
|
|
this.id("left-pane");
|
|
|
|
this.css("height", "100%");
|
2021-06-13 22:55:31 +02:00
|
|
|
this.collapsible();
|
2020-02-04 22:46:17 +01:00
|
|
|
}
|
|
|
|
|
2020-02-08 21:54:39 +01:00
|
|
|
isEnabled() {
|
2025-05-18 10:22:49 +08:00
|
|
|
return super.isEnabled() && this.currentLeftPaneVisible;
|
2020-02-08 21:54:39 +01:00
|
|
|
}
|
|
|
|
|
2025-05-20 14:33:01 +08:00
|
|
|
setLeftPaneVisibilityEvent({ leftPaneVisible }: EventData<"setLeftPaneVisibility">) {
|
|
|
|
this.currentLeftPaneVisible = leftPaneVisible ?? !this.currentLeftPaneVisible;
|
|
|
|
const visible = this.isEnabled();
|
|
|
|
this.toggleInt(visible);
|
2023-01-31 22:35:01 +01:00
|
|
|
|
2025-05-20 14:33:01 +08:00
|
|
|
if (visible) {
|
|
|
|
this.triggerEvent("focusTree", {});
|
|
|
|
} else {
|
|
|
|
this.triggerEvent("focusOnDetail", { ntxId: appContext.tabManager.getActiveContext()?.ntxId });
|
2020-02-04 22:46:17 +01:00
|
|
|
}
|
2025-05-20 14:33:01 +08:00
|
|
|
|
|
|
|
options.save("leftPaneVisible", this.currentLeftPaneVisible.toString());
|
2020-02-04 22:46:17 +01:00
|
|
|
}
|
2021-03-28 22:24:24 +02:00
|
|
|
}
|