Added support for automatic expansion of details when printing

This commit is contained in:
squidfunk
2019-02-13 17:22:27 +01:00
parent 9f4e4c8884
commit 71fc5d1d37
3 changed files with 17 additions and 3 deletions

View File

@@ -498,6 +498,20 @@ function initialize(config) { // eslint-disable-line func-style
.initialize(facts)
})
})
/* Before-print hook */
const print = () => {
const details = document.querySelectorAll("details")
Array.prototype.forEach.call(details, detail => {
detail.setAttribute("open", "")
})
}
/* Open details before printing */
new Material.Event.MatchMedia("print", {
listen: print, unlisten: () => {}
}) // Webkit
window.onbeforeprint = print // IE, FF
}
/* ----------------------------------------------------------------------------