All files / src/components/zd-loading loading.ts

100% Statements 15/15
100% Branches 2/2
100% Functions 3/3
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 4593x     93x       4x       4x   4x   4x             4x 4x 4x 4x             3x 2x 3x             3x      
import { Component } from '../zd-component/component';
import { ILoading } from './interfaces';
 
export class Loading extends Component implements ILoading {
	/**
	 * text to show in Loader Overlay
	 */
	public text?: string = 'Loading';
 
	public defaultText?: string;
 
	public opacity?: number | string = 0.5;
 
	public isVisible = false;
 
	public zIndex: number | string = 1999;
 
	/*
	 * Creates a new Loading Overlay
	 * @param props Modal structure
	 */
	constructor(props: ILoading) {
		super(props);
		this.text = this.getInitValue('text', props.text, this.text);
		this.zIndex = this.getInitValue('zIndex', props.zIndex, this.zIndex);
		this.defaultText = this.text;
	}
 
	/**
	 * Displays overlay
	 */
	public show(text?: string) {
		if (text) this.text = text;
		else this.text = this.defaultText;
		this.isVisible = true;
	}
 
	/**
	 * Close overlay
	 */
	public hide() {
		this.isVisible = false;
	}
}