Fix printing bug which caused unhandled exception in WAAHost

Former-commit-id: e5b1de0e3ce9767dce57fbe50ccc291eeab04309 [formerly 2ee69678462efc83cf2c8baf39915781b3f8500f]
Former-commit-id: 4f82cd78e1e4cca3586fd5c24be1e66a1ba51943
This commit is contained in:
Jaifroid 2018-04-03 17:36:56 +01:00
parent e4605d7dda
commit a6128f295b
2 changed files with 25 additions and 5 deletions

View File

@ -144,6 +144,21 @@
</div>
</div>
</div>
<div id="alertModal" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Alert!</h4>
</div>
<div class="modal-body">
<p id="alertContent"></p>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" data-dismiss="modal">Dismiss</button>
</div>
</div>
</div>
</div>
<section id="search-article" role="region">
<header id="top" style="width:100%;">
<nav id="navbar" class="navbar navbar-inverse" role="navigation">

View File

@ -162,6 +162,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
function printIntercept() {
document.getElementById('btnAbout').classList.add('active');
//Pre-load all images in case user wants to print them
if (params.imageDisplay) {
loadImages(10000);
@ -193,12 +194,17 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
return;
}
uiUtil.printCustomElements();
document.getElementById("alertContent").innerHTML = "Document will reload to restore the DOM after printing...";
$("#alertModal").modal({
backdrop: "static",
keyboard: true
});
//innerDocument.execCommand("print", false, null);
window.frames[0].frameElement.contentWindow.print();
setTimeout(function () {
//Reload article after print dialogue has rendered because DOM is destroyed
goToArticle(decodeURIComponent(history.state.title));
}, 3000);
});
$("#alertModal").off('hide.bs.modal');
$("#alertModal").on('hide.bs.modal', function () {
goToArticle(decodeURIComponent(history.state.title));
});
}
@ -542,7 +548,6 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
$('#btnAbout').on('click', function (e) {
var btnAboutElement = document.getElementById('btnAbout');
if (/glyphicon-print/.test(btnAboutElement.innerHTML)) {
btnAboutElement.classList.add('active');
printIntercept();
return;
}