From 802fadb829af7a038703c45bd3050937f1d64d48 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Sun, 29 Oct 2023 21:57:12 +0100 Subject: [PATCH] close popup on link press --- src/app/main.parser.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/main.parser.js b/src/app/main.parser.js index b2cece0..2050e5e 100644 --- a/src/app/main.parser.js +++ b/src/app/main.parser.js @@ -220,14 +220,16 @@ class SourceParser { newElement.addEventListener('click', () => { const src = 'https://github.com/pytgcalls/pytgcalls/tree/master/' + element.getAttribute('url'); - const closeButton = document.createElement('div'); - closeButton.classList.add('close-button'); - closeButton.addEventListener('click', () => { + const closePopup = () => { fullscreenCodePreview.classList.add('disappear'); fullscreenCodePreview.addEventListener('animationend', () => { fullscreenCodePreview.remove(); }, { once: true }); - }); + }; + + const closeButton = document.createElement('div'); + closeButton.classList.add('close-button'); + closeButton.addEventListener('click', closePopup); closeButton.appendChild(document.createElement('div')); closeButton.appendChild(document.createElement('div')); @@ -242,6 +244,7 @@ class SourceParser { urlBarOpenImage.src = '/src/assets/uprightfromsquare.svg'; const urlBarOpen = document.createElement('a'); urlBarOpen.classList.add('link'); + urlBarOpen.addEventListener('click', closePopup); urlBarOpen.target = '_blank'; urlBarOpen.href = src; urlBarOpen.appendChild(urlBarOpenImage);