From 7c7d91998ff2c8ce4d0bb383f7f158d7ec17f48e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 4 May 2022 23:18:05 +0300 Subject: [PATCH] [DE] Refactoring context menu --- .../main/app/controller/DocumentHolder.js | 14 ++++++++-- .../main/app/view/DocumentHolder.js | 26 +++++++------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index cb97003f1..7756f201e 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -417,7 +417,9 @@ define([ view.menuParagraphDirection.menu.on('item:click', _.bind(me.paragraphDirection, me)); view.langParaMenu.menu.on('item:click', _.bind(me.onLangMenu, me, 'para')); view.langTableMenu.menu.on('item:click', _.bind(me.onLangMenu, me, 'table')); - + view.menuTableTOC.menu.on('item:click', _.bind(me.onTOCMenu, me)); + view.menuParaTOCRefresh.menu.on('item:click', _.bind(me.onTOCMenu, me)); + view.menuParaTOCSettings.on('click', _.bind(me.onParaTOCSettings, me)); }, getView: function (name) { @@ -2219,11 +2221,19 @@ define([ if (!_.isUndefined(item.langid)) me.api.put_TextPrLang(item.langid); - (type=='para') ? (me.documentHolder._currLang.paraid = item.langid) : (me.documentHolder._currLang.tableid = item.langid); + (type==='para') ? (me.documentHolder._currLang.paraid = item.langid) : (me.documentHolder._currLang.tableid = item.langid); me.editComplete(); } }, + onTOCMenu: function(menu, item, e) { + this.documentHolder.fireEvent((item.value==='settings') ? 'links:contents' : 'links:update', [item.value, true]); + }, + + onParaTOCSettings: function(item, e) { + this.documentHolder.fireEvent('links:contents', [item.value, true]); + }, + editComplete: function() { this.documentHolder && this.documentHolder.fireEvent('editcomplete', this.documentHolder); } diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index 80bb81840..41e2eba48 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -905,7 +905,7 @@ define([ }) }); - var menuTableTOC = new Common.UI.MenuItem({ + me.menuTableTOC = new Common.UI.MenuItem({ caption : me.textTOC, menu : new Common.UI.Menu({ cls: 'shifted-right', @@ -926,9 +926,6 @@ define([ ] }) }); - menuTableTOC.menu.on('item:click', function (menu, item, e) { - me.fireEvent((item.value=='settings') ? 'links:contents' : 'links:update', [item.value, true]); - }); /** coauthoring begin **/ me.menuAddCommentTable = new Common.UI.MenuItem({ @@ -1415,7 +1412,7 @@ define([ menuTableControl.setVisible(in_control); me.menuTableRemoveForm.setVisible(in_control); } - menuTableTOC.setVisible(in_toc); + me.menuTableTOC.setVisible(in_toc); /** coauthoring begin **/ // comments @@ -1472,7 +1469,7 @@ define([ menuHyperlinkSeparator, me.menuTableRemoveForm, menuTableControl, - menuTableTOC, + me.menuTableTOC, me.menuParagraphAdvancedInTable ] }).on('hide:after', function(menu, e, isFromInputControl) { @@ -1752,14 +1749,12 @@ define([ caption : '--' }); - var menuParaTOCSettings = new Common.UI.MenuItem({ + me.menuParaTOCSettings = new Common.UI.MenuItem({ caption: me.textTOCSettings, value: 'settings' - }).on('click', function (item, e) { - me.fireEvent('links:contents', [item.value, true]); }); - var menuParaTOCRefresh = new Common.UI.MenuItem({ + me.menuParaTOCRefresh = new Common.UI.MenuItem({ caption : me.textUpdateTOC, menu : new Common.UI.Menu({ cls: 'shifted-right', @@ -1776,9 +1771,6 @@ define([ ] }) }); - menuParaTOCRefresh.menu.on('item:click', function (menu, item, e) { - me.fireEvent('links:update', [item.value, true]); - }); var menuParaTOCSeparator = new Common.UI.MenuItem({ caption : '--' @@ -1991,8 +1983,8 @@ define([ spectype==Asc.c_oAscContentControlSpecificType.ComboBox || spectype==Asc.c_oAscContentControlSpecificType.DropDownList || spectype==Asc.c_oAscContentControlSpecificType.DateTime; } - menuParaTOCSettings.setVisible(in_toc); - menuParaTOCRefresh.setVisible(in_toc); + me.menuParaTOCSettings.setVisible(in_toc); + me.menuParaTOCRefresh.setVisible(in_toc); menuParaTOCSeparator.setVisible(in_toc); /** coauthoring begin **/ @@ -2055,8 +2047,8 @@ define([ menuParaControlSeparator, me.menuParaRefreshField, menuParaFieldSeparator, - menuParaTOCSettings, - menuParaTOCRefresh, + me.menuParaTOCSettings, + me.menuParaTOCRefresh, menuParaTOCSeparator, me.menuParagraphBreakBefore, me.menuParagraphKeepLines,