From 7f79f37804763ab5b004b1be45a2867ada1acb9d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 22 Jun 2018 13:22:57 +0300 Subject: [PATCH] [Mobile] Bug 37604: don't show context menu by long tap --- .../documenteditor/mobile/app/controller/Main.js | 14 ++++++++++++++ .../mobile/app/controller/Main.js | 14 ++++++++++++++ .../mobile/app/controller/Main.js | 16 +++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index fb22e26ef..c93f9d630 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -577,6 +577,8 @@ define([ } me.applyLicense(); + + $(document).on('contextmenu', _.bind(me.onContextMenu, me)); }, onLicenseChanged: function(params) { @@ -1200,6 +1202,18 @@ define([ } }, + onContextMenu: function(event){ + var canCopyAttr = event.target.getAttribute('data-can-copy'), + isInputEl = (event.target instanceof HTMLInputElement) || (event.target instanceof HTMLTextAreaElement); + + if ((isInputEl && canCopyAttr === 'false') || + (!isInputEl && canCopyAttr !== 'true')) { + event.stopPropagation(); + event.preventDefault(); + return false; + } + }, + leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', defaultTitleText: 'ONLYOFFICE Document Editor', criticalErrorTitle: 'Error', diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 290fa2c28..e42a62e6d 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -531,6 +531,8 @@ define([ } me.applyLicense(); + + $(document).on('contextmenu', _.bind(me.onContextMenu, me)); }, onLicenseChanged: function(params) { @@ -1154,6 +1156,18 @@ define([ } }, + onContextMenu: function(event){ + var canCopyAttr = event.target.getAttribute('data-can-copy'), + isInputEl = (event.target instanceof HTMLInputElement) || (event.target instanceof HTMLTextAreaElement); + + if ((isInputEl && canCopyAttr === 'false') || + (!isInputEl && canCopyAttr !== 'true')) { + event.stopPropagation(); + event.preventDefault(); + return false; + } + }, + // Translation leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', defaultTitleText: 'ONLYOFFICE Presentation Editor', diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index 7aa72ad3e..90714d72f 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -547,7 +547,9 @@ define([ $('.view-main').on('click', function (e) { uiApp.closeModal('.document-menu.modal-in'); - }) + }); + + $(document).on('contextmenu', _.bind(me.onContextMenu, me)); }, onLicenseChanged: function(params) { @@ -1320,6 +1322,18 @@ define([ if (url) this.iframePrint.src = url; }, + onContextMenu: function(event){ + var canCopyAttr = event.target.getAttribute('data-can-copy'), + isInputEl = (event.target instanceof HTMLInputElement) || (event.target instanceof HTMLTextAreaElement); + + if ((isInputEl && canCopyAttr === 'false') || + (!isInputEl && canCopyAttr !== 'true')) { + event.stopPropagation(); + event.preventDefault(); + return false; + } + }, + leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', defaultTitleText: 'ONLYOFFICE Spreadsheet Editor', criticalErrorTitle: 'Error',