2022-02-24 17:42:05 +01:00
|
|
|
import {Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild} from '@angular/core';
|
|
|
|
import {FormGroup} from "@angular/forms";
|
|
|
|
import {Subscriber} from "rxjs";
|
2022-06-17 18:47:47 +02:00
|
|
|
import {Background} from "../../utils/background-utils";
|
2022-02-24 17:42:05 +01:00
|
|
|
|
|
|
|
declare var UIkit;
|
2022-02-22 15:40:08 +01:00
|
|
|
|
|
|
|
@Component({
|
2022-02-24 17:42:05 +01:00
|
|
|
selector: 'quick-contact',
|
|
|
|
templateUrl: 'quick-contact.component.html',
|
|
|
|
styleUrls: ['quick-contact.component.css']
|
2022-02-22 15:40:08 +01:00
|
|
|
})
|
2022-02-24 17:42:05 +01:00
|
|
|
export class QuickContactComponent implements OnInit, OnDestroy {
|
2022-03-02 11:27:17 +01:00
|
|
|
public showDrop: boolean = false;
|
2022-02-24 17:42:05 +01:00
|
|
|
@Input()
|
|
|
|
public contactForm: FormGroup;
|
|
|
|
@Input()
|
2022-06-02 16:27:45 +02:00
|
|
|
public images: string[] = [];
|
|
|
|
@Input()
|
|
|
|
public contact: string = 'contact';
|
2022-06-17 18:47:47 +02:00
|
|
|
public backgroundHeader: Background = {class: 'uk-background-primary', dark: true};
|
2022-06-02 16:27:45 +02:00
|
|
|
@Input()
|
2022-02-24 17:42:05 +01:00
|
|
|
public sending = false;
|
|
|
|
@Input()
|
|
|
|
public organizationTypes: string[] = [];
|
|
|
|
@Output() sendEmitter: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
private subscriptions: any[] = [];
|
|
|
|
@ViewChild('drop') drop: ElementRef;
|
|
|
|
|
2022-06-17 18:47:47 +02:00
|
|
|
@Input()
|
|
|
|
set background(background: Background | string) {
|
|
|
|
if(typeof background === 'string') {
|
|
|
|
this.backgroundHeader = {class: background, dark: true}
|
|
|
|
} else {
|
|
|
|
this.backgroundHeader = background;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-24 17:42:05 +01:00
|
|
|
ngOnInit() {
|
2022-05-05 09:42:44 +02:00
|
|
|
if (typeof document !== 'undefined') {
|
2022-02-24 17:42:05 +01:00
|
|
|
this.subscriptions.push(UIkit.util.on(document, 'beforehide', '#quick-contact', (event) => {
|
|
|
|
if(this.sending) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
}));
|
2022-03-02 11:27:17 +01:00
|
|
|
this.subscriptions.push(UIkit.util.on(document, 'show', '#quick-contact', (event) => {
|
|
|
|
this.showDrop = true;
|
|
|
|
}));
|
|
|
|
this.subscriptions.push(UIkit.util.on(document, 'hide', '#quick-contact', (event) => {
|
|
|
|
this.showDrop = false;
|
|
|
|
}));
|
2022-02-24 17:42:05 +01:00
|
|
|
}
|
2022-06-17 18:47:47 +02:00
|
|
|
if(typeof this.background === 'string' ) {
|
|
|
|
this.background = {class: this.background, dark: true};
|
|
|
|
}
|
2022-02-24 17:42:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(value => {
|
|
|
|
if (value instanceof Subscriber) {
|
|
|
|
value.unsubscribe();
|
|
|
|
} else if (value instanceof Function) {
|
|
|
|
value();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public close() {
|
2022-06-03 11:44:21 +02:00
|
|
|
UIkit.drop(this.drop.nativeElement).hide();
|
2022-02-24 17:42:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public send(event) {
|
|
|
|
this.sendEmitter.emit(event);
|
|
|
|
}
|
|
|
|
}
|