Skip to content

Commit

Permalink
Updated to extend the print functionality so that the additional info…
Browse files Browse the repository at this point in the history
…rmation is expanded on the preview and closes again once the preview closes.
  • Loading branch information
sam-c-dfe committed Aug 5, 2024
1 parent 605fba9 commit d9ab2e8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static SecureHeadersMiddlewareConfiguration CustomConfiguration()
var windowPrint = new ContentSecurityPolicyElement
{
CommandType = CspCommandType.Directive,
DirectiveOrUri = "sha256-/rCCQAYo5nH3kqWMvdaSato3ShxLfLrkODJIMZPKHSg="
DirectiveOrUri = "sha256-1f+6vEGZewP7dkvrYIBD4bqMLOhumfg10mwfKd2jU7I="
};

configuration.ContentSecurityPolicyConfiguration.ScriptSrc.Add(backButtonShaCspElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
@Html.Raw(Model.Content!.RequirementsText)

<div class="govuk-!-static-margin-top-6">
<button id="print-button" onclick="window.print();" class="govuk-link govuk-body-s print-button">@Model.Content!.PrintButtonText</button>
<button id="print-button" onclick="printButtonClicked();" class="govuk-link govuk-body-s print-button">@Model.Content!.PrintButtonText</button>
</div>

<p class="govuk-body govuk-!-static-margin-top-6">
Expand Down
6 changes: 6 additions & 0 deletions src/Dfe.EarlyYearsQualification.Web/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,10 @@ body {

.no-padding-right {
padding-right: 0 !important;
}

@media print {
details {
display: block;
}
}
11 changes: 11 additions & 0 deletions src/Dfe.EarlyYearsQualification.Web/wwwroot/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@
// for details on configuring this project to bundle and minify static web assets.

// Write your JavaScript code.
function printButtonClicked()
{
console.log('button clicked');
$('.govuk-details').attr('open', 'open');
window.print();
}

window.addEventListener("afterprint", (event) => {
console.log('after print');
$('.govuk-details').removeAttr('open');
})

0 comments on commit d9ab2e8

Please sign in to comment.