Fix controls errors with permanent credits

This commit is contained in:
3st3ban3 2023-01-22 00:28:56 +01:00
parent 423084e9ea
commit ced62d8eed
2 changed files with 5 additions and 10 deletions

View file

@ -440,8 +440,9 @@ L.U.PermanentCreditsControl = L.Control.extend({
position: 'bottomleft' position: 'bottomleft'
}, },
initialize: function (map) { initialize: function (map, options) {
this.map = map; this.map = map;
L.Control.prototype.initialize.call(this, options);
}, },
onAdd: function () { onAdd: function () {
@ -455,11 +456,6 @@ L.U.PermanentCreditsControl = L.Control.extend({
return paragraphContainer; return paragraphContainer;
}, },
_update: function () {
this.setCredits();
this.setBackground();
},
setCredits: function () { setCredits: function () {
this.paragraphContainer.innerHTML = L.Util.toHTML(this.map.options.permanentCredit); this.paragraphContainer.innerHTML = L.Util.toHTML(this.map.options.permanentCredit);
}, },

View file

@ -277,7 +277,7 @@ L.U.Map.include({
this._controls.measure = (new L.MeasureControl()).initHandler(this); this._controls.measure = (new L.MeasureControl()).initHandler(this);
this._controls.more = new L.U.MoreControls(); this._controls.more = new L.U.MoreControls();
this._controls.scale = L.control.scale(); this._controls.scale = L.control.scale();
if (this.options.permanentCredit) this.permanentCreditControl = (new L.U.PermanentCreditsControl(this)).addTo(this); this._controls.permanentCredit = new L.U.PermanentCreditsControl(this);
if (this.options.scrollWheelZoom) this.scrollWheelZoom.enable(); if (this.options.scrollWheelZoom) this.scrollWheelZoom.enable();
else this.scrollWheelZoom.disable(); else this.scrollWheelZoom.disable();
this.renderControls(); this.renderControls();
@ -310,6 +310,7 @@ L.U.Map.include({
if (status === undefined || status === null) L.DomUtil.addClass(control._container, 'display-on-more'); if (status === undefined || status === null) L.DomUtil.addClass(control._container, 'display-on-more');
else L.DomUtil.removeClass(control._container, 'display-on-more'); else L.DomUtil.removeClass(control._container, 'display-on-more');
} }
if (this.options.permanentCredit) this._controls.permanentCredit.addTo(this);
if (this.options.moreControl) this._controls.more.addTo(this); if (this.options.moreControl) this._controls.more.addTo(this);
if (this.options.scaleControl) this._controls.scale.addTo(this); if (this.options.scaleControl) this._controls.scale.addTo(this);
}, },
@ -1396,9 +1397,7 @@ L.U.Map.include({
['options.permanentCreditBackground', {handler: 'Switch', label: L._('Permanent credits background')}] ['options.permanentCreditBackground', {handler: 'Switch', label: L._('Permanent credits background')}]
]; ];
var creditsBuilder = new L.U.FormBuilder(this, creditsFields, { var creditsBuilder = new L.U.FormBuilder(this, creditsFields, {
callback: function () { callback: this.renderControls,
this._controls.attribution._update();
this.permanentCreditControl._update();},
callbackContext: this callbackContext: this
}); });
credits.appendChild(creditsBuilder.build()); credits.appendChild(creditsBuilder.build());