Skip to content

Commit

Permalink
Add customization.logo.visible parameter (show/hide logo in the heade…
Browse files Browse the repository at this point in the history
…r, true by default)
  • Loading branch information
JuliaRadzhabova committed Feb 16, 2024
1 parent 79bc43c commit 7242854
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 51 deletions.
7 changes: 5 additions & 2 deletions apps/api/documents/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
image: url,
imageDark: url, // logo for dark theme
imageEmbedded: url, // deprecated, use image instead
url: http://...
url: http://...,
visible: true // hide logo if visible=false
},
customer: {
name: 'SuperPuper',
Expand Down Expand Up @@ -1016,7 +1017,9 @@
params += "&logo=" + encodeURIComponent(config.editorConfig.customization.loaderLogo);
}
if ( config.editorConfig.customization.logo ) {
if (config.type=='embedded' && (config.editorConfig.customization.logo.image || config.editorConfig.customization.logo.imageEmbedded))
if (config.editorConfig.customization.logo.visible===false) {
params += "&headerlogo=";
} else if (config.type=='embedded' && (config.editorConfig.customization.logo.image || config.editorConfig.customization.logo.imageEmbedded))
params += "&headerlogo=" + encodeURIComponent(config.editorConfig.customization.logo.image || config.editorConfig.customization.logo.imageEmbedded);
else if (config.type!='embedded' && (config.editorConfig.customization.logo.image || config.editorConfig.customization.logo.imageDark)) {
config.editorConfig.customization.logo.image && (params += "&headerlogo=" + encodeURIComponent(config.editorConfig.customization.logo.image));
Expand Down
35 changes: 18 additions & 17 deletions apps/common/main/lib/view/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,15 @@ define([
$html = $(templateLeftBox);
this.logo = $html.find('#header-logo');

if (this.branding && this.branding.logo && (this.branding.logo.image || this.branding.logo.imageDark) && this.logo) {
var image = Common.UI.Themes.isDarkTheme() ? (this.branding.logo.imageDark || this.branding.logo.image) : (this.branding.logo.image || this.branding.logo.imageDark);
this.logo.html('<img src="' + image + '" style="max-width:100px; max-height:20px; margin: 0;"/>');
this.logo.css({'background-image': 'none', width: 'auto'});
(this.branding.logo.url || this.branding.logo.url===undefined) && this.logo.addClass('link');
if (this.branding && this.branding.logo && this.logo) {
if (this.branding.logo.visible===false) {
this.logo.addClass('hidden');
} else if (this.branding.logo.image || this.branding.logo.imageDark) {
var image = Common.UI.Themes.isDarkTheme() ? (this.branding.logo.imageDark || this.branding.logo.image) : (this.branding.logo.image || this.branding.logo.imageDark);
this.logo.html('<img src="' + image + '" style="max-width:100px; max-height:20px; margin: 0;"/>');
this.logo.css({'background-image': 'none', width: 'auto'});
(this.branding.logo.url || this.branding.logo.url===undefined) && this.logo.addClass('link');
}
}

return $html;
Expand Down Expand Up @@ -828,26 +832,23 @@ define([
},

setBranding: function (value) {
var element;

this.branding = value;

if ( value ) {
if ( value.logo &&(value.logo.image || value.logo.imageDark)) {
var element = $('#header-logo');
if ( value && value.logo && element) {
if (value.logo.visible===false) {
element.addClass('hidden');
} else if (value.logo.image || value.logo.imageDark) {
var image = Common.UI.Themes.isDarkTheme() ? (value.logo.imageDark || value.logo.image) : (value.logo.image || value.logo.imageDark);
element = $('#header-logo');
if (element) {
element.html('<img src="' + image + '" style="max-width:100px; max-height:20px; margin: 0;"/>');
element.css({'background-image': 'none', width: 'auto'});
(value.logo.url || value.logo.url===undefined) && element.addClass('link');
}
element.html('<img src="' + image + '" style="max-width:100px; max-height:20px; margin: 0;"/>');
element.css({'background-image': 'none', width: 'auto'});
(value.logo.url || value.logo.url===undefined) && element.addClass('link');
}
}
},

changeLogo: function () {
var value = this.branding;
if ( value && value.logo && value.logo.image && value.logo.imageDark && (value.logo.image !== value.logo.imageDark)) { // change logo when image and imageDark are different
if ( value && value.logo && (value.logo.visible!==false) && value.logo.image && value.logo.imageDark && (value.logo.image !== value.logo.imageDark)) { // change logo when image and imageDark are different
var image = Common.UI.Themes.isDarkTheme() ? (value.logo.imageDark || value.logo.image) : (value.logo.image || value.logo.imageDark);
$('#header-logo img').attr('src', image);
}
Expand Down
14 changes: 10 additions & 4 deletions apps/documenteditor/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@

var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
hideLogo = params["headerlogo"]==='',
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null;

Expand Down Expand Up @@ -323,10 +324,15 @@
if (stopLoading) {
document.body.removeChild(document.getElementById('loading-mask'));
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
if (hideLogo) {
var elem = document.querySelector('.loading-logo');
elem && (elem.style.display = 'none');
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
}
}
}
</script>
Expand Down
14 changes: 10 additions & 4 deletions apps/documenteditor/main/index.html.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@

var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
hideLogo = params["headerlogo"]==='',
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null;

Expand Down Expand Up @@ -287,10 +288,15 @@
if (stopLoading) {
document.body.removeChild(document.getElementById('loading-mask'));
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
if (hideLogo) {
var elem = document.querySelector('.loading-logo');
elem && (elem.style.display = 'none');
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
}
}
}
</script>
Expand Down
14 changes: 10 additions & 4 deletions apps/pdfeditor/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@

var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
hideLogo = params["headerlogo"]==='',
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null,
isForm = params["isForm"];
Expand Down Expand Up @@ -325,10 +326,15 @@
if (stopLoading) {
document.body.removeChild(document.getElementById('loading-mask'));
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
if (hideLogo) {
var elem = document.querySelector('.loading-logo');
elem && (elem.style.display = 'none');
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
}
}
}
</script>
Expand Down
14 changes: 10 additions & 4 deletions apps/pdfeditor/main/index.html.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@

var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
hideLogo = params["headerlogo"]==='',
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null,
isForm = params["isForm"];
Expand Down Expand Up @@ -289,10 +290,15 @@
if (stopLoading) {
document.body.removeChild(document.getElementById('loading-mask'));
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
if (hideLogo) {
var elem = document.querySelector('.loading-logo');
elem && (elem.style.display = 'none');
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
}
}
}
</script>
Expand Down
14 changes: 10 additions & 4 deletions apps/presentationeditor/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@

var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
hideLogo = params["headerlogo"]==='',
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null;

Expand Down Expand Up @@ -338,10 +339,15 @@
if (stopLoading) {
document.body.removeChild(document.getElementById('loading-mask'));
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
if (hideLogo) {
var elem = document.querySelector('.loading-logo');
elem && (elem.style.display = 'none');
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
}
}
}
</script>
Expand Down
14 changes: 10 additions & 4 deletions apps/presentationeditor/main/index.html.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@

var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
hideLogo = params["headerlogo"]==='',
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null;

Expand Down Expand Up @@ -331,10 +332,15 @@
if (stopLoading) {
document.body.removeChild(document.getElementById('loading-mask'));
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
if (hideLogo) {
var elem = document.querySelector('.loading-logo');
elem && (elem.style.display = 'none');
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
}
}
}
</script>
Expand Down
14 changes: 10 additions & 4 deletions apps/spreadsheeteditor/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@

var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
hideLogo = params["headerlogo"]==='',
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null;

Expand Down Expand Up @@ -359,10 +360,15 @@
if (stopLoading) {
document.body.removeChild(document.getElementById('loading-mask'));
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
if (hideLogo) {
var elem = document.querySelector('.loading-logo');
elem && (elem.style.display = 'none');
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
}
}
}
</script>
Expand Down
14 changes: 10 additions & 4 deletions apps/spreadsheeteditor/main/index.html.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@

var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
hideLogo = params["headerlogo"]==='',
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null;

Expand Down Expand Up @@ -345,10 +346,15 @@
if (stopLoading) {
document.body.removeChild(document.getElementById('loading-mask'));
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
if (hideLogo) {
var elem = document.querySelector('.loading-logo');
elem && (elem.style.display = 'none');
} else {
var elem = document.querySelector('.loading-logo img');
if (elem) {
(logo || logoDark) && elem.setAttribute('src', /theme-(?:[a-z]+-)?dark(?:-[a-z]*)?/.test(document.body.className) ? logoDark || logo : logo || logoDark);
elem.style.opacity = 1;
}
}
}
</script>
Expand Down

0 comments on commit 7242854

Please sign in to comment.