all files / document-editor-container/ribbon/developer-tab/ mapping-group.js

100% Statements 37/37
66.67% Branches 4/6
100% Functions 10/10
100% Lines 37/37
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   14× 14×     139×         14× 14× 14×                             14× 14× 14×                               68× 68× 68× 68× 68× 68×     14× 14×        
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.MAPPING_GROUP = '_mapping_group';
    exports.XMLMAPPING_ID = '_xmlmapping';
    var MappingGroup = (function () {
        function MappingGroup(container) {
            this.container = container;
            this.ribbonId = this.container.element.id + '_ribbon';
        }
        Object.defineProperty(MappingGroup.prototype, "documentEditor", {
            get: function () {
                return this.container.documentEditor;
            },
            enumerable: true,
            configurable: true
        });
        MappingGroup.prototype.getGroupModel = function () {
            var locale = this.container.localObj;
            var id = this.ribbonId + exports.MAPPING_GROUP;
            return {
                id: id,
                header: locale.getConstant('Mapping'),
                orientation: 'Row',
                enableGroupOverflow: true,
                overflowHeader: locale.getConstant('Mapping'),
                collections: [
                    {
                        items: [
                            this.getXmlMappingButtonModel()
                        ]
                    }
                ]
            };
        };
        MappingGroup.prototype.getXmlMappingButtonModel = function () {
            var locale = this.container.localObj;
            var id = this.ribbonId + exports.MAPPING_GROUP;
            return {
                type: 'Button',
                id: id + exports.XMLMAPPING_ID,
                buttonSettings: {
                    iconCss: 'e-icons e-de-ctnr-xml-mapping',
                    content: locale.getConstant('XML Mapping Pane'),
                    clicked: this.onXmlMappingClick.bind(this)
                },
                ribbonTooltipSettings: {
                    content: locale.getConstant('XML Mapping Pane')
                }
            };
        };
        MappingGroup.prototype.onXmlMappingClick = function () {
            var _this = this;
            Eif (!this.documentEditor.isXmlPaneTool) {
                this.documentEditor.showXmlPane();
            }
            this.container.statusBar.toggleWebLayout();
            setTimeout(function () {
                _this.documentEditor.focusIn();
            }, 30);
        };
        MappingGroup.prototype.updateSelection = function () {
            var isReadOnly = this.documentEditor.isReadOnly;
            var isDocumentProtected = this.documentEditor.documentHelper.isDocumentProtected;
            var enableXmlMapping = !isReadOnly && !isDocumentProtected;
            var xmlMappingElement = document.getElementById(this.ribbonId + exports.MAPPING_GROUP + exports.XMLMAPPING_ID);
            Eif (xmlMappingElement) {
                xmlMappingElement.classList.toggle('e-disabled', !enableXmlMapping);
            }
        };
        MappingGroup.prototype.destroy = function () {
            this.container = undefined;
            this.ribbonId = undefined;
        };
        return MappingGroup;
    }());
    exports.MappingGroup = MappingGroup;
});