define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-inputs", "../ribbon-base/ribbon-constants"], function (require, exports, ej2_base_1, ej2_inputs_1, ribbon_constants_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var AltTextDialog = (function () {
function AltTextDialog(container) {
var _this = this;
this.ALT_TEXT_INPUT_ID = '_de-alt-text-input';
this.show = function () {
_this.localObj = new ej2_base_1.L10n('documenteditorcontainer', _this.container.defaultLocale, _this.container.locale);
if (!_this.target) {
_this.initDialog(_this.localObj);
}
var documentHelper = (_this.container.documentEditor).documentHelper;
documentHelper.dialog.header = _this.localObj.getConstant('Alt Text');
documentHelper.dialog.height = 'auto';
documentHelper.dialog.width = 'auto';
documentHelper.dialog.content = _this.target;
documentHelper.dialog.buttons = [{
click: _this.applyAltText,
buttonModel: { content: _this.localObj.getConstant('Apply'), cssClass: 'e-flat', isPrimary: true }
},
{
click: _this.hideDialog,
buttonModel: { content: _this.localObj.getConstant('Cancel'), cssClass: 'e-flat' }
}];
var currentAltText = _this.getCurrentAltText();
_this.altTextArea.value = currentAltText;
documentHelper.dialog.dataBind();
documentHelper.dialog.show();
};
this.applyAltText = function () {
var altText = _this.altTextArea.value;
_this.container.documentEditor.selection.imageFormat.applyImageAlternativeText(altText);
_this.hideDialog();
};
this.hideDialog = function () {
var documentHelper = (_this.container.documentEditor).documentHelper;
_this.altTextArea.value = '';
documentHelper.dialog.hide();
_this.container.documentEditor.focusIn();
};
this.container = container;
this.localObj = new ej2_base_1.L10n('documenteditorcontainer', this.container.defaultLocale, this.container.locale);
}
AltTextDialog.prototype.initDialog = function (localValue) {
var id = this.container.element.id + ribbon_constants_1.RIBBON_ID + '_alt_text_dialog';
this.target = ej2_base_1.createElement('div', { id: id, className: 'e-de-alt-text' });
var container = ej2_base_1.createElement('div');
var label = ej2_base_1.createElement('div', {
className: 'e-de-alt-text-dlg-title',
innerHTML: localValue.getConstant('Alternative Text')
});
this.textAreaElement = ej2_base_1.createElement('textarea', {
id: this.container.element.id + ribbon_constants_1.RIBBON_ID + this.ALT_TEXT_INPUT_ID,
className: 'e-input e-de-alt-text-dlg-textarea'
});
container.appendChild(label);
container.appendChild(this.textAreaElement);
this.target.appendChild(container);
this.altTextArea = new ej2_inputs_1.TextArea({
rows: 5,
cssClass: 'e-de-alt-text-area'
});
this.altTextArea.appendTo(this.textAreaElement);
};
AltTextDialog.prototype.getCurrentAltText = function () {
if (this.container.documentEditor &&
this.container.documentEditor.selection &&
this.container.documentEditor.selection.imageFormat) {
return this.container.documentEditor.selection.imageFormat.alternateText;
}
return '';
};
AltTextDialog.prototype.destroy = function () {
Iif (this.altTextArea) {
this.altTextArea.destroy();
this.altTextArea = undefined;
}
this.container = undefined;
this.target = undefined;
this.textAreaElement = undefined;
};
return AltTextDialog;
}());
exports.AltTextDialog = AltTextDialog;
});
|