define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PicContentControlDialog = (function () {
function PicContentControlDialog(documentHelper) {
var _this = this;
this.onCancelButtonClick = function () {
_this.documentHelper.dialog2.hide();
_this.documentHelper.updateFocus();
};
this.onInsertPicClick = function () {
_this.documentHelper.dialog2.hide();
_this.imagePicker = ej2_base_1.createElement('input', {
attrs: { type: 'file', accept: '.jpg,.jpeg,.png,.bmp,.svg' }, className: 'e-de-ctnr-file-picker'
});
if (ej2_base_1.Browser.isIE) {
document.body.appendChild(_this.imagePicker);
}
_this.imagePicker.value = '';
_this.imagePicker.click();
ej2_base_1.EventHandler.add(_this.imagePicker, 'change', _this.onImageChange, _this);
};
this.documentHelper = documentHelper;
}
PicContentControlDialog.prototype.getModuleName = function () {
return 'PicContentControlDialog';
};
PicContentControlDialog.prototype.show = function () {
var localValue = new ej2_base_1.L10n('documenteditor', this.documentHelper.owner.defaultLocale);
localValue.setLocale(this.documentHelper.owner.locale);
this.localeValue = localValue;
this.documentHelper.dialog2.header = localValue.getConstant('Insert Pictures');
this.documentHelper.dialog2.showCloseIcon = true;
this.documentHelper.dialog2.allowDragging = true;
this.documentHelper.dialog2.position = { X: 'center', Y: 'center' };
this.documentHelper.dialog2.beforeOpen = this.documentHelper.updateFocus;
this.documentHelper.dialog2.buttons = [{
click: this.onInsertPicClick,
buttonModel: { content: localValue.getConstant('Upload from computer'), iconCss: 'e-icons e-de-ctnr-upload', iconPosition: 'Left' }
}];
this.documentHelper.dialog2.dataBind();
this.documentHelper.dialog2.show();
};
PicContentControlDialog.prototype.onImageChange = function () {
var _this = this;
var file = this.imagePicker.files[0];
var fileReader = new FileReader();
fileReader.onload = function () {
_this.insertImage(fileReader.result);
};
fileReader.readAsDataURL(file);
};
PicContentControlDialog.prototype.insertImage = function (data) {
this.image = document.createElement('img');
var documentHelper = this.documentHelper;
var container = this.container;
this.image.addEventListener('load', function () {
documentHelper.owner.editorModule.insertImageInternal(data, true, this.width, this.height, this.alt);
if (!documentHelper.owner.selection.isImageSelected) {
documentHelper.owner.selection.handleShiftLeftKey();
documentHelper.owner.editor.insertContentControl('Picture');
}
});
this.image.src = data;
};
PicContentControlDialog.prototype.destroy = function () {
this.documentHelper = undefined;
Iif (this.imagePicker) {
this.imagePicker.remove();
this.imagePicker = undefined;
}
Iif (this.image) {
this.image.remove();
this.image = undefined;
}
};
return PicContentControlDialog;
}());
exports.PicContentControlDialog = PicContentControlDialog;
});
|