2017-09-18 13:06:15 +00:00
|
|
|
import { Component, ElementRef, HostBinding, Inject, OnDestroy, OnInit, Renderer2, ViewEncapsulation } from '@angular/core';
|
2017-07-27 15:05:50 +00:00
|
|
|
import { Subscription } from 'rxjs/Subscription';
|
2017-08-22 10:45:07 +00:00
|
|
|
import { FuseConfigService } from '../core/services/config.service';
|
2017-09-18 13:06:15 +00:00
|
|
|
import { Platform } from '@angular/cdk/platform';
|
|
|
|
import { DOCUMENT } from '@angular/common';
|
2017-07-12 12:35:07 +00:00
|
|
|
|
|
|
|
@Component({
|
2017-08-02 08:53:30 +00:00
|
|
|
selector : 'fuse-main',
|
|
|
|
templateUrl : './main.component.html',
|
|
|
|
styleUrls : ['./main.component.scss'],
|
2017-07-15 15:03:40 +00:00
|
|
|
encapsulation: ViewEncapsulation.None
|
2017-07-12 12:35:07 +00:00
|
|
|
})
|
2017-08-02 08:53:30 +00:00
|
|
|
export class FuseMainComponent implements OnInit, OnDestroy
|
2017-07-12 12:35:07 +00:00
|
|
|
{
|
2017-07-27 15:05:50 +00:00
|
|
|
onSettingsChanged: Subscription;
|
2017-08-22 10:45:07 +00:00
|
|
|
fuseSettings: any;
|
2017-09-11 09:30:01 +00:00
|
|
|
@HostBinding('class.boxed') boxed;
|
2017-07-12 12:35:07 +00:00
|
|
|
|
2017-08-18 09:31:17 +00:00
|
|
|
constructor(
|
|
|
|
private _renderer: Renderer2,
|
2017-08-22 10:45:07 +00:00
|
|
|
private _elementRef: ElementRef,
|
2017-09-18 13:06:15 +00:00
|
|
|
private fuseConfig: FuseConfigService,
|
|
|
|
private platform: Platform,
|
|
|
|
@Inject(DOCUMENT) private document: any
|
2017-08-18 09:31:17 +00:00
|
|
|
)
|
2017-07-12 12:35:07 +00:00
|
|
|
{
|
2017-07-27 15:05:50 +00:00
|
|
|
this.onSettingsChanged =
|
2017-08-22 10:45:07 +00:00
|
|
|
this.fuseConfig.onSettingsChanged
|
2017-07-27 15:05:50 +00:00
|
|
|
.subscribe(
|
|
|
|
(newSettings) => {
|
2017-08-22 10:45:07 +00:00
|
|
|
this.fuseSettings = newSettings;
|
2017-09-11 09:30:01 +00:00
|
|
|
this.boxed = this.fuseSettings.layout.mode === 'boxed';
|
2017-07-27 15:05:50 +00:00
|
|
|
}
|
|
|
|
);
|
2017-09-18 13:06:15 +00:00
|
|
|
|
|
|
|
if ( this.platform.ANDROID || this.platform.IOS )
|
|
|
|
{
|
|
|
|
this.document.body.className += ' is-mobile';
|
|
|
|
}
|
2017-07-12 12:35:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-07-27 15:05:50 +00:00
|
|
|
ngOnDestroy()
|
|
|
|
{
|
|
|
|
this.onSettingsChanged.unsubscribe();
|
|
|
|
}
|
2017-08-18 09:31:17 +00:00
|
|
|
|
|
|
|
addClass(className: string)
|
|
|
|
{
|
|
|
|
this._renderer.addClass(this._elementRef.nativeElement, className);
|
|
|
|
}
|
|
|
|
|
|
|
|
removeClass(className: string)
|
|
|
|
{
|
|
|
|
this._renderer.removeClass(this._elementRef.nativeElement, className);
|
|
|
|
}
|
2017-07-12 12:35:07 +00:00
|
|
|
}
|