From 420e23988bfe6fda5c39a6e8e136bc5b8812f9c8 Mon Sep 17 00:00:00 2001 From: Henrik Uggla Date: Wed, 19 Jun 2024 13:11:37 +0200 Subject: [PATCH] Update infowindow.js Added minimize button --- src/infowindow.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/infowindow.js b/src/infowindow.js index 8b3210841..84aae4d6b 100644 --- a/src/infowindow.js +++ b/src/infowindow.js @@ -109,6 +109,29 @@ function createCloseButton() { }); } +function createMinimizeButton() { + return Button({ + cls: 'minimizebutton-svg-container small round small icon-smaller grey-lightest margin-top-small margin-right-small z-index-ontop-low ', + icon: '#ic_close_24px', + state: 'initial', + validStates: ['initial', 'hidden'], + ariaLabel: 'Minimera' + }); +} + +function minimizeInfowindow() { + const sidebarcontainer = document.getElementById('sidebarcontainer'); + const urvalcontainer = document.getElementById('sidebarcontainer-draggable'); + const urvalListContainer = urvalcontainer.getElementsByClassName('urvalListContainer')[0]; + const listcontainer = sidebarcontainer.getElementsByClassName('listcontainer')[0]; + const exportcontainer = sidebarcontainer.getElementsByClassName('exportcontainer')[0]; + urvalListContainer.style.display = urvalListContainer.style.display === 'none' ? null : 'none'; + sidebarcontainer.style.width = urvalListContainer.style.display === 'none' ? 'fit-content' : null; + urvalcontainer.style.padding = urvalListContainer.style.display === 'none' ? '9px 5em 2px 0.5em' : null; + listcontainer.style.display = listcontainer.style.display === 'none' ? null : 'none'; + exportcontainer.style.display = exportcontainer.style.display === 'none' ? null : 'none'; +} + function render(viewerId) { mainContainer = document.createElement('div'); setInfowindowStyle(); @@ -126,6 +149,8 @@ function render(viewerId) { urvalTextNodeContainer.appendChild(urvalTextNode); urvalContainer.appendChild(urvalTextNodeContainer); const closeButton = createCloseButton(); + const minimizeButton = createMinimizeButton(); + urvalContainer.appendChild(dom.html(minimizeButton.render())); urvalContainer.appendChild(dom.html(closeButton.render())); urvalContainer.appendChild(urvalListContainer); listContainer = document.createElement('div'); @@ -159,6 +184,10 @@ function render(viewerId) { hideInfowindow(); }); + document.getElementById(minimizeButton.getId()).addEventListener('click', () => { + minimizeInfowindow(); + }); + // Make the DIV element draggagle: makeElementDraggable(mainContainer); }