Use plural form when multiple overlays are active (#378)

This commit is contained in:
Gautier P 2021-03-01 20:13:42 +01:00 committed by GitHub
parent 845a3f0378
commit e188d8f9de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 7 deletions

View file

@ -26,12 +26,14 @@ BR.LayersTab = BR.ControlLayers.extend({
BR.ControlLayers.prototype.onAdd.call(this, map);
map.on('baselayerchange overlayadd overlayremove', this.storeActiveLayers, this);
map.on('overlayadd overlayremove', this.updateOpacityLabel, this);
},
onRemove: function (map) {
BR.ControlLayers.prototype.onRemove.call(this, map);
map.off('baselayerchange overlayadd overlayremove', this.storeActiveLayers, this);
map.off('overlayadd overlayremove', this.updateOpacityLabel, this);
},
initOpacitySlider: function (map) {
@ -472,6 +474,17 @@ BR.LayersTab = BR.ControlLayers.extend({
}
}
},
updateOpacityLabel: function () {
var slider = $('#leaflet-control-layers-overlays-opacity-slider');
var overlaysCount = this.getActiveLayers().length - 1;
if (overlaysCount === 0) {
slider.hide();
} else {
slider.show();
slider.children()[1].innerText = i18next.t('sidebar.layers.overlay-opacity', { count: overlaysCount });
}
},
});
BR.layersTab = function (baseLayers, overlays, options) {