all files / document-editor-container/ribbon/home-tab/ home-paragraph-group.js

85.84% Statements 97/113
61.4% Branches 35/57
80% Functions 24/30
85.45% Lines 94/110
11 statements, 6 functions, 9 branches Ignored     
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283          14× 14× 14× 14× 14×   14× 14× 14×                                                                                                                                                                                                                                                                               118× 118×     118× 118× 118× 118× 118× 118× 118× 118× 118× 118×                 118× 118× 118× 118× 118×       590× 590× 590× 119×     471×                                                     14× 14× 14×   14× 14× 14×   14× 14×          
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "../ribbon-interfaces", "@syncfusion/ej2-ribbon", "./bullets-group", "./numbering-group", "./line-spacing-group"], function (require, exports, ribbon_interfaces_1, ej2_ribbon_1, bullets_group_1, numbering_group_1, line_spacing_group_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.PARAGRAPH_GROUP_ID = '_paragraph_group';
    exports.ALIGN_LEFT_ID = '_align_left';
    exports.ALIGN_CENTER_ID = '_align_center';
    exports.ALIGN_RIGHT_ID = '_align_right';
    exports.JUSTIFY_ID = '_justify';
    exports.DECREASE_INDENT_ID = '_decrease_indent';
    exports.INCREASE_INDENT_ID = '_increase_indent';
    exports.SHOW_HIDE_MARKS_ID = '_show_hide_marks';
    exports.BORDERS_ID = '_borders';
    var HomeParagraphGroup = (function (_super) {
        __extends(HomeParagraphGroup, _super);
        function HomeParagraphGroup(container) {
            var _this = _super.call(this, container) || this;
            _this.bulletsGroup = new bullets_group_1.BulletsGroup(container);
            _this.numberingGroup = new numbering_group_1.NumberingGroup(container);
            _this.lineSpacingGroup = new line_spacing_group_1.LineSpacingGroup(container);
            return _this;
        }
        HomeParagraphGroup.prototype.getGroupModel = function () {
            var _this = this;
            var id = this.ribbonId;
            return {
                id: id + exports.PARAGRAPH_GROUP_ID,
                cssClass: 'e-paragraph-group',
                header: this.localObj.getConstant('Paragraph'),
                isCollapsible: false,
                enableGroupOverflow: true,
                overflowHeader: this.localObj.getConstant('More Paragraph Options'),
                groupIconCss: 'e-icons e-de-paragraph',
                orientation: 'Row',
                showLauncherIcon: true,
                launcherIconKeyTip: 'PG',
                collections: [{
                        id: id + '_paragraph-bullets',
                        items: [
                            this.bulletsGroup.getBulletListItem(),
                            this.numberingGroup.getNumberingListItem(),
                            {
                                type: 'Button',
                                keyTip: 'AO',
                                allowedSizes: ej2_ribbon_1.RibbonItemSize.Small,
                                buttonSettings: {
                                    content: this.localObj.getConstant('Increase indent'),
                                    iconCss: 'e-icons e-de-ctnr-increaseindent',
                                    clicked: function () {
                                        _this.increaseIndentAction();
                                    }
                                },
                                id: id + exports.INCREASE_INDENT_ID,
                                ribbonTooltipSettings: { content: this.localObj.getConstant('Increase indent') }
                            },
                            {
                                type: 'Button',
                                keyTip: 'AI',
                                allowedSizes: ej2_ribbon_1.RibbonItemSize.Small,
                                buttonSettings: {
                                    content: this.localObj.getConstant('Decrease indent'),
                                    iconCss: 'e-icons e-de-ctnr-decreaseindent',
                                    clicked: function () {
                                        _this.decreaseIndentAction();
                                    }
                                },
                                id: id + exports.DECREASE_INDENT_ID,
                                ribbonTooltipSettings: { content: this.localObj.getConstant('Decrease indent') }
                            },
                            {
                                type: 'Button',
                                keyTip: 'FM',
                                allowedSizes: ej2_ribbon_1.RibbonItemSize.Small,
                                buttonSettings: {
                                    content: this.localObj.getConstant('Show/Hide Marks'),
                                    iconCss: 'e-icons e-de-e-paragraph-mark',
                                    isToggle: true,
                                    clicked: function () {
                                        _this.toggleHiddenMarks();
                                    }
                                },
                                id: id + exports.SHOW_HIDE_MARKS_ID,
                                ribbonTooltipSettings: { content: this.localObj.getConstant('ShowHiddenMarks Tooltip') }
                            }
                        ]
                    },
                    {
                        items: [{
                                type: 'Button',
                                keyTip: 'AL',
                                allowedSizes: ej2_ribbon_1.RibbonItemSize.Small,
                                buttonSettings: {
                                    content: this.localObj.getConstant('Align left Tooltip'),
                                    iconCss: 'e-icons e-de-ctnr-alignleft',
                                    isToggle: true,
                                    clicked: function () {
                                        _this.leftAlignmentAction();
                                    }
                                },
                                id: id + exports.ALIGN_LEFT_ID,
                                ribbonTooltipSettings: { content: this.localObj.getConstant('Align left Tooltip') }
                            },
                            {
                                type: 'Button',
                                keyTip: 'AC',
                                allowedSizes: ej2_ribbon_1.RibbonItemSize.Small,
                                buttonSettings: {
                                    content: this.localObj.getConstant('Center Tooltip'),
                                    iconCss: 'e-icons e-de-ctnr-aligncenter',
                                    isToggle: true,
                                    clicked: function () {
                                        _this.centerAlignmentAction();
                                    }
                                },
                                id: id + exports.ALIGN_CENTER_ID,
                                ribbonTooltipSettings: { content: this.localObj.getConstant('Center Tooltip') }
                            },
                            {
                                type: 'Button',
                                keyTip: 'AR',
                                allowedSizes: ej2_ribbon_1.RibbonItemSize.Small,
                                buttonSettings: {
                                    content: this.localObj.getConstant('Align right Tooltip'),
                                    iconCss: 'e-icons e-de-ctnr-alignright',
                                    isToggle: true,
                                    clicked: function () {
                                        _this.rightAlignmentAction();
                                    }
                                },
                                id: id + exports.ALIGN_RIGHT_ID,
                                ribbonTooltipSettings: { content: this.localObj.getConstant('Align right Tooltip') }
                            },
                            {
                                type: 'Button',
                                keyTip: 'AJ',
                                allowedSizes: ej2_ribbon_1.RibbonItemSize.Small,
                                buttonSettings: {
                                    content: this.localObj.getConstant('Justify Tooltip'),
                                    iconCss: 'e-icons e-de-ctnr-justify',
                                    isToggle: true,
                                    clicked: function () {
                                        _this.justifyAction();
                                    }
                                },
                                id: id + exports.JUSTIFY_ID,
                                ribbonTooltipSettings: { content: this.localObj.getConstant('Justify Tooltip') }
                            },
                            this.lineSpacingGroup.getLineSpacingItem(),
                            {
                                type: 'Button',
                                keyTip: 'B',
                                allowedSizes: ej2_ribbon_1.RibbonItemSize.Small,
                                buttonSettings: {
                                    content: this.localObj.getConstant('Borders'),
                                    iconCss: 'e-icons e-de-ctnr-borders',
                                    clicked: function () {
                                        _this.bordersAction();
                                    }
                                },
                                id: id + exports.BORDERS_ID,
                                ribbonTooltipSettings: { content: this.localObj.getConstant('Borders') }
                            }
                        ]
                    }]
            };
        };
        HomeParagraphGroup.prototype.updateSelection = function () {
            var ribbon = this.container.ribbonModule.ribbon;
            Iif (!ribbon) {
                return;
            }
            var id = this.ribbonId;
            Eif (this.documentEditor.selection) {
                var paragraphFormat = this.documentEditor.selection.paragraphFormat;
                this.updateToggleButtonState(id + exports.ALIGN_LEFT_ID, paragraphFormat.textAlignment === 'Left');
                this.updateToggleButtonState(id + exports.ALIGN_CENTER_ID, paragraphFormat.textAlignment === 'Center');
                this.updateToggleButtonState(id + exports.ALIGN_RIGHT_ID, paragraphFormat.textAlignment === 'Right');
                this.updateToggleButtonState(id + exports.JUSTIFY_ID, paragraphFormat.textAlignment === 'Justify');
                this.updateToggleButtonState(id + exports.SHOW_HIDE_MARKS_ID, this.container.documentEditorSettings.showHiddenMarks);
                this.lineSpacingGroup.setLineSpacing();
                Iif (this.documentEditor.isReadOnly) {
                    ribbon.disableItem(id + exports.INCREASE_INDENT_ID);
                    ribbon.disableItem(id + exports.DECREASE_INDENT_ID);
                    ribbon.disableItem(id + bullets_group_1.BULLET_LIST_ID);
                    ribbon.disableItem(id + numbering_group_1.NUMBER_LIST_ID);
                    ribbon.disableItem(id + exports.BORDERS_ID);
                    ribbon.disableItem(id + line_spacing_group_1.LINE_SPACING_ID);
                }
                else {
                    ribbon.enableItem(id + exports.INCREASE_INDENT_ID);
                    ribbon.enableItem(id + bullets_group_1.BULLET_LIST_ID);
                    ribbon.enableItem(id + numbering_group_1.NUMBER_LIST_ID);
                    ribbon.enableItem(id + exports.BORDERS_ID);
                    ribbon.enableItem(id + line_spacing_group_1.LINE_SPACING_ID);
                }
            }
        };
        HomeParagraphGroup.prototype.updateToggleButtonState = function (buttonId, isActive) {
            var buttonElement = document.querySelector('#' + buttonId);
            Eif (buttonElement) {
                if (isActive) {
                    buttonElement.classList.add('e-active');
                }
                else {
                    buttonElement.classList.remove('e-active');
                }
            }
        };
        HomeParagraphGroup.prototype.leftAlignmentAction = function () {
            Eif (!this.documentEditor.isReadOnly && this.documentEditor.selection) {
                this.documentEditor.selection.paragraphFormat.textAlignment = 'Left';
            }
        };
        HomeParagraphGroup.prototype.centerAlignmentAction = function () {
            Eif (!this.documentEditor.isReadOnly && this.documentEditor.selection) {
                this.documentEditor.selection.paragraphFormat.textAlignment = 'Center';
            }
        };
        HomeParagraphGroup.prototype.rightAlignmentAction = function () {
            Eif (!this.documentEditor.isReadOnly && this.documentEditor.selection) {
                this.documentEditor.selection.paragraphFormat.textAlignment = 'Right';
            }
        };
        HomeParagraphGroup.prototype.justifyAction = function () {
            Eif (!this.documentEditor.isReadOnly && this.documentEditor.selection) {
                this.documentEditor.selection.paragraphFormat.textAlignment = 'Justify';
            }
        };
        HomeParagraphGroup.prototype.increaseIndentAction = function () {
            if (!this.documentEditor.isReadOnly && this.documentEditor.editor) {
                this.documentEditor.editor.increaseIndent();
            }
        };
        HomeParagraphGroup.prototype.decreaseIndentAction = function () {
            if (!this.documentEditor.isReadOnly && this.documentEditor.editor) {
                this.documentEditor.editor.decreaseIndent();
            }
        };
        HomeParagraphGroup.prototype.toggleHiddenMarks = function () {
            var _this = this;
            Eif (this.documentEditor) {
                this.container.documentEditorSettings.showHiddenMarks = !this.container.documentEditorSettings.showHiddenMarks;
                setTimeout(function () {
                    _this.documentEditor.focusIn();
                }, 30);
            }
        };
        HomeParagraphGroup.prototype.bordersAction = function () {
            if (!this.documentEditor.isReadOnly) {
                this.documentEditor.showDialog('BordersAndShading');
            }
        };
        HomeParagraphGroup.prototype.destroy = function () {
            Eif (this.bulletsGroup) {
                this.bulletsGroup.destroy();
                this.bulletsGroup = null;
            }
            Eif (this.numberingGroup) {
                this.numberingGroup.destroy();
                this.numberingGroup = null;
            }
            Eif (this.lineSpacingGroup) {
                this.lineSpacingGroup = null;
            }
        };
        return HomeParagraphGroup;
    }(ribbon_interfaces_1.RibbonGroupBase));
    exports.HomeParagraphGroup = HomeParagraphGroup;
});