Sha256: 0e1b0bc69c4e38151b26b4c8b0c6884ef892aa416bfbbdd9c41889b44f42eda7

Contents?: true

Size: 1.38 KB

Versions: 8

Compression:

Stored size: 1.38 KB

Contents

import ApplicationController from "satis/controllers/application_controller"
import { debounce } from "satis/utils"

export default class SidebarComponentController extends ApplicationController {
    connect() {
        super.connect();
        this.initializeSidebar();
    }

    initializeSidebar() {
        let sidebar_collapse = document.querySelector(".sidebar");
        let topbar = document.querySelector(".topbar");
        let page_body = document.querySelector(".page_body");
        let sidebarBtn = document.querySelector(".arrow");

        // Check stored state and apply it
        const isClosed = sessionStorage.getItem('sidebarClosed') === 'true';
        if (isClosed) {
            sidebar_collapse.classList.add("close");
            topbar.classList.add("close");
            page_body.classList.add("close");
        }


        sidebarBtn.addEventListener("click", () => {
            const isClosed = sidebar_collapse.classList.toggle("close");
            topbar.classList.toggle("close");
            page_body.classList.toggle("close");

            // Save the current state to sessionStorage
            sessionStorage.setItem('sidebarClosed', isClosed);
        });
        }
    }

// Ensure the function runs on every Turbo page load
document.addEventListener("turbo:load", () => {
    const controller = new SidebarComponentController();
    controller.initializeSidebar();
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
satis-2.1.38 app/components/satis/sidebar/component_controller.js
satis-2.1.37 app/components/satis/sidebar/component_controller.js
satis-2.1.36 app/components/satis/sidebar/component_controller.js
satis-2.1.35 app/components/satis/sidebar/component_controller.js
satis-2.1.33 app/components/satis/sidebar/component_controller.js
satis-2.1.31 app/components/satis/sidebar/component_controller.js
satis-2.1.30 app/components/satis/sidebar/component_controller.js
satis-2.1.29 app/components/satis/sidebar/component_controller.js