-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathheader.component.ts
More file actions
53 lines (44 loc) · 1.44 KB
/
header.component.ts
File metadata and controls
53 lines (44 loc) · 1.44 KB
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
import { Component, OnInit } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
public pushRightClass: string;
constructor(private translate: TranslateService, public router: Router) {
this.router.events.subscribe((val) => {
if (val instanceof NavigationEnd && window.innerWidth <= 992 && this.isToggled()) {
this.toggleSidebar();
}
});
}
ngOnInit() {
this.pushRightClass = 'push-right';
}
isToggled(): boolean {
const dom: Element = document.querySelector('body');
return dom.classList.contains(this.pushRightClass);
}
toggleSidebar() {
const dom: any = document.querySelector('body');
dom.classList.toggle(this.pushRightClass);
}
rltAndLtr() {
const dom: any = document.querySelector('body');
dom.classList.toggle('rtl');
}
upAndDown() {
const dom: any = document.querySelector('nav');
dom.classList.toggle('fixed-bottom');
dom.classList.toggle('fixed-top')
}
onLoggedout() {
localStorage.removeItem('isLoggedin');
}
changeLang(language: string) {
this.translate.use(language);
}
}