jec-glasscat
Version:
JEC GlassCat - The GlassCat Aplication Server is the default JEC implementation.
95 lines (78 loc) • 2.84 kB
text/typescript
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
//
// Copyright 2016-2018 Pascal ECHEMANN.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import {NgModule,Component,Input,AfterViewInit,OnDestroy,EventEmitter,ElementRef} from '@angular/core';
import {CommonModule} from '@angular/common';
import {DomHandler} from 'primeng/components/dom/domhandler';
import {BlockableUI} from 'primeng/components/common/api';
export class BlockUI implements AfterViewInit,OnDestroy {
target: any;
_blocked: boolean;
_mask: HTMLDivElement;
constructor(public el: ElementRef,public domHandler: DomHandler) {}
get blocked(): boolean {
return this._blocked;
}
set blocked(val: boolean) {
this._blocked = val;
if(this._mask) {
if(this._blocked)
this.block();
else
this.unblock();
}
}
ngAfterViewInit() {
this._mask = this.el.nativeElement.children[0];
if(this.target && !this.target.getBlockableElement) {
throw 'Target of BlockUI must implement BlockableUI interface';
}
}
block() {
if(this.target) {
this.target.getBlockableElement().appendChild(this._mask);
const style = this.target.style||{};
style.position = 'relative';
this.target.style = style;
}
else {
document.body.appendChild(this._mask);
}
this._mask.style.zIndex = String(++DomHandler.zindex);
}
unblock() {
this.el.nativeElement.appendChild(this._mask);
}
ngOnDestroy() {
}
}
export class BlockUIModule { }