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;
});
|