|
1 |
import {Component, ElementRef, EventEmitter, Input, OnInit, Output} from "@angular/core";
|
|
2 |
|
|
3 |
@Component({
|
|
4 |
selector: 'fs-modal',
|
|
5 |
template: `
|
|
6 |
<div class="fs-modal" [class.uk-hidden]="!opened">
|
|
7 |
<a class="close" (click)="close()">
|
|
8 |
<icon name="close" ratio="2"></icon>
|
|
9 |
</a>
|
|
10 |
<div class="header">
|
|
11 |
<div class="uk-position-relative uk-height-1-1">
|
|
12 |
<h5 *ngIf="title" class="uk-position-center">
|
|
13 |
{{title}}
|
|
14 |
</h5>
|
|
15 |
<div class="uk-position-center-right uk-visible@m">
|
|
16 |
<button class="uk-button uk-button-secondary outlined" (click)="close()">{{cancelButtonText}}</button>
|
|
17 |
<button class="uk-button uk-button-secondary space" (click)="ok()">{{okButtonText}}</button>
|
|
18 |
</div>
|
|
19 |
</div>
|
|
20 |
</div>
|
|
21 |
<div class="content">
|
|
22 |
<div class="content-header">
|
|
23 |
<div class="uk-flex uk-flex-center uk-width-1-1 uk-margin-medium-bottom uk-hidden@m">
|
|
24 |
<button class="uk-button uk-button-secondary outlined" (click)="close()">{{cancelButtonText}}</button>
|
|
25 |
<button class="uk-button uk-button-secondary space" (click)="ok()">{{okButtonText}}</button>
|
|
26 |
</div>
|
|
27 |
<ng-content select="[header]">
|
|
28 |
</ng-content>
|
|
29 |
</div>
|
|
30 |
<div class="content-inner">
|
|
31 |
<ng-content></ng-content>
|
|
32 |
</div>
|
|
33 |
</div>
|
|
34 |
</div>
|
|
35 |
`
|
|
36 |
})
|
|
37 |
export class FullScreenModalComponent implements OnInit {
|
|
38 |
okButtonText = 'OK';
|
|
39 |
cancelButtonText = 'Cancel';
|
|
40 |
title: string = null;
|
|
41 |
@Input()
|
|
42 |
customKeys: boolean = false;
|
|
43 |
@Output()
|
|
44 |
okEmitter: EventEmitter<boolean> = new EventEmitter<boolean>();
|
|
45 |
opened: boolean = false;
|
|
46 |
private readonly element: any;
|
|
47 |
|
|
48 |
constructor(private el: ElementRef) {
|
|
49 |
this.element = el.nativeElement;
|
|
50 |
}
|
|
51 |
|
|
52 |
ngOnInit() {
|
|
53 |
if(typeof document !== "undefined") {
|
|
54 |
document.body.appendChild(this.element);
|
|
55 |
}
|
|
56 |
}
|
|
57 |
|
|
58 |
ngOnDestroy(): void {
|
|
59 |
this.element.remove();
|
|
60 |
}
|
|
61 |
|
|
62 |
open() {
|
|
63 |
if(typeof document !== "undefined") {
|
|
64 |
this.opened = true;
|
|
65 |
document.getElementsByTagName('html')[0].classList.add('fs-modal-open');
|
|
66 |
}
|
|
67 |
}
|
|
68 |
|
|
69 |
close() {
|
|
70 |
if(typeof document !== "undefined") {
|
|
71 |
this.opened = false;
|
|
72 |
document.getElementsByTagName('html')[0].classList.remove('fs-modal-open');
|
|
73 |
}
|
|
74 |
}
|
|
75 |
|
|
76 |
ok() {
|
|
77 |
this.close();
|
|
78 |
this.okEmitter.emit(true);
|
|
79 |
}
|
|
80 |
}
|
[Library | Trunk]: Add full screen modal