1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var redirect_1 = require("./redirect");
|
4 | function isRunningOniOS() {
|
5 | return navigator.userAgent.indexOf('iOS') >= 0;
|
6 | }
|
7 | function createHiddenInput() {
|
8 | var currentWindow = redirect_1.getWindow();
|
9 | if (!currentWindow || !currentWindow.document || !currentWindow.document.body) {
|
10 | return;
|
11 | }
|
12 | var inputElement = window.document.createElement('input');
|
13 | inputElement.style.display = 'none';
|
14 | window.document.body.appendChild(inputElement);
|
15 | return inputElement;
|
16 | }
|
17 | function printWindow() {
|
18 | if (!redirect_1.getWindow()) {
|
19 | return;
|
20 | }
|
21 |
|
22 | window.print();
|
23 | }
|
24 | function handleMobileAppPrint() {
|
25 | var input = createHiddenInput();
|
26 | if (!input) {
|
27 | return;
|
28 | }
|
29 | input.select();
|
30 | printWindow();
|
31 | input.remove();
|
32 | }
|
33 | function handleAppPrint() {
|
34 | if (isRunningOniOS()) {
|
35 | handleMobileAppPrint();
|
36 | }
|
37 | else {
|
38 | printWindow();
|
39 | }
|
40 | }
|
41 | exports.handleAppPrint = handleAppPrint;
|