{"size": 980, "ext": "js", "max_stars_repo_path": "resources/js/controllers/menu-controller.js", "max_stars_repo_name": "DirectoryTree/Scout", "max_stars_repo_stars_event_min_datetime": "2019-09-25T07:59:44.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-05T19:18:44.000Z", "max_issues_repo_path": "resources/js/controllers/menu-controller.js", "max_issues_repo_name": "DirectoryTree/Scout", "max_issues_repo_issues_event_min_datetime": "2019-09-26T16:17:00.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-13T18:57:20.000Z", "max_forks_repo_path": "resources/js/controllers/menu-controller.js", "max_forks_repo_name": "DirectoryTree/Scout", "max_forks_repo_forks_event_min_datetime": "2019-09-26T13:38:10.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-31T21:39:21.000Z"}
{"max_stars_count": 9, "max_issues_count": 11, "max_forks_count": 3, "avg_line_length": 21.3043478261, "max_line_length": 93, "alphanum_fraction": 0.5367346939}
import { Controller } from 'stimulus';

export default class extends Controller {
    static targets = ['container', 'toggleButton'];

    /**
     * Initialize the expand button.
     */
    initialize() {
        this.showExpandButton();

        $(this.toggleButtonTarget).click(() => {
            this.toggleMenu();
        });
    }

    /**
     * Toggle the menu.
     */
    toggleMenu() {
        let container = $(this.containerTarget);

        container.toggleClass('d-none');

        if (container.hasClass('d-none')) {
            this.showExpandButton();
        } else {
            this.showHideButton();
        }
    }

    /**
     * Show the expand button.
     */
    showExpandButton() {
        this.toggleButtonTarget.innerHTML = '<i class="fa fa-angle-double-down"></i> Expand';
    }

    /**
     * Show the hide button.
     */
    showHideButton() {
        this.toggleButtonTarget.innerHTML = '<i class="fa fa-angle-double-up"></i> Hide';
    }
}
