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); }