@shopify/app-bridge
Version:
**Shopify is doubling our engineering staff in 2021! [Join our team and work on libraries like this one.](https://smrtr.io/5GGrc)**
42 lines (41 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleAppPrint = void 0;
var redirect_1 = require("./redirect");
function isRunningOniOS() {
return navigator.userAgent.indexOf('iOS') >= 0;
}
function createHiddenInput() {
var currentWindow = redirect_1.getWindow();
if (!currentWindow || !currentWindow.document || !currentWindow.document.body) {
return;
}
var inputElement = window.document.createElement('input');
inputElement.style.display = 'none';
window.document.body.appendChild(inputElement);
return inputElement;
}
function printWindow() {
if (!redirect_1.getWindow()) {
return;
}
window.print();
}
function handleMobileAppPrint() {
var input = createHiddenInput();
if (!input) {
return;
}
input.select();
printWindow();
input.remove();
}
function handleAppPrint() {
if (isRunningOniOS()) {
handleMobileAppPrint();
}
else {
printWindow();
}
}
exports.handleAppPrint = handleAppPrint;