Skip to content

Commit

Permalink
Update popup.js
Browse files Browse the repository at this point in the history
Code suggestion from Grammostola
  • Loading branch information
huggla authored Feb 28, 2024
1 parent a0addba commit 336ccbe
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function render(target) {
<div class="o-popup o-card">
<div class="flex row justify-end">
<div id="o-card-title" class="justify-start margin-y-smaller margin-left text-weight-bold" style="width:100%;"></div>
<button id="o-minimize-button" class="small round margin-top-smaller margin-bottom-auto margin-right-small icon-smallest grey-lightest no-shrink" aria-label="Minimera" onclick='var oidentify=document.getElementById("o-identify"),opopup=document.getElementById("o-popup"); if (oidentify.style.display === "none") { oidentify.style.display="block"; opopup.style.width=null; } else { oidentify.style.display="none"; opopup.style.width="auto"; }' >
<button id="o-minimize-button" class="small round margin-top-smaller margin-bottom-auto margin-right-small icon-smallest grey-lightest no-shrink" aria-label="Minimera">
<span class="icon ">_</span>
</button>
<button id="o-close-button" class="small round margin-top-smaller margin-bottom-auto margin-right-small icon-smallest grey-lightest no-shrink" aria-label="Stäng">
Expand Down Expand Up @@ -60,6 +60,13 @@ function setContent(config) {
}
}

function minimizePopup() {
const oidentify = document.getElementById('o-identify');
const opopup = document.getElementById('o-popup');
oidentify.style.display = oidentify.style.display === 'none' ? 'block' : 'none';
opopup.style.width = oidentify.style.display === 'none' ? 'auto' : null;
}

/**
* Closes the window and optionally calls a callback set at init
* @param {any} cb
Expand Down Expand Up @@ -88,6 +95,11 @@ export default function popup(target, opts = {}) {
closePopupInternal(closeCb);
evt.preventDefault();
});
const minel = document.querySelector('#o-popup .o-popup #o-minimize-button');
minel.addEventListener('click', (evt) => {
minimizePopup();
evt.preventDefault();
});
}

render(target);
Expand Down

0 comments on commit 336ccbe

Please sign in to comment.