From 348a77117138fa1829ede273c2a67422777273c9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 11 Feb 2021 15:52:38 +0300 Subject: [PATCH] Refactoring editors loading --- apps/api/documents/api.js | 2 ++ .../main/app/controller/Main.js | 14 +++++++------ apps/documenteditor/main/index.html | 18 +++++++++------- apps/documenteditor/main/index.html.deploy | 15 +++++++------ apps/presentationeditor/main/index.html | 17 ++++++++------- .../presentationeditor/main/index.html.deploy | 18 +++++++++------- apps/spreadsheeteditor/main/index.html | 20 ++++++++++-------- apps/spreadsheeteditor/main/index.html.deploy | 21 +++++++++++-------- 8 files changed, 71 insertions(+), 54 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index b54f3e35f..2e124180b 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -874,6 +874,8 @@ if (config.editorConfig && config.editorConfig.customization && (config.editorConfig.customization.toolbar===false)) params += "&toolbar=false"; + else if (config.document && config.document.permissions && (config.document.permissions.edit === false && config.document.permissions.fillForms )) + params += "&toolbar=true"; if (config.parentOrigin) params += "&parentOrigin=" + config.parentOrigin; diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 7fdabb933..0f93bfb97 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -399,12 +399,6 @@ define([ if (this.appOptions.location == 'us' || this.appOptions.location == 'ca') Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch); - if (!( this.editorConfig.customization && ( this.editorConfig.customization.toolbarNoTabs || - (this.editorConfig.targetApp!=='desktop') && (this.editorConfig.customization.loaderName || this.editorConfig.customization.loaderLogo)))) { - $('#editor-container').css('overflow', 'hidden'); - $('#editor-container').append('
' + '
'.repeat(20) + '
'); - } - value = Common.localStorage.getItem("de-macros-mode"); if (value === null) { value = this.editorConfig.customization ? this.editorConfig.customization.macrosMode : 'warn'; @@ -457,6 +451,14 @@ define([ } } + if (!( this.editorConfig.customization && ( this.editorConfig.customization.toolbarNoTabs || + (this.editorConfig.targetApp!=='desktop') && (this.editorConfig.customization.loaderName || this.editorConfig.customization.loaderLogo)))) { + $('#editor-container').css('overflow', 'hidden'); + $('#editor-container').append('
' + '
'.repeat(20) + '
'); + if (this.editorConfig.mode == 'view' || (this.permissions.edit === false && !this.permissions.review )) + $('#editor-container').find('.doc-placeholder').css('margin-top', 19); + } + this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); this.api.asc_registerCallback('asc_onRunAutostartMacroses', _.bind(this.onRunAutostartMacroses, this)); diff --git a/apps/documenteditor/main/index.html b/apps/documenteditor/main/index.html index dfb698f8f..1c2ab5ebe 100644 --- a/apps/documenteditor/main/index.html +++ b/apps/documenteditor/main/index.html @@ -219,13 +219,13 @@
-
+ -
+ -
+
@@ -236,23 +236,25 @@ var params = getUrlParams(), notoolbar = params["toolbar"] == 'false', compact = params["compact"] == 'true', - view = params["mode"] == 'view'; + view = params["mode"] == 'view', + visible = true; (compact || view || notoolbar) && document.querySelector('.brendpanel > :nth-child(2)').remove(); if (compact || view) { if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').remove(); - document.querySelector('.brendpanel').remove(); + visible = false; } else document.querySelector('.brendpanel > :nth-child(1)').style.height = '32px'; } else if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').style.height = '28px'; } - if (view || notoolbar) { - document.querySelector('.sktoolbar').remove(); - } + visible && (document.querySelector('.brendpanel').style.display = 'block'); + !(view && (params["toolbar"] !== 'true') || notoolbar) && (document.querySelector('.sktoolbar').style.display = 'block'); + view && (document.querySelector('.placeholder').style.marginTop = '19px'); + document.querySelector('.placeholder').style.display = 'block'; if (stopLoading) { document.body.removeChild(document.getElementById('loading-mask')); diff --git a/apps/documenteditor/main/index.html.deploy b/apps/documenteditor/main/index.html.deploy index c8981088c..8eb457ccc 100644 --- a/apps/documenteditor/main/index.html.deploy +++ b/apps/documenteditor/main/index.html.deploy @@ -217,7 +217,7 @@ -
+
-
+ -
+ -
+
@@ -274,23 +274,24 @@ var params = getUrlParams(), notoolbar = params["toolbar"] == 'false', compact = params["compact"] == 'true', - view = params["mode"] == 'view'; + view = params["mode"] == 'view', + visible = true; (compact || view || notoolbar) && document.querySelector('.brendpanel > :nth-child(2)').remove(); if (compact || view) { if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').remove(); - document.querySelector('.brendpanel').remove(); + visible = false; } else document.querySelector('.brendpanel > :nth-child(1)').style.height = '32px'; } else if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').style.height = '28px'; } - if (view || notoolbar) { - document.querySelector('.sktoolbar').remove(); - } + visible && (document.querySelector('.brendpanel').style.display = 'block'); + !(view || notoolbar) && (document.querySelector('.sktoolbar').style.display = 'block'); + document.querySelector('.placeholder').style.display = 'block'; if (stopLoading) { document.body.removeChild(document.getElementById('loading-mask')); diff --git a/apps/presentationeditor/main/index.html.deploy b/apps/presentationeditor/main/index.html.deploy index 215c3ff66..ceaea5b9c 100644 --- a/apps/presentationeditor/main/index.html.deploy +++ b/apps/presentationeditor/main/index.html.deploy @@ -267,14 +267,14 @@
-
+ -
+ -
+
@@ -291,22 +291,24 @@ var params = getUrlParams(), notoolbar = params["toolbar"] == 'false', compact = params["compact"] == 'true', - view = params["mode"] == 'view'; + view = params["mode"] == 'view', + visible = true; (compact || view || notoolbar) && document.querySelector('.brendpanel > :nth-child(2)').remove(); if (compact || view) { if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').remove(); - document.querySelector('.brendpanel').remove(); + visible = false; } else document.querySelector('.brendpanel > :nth-child(1)').style.height = '32px'; } else if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').style.height = '28px'; } - if (view || notoolbar) { - document.querySelector('.sktoolbar').remove(); - } + + visible && (document.querySelector('.brendpanel').style.display = 'block'); + !(view || notoolbar) && (document.querySelector('.sktoolbar').style.display = 'block'); + document.querySelector('.placeholder').style.display = 'block'; if (stopLoading) { document.body.removeChild(document.getElementById('loading-mask')); diff --git a/apps/spreadsheeteditor/main/index.html b/apps/spreadsheeteditor/main/index.html index ea807bece..a25ef410a 100644 --- a/apps/spreadsheeteditor/main/index.html +++ b/apps/spreadsheeteditor/main/index.html @@ -250,18 +250,18 @@
-
+ -
+ -
+ -
+
@@ -273,7 +273,8 @@ notoolbar = params["toolbar"] == 'false', internal = params["internal"] == 'true', compact = params["compact"] == 'true', - view = params["mode"] == 'view'; + view = params["mode"] == 'view', + visible = true; if (internal) { document.querySelector('.brendpanel').remove(); @@ -285,16 +286,17 @@ if (compact || view) { if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').remove(); - document.querySelector('.brendpanel').remove(); + visible = false; } else document.querySelector('.brendpanel > :nth-child(1)').style.height = '32px'; } else if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').style.height = '28px'; } - if (view || notoolbar) { - document.querySelector('.sktoolbar').remove(); - } + visible && (document.querySelector('.brendpanel').style.display = 'block'); + !(view || notoolbar) && (document.querySelector('.sktoolbar').style.display = 'block'); + document.querySelector('.skformula').style.display = 'block'; + document.querySelector('.placeholder').style.display = 'block'; if (stopLoading) { document.body.removeChild(document.getElementById('loading-mask')); diff --git a/apps/spreadsheeteditor/main/index.html.deploy b/apps/spreadsheeteditor/main/index.html.deploy index 6e78a7d91..487c5c9f7 100644 --- a/apps/spreadsheeteditor/main/index.html.deploy +++ b/apps/spreadsheeteditor/main/index.html.deploy @@ -259,18 +259,18 @@
-
+ -
+ -
+ -
+
@@ -289,7 +289,8 @@ internal = params["internal"] == 'true', notoolbar = params["toolbar"] == 'false', compact = params["compact"] == 'true', - view = params["mode"] == 'view'; + view = params["mode"] == 'view', + visible = true; if (internal) { document.querySelector('.brendpanel').remove(); @@ -301,15 +302,17 @@ if (compact || view) { if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').remove(); - document.querySelector('.brendpanel').remove(); + visible = false; } else document.querySelector('.brendpanel > :nth-child(1)').style.height = '32px'; } else if (notoolbar) { document.querySelector('.brendpanel > :nth-child(1)').style.height = '28px'; } - if (view || notoolbar) { - document.querySelector('.sktoolbar').remove(); - } + + visible && (document.querySelector('.brendpanel').style.display = 'block'); + !(view || notoolbar) && (document.querySelector('.sktoolbar').style.display = 'block'); + document.querySelector('.skformula').style.display = 'block'; + document.querySelector('.placeholder').style.display = 'block'; if (stopLoading) { document.body.removeChild(document.getElementById('loading-mask'));