1
0
mirror of synced 2025-12-21 02:46:50 -05:00
Files
docs/javascripts/print.js
Vanessa Yuen 3df90fc9b8 Hello git history spelunker!
Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2020-09-27 14:10:11 +02:00

21 lines
533 B
JavaScript

export default function () {
const printButton = document.querySelector('.js-print')
if (printButton) {
// Open the print dialog when the button is clicked
printButton.addEventListener('click', () => {
window.print()
})
}
// Track print events
window.onbeforeprint = function () {
// Ensure that Google Analytics was registered
if (!window.ga) return
const category = 'Print'
const action = 'print'
const label = 'print'
window.ga('send', 'event', category, action, label)
}
}