import { Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, ChangeDetectorRef, Input, ContentChildren, ViewChild, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { DomHandler } from 'primeng/dom'; import { PrimeTemplate } from 'primeng/api'; class BlockUI { constructor(el, cd) { this.el = el; this.cd = cd; this.autoZIndex = true; this.baseZIndex = 0; } get blocked() { return this._blocked; } set blocked(val) { this._blocked = val; if (this.mask && this.mask.nativeElement) { if (this._blocked) this.block(); else this.unblock(); } } ngAfterViewInit() { if (this.target && !this.target.getBlockableElement) { throw 'Target of BlockUI must implement BlockableUI interface'; } } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'content': this.contentTemplate = item.template; break; default: this.contentTemplate = item.template; break; } }); } block() { if (this.target) { this.target.getBlockableElement().appendChild(this.mask.nativeElement); this.target.getBlockableElement().style.position = 'relative'; } else { document.body.appendChild(this.mask.nativeElement); } if (this.autoZIndex) { this.mask.nativeElement.style.zIndex = String(this.baseZIndex + (++DomHandler.zindex)); } } unblock() { this.el.nativeElement.appendChild(this.mask.nativeElement); } ngOnDestroy() { this.unblock(); } } BlockUI.decorators = [ { type: Component, args: [{ selector: 'p-blockUI', template: `