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

95.24% Statements 40/42
50% Branches 2/4
100% Functions 11/11
95.24% Lines 40/42
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×     138×         14× 14× 14×                             14× 14× 14×                             68× 68× 68× 68× 68× 68× 68×     68×         68× 68×     14× 14×        
define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.PROTECT_GROUP = '_developer_protect_group';
    exports.RESTRICT_EDITING_ID = '_restrict_edit';
    var ProtectGroup = (function () {
        function ProtectGroup(container) {
            this.container = container;
            this.ribbonId = this.container.element.id + '_ribbon';
        }
        Object.defineProperty(ProtectGroup.prototype, "documentEditor", {
            get: function () {
                return this.container.documentEditor;
            },
            enumerable: true,
            configurable: true
        });
        ProtectGroup.prototype.getGroupModel = function () {
            var locale = this.container.localObj;
            var id = this.ribbonId + exports.PROTECT_GROUP;
            return {
                id: id,
                header: locale.getConstant('Protect'),
                orientation: 'Row',
                enableGroupOverflow: true,
                overflowHeader: locale.getConstant('Protect'),
                collections: [
                    {
                        items: [
                            this.getRestrictEditingButtonModel()
                        ]
                    }
                ]
            };
        };
        ProtectGroup.prototype.getRestrictEditingButtonModel = function () {
            var locale = this.container.localObj;
            var id = this.ribbonId + exports.PROTECT_GROUP;
            return {
                type: 'Button',
                id: id + exports.RESTRICT_EDITING_ID,
                buttonSettings: {
                    iconCss: 'e-icons e-de-ctnr-lock',
                    content: locale.getConstant('Restrict Editing'),
                    clicked: this.onRestrictEditingClick.bind(this)
                },
                ribbonTooltipSettings: {
                    content: locale.getConstant('Restrict editing')
                }
            };
        };
        ProtectGroup.prototype.onRestrictEditingClick = function () {
            var _this = this;
            this.documentEditor.documentHelper.restrictEditingPane.showHideRestrictPane(true);
            setTimeout(function () {
                _this.documentEditor.focusIn();
            }, 30);
        };
        ProtectGroup.prototype.updateSelection = function () {
            var isReadOnly = this.documentEditor.isReadOnly;
            var isDocumentProtected = this.documentEditor.documentHelper.isDocumentProtected;
            var enableRestrictEditing = !isReadOnly;
            var restrictEditingElement = document.getElementById(this.ribbonId + exports.PROTECT_GROUP + exports.RESTRICT_EDITING_ID);
            Eif (restrictEditingElement) {
                restrictEditingElement.classList.toggle('e-disabled', !enableRestrictEditing);
                this.toggleButton(restrictEditingElement, this.container.restrictEditing);
            }
        };
        ProtectGroup.prototype.toggleButton = function (element, toggle) {
            Iif (toggle) {
                ej2_base_1.classList(element, ['e-btn-toggle'], []);
                element.setAttribute('aria-pressed', 'true');
            }
            else {
                ej2_base_1.classList(element, [], ['e-btn-toggle']);
                element.setAttribute('aria-pressed', 'false');
            }
        };
        ProtectGroup.prototype.destroy = function () {
            this.container = undefined;
            this.ribbonId = undefined;
        };
        return ProtectGroup;
    }());
    exports.ProtectGroup = ProtectGroup;
});