Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimize button to infowindow #2030

Merged
merged 12 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scss/_infowindow.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,24 @@
font-weight: normal;
}

.minimizedurvalelement {
padding: 0.5rem calc(38px + 2rem) 0 0.5rem;
}

.closebutton-svg-container {
cursor: pointer;
position: absolute;
right: 0;
top: 0;
}

.minimizebutton-svg-container {
cursor: pointer;
position: absolute;
right: 30px;
top: 0;
}


/**
* ============ List ==============
Expand Down Expand Up @@ -271,6 +282,10 @@
display: none;
}

.fit-width {
width: fit-content;
}

::-webkit-scrollbar {
width: 4px;
}
Expand Down
54 changes: 54 additions & 0 deletions src/infowindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ let activeSelectionGroup;
let selectionManager;
let viewer;
let infowindowOptions;
let initialMinimizeButtonIcon;
let hiddenMinimizeButtonIcon;
let minimizeButton;

function createSvgElement(id, className) {
const svgContainer = document.createElement('div');
Expand Down Expand Up @@ -109,6 +112,46 @@ 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: initialMinimizeButtonIcon,
state: 'initial',
validStates: ['initial', 'hidden'],
ariaLabel: 'Minimera'
});
}

function resetInfowindow() {
urvalListContainer.classList.remove('hidden');
listContainer.classList.remove('hidden');
exportContainer.classList.remove('hidden');
groupFooterContainer.classList.remove('hidden');
mainContainer.classList.remove('fit-width');
urvalContainer.classList.remove('minimizedurvalelement');
minimizeButton.setIcon(initialMinimizeButtonIcon);
minimizeButton.setState('initial');
}

function minimizeInfowindow() {
urvalListContainer.classList.add('hidden');
listContainer.classList.add('hidden');
exportContainer.classList.add('hidden');
groupFooterContainer.classList.add('hidden');
mainContainer.classList.add('fit-width');
urvalContainer.classList.add('minimizedurvalelement');
minimizeButton.setIcon(hiddenMinimizeButtonIcon);
minimizeButton.setState('hidden');
}

function toggleInfowindow() {
if (urvalListContainer.classList.contains('hidden')) {
resetInfowindow();
} else {
minimizeInfowindow();
}
}

function render(viewerId) {
mainContainer = document.createElement('div');
setInfowindowStyle();
Expand All @@ -126,6 +169,8 @@ function render(viewerId) {
urvalTextNodeContainer.appendChild(urvalTextNode);
urvalContainer.appendChild(urvalTextNodeContainer);
const closeButton = createCloseButton();
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 @@ -157,6 +202,13 @@ function render(viewerId) {
viewer.dispatch('toggleClickInteraction', detail);
selectionManager.clearSelection();
hideInfowindow();
if (urvalListContainer.classList.contains('hidden')) {
resetInfowindow();
}
});

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

// Make the DIV element draggagle:
Expand Down Expand Up @@ -430,6 +482,8 @@ function init(options) {
urvalElements = new Map();
expandableContents = new Map();
footerContainers = new Map();
initialMinimizeButtonIcon = '#ic_close_fullscreen_24px';
hiddenMinimizeButtonIcon = '#ic_open_in_full_24px';

render(options.viewer.getId());

Expand Down
Loading