1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-09-24 11:28:23 +02:00

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

@ -190,7 +190,7 @@
{% endblock %}
</div>
{% block scripts %}
<script src="{{ 'assets/javascripts/application.a8c1b0c3.js' | url }}"></script>
<script src="{{ 'assets/javascripts/application.efe184c7.js' | url }}"></script>
{% if lang.t("search.language") != "en" %}
{% set languages = lang.t("search.language").split(",") %}
{% if languages | length and languages[0] != "" %}

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
}
/* ----------------------------------------------------------------------------