[Embedded] Customize header logo depending on the license

This commit is contained in:
Julia Radzhabova 2021-10-04 21:08:02 +03:00
parent 9a5632668f
commit 19617d9943
4 changed files with 81 additions and 67 deletions

View file

@ -595,27 +595,12 @@ DE.ApplicationController = new(function(){
} }
function onEditorPermissions(params) { 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('<img src="'+(config.customization.logo.image || config.customization.logo.imageEmbedded)+'" style="max-width:100px; max-height:20px;"/>');
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(); var licType = params.asc_getLicenseType();
appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit); appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit);
appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view'); appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view');
appOptions.canSubmitForms = appOptions.canLicense && (typeof (config.customization) == 'object') && !!config.customization.submitForm; 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); api.asc_setViewMode(!appOptions.canFillForms);
@ -821,6 +806,24 @@ DE.ApplicationController = new(function(){
function onBeforeUnload () { function onBeforeUnload () {
common.localStorage.save(); common.localStorage.save();
} }
function setBranding(value) {
if ( value && value.logo) {
var logo = $('#header-logo');
if (value.logo.image || value.logo.imageEmbedded) {
logo.html('<img src="'+(value.logo.image || value.logo.imageEmbedded)+'" style="max-width:100px; max-height:20px;"/>');
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 // Helpers
// ------------------------- // -------------------------

View file

@ -433,22 +433,6 @@ define([
if ( this.onServerVersion(params.asc_getBuildVersion())) return; 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('<img src="'+this.appOptions.customization.logo.image+'" style="max-width:100px; max-height:20px;"/>');
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; this.permissions.review = (this.permissions.review === undefined) ? (this.permissions.edit !== false) : this.permissions.review;
if (params.asc_getRights() !== Asc.c_oRights.Edit) if (params.asc_getRights() !== Asc.c_oRights.Edit)
this.permissions.edit = this.permissions.review = false; 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.appOptions.canFillForms = this.appOptions.canLicense && (this.permissions.fillForms===true) && (this.editorConfig.mode !== 'view');
this.api.asc_setViewMode(!this.appOptions.canFillForms); 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.canDownload = this.permissions.download !== false;
this.appOptions.canPrint = (this.permissions.print !== 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('<img src="'+value.logo.image+'" style="max-width:100px; max-height:20px;"/>');
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) { onLongActionBegin: function(type, id) {
var action = {id: id, type: type}; var action = {id: id, type: type};
this.stackLongActions.push(action); this.stackLongActions.push(action);

View file

@ -37,6 +37,7 @@ PE.ApplicationController = new(function(){
docConfig = {}, docConfig = {},
embedConfig = {}, embedConfig = {},
permissions = {}, permissions = {},
appOptions = {},
maxPages = 0, maxPages = 0,
created = false, created = false,
currentPage = 0, currentPage = 0,
@ -453,23 +454,8 @@ PE.ApplicationController = new(function(){
} }
function onEditorPermissions(params) { function onEditorPermissions(params) {
if ( (params.asc_getLicenseType() === Asc.c_oLicenseResult.Success) && (typeof config.customization == 'object') && appOptions.canBranding = params.asc_getCustomization();
config.customization && config.customization.logo ) { appOptions.canBranding && setBranding(config.customization);
var logo = $('#header-logo');
if (config.customization.logo.image || config.customization.logo.imageEmbedded) {
logo.html('<img src="'+(config.customization.logo.image || config.customization.logo.imageEmbedded)+'" style="max-width:100px; max-height:20px;"/>');
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 $parent = labelDocName.parent(); var $parent = labelDocName.parent();
var _left_width = $parent.position().left, var _left_width = $parent.position().left,
@ -655,6 +641,24 @@ PE.ApplicationController = new(function(){
function onBeforeUnload () { function onBeforeUnload () {
common.localStorage.save(); common.localStorage.save();
} }
function setBranding(value) {
if ( value && value.logo) {
var logo = $('#header-logo');
if (value.logo.image || value.logo.imageEmbedded) {
logo.html('<img src="'+(value.logo.image || value.logo.imageEmbedded)+'" style="max-width:100px; max-height:20px;"/>');
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 // Helpers
// ------------------------- // -------------------------

View file

@ -37,6 +37,7 @@ SSE.ApplicationController = new(function(){
docConfig = {}, docConfig = {},
embedConfig = {}, embedConfig = {},
permissions = {}, permissions = {},
appOptions = {},
maxPages = 0, maxPages = 0,
created = false, created = false,
iframePrint = null; iframePrint = null;
@ -349,23 +350,8 @@ SSE.ApplicationController = new(function(){
} }
function onEditorPermissions(params) { function onEditorPermissions(params) {
if ( (params.asc_getLicenseType() === Asc.c_oLicenseResult.Success) && (typeof config.customization == 'object') && appOptions.canBranding = params.asc_getCustomization();
config.customization && config.customization.logo ) { appOptions.canBranding && setBranding(config.customization);
var logo = $('#header-logo');
if (config.customization.logo.image || config.customization.logo.imageEmbedded) {
logo.html('<img src="'+(config.customization.logo.image || config.customization.logo.imageEmbedded)+'" style="max-width:100px; max-height:20px;"/>');
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 $parent = labelDocName.parent(); var $parent = labelDocName.parent();
var _left_width = $parent.position().left, var _left_width = $parent.position().left,
@ -608,6 +594,24 @@ SSE.ApplicationController = new(function(){
function onBeforeUnload () { function onBeforeUnload () {
common.localStorage.save(); common.localStorage.save();
} }
function setBranding(value) {
if ( value && value.logo) {
var logo = $('#header-logo');
if (value.logo.image || value.logo.imageEmbedded) {
logo.html('<img src="'+(value.logo.image || value.logo.imageEmbedded)+'" style="max-width:100px; max-height:20px;"/>');
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 // Helpers
// ------------------------- // -------------------------