From 36565b79be7cbe284e0860920be812f7ecf7ab96 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 10 Dec 2024 16:27:39 +0300 Subject: [PATCH] Add onUserActionRequired event --- apps/api/documents/api.js | 1 + apps/common/Gateway.js | 4 ++++ apps/documenteditor/embed/js/ApplicationController.js | 8 +++++++- .../forms/app/controller/ApplicationController.js | 8 +++++++- apps/documenteditor/main/app/controller/Main.js | 7 ++++++- apps/documenteditor/mobile/src/controller/Main.jsx | 8 +++++++- apps/pdfeditor/main/app/controller/Main.js | 7 ++++++- .../presentationeditor/embed/js/ApplicationController.js | 8 +++++++- apps/presentationeditor/main/app/controller/Main.js | 7 ++++++- apps/presentationeditor/mobile/src/controller/Main.jsx | 8 +++++++- apps/spreadsheeteditor/embed/js/ApplicationController.js | 9 +++++++-- apps/spreadsheeteditor/main/app/controller/Main.js | 8 +++++++- apps/spreadsheeteditor/mobile/src/controller/Main.jsx | 8 +++++++- apps/visioeditor/main/app/controller/Main.js | 7 ++++++- apps/visioeditor/mobile/src/controller/Main.jsx | 8 +++++++- 15 files changed, 92 insertions(+), 14 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 2bda81aa1c..5f958e7ccd 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -311,6 +311,7 @@ 'onRequestStartFilling': // used in pdf-form edit mode. must call startFilling method 'onSubmit': // send when filled form is submitted successfully 'onRequestRefreshFile': // send when file version is updated. use instead of onOutdatedVersion + 'onUserActionRequired': // send if the user needs to enter a password or select encoding/delimiters when opening a file } } diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index 72cfaabdea..baebabcbe0 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -414,6 +414,10 @@ if (window.Common === undefined) { _postMessage({ event: 'onRequestRefreshFile' }); }, + userActionRequired: function() { + _postMessage({ event: 'onUserActionRequired' }); + }, + saveDocument: function(data) { data && _postMessage({ event: 'onSaveDocument', diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js index 648ea9309e..328e90fa4e 100644 --- a/apps/documenteditor/embed/js/ApplicationController.js +++ b/apps/documenteditor/embed/js/ApplicationController.js @@ -44,7 +44,8 @@ DE.ApplicationController = new(function(){ btnSubmit, _submitFail, $submitedTooltip, $requiredTooltip, $listControlMenu, listControlItems = [], listObj, - bodyWidth = 0; + bodyWidth = 0, + requireUserAction = true; var LoadingDocument = -256; @@ -647,6 +648,7 @@ DE.ApplicationController = new(function(){ Common.Gateway.documentReady(); Common.Analytics.trackEvent('Load', 'Complete'); + requireUserAction = false; } function onEditorPermissions(params) { @@ -750,6 +752,10 @@ DE.ApplicationController = new(function(){ api && api.asc_setAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, advOptions.asc_getRecommendedSettings() || new Asc.asc_CTextOptions()); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); } + if (requireUserAction) { + Common.Gateway.userActionRequired(); + requireUserAction = false; + } } function onError(id, level, errData) { diff --git a/apps/documenteditor/forms/app/controller/ApplicationController.js b/apps/documenteditor/forms/app/controller/ApplicationController.js index c39f283802..60942cf277 100644 --- a/apps/documenteditor/forms/app/controller/ApplicationController.js +++ b/apps/documenteditor/forms/app/controller/ApplicationController.js @@ -57,7 +57,8 @@ define([ isTooltipHiding = false, bodyWidth = 0, ttOffset = [0, -10], - _logoImage = ''; + _logoImage = '', + requireUserAction = true; DE.Controllers.ApplicationController = Backbone.Controller.extend(_.assign({ views: [ @@ -995,6 +996,10 @@ define([ this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); me._openDlg.show(); } + if (requireUserAction) { + Common.Gateway.userActionRequired(); + requireUserAction = false; + } }, onDocMouseMoveStart: function() { @@ -1551,6 +1556,7 @@ define([ Common.Gateway.documentReady(); Common.Analytics.trackEvent('Load', 'Complete'); Common.NotificationCenter.trigger('document:ready'); + requireUserAction = false; }, onOptionsClick: function(menu, item, e) { diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 10bcc68065..091cb66189 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -179,7 +179,7 @@ define([ this.stackMacrosRequests = []; - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false}; + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true}; this.languages = null; // Initialize viewport @@ -1522,6 +1522,7 @@ define([ $(document).on('contextmenu', _.bind(me.onContextMenu, me)); Common.Gateway.documentReady(); + this._state.requireUserAction = false; $('#editor-container').css('overflow', ''); $('.doc-placeholder').remove(); @@ -2889,6 +2890,10 @@ define([ this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); me._state.openDlg.show(); } + if (me._state.requireUserAction) { + Common.Gateway.userActionRequired(); + me._state.requireUserAction = false; + } }, onTryUndoInFastCollaborative: function() { diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 431bc98853..7b69fd3b47 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -128,7 +128,8 @@ class MainController extends Component { licenseType: false, isFromGatewayDownloadAs: false, isDocModified: false, - docProtection: false + docProtection: false, + requireUserAction: true }; this.defaultTitleText = __APP_TITLE_TEXT__; @@ -421,6 +422,7 @@ class MainController extends Component { Common.Notifications.trigger('document:ready'); Common.Gateway.documentReady(); appOptions.changeDocReady(true); + this._state.requireUserAction = false; if(isOForm) { f7.dialog.create({ @@ -974,6 +976,10 @@ class MainController extends Component { onAdvancedOptions(type, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose, this.isDRM); this.isDRM = true; } + if (this._state.requireUserAction) { + Common.Gateway.userActionRequired(); + this._state.requireUserAction = false; + } }); // Protection document diff --git a/apps/pdfeditor/main/app/controller/Main.js b/apps/pdfeditor/main/app/controller/Main.js index 689b3db150..1011a99b55 100644 --- a/apps/pdfeditor/main/app/controller/Main.js +++ b/apps/pdfeditor/main/app/controller/Main.js @@ -119,7 +119,7 @@ define([ this.stackMacrosRequests = []; - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false}; + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true}; this.languages = null; // Initialize viewport @@ -1166,6 +1166,7 @@ define([ $(document).on('contextmenu', _.bind(me.onContextMenu, me)); Common.Gateway.documentReady(); + this._state.requireUserAction = false; $('#editor-container').css('overflow', ''); $('.doc-placeholder').remove(); @@ -2330,6 +2331,10 @@ define([ this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); me._state.openDlg.show(); } + if (me._state.requireUserAction) { + Common.Gateway.userActionRequired(); + me._state.requireUserAction = false; + } }, onTryUndoInFastCollaborative: function() { diff --git a/apps/presentationeditor/embed/js/ApplicationController.js b/apps/presentationeditor/embed/js/ApplicationController.js index d31984750a..7ba4431eae 100644 --- a/apps/presentationeditor/embed/js/ApplicationController.js +++ b/apps/presentationeditor/embed/js/ApplicationController.js @@ -41,7 +41,8 @@ PE.ApplicationController = new(function(){ created = false, currentPage = 0, ttOffset = [5, -10], - labelDocName; + labelDocName, + requireUserAction = true; var LoadingDocument = -256; @@ -518,6 +519,7 @@ PE.ApplicationController = new(function(){ $('#btn-play').on('click', onPlayStart); Common.Gateway.documentReady(); Common.Analytics.trackEvent('Load', 'Complete'); + requireUserAction = false; } function onEditorPermissions(params) { @@ -593,6 +595,10 @@ PE.ApplicationController = new(function(){ else $('#loading-mask').addClass("none-animation"); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); } + if (requireUserAction) { + Common.Gateway.userActionRequired(); + requireUserAction = false; + } } function onError(id, level, errData) { diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 69f791528e..0c7c611cfd 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -160,7 +160,7 @@ define([ onLaunch: function() { var me = this; - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false}; + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true}; this.languages = null; window.storagename = 'presentation'; @@ -1105,6 +1105,7 @@ define([ }); $(document).on('contextmenu', _.bind(me.onContextMenu, me)); Common.Gateway.documentReady(); + this._state.requireUserAction = false; $('.doc-placeholder').remove(); this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog(); @@ -2555,6 +2556,10 @@ define([ this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); me._state.openDlg.show(); } + if (me._state.requireUserAction) { + Common.Gateway.userActionRequired(); + me._state.requireUserAction = false; + } }, warningDocumentIsLocked: function() { diff --git a/apps/presentationeditor/mobile/src/controller/Main.jsx b/apps/presentationeditor/mobile/src/controller/Main.jsx index cdbef60fa8..0884e49c7e 100644 --- a/apps/presentationeditor/mobile/src/controller/Main.jsx +++ b/apps/presentationeditor/mobile/src/controller/Main.jsx @@ -73,7 +73,8 @@ class MainController extends Component { this._state = { licenseType: false, - isDocModified: false + isDocModified: false, + requireUserAction: true }; this.defaultTitleText = __APP_TITLE_TEXT__; @@ -603,6 +604,7 @@ class MainController extends Component { Common.Notifications.trigger('document:ready'); appOptions.changeDocReady(true); + this._state.requireUserAction = false; } insertImage (data) { @@ -848,6 +850,10 @@ class MainController extends Component { }).open(); this.isDRM = true; } + if (this._state.requireUserAction) { + Common.Gateway.userActionRequired(); + this._state.requireUserAction = false; + } } onDocumentName () { diff --git a/apps/spreadsheeteditor/embed/js/ApplicationController.js b/apps/spreadsheeteditor/embed/js/ApplicationController.js index a029732027..888f1371ee 100644 --- a/apps/spreadsheeteditor/embed/js/ApplicationController.js +++ b/apps/spreadsheeteditor/embed/js/ApplicationController.js @@ -40,7 +40,8 @@ SSE.ApplicationController = new(function(){ maxPages = 0, created = false, iframePrint = null, - isRtlSheet = false; + isRtlSheet = false, + requireUserAction = true; var $ttEl, $tooltip, ttOffset = [6, -15], @@ -557,7 +558,7 @@ SSE.ApplicationController = new(function(){ Common.Gateway.documentReady(); Common.Analytics.trackEvent('Load', 'Complete'); - + requireUserAction = false; onSheetsChanged(); setupScrollButtons(); } @@ -640,6 +641,10 @@ SSE.ApplicationController = new(function(){ api && api.asc_setAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, advOptions.asc_getRecommendedSettings() || new Asc.asc_CTextOptions()); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); } + if (requireUserAction) { + Common.Gateway.userActionRequired(); + requireUserAction = false; + } } function onError(id, level, errData) { diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index b8ac9191f3..74131e3a65 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -183,7 +183,7 @@ define([ // $(document.body).css('position', 'absolute'); var me = this; - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false}; + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true}; if (!Common.Utils.isBrowserSupported()){ Common.Utils.showBrowserRestriction(); @@ -1181,6 +1181,8 @@ define([ } else checkWarns(); Common.Gateway.documentReady(); + this._state.requireUserAction = false; + if (this.appOptions.user.guest && this.appOptions.canRenameAnonymous && !this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && !this.appOptions.isEditOle && (Common.Utils.InternalSettings.get("guest-username")===null)) this.showRenameUserDialog(); if (this._needToSaveAsFile) // warning received before document is ready @@ -2595,6 +2597,10 @@ define([ this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); me._state.openDlg.show(); } + if (me._state.requireUserAction) { + Common.Gateway.userActionRequired(); + me._state.requireUserAction = false; + } }, onActiveSheetChanged: function(index) { diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index 72bab098fd..190206d6c6 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -143,7 +143,8 @@ class MainController extends Component { this._state = { licenseType: false, - isDocModified: false + isDocModified: false, + requireUserAction: true }; this.wsLockOptions = ['SelectLockedCells', 'SelectUnlockedCells', 'FormatCells', 'FormatColumns', 'FormatRows', 'InsertColumns', 'InsertRows', 'InsertHyperlinks', 'DeleteColumns', @@ -486,6 +487,10 @@ class MainController extends Component { onAdvancedOptions(type, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose, this.isDRM); this.isDRM = true; } + if (this._state.requireUserAction) { + Common.Gateway.userActionRequired(); + this._state.requireUserAction = false; + } }); // Toolbar settings @@ -766,6 +771,7 @@ class MainController extends Component { f7.emit('resize'); appOptions.changeDocReady(true); + this._state.requireUserAction = false; } insertImage (data) { diff --git a/apps/visioeditor/main/app/controller/Main.js b/apps/visioeditor/main/app/controller/Main.js index a286b09e11..4c4158e349 100644 --- a/apps/visioeditor/main/app/controller/Main.js +++ b/apps/visioeditor/main/app/controller/Main.js @@ -108,7 +108,7 @@ define([ this.stackMacrosRequests = []; - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false}; + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true}; this.languages = null; // Initialize viewport @@ -997,6 +997,7 @@ define([ $(document).on('contextmenu', _.bind(me.onContextMenu, me)); Common.Gateway.documentReady(); + this._state.requireUserAction = false; $('.doc-placeholder').remove(); @@ -1771,6 +1772,10 @@ define([ this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); me._state.openDlg.show(); } + if (me._state.requireUserAction) { + Common.Gateway.userActionRequired(); + me._state.requireUserAction = false; + } }, onAuthParticipantsChanged: function(users) { diff --git a/apps/visioeditor/mobile/src/controller/Main.jsx b/apps/visioeditor/mobile/src/controller/Main.jsx index 4bd7b6f1c8..b09c48eb24 100644 --- a/apps/visioeditor/mobile/src/controller/Main.jsx +++ b/apps/visioeditor/mobile/src/controller/Main.jsx @@ -33,7 +33,8 @@ class MainController extends Component { this._state = { licenseType: false, - isDocModified: false + isDocModified: false, + requireUserAction: true }; this.defaultTitleText = __APP_TITLE_TEXT__; @@ -391,6 +392,7 @@ class MainController extends Component { Common.Notifications.trigger('document:ready'); appOptions.changeDocReady(true); + this._state.requireUserAction = false; } onLicenseChanged (params) { @@ -610,6 +612,10 @@ class MainController extends Component { }).open(); this.isDRM = true; } + if (this._state.requireUserAction) { + Common.Gateway.userActionRequired(); + this._state.requireUserAction = false; + } } onDocumentName () {