Skip to content

Conversation

@oscarlevin
Copy link
Member

The print preview for worksheets and handouts is currently handled by creating a separate page with just that "printout" and some different CSS. This eliminates those additional files. The main reason this is needed is for portable builds to still get printable worksheets and handouts, but this also simplifies the code and reduces the number of files that need to be built.

How it works: now on any page that contains worksheets or handouts, a header for print previews is included (but hidden by CSS). The links to the print preview now open the current page with a ?print-preview=[id-of-printout] parameter. This reloads the page (so the back button still works the same way as it always has) and tells the javascript to load just that printout and use the css for print previews.

While getting the javascript to work for this (second commit) I also refactored to make the javascript more robust. In particular, switching page sizes while the highlight workspace is on no longer requires a full page reload, and this eliminates a minor bug that showed up if a user highlighted workspace, then unhighlighted it and then switch pages (doing so would set workspace incorrectly).

As an added bonus, this cleans up the pretext-html templates around the print-preview controls, as suggested in #2745

@rbeezer
Copy link
Collaborator

rbeezer commented Dec 27, 2025

Cursory visual review looks good. Do you know the descendant-or-self:: axis? Perhaps for use in

<xsl:with-param name="b-has-printout" select="self::worksheet or self::handout or .//worksheet or .//handout"/>

@oscarlevin
Copy link
Member Author

Ah! I did not know about that. Agree that's better. Will update soon, unless you beat me to it.

@oscarlevin
Copy link
Member Author

Force pushed with the improved xsl selector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants