changed type selection to button + dropdown menu

This commit is contained in:
Elad Bernard Haviv 2023-08-05 11:48:00 +03:00
parent 128231144e
commit 7a8254a9b4
3 changed files with 61 additions and 11 deletions

View file

@ -2357,6 +2357,38 @@ svg.button {
opacity: 0.8; opacity: 0.8;
} }
#markerTypeSelector {
font-size: 0.85em;
}
#markerTypeSelectorWrapper {
position: relative;
}
#markerTypeSelectMenu {
display: none;
}
#markerTypeSelectMenu.visible {
display: block;
position: absolute;
height: 250px;
width: 170px;
overflow-y: scroll;
background: inherit;
bottom: 100%;
left: 0;
background: white;
}
#markerTypeSelectMenu > button {
display: block;
width: 100%;
border: 1px solid #ddd;
margin-bottom: 1px;
}
#markerTypeSelectMenu > button:hover {
background: #ccc;
}
@media print { @media print {
div, div,
canvas { canvas {

View file

@ -5509,9 +5509,14 @@
<div id="markersBottom"> <div id="markersBottom">
<button id="markersOverviewRefresh" data-tip="Refresh the Overview screen" class="icon-cw"></button> <button id="markersOverviewRefresh" data-tip="Refresh the Overview screen" class="icon-cw"></button>
<select id="addedMarkerType" style="width: 40px"> <input type="hidden" id="addedMarkerType" name="addedMarkerType" value="" />
<option value="" selected>❓empty marker</option> <span id="markerTypeSelectorWrapper">
</select> <button
id="markerTypeSelector"
data-tip="Select marker type for newly added markers."
>❓</button>
<div id="markerTypeSelectMenu"></div>
</span>
<button <button
id="markersAddFromOverview" id="markersAddFromOverview"
data-tip="Add a new marker. Hold Shift to add multiple" data-tip="Add a new marker. Hold Shift to add multiple"

View file

@ -15,6 +15,7 @@ function overviewMarkers() {
const markersRemoveAll = document.getElementById("markersRemoveAll"); const markersRemoveAll = document.getElementById("markersRemoveAll");
const markersExport = document.getElementById("markersExport"); const markersExport = document.getElementById("markersExport");
const markerTypeInput = document.getElementById("addedMarkerType"); const markerTypeInput = document.getElementById("addedMarkerType");
const markerTypeSelector = document.getElementById("markerTypeSelector");
addLines(); addLines();
@ -26,13 +27,6 @@ function overviewMarkers() {
position: {my: "right top", at: "right-10 top+10", of: "svg", collision: "fit"} position: {my: "right top", at: "right-10 top+10", of: "svg", collision: "fit"}
}); });
Markers.getConfig().forEach(markerConfig => {
const option = document.createElement("option");
option.setAttribute("value", markerConfig.type);
option.textContent = `${markerConfig.icon} ${markerConfig.type}`;
markerTypeInput.appendChild(option);
});
const listeners = [ const listeners = [
listen(body, "click", handleLineClick), listen(body, "click", handleLineClick),
listen(markersInverPin, "click", invertPin), listen(markersInverPin, "click", invertPin),
@ -42,9 +36,23 @@ function overviewMarkers() {
listen(markersGenerationConfig, "click", configMarkersGeneration), listen(markersGenerationConfig, "click", configMarkersGeneration),
listen(markersRemoveAll, "click", triggerRemoveAll), listen(markersRemoveAll, "click", triggerRemoveAll),
listen(markersExport, "click", exportMarkers), listen(markersExport, "click", exportMarkers),
listen(markerTypeInput, "change", changeMarkerType), listen(markerTypeSelector, "click", toggleMarkerTypeMenu),
//listen(markerTypeInput, "change", changeMarkerType),
]; ];
[{type: "empty", icon: "❓"}, ...Markers.getConfig()].forEach(markerConfig => {
const option = document.createElement("button");
option.textContent = `${markerConfig.icon} ${markerConfig.type}`;
markerTypeSelectMenu.appendChild(option);
console.log(option.textContent);
listeners.push(listen(option, "click", () => {
markerTypeSelector.textContent = markerConfig.icon;
markerTypeInput.value = markerConfig.type;
changeMarkerType();
toggleMarkerTypeMenu();
}));
});
function handleLineClick(ev) { function handleLineClick(ev) {
const el = ev.target; const el = ev.target;
const i = +el.parentNode.dataset.i; const i = +el.parentNode.dataset.i;
@ -148,6 +156,11 @@ function overviewMarkers() {
}); });
} }
function toggleMarkerTypeMenu() {
document.getElementById("markerTypeSelectMenu").classList.toggle("visible");
}
function toggleAddMarker() { function toggleAddMarker() {
markersAddFromOverview.classList.toggle("pressed"); markersAddFromOverview.classList.toggle("pressed");
addMarker.click(); addMarker.click();