mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
Added bootstrap with ng-bootstrap
This commit is contained in:
@@ -1,11 +1,59 @@
|
||||
import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, HostListener, Input, ChangeDetectionStrategy, ViewEncapsulation, OnDestroy, OnInit } from '@angular/core';
|
||||
|
||||
import { Event, NavigationEnd, Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
encapsulation: ViewEncapsulation.Emulated,
|
||||
selector: 'ds-app',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: [ './app.component.scss' ]
|
||||
styleUrls: ['./app.component.scss']
|
||||
})
|
||||
export class AppComponent {
|
||||
export class AppComponent implements OnDestroy, OnInit {
|
||||
|
||||
// TODO: move header and all related properties into its own component
|
||||
|
||||
private navCollapsed: boolean;
|
||||
|
||||
private routerSubscription: any;
|
||||
|
||||
constructor(private router: Router) {
|
||||
this.collapse();
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
private onResize(event): void {
|
||||
this.collapse();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.routerSubscription = this.router.events.subscribe((event: Event) => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
this.collapse();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.routerSubscription) {
|
||||
this.routerSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
private collapse(): void {
|
||||
this.navCollapsed = true;
|
||||
}
|
||||
|
||||
private expand(): void {
|
||||
this.navCollapsed = false;
|
||||
}
|
||||
|
||||
public toggle(): void {
|
||||
this.navCollapsed ? this.expand() : this.collapse();
|
||||
}
|
||||
|
||||
public isNavBarCollaped(): boolean {
|
||||
return this.navCollapsed;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user