From fcf1e3340eb52c96480a30eeb2968fe413a47fc1 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sun, 13 Aug 2023 03:01:41 +0100 Subject: [PATCH] releases.jquery.com: Attempt to fix script showing in page previews Add the `hidden` attribute to the template so that static analysis (such as preview cards that only process the first few KB of the HTML on its own) can know that this is not intended as visible content hidden, without relying on runtime CSS (which is where we also set it to display none). Ref https://github.com/jquery/codeorigin.jquery.com/issues/96 --- themes/jquery/js/sri-modal.js | 31 +++++++++++++++++------------ themes/releases.jquery.com/page.php | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/themes/jquery/js/sri-modal.js b/themes/jquery/js/sri-modal.js index 7330db6c..a822330a 100644 --- a/themes/jquery/js/sri-modal.js +++ b/themes/jquery/js/sri-modal.js @@ -1,25 +1,30 @@ $( function() { // Store modal templates - var modalTemplate = $( "#sri-modal-template" )[ 0 ].outerHTML; + var modalTemplate = $( "#sri-modal-template" )[ 0 ].outerHTML, + $modal = $( "
" ).attr( "title", "Code Integration" ); // Show modal on click $( "body" ).on( "click", ".open-sri-modal", function( event ) { if ( event.ctrlKey || event.metaKey ) { return; } + var link = this; - $( replace( modalTemplate, { - link: $( this ).prop( "href" ), - hash: $( this ).attr( "data-hash" ) - } ) ).removeAttr( "id" ).appendTo( "body" ).dialog( { - modal: true, - resizable: false, - dialogClass: "sri-modal", - draggable: false, - close: function() { - $( this ).remove(); - } - } ); + $modal + .html( replace( modalTemplate, { + link: link.href, + hash: $( link ).attr( "data-hash" ) + } ) ) + .appendTo( "body" ) + .dialog( { + modal: true, + resizable: false, + dialogClass: "sri-modal", + draggable: false, + close: function() { + $( this ).remove(); + } + } ); $('.sri-modal-copy-btn') .tooltip() diff --git a/themes/releases.jquery.com/page.php b/themes/releases.jquery.com/page.php index ed023195..90abe1a6 100644 --- a/themes/releases.jquery.com/page.php +++ b/themes/releases.jquery.com/page.php @@ -11,7 +11,7 @@ -
+