diff --git a/htdocs/js/Feedback/feedback.js b/htdocs/js/Feedback/feedback.js index ee39da494c..b7271cee39 100644 --- a/htdocs/js/Feedback/feedback.js +++ b/htdocs/js/Feedback/feedback.js @@ -3,7 +3,7 @@ if (feedbackBtn.dataset.popoverInitialized) return; feedbackBtn.dataset.popoverInitialized = 'true'; - new bootstrap.Popover(feedbackBtn, { sanitize: false }); + new bootstrap.Popover(feedbackBtn, { sanitize: false, container: feedbackBtn.parentElement }); // Render MathJax previews. if (window.MathJax) { @@ -12,15 +12,19 @@ }); } - // Execute javascript in the answer preview. feedbackBtn.addEventListener('shown.bs.popover', () => { const bsPopover = bootstrap.Popover.getInstance(feedbackBtn); + + // Execute javascript in the answer preview. bsPopover.tip?.querySelectorAll('script').forEach((origScript) => { const newScript = document.createElement('script'); Array.from(origScript.attributes).forEach((attr) => newScript.setAttribute(attr.name, attr.value)); newScript.appendChild(document.createTextNode(origScript.innerHTML)); origScript.parentNode.replaceChild(newScript, origScript); }); + + // Make a click on the popover header close the popover. + bsPopover.tip?.querySelector('.popover-header')?.addEventListener('click', () => bsPopover?.hide()); }); }; diff --git a/htdocs/js/Problem/problem.scss b/htdocs/js/Problem/problem.scss index bba7d0de77..b2ee8ea366 100644 --- a/htdocs/js/Problem/problem.scss +++ b/htdocs/js/Problem/problem.scss @@ -223,6 +223,7 @@ .popover-header { --bs-popover-header-bg: var(--bs-success); --bs-popover-header-color: white; + cursor: pointer; } } diff --git a/macros/PG.pl b/macros/PG.pl index 5c4b8b1531..2770286d50 100644 --- a/macros/PG.pl +++ b/macros/PG.pl @@ -1239,7 +1239,7 @@ sub ENDDOCUMENT { return '' unless defined $line && $line =~ /\S/; return Mojo::DOM->new_tag( 'div', - class => 'card-header text-center', + class => 'card-header text-center p-1', sub { Mojo::DOM->new_tag('h4', class => 'card-title fs-6 m-0', $title); } ) . Mojo::DOM->new_tag('div', class => "card-body text-center $class", sub {$line}); }