Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dubbs/jquery-printevents
This plugin publishes jQuery events before and after print
https://github.com/dubbs/jquery-printevents
events javascript jquery jquery-plugin print publish-subscribe pubsub
Last synced: about 6 hours ago
JSON representation
This plugin publishes jQuery events before and after print
- Host: GitHub
- URL: https://github.com/dubbs/jquery-printevents
- Owner: dubbs
- License: mit
- Created: 2017-07-11T19:53:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-12T16:21:32.000Z (over 7 years ago)
- Last Synced: 2025-01-16T05:12:21.988Z (17 days ago)
- Topics: events, javascript, jquery, jquery-plugin, print, publish-subscribe, pubsub
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jQuery Print Events
This plugin publishes jQuery events before and after print. It normalizes [onbeforeprint](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeprint)/[onafterprint](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint) and [window.matchMedia](https://developer.mozilla.org/en/docs/Web/API/Window/matchMedia) using techniques described in this [article](https://www.tjvantoll.com/2012/06/15/detecting-print-requests-with-javascript/).
## Usage
Include dependencies:
```html```
Create subscribers for the published events:
```js
$(document).on('print:before', function () {
// run code before print
});$(document).on('print:after', function () {
// run code after print
});
```