import {IHeader} from '../interfaces/components/IHeader';
import {IAdminPanelBus} from '../interfaces/bus/IAdminPanelBus';

export class Header implements IHeader {

    protected container:HTMLElement;

    protected sidebarToggleButton:HTMLElement;

    protected adminPanelBus:IAdminPanelBus;

    public init(container:HTMLElement)
    {
        this.container = container;
        this.sidebarToggleButton = this.container.querySelector('.js-sidebar-toggle-button');
        this.eventListen();
    }

    public setAdminPanelBus(bus:IAdminPanelBus):void
    {
        this.adminPanelBus = bus;
    }

    private eventListen():void
    {
        this.sidebarToggleButton.onclick = this.onToggleButtonClick.bind(this);
    }

    private onToggleButtonClick(event:Event)
    {
        event.preventDefault();
        this.adminPanelBus.toggleSidebar();
    }

}