all files / common/popups/ error-dialog.js

100% Statements 21/21
87.5% Branches 7/8
100% Functions 6/6
100% Lines 21/21
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58   219×                                                                        
define(["require", "exports", "@syncfusion/ej2-base", "../base/css-constant", "@syncfusion/ej2-popups"], function (require, exports, ej2_base_1, cls, ej2_popups_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ErrorDialog = (function () {
        function ErrorDialog(parent) {
            this.parent = parent;
        }
        ErrorDialog.prototype.createErrorDialog = function (title, description) {
            var errorDialog = ej2_base_1.createElement('div', {
                id: this.parent.parentID + '_ErrorDialog',
                className: cls.ERROR_DIALOG_CLASS
            });
            this.parent.element.appendChild(errorDialog);
            this.errorPopUp = new ej2_popups_1.Dialog({
                animationSettings: { effect: 'Fade' },
                allowDragging: false,
                header: title,
                content: description,
                isModal: true,
                visible: true,
                showCloseIcon: true,
                enableRtl: this.parent.enableRtl,
                enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
                width: 'auto',
                height: 'auto',
                position: { X: 'center', Y: 'center' },
                buttons: [
                    {
                        click: this.closeErrorDialog.bind(this),
                        isFlat: false,
                        buttonModel: { cssClass: cls.OK_BUTTON_CLASS + (this.parent.cssClass ? (' ' + this.parent.cssClass) : ''), content: this.parent.localeObj.getConstant('ok'), isPrimary: true }
                    }
                ],
                cssClass: this.parent.cssClass,
                closeOnEscape: true,
                target: document.body,
                close: this.removeErrorDialog.bind(this)
            });
            this.errorPopUp.isStringTemplate = true;
            this.errorPopUp.appendTo(errorDialog);
        };
        ErrorDialog.prototype.closeErrorDialog = function () {
            this.errorPopUp.close();
        };
        ErrorDialog.prototype.removeErrorDialog = function () {
            if (this.errorPopUp && !this.errorPopUp.isDestroyed) {
                this.errorPopUp.destroy();
                this.errorPopUp = null;
            }
            if (document.getElementById(this.parent.parentID + '_ErrorDialog')) {
                ej2_base_1.remove(document.getElementById(this.parent.parentID + '_ErrorDialog'));
            }
        };
        return ErrorDialog;
    }());
    exports.ErrorDialog = ErrorDialog;
});