From eb1d1d7191ba6670e5d9775a2cdfc753edead9f0 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 16 Nov 2021 22:26:34 +0300 Subject: [PATCH] [desktop] for bug 53723 --- apps/common/main/lib/controller/Desktop.js | 20 ++++++++++++++++++- apps/documenteditor/main/app/view/FileMenu.js | 15 ++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index 15367696b..5a4c6a9ef 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -251,6 +251,17 @@ define([ native.execCommand("uitheme:changed", JSON.stringify({name:name, type:theme.type})); } }); + + webapp.addListeners({ + 'FileMenu': { + 'item:click': function (menu, action, isopts) { + if ( action == 'app:exit' ) { + native.execCommand('editor:event', JSON.stringify({action: 'close'})); + menu.hide(); + } + }, + }, + }, {id: 'desktop'}); } }, process: function (opts) { @@ -278,7 +289,14 @@ define([ if ( config.isDesktopApp && !!native ) { native.execCommand('editor:event', JSON.stringify({action:'close', url: config.customization.goback.url})); } - } + }, + isActive: function () { + return !!native; + }, + isOffline: function () { + // return webapp.getController('Main').api.asc_isOffline(); + return webapp.getController('Main').appOptions.isOffline; + }, }; }; diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index 351883d08..130972c77 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -419,6 +419,21 @@ define([ } this.miHistory[this.mode.canUseHistory&&!this.mode.isDisconnected?'show':'hide'](); + + if ( Common.Controllers.Desktop.isActive() ) { + $('
  • ' + + '
  • ').insertAfter($('#fm-btn-back', this.$el)); + this.items.push( + new Common.UI.MenuItem({ + el : $('#fm-btn-exit', this.$el), + action : 'app:exit', + caption : 'Exit', + canFocused: false, + dataHint: 1, + dataHintDirection: 'left-top', + dataHintOffset: [2, 14] + })); + } }, setMode: function(mode, delay) {