From caa3d19d52e4060f380be27fcf99af5f045d5e62 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 25 Jul 2018 16:33:46 +0300 Subject: [PATCH] Disable printing when modal window is visible, disable browser printing --- .../main/app/controller/Main.js | 19 +++++++++++-------- .../main/app/controller/Main.js | 19 +++++++++++-------- .../main/app/controller/Main.js | 19 +++++++++++-------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 0e1c790c3..5912878bd 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -111,6 +111,7 @@ define([ this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; this.languages = null; this.translationTable = []; + this.isModalShowed = 0; // Initialize viewport if (!Common.Utils.isBrowserSupported()){ @@ -244,20 +245,18 @@ define([ Common.NotificationCenter.on({ 'modal:show': function(){ - me.isModalShowed = true; + me.isModalShowed++; me.api.asc_enableKeyEvents(false); }, 'modal:close': function(dlg) { - if (dlg && dlg.$lastmodal && dlg.$lastmodal.length < 1) { - me.isModalShowed = false; + me.isModalShowed--; + if (!me.isModalShowed) me.api.asc_enableKeyEvents(true); - } }, 'modal:hide': function(dlg) { - if (dlg && dlg.$lastmodal && dlg.$lastmodal.length < 1) { - me.isModalShowed = false; + me.isModalShowed--; + if (!me.isModalShowed) me.api.asc_enableKeyEvents(true); - } }, 'settings:unitschanged':_.bind(this.unitsChanged, this), 'dataview:focus': function(e){ @@ -283,6 +282,10 @@ define([ 'command+s,ctrl+s': _.bind(function (e) { e.preventDefault(); e.stopPropagation(); + }, this), + 'command+p,ctrl+p': _.bind(function (e) { + e.preventDefault(); + e.stopPropagation(); }, this) } }); @@ -1973,7 +1976,7 @@ define([ }, onPrint: function() { - if (!this.appOptions.canPrint) return; + if (!this.appOptions.canPrint || this.isModalShowed) return; if (this.api) this.api.asc_Print(Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera); // if isChrome or isSafari or isOpera == true use asc_onPrintUrl event diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 042a713c8..585a7c954 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -105,6 +105,7 @@ define([ this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; this.languages = null; this.translationTable = []; + this.isModalShowed = 0; window.storagename = 'presentation'; @@ -231,20 +232,18 @@ define([ Common.NotificationCenter.on({ 'modal:show': function(e){ - me.isModalShowed = true; + me.isModalShowed++; me.api.asc_enableKeyEvents(false); }, 'modal:close': function(dlg) { - if (dlg && dlg.$lastmodal && dlg.$lastmodal.length < 1) { - me.isModalShowed = false; + me.isModalShowed--; + if (!me.isModalShowed) me.api.asc_enableKeyEvents(true); - } }, 'modal:hide': function(dlg) { - if (dlg && dlg.$lastmodal && dlg.$lastmodal.length < 1) { - me.isModalShowed = false; + me.isModalShowed--; + if (!me.isModalShowed) me.api.asc_enableKeyEvents(true); - } }, 'settings:unitschanged':_.bind(this.unitsChanged, this), 'dataview:focus': function(e){ @@ -269,6 +268,10 @@ define([ 'command+s,ctrl+s': _.bind(function (e) { e.preventDefault(); e.stopPropagation(); + }, this), + 'command+p,ctrl+p': _.bind(function (e) { + e.preventDefault(); + e.stopPropagation(); }, this) } }); @@ -1689,7 +1692,7 @@ define([ }, onPrint: function() { - if (!this.appOptions.canPrint) return; + if (!this.appOptions.canPrint || this.isModalShowed) return; if (this.api) this.api.asc_Print(Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera); // if isChrome or isSafari or isOpera == true use asc_onPrintUrl event diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index a64362d46..197344325 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -109,6 +109,7 @@ define([ this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; this.translationTable = []; + this.isModalShowed = 0; if (!Common.Utils.isBrowserSupported()){ Common.Utils.showBrowserRestriction(); @@ -232,20 +233,18 @@ define([ Common.NotificationCenter.on({ 'modal:show': function(e){ - me.isModalShowed = true; + me.isModalShowed++; me.api.asc_enableKeyEvents(false); }, 'modal:close': function(dlg) { - if (dlg && dlg.$lastmodal && dlg.$lastmodal.length < 1) { - me.isModalShowed = false; + me.isModalShowed--; + if (!me.isModalShowed) me.api.asc_enableKeyEvents(true); - } }, 'modal:hide': function(dlg) { - if (dlg && dlg.$lastmodal && dlg.$lastmodal.length < 1) { - me.isModalShowed = false; + me.isModalShowed--; + if (!me.isModalShowed) me.api.asc_enableKeyEvents(true); - } }, 'dataview:focus': function(e){ }, @@ -273,6 +272,10 @@ define([ 'command+s,ctrl+s': _.bind(function (e) { e.preventDefault(); e.stopPropagation(); + }, this), + 'command+p,ctrl+p': _.bind(function (e) { + e.preventDefault(); + e.stopPropagation(); }, this) } }); @@ -1919,7 +1922,7 @@ define([ }, onPrint: function() { - if (!this.appOptions.canPrint) return; + if (!this.appOptions.canPrint || this.isModalShowed) return; Common.NotificationCenter.trigger('print', this); },