aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/dumbymap.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-31 17:11:55 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-11-03 14:01:05 +0800
commit1fc35b33eacf0f06370fc14798f65f5ec0972195 (patch)
treec745d7c1691d4baa92d208bcee26abacb5485d0c /src/dumbymap.mjs
parent11ff731337c6823e74821d06457972c6d0528c34 (diff)
feat: patch 7ee1ad6
* add spinning circle for Networking UX * display marker for each results
Diffstat (limited to 'src/dumbymap.mjs')
-rw-r--r--src/dumbymap.mjs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs
index 77f3515..217c1b6 100644
--- a/src/dumbymap.mjs
+++ b/src/dumbymap.mjs
@@ -534,6 +534,7 @@ export const generateMaps = (container, {
534 534
535 /** MENU: Menu Items for Context Menu */ 535 /** MENU: Menu Items for Context Menu */
536 container.oncontextmenu = e => { 536 container.oncontextmenu = e => {
537 /** Check if OK to show custom menu over context menu */
537 if (container.dataset.menu === 'disabled') return 538 if (container.dataset.menu === 'disabled') return
538 539
539 container.querySelectorAll('.dumby-menu').forEach(m => m.remove()) 540 container.querySelectorAll('.dumby-menu').forEach(m => m.remove())
@@ -554,6 +555,10 @@ export const generateMaps = (container, {
554 container.appendChild(menu) 555 container.appendChild(menu)
555 const containerRect = container.getBoundingClientRect() 556 const containerRect = container.getBoundingClientRect()
556 new window.MutationObserver(() => { 557 new window.MutationObserver(() => {
558 if (menu.childElementCount === 0) {
559 menu.style.display = 'none'
560 return
561 }
557 menu.style.display = 'block' 562 menu.style.display = 'block'
558 menu.style.left = (e.pageX - containerRect.left + 10) + 'px' 563 menu.style.left = (e.pageX - containerRect.left + 10) + 'px'
559 menu.style.top = (e.pageY - containerRect.top + 5) + 'px' 564 menu.style.top = (e.pageY - containerRect.top + 5) + 'px'
@@ -565,8 +570,10 @@ export const generateMaps = (container, {
565 if (rangeSelected) { 570 if (rangeSelected) {
566 // TODO check click is inside selection 571 // TODO check click is inside selection
567 const range = document.getSelection().getRangeAt(0) 572 const range = document.getSelection().getRangeAt(0)
568 menu.appendChild(menuItem.addLinkbyNominatim(range)) 573 menu.appendChild(menuItem.addLinkbyGeocoding(range))
574 return menu
569 } 575 }
576
570 /** Menu Item for editing map */ 577 /** Menu Item for editing map */
571 const mapEditor = e.target.closest('.edit-map') 578 const mapEditor = e.target.closest('.edit-map')
572 if (mapEditor) { 579 if (mapEditor) {
@@ -574,7 +581,7 @@ export const generateMaps = (container, {
574 text: 'Finish Editig', 581 text: 'Finish Editig',
575 onclick: () => mapEditor.blur(), 582 onclick: () => mapEditor.blur(),
576 })) 583 }))
577 return 584 return menu
578 } 585 }
579 586
580 /** Menu Items for Links */ 587 /** Menu Items for Links */
@@ -621,7 +628,7 @@ export const generateMaps = (container, {
621 628
622 if (linkWithLine) { 629 if (linkWithLine) {
623 menu.appendChild(menuItem.setLeaderLineType(linkWithLine)) 630 menu.appendChild(menuItem.setLeaderLineType(linkWithLine))
624 return 631 return menu
625 } 632 }
626 633
627 /** Menu Items for map */ 634 /** Menu Items for map */