all files / document-editor-container/ribbon/picture-format-tab/ alt-text-dialog.js

36.36% Statements 20/55
11.11% Branches 1/9
44.44% Functions 4/9
36.36% Lines 20/55
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87   14× 14× 14×                                             14×         14×           14× 14×                                                         14×       14× 14× 14×        
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;
});