all files / spreadsheet/services/ dialog.js

97.44% Statements 38/39
100% Branches 14/14
87.5% Functions 7/8
97.44% Lines 38/39
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 59 60 61 62   885×   433× 433× 433× 433× 433×             433× 337× 319× 135×     433× 433× 272× 272×         433× 433× 433× 433× 433× 433×   338× 320× 320×   358× 316× 58× 58×   316×              
define(["require", "exports", "@syncfusion/ej2-popups", "@syncfusion/ej2-base", "../common/index"], function (require, exports, ej2_popups_1, ej2_base_1, index_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Dialog = (function () {
        function Dialog(parent) {
            this.parent = parent;
        }
        Dialog.prototype.show = function (dialogModel, cancelBtn) {
            var _this = this;
            var btnContent;
            cancelBtn = ej2_base_1.isNullOrUndefined(cancelBtn) ? true : false;
            var closeHandler = dialogModel.close || null;
            var model = {
                header: 'Spreadsheet',
                cssClass: this.parent.cssClass,
                target: this.parent.element,
                buttons: [],
                allowDragging: true
            };
            dialogModel.close = function () {
                _this.destroyDialog();
                if (closeHandler) {
                    closeHandler();
                }
            };
            ej2_base_1.extend(model, dialogModel);
            if (cancelBtn) {
                btnContent = this.parent.serviceLocator.getService(index_1.locale).getConstant(model.buttons.length ? 'Cancel' : 'Ok');
                model.buttons.push({
                    buttonModel: { content: btnContent, isPrimary: model.buttons.length === 0 },
                    click: this.hide.bind(this)
                });
            }
            var div = this.parent.createElement('div');
            document.body.appendChild(div);
            this.dialogInstance = new ej2_popups_1.Dialog(model);
            this.dialogInstance.createElement = this.parent.createElement;
            this.dialogInstance.appendTo(div);
            this.dialogInstance.refreshPosition();
        };
        Dialog.prototype.destroyDialog = function () {
            this.dialogInstance.destroy();
            ej2_base_1.remove(this.dialogInstance.element);
            this.dialogInstance = null;
        };
        Dialog.prototype.hide = function (disableAnimation) {
            if (this.dialogInstance) {
                if (disableAnimation) {
                    this.dialogInstance.animationSettings.effect = 'None';
                    this.dialogInstance.dataBind();
                }
                this.dialogInstance.hide();
            }
        };
        Dialog.prototype.destroy = function () {
            this.parent = null;
        };
        return Dialog;
    }());
    exports.Dialog = Dialog;
});