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";
|
|
|
|
|
|
|
|
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 {
|
|
|
|
public showForm: boolean = false;
|
|
|
|
@Input()
|
|
|
|
public contactForm: FormGroup;
|
|
|
|
@Input()
|
|
|
|
public sending = false;
|
|
|
|
@Input()
|
|
|
|
public organizationTypes: string[] = [];
|
|
|
|
@Output() sendEmitter: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
private subscriptions: any[] = [];
|
|
|
|
@ViewChild('drop') drop: ElementRef;
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
if (document !== undefined) {
|
|
|
|
this.subscriptions.push(UIkit.util.on(document, 'beforehide', '#quick-contact', (event) => {
|
|
|
|
if(this.sending) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(value => {
|
|
|
|
if (value instanceof Subscriber) {
|
|
|
|
value.unsubscribe();
|
|
|
|
} else if (value instanceof Function) {
|
|
|
|
value();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public close() {
|
|
|
|
UIkit.drop(this.drop.nativeElement).hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
public send(event) {
|
|
|
|
this.sendEmitter.emit(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public toggleModal() {
|
|
|
|
this.showForm = !this.showForm;
|
|
|
|
}
|
|
|
|
}
|