From 19617d9943e96a4b1b8d3a90b891686fc3cafcb6 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 4 Oct 2021 21:08:02 +0300 Subject: [PATCH] [Embedded] Customize header logo depending on the license --- .../embed/js/ApplicationController.js | 37 +++++++++--------- .../app/controller/ApplicationController.js | 35 +++++++++-------- .../embed/js/ApplicationController.js | 38 ++++++++++--------- .../embed/js/ApplicationController.js | 38 ++++++++++--------- 4 files changed, 81 insertions(+), 67 deletions(-) diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js index b2a3150fc..2879e3683 100644 --- a/apps/documenteditor/embed/js/ApplicationController.js +++ b/apps/documenteditor/embed/js/ApplicationController.js @@ -595,27 +595,12 @@ DE.ApplicationController = new(function(){ } function onEditorPermissions(params) { - if ( (params.asc_getLicenseType() === Asc.c_oLicenseResult.Success) && (typeof config.customization == 'object') && - config.customization && config.customization.logo ) { - - var logo = $('#header-logo'); - if (config.customization.logo.image || config.customization.logo.imageEmbedded) { - logo.html(''); - logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); - - config.customization.logo.imageEmbedded && console.log("Obsolete: The 'imageEmbedded' parameter of the 'customization.logo' section is deprecated. Please use 'image' parameter instead."); - } - - if (config.customization.logo.url) { - logo.attr('href', config.customization.logo.url); - } else if (config.customization.logo.url!==undefined) { - logo.removeAttr('href');logo.removeAttr('target'); - } - } var licType = params.asc_getLicenseType(); appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit); appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view'); appOptions.canSubmitForms = appOptions.canLicense && (typeof (config.customization) == 'object') && !!config.customization.submitForm; + appOptions.canBranding = params.asc_getCustomization(); + appOptions.canBranding && setBranding(config.customization); api.asc_setViewMode(!appOptions.canFillForms); @@ -821,6 +806,24 @@ DE.ApplicationController = new(function(){ function onBeforeUnload () { common.localStorage.save(); } + + function setBranding(value) { + if ( value && value.logo) { + var logo = $('#header-logo'); + if (value.logo.image || value.logo.imageEmbedded) { + logo.html(''); + logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); + + value.logo.imageEmbedded && console.log("Obsolete: The 'imageEmbedded' parameter of the 'customization.logo' section is deprecated. Please use 'image' parameter instead."); + } + + if (value.logo.url) { + logo.attr('href', value.logo.url); + } else if (value.logo.url!==undefined) { + logo.removeAttr('href');logo.removeAttr('target'); + } + } + } // Helpers // ------------------------- diff --git a/apps/documenteditor/forms/app/controller/ApplicationController.js b/apps/documenteditor/forms/app/controller/ApplicationController.js index 5a02dea1c..ab9a8b5cd 100644 --- a/apps/documenteditor/forms/app/controller/ApplicationController.js +++ b/apps/documenteditor/forms/app/controller/ApplicationController.js @@ -433,22 +433,6 @@ define([ if ( this.onServerVersion(params.asc_getBuildVersion())) return; - if ( (licType === Asc.c_oLicenseResult.Success) && (typeof this.appOptions.customization == 'object') && - this.appOptions.customization && this.appOptions.customization.logo ) { - - var logo = $('#header-logo'); - if (this.appOptions.customization.logo.image) { - logo.html(''); - logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); - } - - if (this.appOptions.customization.logo.url) { - logo.attr('href', this.appOptions.customization.logo.url); - } else if (this.appOptions.customization.logo.url!==undefined) { - logo.removeAttr('href');logo.removeAttr('target'); - } - } - this.permissions.review = (this.permissions.review === undefined) ? (this.permissions.edit !== false) : this.permissions.review; if (params.asc_getRights() !== Asc.c_oRights.Edit) this.permissions.edit = this.permissions.review = false; @@ -460,6 +444,9 @@ define([ this.appOptions.canFillForms = this.appOptions.canLicense && (this.permissions.fillForms===true) && (this.editorConfig.mode !== 'view'); this.api.asc_setViewMode(!this.appOptions.canFillForms); + this.appOptions.canBranding = params.asc_getCustomization(); + this.appOptions.canBranding && this.setBranding(this.appOptions.customization); + this.appOptions.canDownload = this.permissions.download !== false; this.appOptions.canPrint = (this.permissions.print !== false); @@ -582,6 +569,22 @@ define([ } }, + setBranding: function (value) { + if ( value && value.logo) { + var logo = $('#header-logo'); + if (value.logo.image) { + logo.html(''); + logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); + } + + if (value.logo.url) { + logo.attr('href', value.logo.url); + } else if (value.logo.url!==undefined) { + logo.removeAttr('href');logo.removeAttr('target'); + } + } + }, + onLongActionBegin: function(type, id) { var action = {id: id, type: type}; this.stackLongActions.push(action); diff --git a/apps/presentationeditor/embed/js/ApplicationController.js b/apps/presentationeditor/embed/js/ApplicationController.js index 766dba5fd..2519cb58b 100644 --- a/apps/presentationeditor/embed/js/ApplicationController.js +++ b/apps/presentationeditor/embed/js/ApplicationController.js @@ -37,6 +37,7 @@ PE.ApplicationController = new(function(){ docConfig = {}, embedConfig = {}, permissions = {}, + appOptions = {}, maxPages = 0, created = false, currentPage = 0, @@ -453,23 +454,8 @@ PE.ApplicationController = new(function(){ } function onEditorPermissions(params) { - if ( (params.asc_getLicenseType() === Asc.c_oLicenseResult.Success) && (typeof config.customization == 'object') && - config.customization && config.customization.logo ) { - - var logo = $('#header-logo'); - if (config.customization.logo.image || config.customization.logo.imageEmbedded) { - logo.html(''); - logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); - - config.customization.logo.imageEmbedded && console.log("Obsolete: The 'imageEmbedded' parameter of the 'customization.logo' section is deprecated. Please use 'image' parameter instead."); - } - - if (config.customization.logo.url) { - logo.attr('href', config.customization.logo.url); - } else if (config.customization.logo.url!==undefined) { - logo.removeAttr('href');logo.removeAttr('target'); - } - } + appOptions.canBranding = params.asc_getCustomization(); + appOptions.canBranding && setBranding(config.customization); var $parent = labelDocName.parent(); var _left_width = $parent.position().left, @@ -655,6 +641,24 @@ PE.ApplicationController = new(function(){ function onBeforeUnload () { common.localStorage.save(); } + + function setBranding(value) { + if ( value && value.logo) { + var logo = $('#header-logo'); + if (value.logo.image || value.logo.imageEmbedded) { + logo.html(''); + logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); + + value.logo.imageEmbedded && console.log("Obsolete: The 'imageEmbedded' parameter of the 'customization.logo' section is deprecated. Please use 'image' parameter instead."); + } + + if (value.logo.url) { + logo.attr('href', value.logo.url); + } else if (value.logo.url!==undefined) { + logo.removeAttr('href');logo.removeAttr('target'); + } + } + } // Helpers // ------------------------- diff --git a/apps/spreadsheeteditor/embed/js/ApplicationController.js b/apps/spreadsheeteditor/embed/js/ApplicationController.js index 68d8687a2..c17650446 100644 --- a/apps/spreadsheeteditor/embed/js/ApplicationController.js +++ b/apps/spreadsheeteditor/embed/js/ApplicationController.js @@ -37,6 +37,7 @@ SSE.ApplicationController = new(function(){ docConfig = {}, embedConfig = {}, permissions = {}, + appOptions = {}, maxPages = 0, created = false, iframePrint = null; @@ -349,23 +350,8 @@ SSE.ApplicationController = new(function(){ } function onEditorPermissions(params) { - if ( (params.asc_getLicenseType() === Asc.c_oLicenseResult.Success) && (typeof config.customization == 'object') && - config.customization && config.customization.logo ) { - - var logo = $('#header-logo'); - if (config.customization.logo.image || config.customization.logo.imageEmbedded) { - logo.html(''); - logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); - - config.customization.logo.imageEmbedded && console.log("Obsolete: The 'imageEmbedded' parameter of the 'customization.logo' section is deprecated. Please use 'image' parameter instead."); - } - - if (config.customization.logo.url) { - logo.attr('href', config.customization.logo.url); - } else if (config.customization.logo.url!==undefined) { - logo.removeAttr('href');logo.removeAttr('target'); - } - } + appOptions.canBranding = params.asc_getCustomization(); + appOptions.canBranding && setBranding(config.customization); var $parent = labelDocName.parent(); var _left_width = $parent.position().left, @@ -608,6 +594,24 @@ SSE.ApplicationController = new(function(){ function onBeforeUnload () { common.localStorage.save(); } + + function setBranding(value) { + if ( value && value.logo) { + var logo = $('#header-logo'); + if (value.logo.image || value.logo.imageEmbedded) { + logo.html(''); + logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); + + value.logo.imageEmbedded && console.log("Obsolete: The 'imageEmbedded' parameter of the 'customization.logo' section is deprecated. Please use 'image' parameter instead."); + } + + if (value.logo.url) { + logo.attr('href', value.logo.url); + } else if (value.logo.url!==undefined) { + logo.removeAttr('href');logo.removeAttr('target'); + } + } + } // Helpers // -------------------------