* Add link * Allow multiple print buttons * Fix scrolling for tall sidebar Co-authored-by: Chiedo John <2156688+chiedo@users.noreply.github.com>
18 lines
408 B
JavaScript
18 lines
408 B
JavaScript
import { sendEvent } from './events'
|
|
|
|
export default function () {
|
|
const printButtons = document.querySelectorAll('.js-print')
|
|
|
|
Array.from(printButtons).forEach(btn => {
|
|
// Open the print dialog when the button is clicked
|
|
btn.addEventListener('click', () => {
|
|
window.print()
|
|
})
|
|
})
|
|
|
|
// Track print events
|
|
window.onbeforeprint = function () {
|
|
sendEvent({ type: 'print' })
|
|
}
|
|
}
|