All 'isMobile' methods replaced by deviceService method

pull/7031/head
Inga Mai 6 years ago
parent 21a2e81c02
commit 4fd482631f
  1. 10
      frontend/src/app/components/resizer/main-menu-toggle.component.ts
  2. 16
      frontend/src/app/components/resizer/main-menu-toggle.service.ts

@ -33,12 +33,13 @@ import {untilComponentDestroyed} from 'ng2-rx-componentdestroyed';
import {MainMenuResizerComponent} from "core-components/resizer/main-menu-resizer.component";
import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper";
import {CurrentProjectService} from "core-components/projects/current-project.service";
import {DeviceService} from "app/modules/common/browser/device.service";
import {Injector} from "@angular/core";
@Component({
selector: 'main-menu-toggle',
template: `
<div *ngIf="this.currentProject.id !== null || toggleService.isMobile" id="main-menu-toggle"
<div *ngIf="this.currentProject.id !== null || this.deviceService.isMobile" id="main-menu-toggle"
aria-haspopup="true"
[attr.title]="toggleTitle"
(accessibleClick)="toggleService.toggleNavigation($event)"
@ -50,18 +51,13 @@ import {Injector} from "@angular/core";
`
})
/*
* Groesse des Menus feststellen
* pruefen, ob kleiner 10 -> Groesse der Sidebar setzen
* collapsed boolean setzen, label im resizer und hamburger icon setzen
*
*/
export class MainMenuToggleComponent implements OnInit, OnDestroy {
toggleTitle:string = "";
currentProject:CurrentProjectService = this.injector.get(CurrentProjectService);
constructor(readonly toggleService:MainMenuToggleService,
readonly cdRef:ChangeDetectorRef,
readonly deviceService:DeviceService,
protected injector:Injector) {
}

@ -30,6 +30,7 @@ import {Injectable} from '@angular/core';
import {BehaviorSubject, fromEvent, Observable, Subscription} from 'rxjs';
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {CurrentProjectService} from "core-components/projects/current-project.service";
import {DeviceService} from "app/modules/common/browser/device.service";
import {Injector} from "@angular/core";
@Injectable()
@ -58,7 +59,8 @@ export class MainMenuToggleService {
private resizeSubscription$:Subscription;
constructor(protected I18n:I18nService,
protected injector:Injector) {
protected injector:Injector,
readonly deviceService:DeviceService) {
}
public initializeMenu():void {
@ -78,7 +80,7 @@ export class MainMenuToggleService {
}
// mobile version default: hide menu on initialization
if (this.isMobile) {
if (this.deviceService.isMobile) {
this.closeMenu();
}
}
@ -91,7 +93,7 @@ export class MainMenuToggleService {
}
if (!this.showNavigation) { // sidebar is hidden -> show menu
if (this.isMobile) { // mobile version
if (this.deviceService.isMobile) { // mobile version
this.setWidth(window.innerWidth);
// On mobile the main menu shall close whenever you click outside the menu.
this.setupAutocloseMainMenu();
@ -113,7 +115,7 @@ export class MainMenuToggleService {
}
public closeMenu():void {
if (this.isMobile) {
if (this.deviceService.isMobile) {
this.saveWidth(0);
} else {
this.setWidth(0);
@ -122,7 +124,7 @@ export class MainMenuToggleService {
}
public closeWhenOnMobile():void {
if (this.isMobile) {
if (this.deviceService.isMobile) {
this.closeMenu()
};
}
@ -206,10 +208,6 @@ export class MainMenuToggleService {
}
}
public get isMobile():boolean {
return (window.innerWidth < 680);
}
public get showNavigation():boolean {
return (this.elementWidth > 10);
}

Loading…
Cancel
Save