Allow zoomed in images be closed by click outside - Add event listener to close image enlarge popup when clicked outside of image or description - Change img div to not be width:100% by default, was useless and just confusing when you could click next to the image and it zoomed in

ba73d278ae4668774f44736489813b14e3914e83

Wolfsblvt <wolfsblvt@gmail.com>

2 files changed, +14 -4Ignore whitespace
public/scripts/chats.js+13 -3
@@ -585,10 +585,12 @@ async function enlargeMessageImage() {
585585 const imgHolder = document.createElement('div');
586586 imgHolder.classList.add('img_enlarged_holder');
587587 imgHolder.append(img);
588588 const imgContainer = $('<div><pre><code class="img_enlarged_title"></code></code></pre></div>');
589589 imgContainer.prepend(imgHolder);
590590 imgContainer.addClass('img_enlarged_container');
591- imgContainer.find('code').addClass('txt').text(title);
591+
592+ const codeTitle = imgContainer.find('.img_enlarged_title');
593+ codeTitle.addClass('txt').text(title);
592594 const titleEmpty = !title || title.trim().length === 0;
593595 imgContainer.find('pre').toggle(!titleEmpty);
594596 addCopyToCodeBlocks(imgContainer);
@@ -598,9 +600,17 @@ async function enlargeMessageImage() {
598600 popup.dlg.style.width = 'unset';
599601 popup.dlg.style.height = 'unset';
600602
601603 img.addEventListener('click', ()event => {
602604 const shouldZoom = !img.classList.contains('zoomed');
603605 img.classList.toggle('zoomed', shouldZoom);
606+ event.stopPropagation();
607+ });
608+ codeTitle[0]?.addEventListener('click', event => {
609+ event.stopPropagation();
610+ });
611+
612+ popup.dlg.addEventListener('click', event => {
613+ popup.completeCancelled();
604614 });
605615
606616 await popup.show();
public/style.css+1 -1
@@ -4799,7 +4799,7 @@ body:not(.sd) .mes_img_swipes {
47994799
48004800.img_enlarged {
48014801 object-fit: contain;
48024802 max-width: 100%;
48034803 height: 100%;
48044804 cursor: zoom-in
48054805}