All files / src/lib/tl-dropdown-menu/tl-dropdown-menu-section tl-dropdown-menu-section.component.ts

78.57% Statements 11/14
50% Branches 1/2
60% Functions 3/5
76.92% Lines 10/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67                    1x         1x             1x                 1x   1x 1x   1x     1x                   1x   1x                              
import { AfterContentInit, ChangeDetectionStrategy, Component, HostBinding, Injector, OnInit } from '@angular/core';
import { TamuAbstractBaseComponent } from '../../shared/tl-abstract-base.component';
import { TlDropDownMenuComponent } from '../tl-dropdown-menu.component';
 
@Component({
  selector: 'tl-dropdown-menu-section-component',
  templateUrl: './tl-dropdown-menu-section.component.html',
  styleUrls: ['./tl-dropdown-menu-section.component.scss'],
  changeDetection: ChangeDetectionStrategy.Default
})
export class TlDropDownMenuSectionComponent extends TamuAbstractBaseComponent implements AfterContentInit, OnInit  {
 
  private parent: TlDropDownMenuComponent;
 
  /** Toggles the mobile-layout class on the root element. */
  @HostBinding('class.mobile-layout') mobileLayout = this.isMobileLayout;
 
  /** Allows for the override of the --tl-mobile-display-wvr-nav-list-component-max-height variable. */
  @HostBinding('style.--wvr-nav-list-component-max-height') wvrNavListComponentMaxHeight: string;
 
  // tslint:disable-next-line:unnecessary-constructor
  constructor(injector: Injector) {
    super(injector);
  }
 
  /**
   * Perform initialization operations.
   *
   * This will identify the parent element.
   */
  ngOnInit(): void {
    super.ngOnInit();
 
    const elem = this.eRef.nativeElement as HTMLElement;
    const parentElem = elem.closest('tl-dropdown-menu');
 
    Iif (parentElem) {
      this.parent = this.componentRegistry.getComponentByElement(parentElem as HTMLElement) as TlDropDownMenuComponent;
    } else {
      console.warn(`TlDropDownMenuSectionComponent (${this.id}) is not within a TlDropDownMenuComponent`);
    }
  }
 
  /**
   * Perform after-initialization operations.
   *
   * This will add the section to the parent's component.
   */
  ngAfterContentInit(): void {
    super.ngAfterContentInit();
 
    setTimeout(() => {
      this.parent.addSection(this);
    }, 1500);
  }
 
  /**
   * Get the clientHeight of the element.
   *
   * @returns the height of the element, in pixels.
   */
  getElementHeight(): number {
    return (this.eRef.nativeElement as HTMLElement).clientHeight;
  }
 
}