Skip to content

Commit

Permalink
Merge pull request #2849 from ONLYOFFICE/feature/hide-logo
Browse files Browse the repository at this point in the history
Feature/hide logo
  • Loading branch information
JuliaRadzhabova authored Feb 16, 2024
2 parents 79bc43c + 43d3283 commit 5e4cdeb
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 101 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
19 changes: 12 additions & 7 deletions apps/documenteditor/embed/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,25 @@

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

window.frameEditorId = params["frameEditorId"];
window.parentOrigin = params["parentOrigin"];

var elem = document.querySelector('.loading-logo');
if (elem && logo) {
elem.style.backgroundImage= 'none';
elem.style.width = 'auto';
elem.style.height = 'auto';
var img = document.querySelector('.loading-logo img');
img && img.setAttribute('src', logo);
img.style.opacity = 1;
if (elem) {
if (hideLogo) {
elem.style.display = 'none';
} else if (logo) {
elem.style.backgroundImage= 'none';
elem.style.width = 'auto';
elem.style.height = 'auto';
var img = document.querySelector('.loading-logo img');
img && img.setAttribute('src', logo);
img.style.opacity = 1;
}
}
</script>

Expand Down
21 changes: 13 additions & 8 deletions apps/documenteditor/embed/index.html.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,25 @@

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

window.frameEditorId = params["frameEditorId"];
window.parentOrigin = params["parentOrigin"];
var elem = document.querySelector('.loading-logo');
if (elem && logo) {
elem.style.backgroundImage= 'none';
elem.style.width = 'auto';
elem.style.height = 'auto';
var img = document.querySelector('.loading-logo img');
img && img.setAttribute('src', logo);
img.style.opacity = 1;
}
if (elem) {
if (hideLogo) {
elem.style.display = 'none';
} else if (logo) {
elem.style.backgroundImage= 'none';
elem.style.width = 'auto';
elem.style.height = 'auto';
var img = document.querySelector('.loading-logo img');
img && img.setAttribute('src', logo);
img.style.opacity = 1;
}
}
</script>

<div id="editor_sdk" class="viewer" style="overflow: hidden;" tabindex="-1"></div>
Expand Down
9 changes: 7 additions & 2 deletions apps/documenteditor/embed/js/ApplicationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,9 @@ DE.ApplicationController = new(function(){
_right_width = $parent.next().outerWidth();

if ( _left_width < _right_width )
$parent.css('padding-left', _right_width - _left_width);
$parent.css('padding-left', parseFloat($parent.css('padding-left')) + _right_width - _left_width);
else
$parent.css('padding-right', _left_width - _right_width);
$parent.css('padding-right', parseFloat($parent.css('padding-right')) + _left_width - _right_width);

onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument);

Expand Down Expand Up @@ -884,6 +884,11 @@ DE.ApplicationController = new(function(){
function setBranding(value) {
if ( value && value.logo) {
var logo = $('#header-logo');
if (value.logo.visible===false) {
logo.addClass('hidden');
return;
}

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'});
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
19 changes: 12 additions & 7 deletions apps/presentationeditor/embed/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,24 @@

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

window.frameEditorId = params["frameEditorId"];
window.parentOrigin = params["parentOrigin"];

var elem = document.querySelector('.loading-logo');
if (elem && logo) {
elem.style.backgroundImage= 'none';
elem.style.width = 'auto';
elem.style.height = 'auto';
var img = document.querySelector('.loading-logo img');
img && img.setAttribute('src', logo);
img.style.opacity = 1;
if (elem) {
if (hideLogo) {
elem.style.display = 'none';
} else if (logo) {
elem.style.backgroundImage= 'none';
elem.style.width = 'auto';
elem.style.height = 'auto';
var img = document.querySelector('.loading-logo img');
img && img.setAttribute('src', logo);
img.style.opacity = 1;
}
}
</script>

Expand Down
21 changes: 13 additions & 8 deletions apps/presentationeditor/embed/index.html.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,25 @@

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

window.frameEditorId = params["frameEditorId"];
window.parentOrigin = params["parentOrigin"];

var elem = document.querySelector('.loading-logo');
if (elem && logo) {
elem.style.backgroundImage= 'none';
elem.style.width = 'auto';
elem.style.height = 'auto';
var img = document.querySelector('.loading-logo img');
img && img.setAttribute('src', logo);
img.style.opacity = 1;
}
if (elem) {
if (hideLogo) {
elem.style.display = 'none';
} else if (logo) {
elem.style.backgroundImage= 'none';
elem.style.width = 'auto';
elem.style.height = 'auto';
var img = document.querySelector('.loading-logo img');
img && img.setAttribute('src', logo);
img.style.opacity = 1;
}
}
</script>

<div id="box-preview">
Expand Down
9 changes: 7 additions & 2 deletions apps/presentationeditor/embed/js/ApplicationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,9 @@ PE.ApplicationController = new(function(){
_right_width = $parent.next().outerWidth();

if ( _left_width < _right_width )
$parent.css('padding-left', _right_width - _left_width);
$parent.css('padding-left', parseFloat($parent.css('padding-left')) + _right_width - _left_width);
else
$parent.css('padding-right', _left_width - _right_width);
$parent.css('padding-right', parseFloat($parent.css('padding-right')) + _left_width - _right_width);

onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument);
api.asc_setViewMode(true);
Expand Down Expand Up @@ -736,6 +736,11 @@ PE.ApplicationController = new(function(){
function setBranding(value) {
if ( value && value.logo) {
var logo = $('#header-logo');
if (value.logo.visible===false) {
logo.addClass('hidden');
return;
}

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'});
Expand Down
Loading

0 comments on commit 5e4cdeb

Please sign in to comment.