diff --git a/src/app/theme/components/baMenu/baMenu.component.ts b/src/app/theme/components/baMenu/baMenu.component.ts index 8f682a44..8e2b57ad 100644 --- a/src/app/theme/components/baMenu/baMenu.component.ts +++ b/src/app/theme/components/baMenu/baMenu.component.ts @@ -1,9 +1,9 @@ -import {Component, ViewEncapsulation, Input, Output, EventEmitter} from '@angular/core'; -import {Router, Routes, NavigationEnd} from '@angular/router'; -import {Subscription} from 'rxjs/Rx'; +import { Component, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; +import { Router, NavigationEnd } from '@angular/router'; +import { Subscription } from 'rxjs/Rx'; import { BaMenuService } from '../../services'; -import {GlobalState} from '../../../global.state'; +import { GlobalState } from '../../../global.state'; @Component({ selector: 'ba-menu', @@ -13,20 +13,35 @@ import {GlobalState} from '../../../global.state'; }) export class BaMenu { - @Input() sidebarCollapsed:boolean = false; - @Input() menuHeight:number; + @Input() sidebarCollapsed: boolean = false; + @Input() menuHeight: number; @Output() expandMenu = new EventEmitter(); public menuItems: any[]; protected _menuItemsSub: Subscription; - public showHoverElem:boolean; - public hoverElemHeight:number; - public hoverElemTop:number; - protected _onRouteChange:Subscription; - public outOfArea:number = -200; + public showHoverElem: boolean; + public hoverElemHeight: number; + public hoverElemTop: number; + protected _onRouteChange: Subscription; + public outOfArea: number = -200; - constructor(private _router:Router, private _service:BaMenuService, private _state:GlobalState) { + constructor(private _router: Router, private _service: BaMenuService, private _state: GlobalState) { + } + + public updateMenu(newMenuItems) { + this.menuItems = newMenuItems; + this.selectMenuAndNotify(); + } + + public selectMenuAndNotify(): void { + if (this.menuItems) { + this.menuItems = this._service.selectMenuItem(this.menuItems); + this._state.notifyDataChanged('menu.activeLink', this._service.getCurrentItem()); + } + } + + public ngOnInit(): void { this._onRouteChange = this._router.events.subscribe((event) => { if (event instanceof NavigationEnd) { @@ -42,35 +57,20 @@ export class BaMenu { this._menuItemsSub = this._service.menuItems.subscribe(this.updateMenu.bind(this)); } - public updateMenu(newMenuItems) { - this.menuItems = newMenuItems; - this.selectMenuAndNotify(); - } - - public selectMenuAndNotify():void { - if (this.menuItems) { - this.menuItems = this._service.selectMenuItem(this.menuItems); - this._state.notifyDataChanged('menu.activeLink', this._service.getCurrentItem()); - } - } - - public ngOnInit():void { - } - - public ngOnDestroy():void { + public ngOnDestroy(): void { this._onRouteChange.unsubscribe(); this._menuItemsSub.unsubscribe(); } - public hoverItem($event):void { + public hoverItem($event): void { this.showHoverElem = true; this.hoverElemHeight = $event.currentTarget.clientHeight; // TODO: get rid of magic 66 constant this.hoverElemTop = $event.currentTarget.getBoundingClientRect().top - 66; } - public toggleSubMenu($event):boolean { - var submenu = jQuery($event.currentTarget).next(); + public toggleSubMenu($event): boolean { + let submenu = jQuery($event.currentTarget).next(); if (this.sidebarCollapsed) { this.expandMenu.emit(null); diff --git a/tslint.json b/tslint.json index 05323997..c11fdac3 100644 --- a/tslint.json +++ b/tslint.json @@ -76,7 +76,7 @@ ], "max-line-length": [ true, - 100 + 120 ], "no-require-imports": false, "no-trailing-whitespace": true,