Skip to content

Commit

Permalink
Update infowindow.js
Browse files Browse the repository at this point in the history
Added minimize button
  • Loading branch information
huggla authored Jun 19, 2024
1 parent 4586b2a commit 420e239
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/infowindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
Expand Down Expand Up @@ -159,6 +184,10 @@ function render(viewerId) {
hideInfowindow();
});

document.getElementById(minimizeButton.getId()).addEventListener('click', () => {
minimizeInfowindow();
});

// Make the DIV element draggagle:
makeElementDraggable(mainContainer);
}
Expand Down

0 comments on commit 420e239

Please sign in to comment.