don't show empty tooltips in backgrounds list

This commit is contained in:
Martin Raifer
2022-09-27 14:00:28 +02:00
parent a551730aaa
commit df1f755150
2 changed files with 10 additions and 3 deletions
+7
View File
@@ -79,6 +79,13 @@ export function rendererBackgroundSource(data) {
};
source.hasDescription = function() {
var id_safe = source.id.replace(/\./g, '<TX_DOT>');
var descriptionText = localizer.tInfo('imagery.' + id_safe + '.description', { default: escape(_description) }).text;
return descriptionText !== '';
};
source.description = function() {
var id_safe = source.id.replace(/\./g, '<TX_DOT>');
return t.append('imagery.' + id_safe + '.description', { default: escape(_description) });
+3 -3
View File
@@ -142,7 +142,7 @@ export function uiSectionBackgroundList(context) {
var item = d3_select(this).select('label');
var span = item.select('span');
var placement = (i < nodes.length / 2) ? 'bottom' : 'top';
var description = d.description();
var hasDescription = d.hasDescription();
var isOverflowing = (span.property('clientWidth') !== span.property('scrollWidth'));
item.call(uiTooltip().destroyAny);
@@ -153,10 +153,10 @@ export function uiSectionBackgroundList(context) {
.title(() => t.append('background.switch'))
.keys([uiCmd('⌘' + t('background.key'))])
);
} else if (description || isOverflowing) {
} else if (hasDescription || isOverflowing) {
item.call(uiTooltip()
.placement(placement)
.title(() => description || d.label())
.title(() => hasDescription ? d.description() : d.label())
);
}
});