From 76a5e3fbc535be93963b84dfab3eefcc002e5805 Mon Sep 17 00:00:00 2001 From: Danis Date: Fri, 17 Oct 2025 17:00:17 +0400 Subject: [PATCH] added other options --- .../main/app/controller/Toolbar.js | 115 +++++++++++++----- .../main/app/view/Toolbar.js | 34 +++++- 2 files changed, 115 insertions(+), 34 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 9c92412c50..c06cad1637 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -1698,43 +1698,71 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Cell delete'); }, - onShowBeforeCellFormat: function(cmp, item, e) { - if (cmp.mnuShowSheets.menu.items.length>0) return; - - cmp.btnFormatCell.menu.items[0].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); - cmp.btnFormatCell.menu.items[1].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); - cmp.btnFormatCell.menu.items[3].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); - cmp.btnFormatCell.menu.items[4].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); - cmp.btnFormatCell.menu.items[4].menu.items[2].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); - - let hiddenItems = SSE.getController('Statusbar').statusbar.tabMenu.items[5].menu.items; - cmp.mnuShowSheets.menu.removeAll(); - hiddenItems.forEach(item => { - cmp.mnuShowSheets.menu.addItem(new Common.UI.MenuItem({ - style: 'white-space: pre-wrap', - caption: item.caption, - value: 'showSheet', - sheetId: item.value - })) - }) + onShowBeforeCellFormat: function(cmp, item, e) { + + // if (cmp.mnuShowSheets.menu.items.length>0) return; + // cmp.btnFormatCell.menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + // cmp.btnFormatCell.menu.items[0].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + // cmp.btnFormatCell.menu.items[1].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + // cmp.btnFormatCell.menu.items[3].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + // cmp.btnFormatCell.menu.items[4].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + // cmp.btnFormatCell.menu.items[4].menu.items[2].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + + // let hiddenItems = SSE.getController('Statusbar').statusbar.tabMenu.items[5].menu.items; + // cmp.mnuShowSheets.menu.removeAll(); + // hiddenItems.forEach(item => { + // cmp.mnuShowSheets.menu.addItem(new Common.UI.MenuItem({ + // style: 'white-space: pre-wrap', + // caption: item.caption, + // value: 'showSheet', + // sheetId: item.value + // })) + // }) + // console.log(Common.NotificationCenter); + + // Common.NotificationCenter.trigger('edit:complete', this.toolbar); // Common.component.Analytics.trackEvent('ToolBar', 'Cell delete'); }, onCellFormatMenu: function(menu, item, e) { if (!this.api) return; - - if (['row-height', 'column-width', 'auto-row-height', 'auto-column-width'].includes(item.value)) - SSE.getController('DocumentHolder').onSetSize(menu, item); - if (item.value === 'hideCell') - this.api[item.options.isRowMenu ? 'asc_hideRows' : 'asc_hideColumns'](); - if (item.value === 'showCell') - this.api[item.options.isRowMenu ? 'asc_showRows' : 'asc_showColumns'](); - if (item.value === 'hideSheet') - SSE.getController('Statusbar').hideWorksheet(true, [this.api.asc_getActiveWorksheetIndex()]); - if (item.value === 'showSheet') { - SSE.getController('Statusbar').hideWorksheet(false, item.options.sheetId); + + switch (item.value) { + case 'row-height': + case 'column-width': + case 'auto-row-height': + case 'auto-column-width': + SSE.getController('DocumentHolder').onSetSize(menu, item); + break; + case 'hideCell': + this.api[item.options.isRowMenu ? 'asc_hideRows' : 'asc_hideColumns'](); + break; + case 'showCell': + this.api[item.options.isRowMenu ? 'asc_showRows' : 'asc_showColumns'](); + break; + case 'hideSheet': + SSE.getController('Statusbar').hideWorksheet(true, [this.api.asc_getActiveWorksheetIndex()]); + break; + case 'showSheet': + SSE.getController('Statusbar').hideWorksheet(false, item.options.sheetId); + break; + case 'renameSheet': + SSE.getController('Statusbar').statusbar.fireEvent('sheet:changename'); + break; + case 'moveCopySheet': + SSE.getController('Statusbar').moveWorksheet([this.api.asc_getActiveWorksheetIndex()]); + break; + case 'protectSheet': + Common.NotificationCenter.trigger('protect:sheet', !this.api.asc_isProtectedSheet()); + break; + case 'lockedCell': + this.api.asc_setCellLocked(false); + break; + case 'formatCells': + SSE.getController('RightMenu').onRightMenuOpen(Common.Utils.documentSettingsType.Cell); + break; } }, @@ -2662,6 +2690,29 @@ define([ this.api.asc_isLayoutLocked(currentSheet) ? this.onApiLockDocumentProps(currentSheet) : this.onApiUnLockDocumentProps(currentSheet); this.toolbar.lockToolbar(Common.enumLock.printAreaLock, this.api.asc_isPrintAreaLocked(currentSheet), {array: [this.toolbar.btnPrintArea]}); this.toolbar.lockToolbar(Common.enumLock.pageBreakLock, this.api.asc_GetPageBreaksDisableType(currentSheet)===Asc.c_oAscPageBreaksDisableType.all, {array: [this.toolbar.btnPageBreak]}); + + if (this.toolbar.mnuShowSheets) { + if (!this.toolbar.mnuShowSheets.menu.items.length>0) { + this.toolbar.btnFormatCell.menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + this.toolbar.btnFormatCell.menu.items[0].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + this.toolbar.btnFormatCell.menu.items[1].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + this.toolbar.btnFormatCell.menu.items[3].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + this.toolbar.btnFormatCell.menu.items[4].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + this.toolbar.btnFormatCell.menu.items[4].menu.items[2].menu.on('item:click', _.bind(this.onCellFormatMenu, this)); + } + + let hiddenItems = SSE.getController('Statusbar').statusbar.tabMenu.items[5].menu.items; + this.toolbar.mnuShowSheets.menu.removeAll(); + hiddenItems.forEach(item => { + this.toolbar.mnuShowSheets.menu.addItem(new Common.UI.MenuItem({ + style: 'white-space: pre-wrap', + caption: item.caption, + value: 'showSheet', + sheetId: item.value + })) + }) + } + }, onUpdateDocumentProps: function(nIndex) { @@ -3899,6 +3950,10 @@ define([ } }; + if (this.toolbar) { + updateColors(this.toolbar.mnuTabColorToolbar, 1); + } + updateColors(this.toolbar.mnuTextColorPicker, Common.Utils.ThemeColor.getStandartColors()[1]); if (this.toolbar.btnTextColor.currentColor === undefined || !this.toolbar.btnTextColor.currentColor.isAuto) { this.toolbar.btnTextColor.currentColor=Common.Utils.ThemeColor.getStandartColors()[1]; diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 0ef2d7ddf9..e8a2ef015b 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -54,7 +54,8 @@ define([ 'common/main/lib/component/ComboBoxFonts', 'common/main/lib/component/ComboDataView' ,'common/main/lib/component/SynchronizeTip' - ,'common/main/lib/component/Mixtbar' + ,'common/main/lib/component/Mixtbar', + 'common/main/lib/component/ThemeColorPalette' ], function (Backbone, template, simple, template_view) { 'use strict'; if (!Common.enumLock) @@ -3339,7 +3340,7 @@ define([ menuAlign : 'tl-tr', style: 'min-width: auto;', items: [] - }) + }) }) ] }) @@ -3347,7 +3348,7 @@ define([ {caption: '--'}, { caption : this.textRenameSheet, - value : 'rename' + value : 'renameSheet' }, { caption : this.textMoveCopySheet, @@ -3356,6 +3357,18 @@ define([ { caption : this.textTabColor, value : 'fillColor', + menu : new Common.UI.Menu({ + menuAlign: 'tl-tr', + cls: 'color-tab', + items: [ + { template: _.template('
') }, + { caption: '--' }, + { + id: "id-toolbar-menu-new-color", + template: _.template('' + this.textNewColor + '') + } + ] + }) }, { caption : this.textProtectSheet, @@ -3374,7 +3387,20 @@ define([ value : 'formatCells', }, ] - }) ) + }).on('render:after', _.bind(function(menu) { + this.mnuTabColorToolbar = new Common.UI.ThemeColorPalette({ + el: $('#id-toolbar-menu-tab-color'), + outerMenu: { menu: menu, index: 0, focusOnShow: true }, + transparent: true + }); + menu.setInnerMenu([{ menu: this.mnuTabColorToolbar, index: 0 }]); + this.mnuTabColorToolbar.on('select', _.bind(function(picker, color) { + SSE.getController('Statusbar').statusbar.fireEvent('sheet:setcolor', [color]); + setTimeout(_.bind(function() { + menu.hide(); + }, this), 1); + }, this)); + }, this)) ) } if (!this.mode.isEditMailMerge && !this.mode.isEditDiagram && !this.mode.isEditOle)