Skip to content

Commit

Permalink
Merge pull request #9 from SaphireLattice/fix/no-disappearing-buttons
Browse files Browse the repository at this point in the history
Don't hide the button of the currently active map
  • Loading branch information
juliangiebel authored Oct 6, 2024
2 parents e6ded00 + da4e485 commit 4dd83c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@ canvas {

#map-selector-maps > button {
width: 100%;
}

#map-selector-maps > button[disabled] {
color: #bbb;
/* based on ol.css button styling */
background-color: rgba(0, 30, 68, 0.75);
}
12 changes: 7 additions & 5 deletions js/MapSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class MapSelector extends Control {
this.maps = list.maps;

this.updateList();

});
}

handleMapChange(selected) {
const map = this.getMap();
MapLoader.loadLayers(map, selected.id).then(() => this.mapChangeCallback(selected, map));

this.selected = selected;
this.updateList();
}
Expand All @@ -58,12 +58,14 @@ class MapSelector extends Control {
this.selectedLabel.innerHTML = this.selected.name;

for (const map of this.maps) {
if (this.selected.id === map.id)
continue;

const mapButton = document.createElement('button');
mapButton.innerHTML = map.name;
mapButton.addEventListener('click', this.handleMapChange.bind(this, map), false);

if (this.selected.id === map.id)
mapButton.setAttribute("disabled", "")
else
mapButton.addEventListener('click', this.handleMapChange.bind(this, map), false);

this.listElement.appendChild(mapButton);
}
Expand Down

0 comments on commit 4dd83c6

Please sign in to comment.