diff --git a/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/ShowPageProducer.java b/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/ShowPageProducer.java index 8dce9ab7c91a..09ecfab985dd 100644 --- a/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/ShowPageProducer.java +++ b/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/ShowPageProducer.java @@ -965,13 +965,11 @@ public int compare(SimpleStudentPage o1, SimpleStudentPage o2) { List itemList = null; // items to show - if(httpServletRequest.getParameter("printall") != null && currentPage.getTopParent() != null) - { - itemList = (List) simplePageBean.getItemsOnPage(currentPage.getTopParent()); + if(httpServletRequest.getParameter("printall") != null && currentPage.getTopParent() != null) { + itemList = simplePageBean.getItemsOnPage(currentPage.getTopParent()); } - else - { - itemList = (List) simplePageBean.getItemsOnPage(currentPage.getPageId()); + else { + itemList = simplePageBean.getItemsOnPage(currentPage.getPageId()); } // Move all items with sequence <= 0 to the end of the list. diff --git a/lessonbuilder/tool/src/webapp/js/show-page.js b/lessonbuilder/tool/src/webapp/js/show-page.js index a1eb80d69ac2..c274ddd60585 100644 --- a/lessonbuilder/tool/src/webapp/js/show-page.js +++ b/lessonbuilder/tool/src/webapp/js/show-page.js @@ -33,6 +33,24 @@ $(window).load(function () { document.getElementById(questionToScrollTo).scrollIntoView(true); } + // Print the current page + document.getElementById('print-view').addEventListener('click', function() { + const url = printView(window.location.href); + const win = window.open(url, '_blank'); + win.focus(); + win.print(); + return false; + }); + + // Print all pages + document.getElementById('print-all').addEventListener('click', function() { + const url = printViewWithParameter(window.location.href); + const win = window.open(url, '_blank'); + win.focus(); + win.print(); + return false; + }); + }); function fixAddBefore(href) { @@ -3620,27 +3638,19 @@ function toggleShortUrlOutput(defaultUrl, checkbox, textbox) { } function printView(url) { - var i = url.indexOf("/site/"); - if (i < 0) - return url; - var j = url.indexOf("/tool/"); - if (j < 0) - return url; - return url.substring(0, i) + url.substring(j); + const siteIndex = url.indexOf("/site/"); + const toolIndex = url.indexOf("/tool/"); + if (siteIndex < 0 || toolIndex < 0) return url; + return url.substring(0, siteIndex) + url.substring(toolIndex); } function printViewWithParameter(url) { - var i = url.indexOf("/site/"); - if (i < 0) - return url; - var j = url.indexOf("/tool/"); - if (j < 0) - return url; - var z = url.indexOf("ShowPage"); - if (z < 0) - return url.substring(0, i) + url.substring(j) + '?printall=true'; - else - return url.substring(0, i) + url.substring(j) + '&printall=true'; + const siteIndex = url.indexOf("/site/"); + const toolIndex = url.indexOf("/tool/"); + const showPageIndex = url.indexOf("ShowPage"); + if (siteIndex < 0 || toolIndex < 0) return url; + const modifiedUrl = url.substring(0, siteIndex) + url.substring(toolIndex); + return showPageIndex < 0 ? `${modifiedUrl}?printall=true` : `${modifiedUrl}&printall=true`; } // make columns in a section the same height. Is there a better place to trigger this? diff --git a/lessonbuilder/tool/src/webapp/templates/ShowPage.html b/lessonbuilder/tool/src/webapp/templates/ShowPage.html index 6470b7c36262..0c79e69ed9e1 100644 --- a/lessonbuilder/tool/src/webapp/templates/ShowPage.html +++ b/lessonbuilder/tool/src/webapp/templates/ShowPage.html @@ -149,21 +149,21 @@

diff --git a/library/src/skins/default/src/sass/print.scss b/library/src/skins/default/src/sass/print.scss index 0e5e04084488..f78cbebe07d5 100644 --- a/library/src/skins/default/src/sass/print.scss +++ b/library/src/skins/default/src/sass/print.scss @@ -60,15 +60,26 @@ aside.offcanvas, height: 32px; } -.#{$namespace}sakai-lessonbuildertool { +/* This is Lessons in print mode */ +div.portletBody { ul#toolbar, .lb-offscreen, .modal-dialog, a.ui-button, + .edit-col, + .sectionedit, + img.question-image, + .editsection, .showPollGraph { display: none !important; } + [role="listitem"] { + border-bottom: 2px solid black; + margin-bottom: 20px; + padding-bottom: 10px; + } + .oldPortal .portletTitle { padding-top: 30px !important }