Same page printout previews #2751
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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