Skip to content

Commit e0c6af0

Browse files
authored
Merge pull request #31 from ProLoser/copilot/switch-to-html5-details-element
2 parents 4acaf76 + a386325 commit e0c6af0

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

map.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,11 @@ window.viewEventDetails = function(eventIndex, expandDetails = false) {
367367

368368
// Automatically expand details if requested
369369
if (expandDetails) {
370-
// Wait for the info window to render, then check the checkbox
370+
// Wait for the info window to render, then open the details
371371
setTimeout(() => {
372-
const detailsCheckbox = document.getElementById('moreInfo');
373-
if (detailsCheckbox && !detailsCheckbox.checked) {
374-
detailsCheckbox.checked = true;
372+
const detailsElement = document.querySelector('.info-body details');
373+
if (detailsElement && !detailsElement.open) {
374+
detailsElement.open = true;
375375
// Trigger the reposition
376376
infoWindow.open(window.map, event.marker);
377377
}
@@ -502,15 +502,16 @@ class Events {
502502
<p class="categories">Categories: ${event.categories.map(category => `<a onclick="filter({category:'${category}'})">${category}</a>`).join('')}</p>
503503
</div>
504504
<div class="info-body">
505-
<input id="moreInfo" type="checkbox" onchange=>
506-
<label for="moreInfo">+ Expand Details +</label>
507-
<div id="details">
508-
${event.details}
509-
</div>
505+
<details>
506+
<summary>+ Expand Details +</summary>
507+
<div id="details">
508+
${event.details}
509+
</div>
510+
</details>
510511
</div>
511512
`
512513
// Reposition after expanding
513-
content.querySelector('input').addEventListener('change', () => {
514+
content.querySelector('details').addEventListener('toggle', () => {
514515
this.cachedInfoWindow.open(window.map, event.marker);
515516
})
516517
this.cachedInfoWindow.setContent(content);

style.css

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,22 @@ html, body, #map-canvas {
104104
.info-body {
105105
max-width: 80vw;
106106
max-height: 40vh;
107-
& > * {
108-
display: none;
109-
}
110-
& > label {
111-
display: block;
112-
text-align: center;
113-
padding: 10px;
114-
color: blue;
115-
text-decoration: underline;
116-
cursor: pointer;
117-
}
118-
& > input:checked ~ div {
119-
display: block;
120-
}
121-
& > input:checked ~ label {
122-
display: none;
107+
details {
108+
summary {
109+
display: block;
110+
text-align: center;
111+
padding: 10px;
112+
color: blue;
113+
text-decoration: underline;
114+
cursor: pointer;
115+
list-style: none;
116+
&::-webkit-details-marker {
117+
display: none;
118+
}
119+
&::-moz-list-bullet {
120+
display: none;
121+
}
122+
}
123123
}
124124
}
125125
/* HTML from FunCheapSF */

0 commit comments

Comments
 (0)