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

95.08% Statements 58/61
81.82% Branches 18/22
100% Functions 10/10
95.08% Lines 58/61
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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148   14× 14×     284×         14× 14× 14×                               14× 14× 14×                                                                                                                       68× 68× 68× 68× 68× 68× 68× 68×     14×       14× 14×        
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.CONTROL_GROUP = '_control_group';
    exports.CONTENT_CONTROL_ID = '_content_control';
    exports.RICHTEXT_CONTENT_CONTROL_ID = '_richtext_content_control';
    exports.PLAINTEXT_CONTENT_CONTROL_ID = '_plaintext_content_control';
    exports.COMBOBOX_CONTENT_CONTROL_ID = '_combobox_content_control';
    exports.DROPDOWNDOWN_CONTENT_CONTROL_ID = '_dropdown_content_control';
    exports.DATEPICKER_CONTENT_CONTROL_ID = '_datepicker_content_control';
    exports.CHECKBOX_CONTENT_CONTROL_ID = '_checkbox_content_control';
    exports.PICTURE_CONTENT_CONTROL_ID = '_picture_content_control';
    var ControlGroup = (function () {
        function ControlGroup(container) {
            this.container = container;
            this.ribbonId = this.container.element.id + '_ribbon';
        }
        Object.defineProperty(ControlGroup.prototype, "documentEditor", {
            get: function () {
                return this.container.documentEditor;
            },
            enumerable: true,
            configurable: true
        });
        ControlGroup.prototype.getGroupModel = function () {
            var locale = this.container.localObj;
            var id = this.ribbonId + exports.CONTROL_GROUP;
            return {
                id: id,
                header: locale.getConstant('Controls'),
                orientation: 'Row',
                cssClass: 'e-controls-group',
                enableGroupOverflow: true,
                overflowHeader: locale.getConstant('Controls'),
                collections: [
                    {
                        items: [
                            this.getContentControlDropDownModel()
                        ]
                    }
                ]
            };
        };
        ControlGroup.prototype.getContentControlDropDownModel = function () {
            var locale = this.container.localObj;
            var id = this.ribbonId + exports.CONTROL_GROUP;
            return {
                type: 'DropDown',
                id: id + exports.CONTENT_CONTROL_ID,
                dropDownSettings: {
                    iconCss: 'e-icons e-de-ctnr-content-control',
                    content: locale.getConstant('Content Control'),
                    items: [
                        {
                            text: locale.getConstant('Rich Text Content Control'),
                            iconCss: 'e-icons e-de-ctnr-change-case',
                            id: id + exports.RICHTEXT_CONTENT_CONTROL_ID
                        },
                        {
                            text: locale.getConstant('Plain Text Content Control'),
                            iconCss: 'e-icons e-de-ctnr-change-case',
                            id: id + exports.PLAINTEXT_CONTENT_CONTROL_ID
                        },
                        {
                            text: locale.getConstant('Picture Content Control'),
                            iconCss: 'e-icons e-de-ctnr-image',
                            id: id + exports.PICTURE_CONTENT_CONTROL_ID
                        },
                        {
                            text: locale.getConstant('Combo Box Content Control'),
                            iconCss: 'e-icons e-de-combo-box',
                            id: id + exports.COMBOBOX_CONTENT_CONTROL_ID
                        },
                        {
                            text: locale.getConstant('Drop-Down List Content Control'),
                            iconCss: 'e-icons e-de-dropdown-list',
                            id: id + exports.DROPDOWNDOWN_CONTENT_CONTROL_ID
                        },
                        {
                            text: locale.getConstant('Date Picker Content Control'),
                            iconCss: 'e-icons e-timeline-today',
                            id: id + exports.DATEPICKER_CONTENT_CONTROL_ID
                        },
                        {
                            text: locale.getConstant('Check Box Content Control'),
                            iconCss: 'e-icons e-check-box',
                            id: id + exports.CHECKBOX_CONTENT_CONTROL_ID
                        }
                    ],
                    select: this.onContentControlDropDownSelect.bind(this)
                },
                ribbonTooltipSettings: {
                    content: locale.getConstant('Insert content controls')
                }
            };
        };
        ControlGroup.prototype.onContentControlDropDownSelect = function (args) {
            var _this = this;
            var id = this.ribbonId + exports.CONTROL_GROUP;
            if (args.item.id === id + exports.RICHTEXT_CONTENT_CONTROL_ID) {
                this.documentEditor.editor.insertContentControl('RichText');
            }
            else if (args.item.id === id + exports.PLAINTEXT_CONTENT_CONTROL_ID) {
                this.documentEditor.editor.insertContentControl('Text');
            }
            else Iif (args.item.id === id + exports.PICTURE_CONTENT_CONTROL_ID) {
                this.documentEditor.showDialog('PictureContentControl');
            }
            else if (args.item.id === id + exports.COMBOBOX_CONTENT_CONTROL_ID) {
                this.documentEditor.editor.insertContentControl('ComboBox');
            }
            else if (args.item.id === id + exports.DROPDOWNDOWN_CONTENT_CONTROL_ID) {
                this.documentEditor.editor.insertContentControl('DropDownList');
            }
            else if (args.item.id === id + exports.DATEPICKER_CONTENT_CONTROL_ID) {
                this.documentEditor.editor.insertContentControl('Date');
            }
            else Eif (args.item.id === id + exports.CHECKBOX_CONTENT_CONTROL_ID) {
                this.documentEditor.editor.insertContentControl('CheckBox');
            }
            setTimeout(function () {
                _this.documentEditor.focusIn();
            }, 30);
        };
        ControlGroup.prototype.updateSelection = function () {
            var isReadOnly = this.documentEditor.isReadOnly;
            var isDocumentProtected = this.documentEditor.documentHelper.isDocumentProtected;
            var isHeaderFooter = this.documentEditor.enableHeaderAndFooter;
            var isPlainContentControl = this.documentEditor.selectionModule.isPlainContentControl();
            var enableContentControls = !isReadOnly && !isDocumentProtected && !isHeaderFooter && !isPlainContentControl;
            var contentControlElement = document.getElementById(this.ribbonId + exports.CONTROL_GROUP + exports.CONTENT_CONTROL_ID);
            Eif (contentControlElement) {
                contentControlElement.classList.toggle('e-disabled', !enableContentControls);
            }
        };
        ControlGroup.prototype.destroy = function () {
            Iif (this.contentControlDropDown) {
                this.contentControlDropDown.destroy();
                this.contentControlDropDown = undefined;
            }
            this.container = undefined;
            this.ribbonId = undefined;
        };
        return ControlGroup;
    }());
    exports.ControlGroup = ControlGroup;
});