all files / document-editor-container/ribbon/table-layout-tab/ table-operations-group.js

55.71% Statements 39/70
54.17% Branches 13/24
68.42% Functions 13/19
53.73% Lines 36/67
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          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"], function (require, exports, ribbon_interfaces_1, ej2_ribbon_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.TABLE_OPERATIONS_GROUP_ID = '_table_operations_group';
    exports.SELECT_DROPDOWN_ID = '_select_dropdown';
    exports.DELETE_DROPDOWN_ID = '_delete_dropdown';
    exports.INSERT_DROPDOWN_ID = '_insert_dropdown';
    var TableOperationsGroup = (function (_super) {
        __extends(TableOperationsGroup, _super);
        function TableOperationsGroup(container) {
            return _super.call(this, container) || this;
        }
        TableOperationsGroup.prototype.getGroupModel = function () {
            return {
                id: this.ribbonId + exports.TABLE_OPERATIONS_GROUP_ID,
                header: this.localObj.getConstant('Rows & Columns'),
                orientation: ej2_ribbon_1.ItemOrientation.Row,
                enableGroupOverflow: true,
                overflowHeader: this.localObj.getConstant('Rows & Columns'),
                collections: [
                    {
                        items: [
                            this.getSelectDropDown(),
                            this.getDeleteDropDown(),
                            this.getInsertDropDown()
                        ]
                    }
                ]
            };
        };
        TableOperationsGroup.prototype.getSelectDropDown = function () {
            var _this = this;
            return {
                type: ej2_ribbon_1.RibbonItemType.DropDown,
                id: this.ribbonId + exports.SELECT_DROPDOWN_ID,
                keyTip: 'K',
                dropDownSettings: {
                    content: this.localObj.getConstant('Select'),
                    iconCss: 'e-icons e-de-ctnr-mouse-pointer',
                    items: [
                        { text: this.localObj.getConstant('Table'), id: this.ribbonId + '_select_table', iconCss: 'e-icons e-de-ctnr-table-2' },
                        { text: this.localObj.getConstant('Row'), id: this.ribbonId + '_select_row', iconCss: 'e-icons e-de-ctnr-freeze-row' },
                        { text: this.localObj.getConstant('Column'), id: this.ribbonId + '_select_column', iconCss: 'e-icons e-de-ctnr-freeze-column' },
                        { text: this.localObj.getConstant('Cell'), id: this.ribbonId + '_select_cell', iconCss: 'e-icons e-de-ctnr-table-cell' }
                    ],
                    select: function (args) {
                        _this.handleTableSelection(args.item.text);
                    }
                },
                ribbonTooltipSettings: {
                    content: this.localObj.getConstant('Select the table')
                }
            };
        };
        TableOperationsGroup.prototype.getDeleteDropDown = function () {
            var _this = this;
            return {
                type: ej2_ribbon_1.RibbonItemType.DropDown,
                id: exports.DELETE_DROPDOWN_ID,
                keyTip: 'H',
                dropDownSettings: {
                    content: this.localObj.getConstant('Delete'),
                    iconCss: 'e-icons e-de-ctnr-table-delete',
                    items: [
                        { text: this.localObj.getConstant('Table'), id: this.ribbonId + '_delete_table', iconCss: 'e-icons e-de-ctnr-table-delete' },
                        { text: this.localObj.getConstant('Row'), id: this.ribbonId + '_delete_row', iconCss: 'e-icons e-de-ctnr-deleterows' },
                        { text: this.localObj.getConstant('Column'), id: this.ribbonId + '_delete_column', iconCss: 'e-icons e-de-ctnr-deletecolumns' }
                    ],
                    select: function (args) {
                        _this.handleTableDeletion(args.item.text);
                    }
                },
                ribbonTooltipSettings: {
                    content: this.localObj.getConstant('Delete the table')
                }
            };
        };
        TableOperationsGroup.prototype.getInsertDropDown = function () {
            var _this = this;
            return {
                type: ej2_ribbon_1.RibbonItemType.DropDown,
                id: exports.INSERT_DROPDOWN_ID,
                keyTip: 'N',
                dropDownSettings: {
                    content: this.localObj.getConstant('Insert'),
                    iconCss: 'e-icons e-de-ctnr-table',
                    items: [
                        { text: this.localObj.getConstant('Row Above'), id: this.ribbonId + '_insert_row_above', iconCss: 'e-icons e-de-ctnr-insertabove' },
                        { text: this.localObj.getConstant('Row Below'), id: this.ribbonId + '_insert_row_below', iconCss: 'e-icons e-de-ctnr-insertbelow' },
                        { text: this.localObj.getConstant('Column Left'), id: this.ribbonId + '_insert_column_left', iconCss: 'e-icons e-de-ctnr-insertleft' },
                        { text: this.localObj.getConstant('Column Right'), id: this.ribbonId + '_insert_column_right', iconCss: 'e-icons e-de-ctnr-insertright' }
                    ],
                    select: function (args) {
                        _this.handleTableInsertion(args.item.text);
                    }
                },
                ribbonTooltipSettings: {
                    content: this.localObj.getConstant('Insert rows and columns')
                }
            };
        };
        TableOperationsGroup.prototype.handleTableSelection = function (action) {
            var selection = this.documentEditor.selection;
            switch (action) {
                case this.localObj.getConstant('Table'):
                    selection.selectTable();
                    break;
                case this.localObj.getConstant('Row'):
                    selection.selectRow();
                    break;
                case this.localObj.getConstant('Column'):
                    selection.selectColumn();
                    break;
                case this.localObj.getConstant('Cell'):
                    selection.selectCell();
                    break;
            }
        };
        TableOperationsGroup.prototype.handleTableDeletion = function (action) {
            var editor = this.documentEditor.editorModule;
            switch (action) {
                case this.localObj.getConstant('Table'):
                    editor.deleteTable();
                    break;
                case this.localObj.getConstant('Row'):
                    editor.deleteRow();
                    break;
                case this.localObj.getConstant('Column'):
                    editor.deleteColumn();
                    break;
            }
        };
        TableOperationsGroup.prototype.handleTableInsertion = function (action) {
            var editor = this.documentEditor.editorModule;
            switch (action) {
                case this.localObj.getConstant('Row Above'):
                    editor.insertRow(true);
                    break;
                case this.localObj.getConstant('Row Below'):
                    editor.insertRow(false);
                    break;
                case this.localObj.getConstant('Column Left'):
                    editor.insertColumn(true);
                    break;
                case this.localObj.getConstant('Column Right'):
                    editor.insertColumn(false);
                    break;
            }
        };
        return TableOperationsGroup;
    }(ribbon_interfaces_1.RibbonGroupBase));
    exports.TableOperationsGroup = TableOperationsGroup;
});