UNPKG

38 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory();
4 else if(typeof define === 'function' && define.amd)
5 define([], factory);
6 else if(typeof exports === 'object')
7 exports["printJS"] = factory();
8 else
9 root["printJS"] = factory();
10})(window, function() {
11return /******/ (function(modules) { // webpackBootstrap
12/******/ // The module cache
13/******/ var installedModules = {};
14/******/
15/******/ // The require function
16/******/ function __webpack_require__(moduleId) {
17/******/
18/******/ // Check if module is in cache
19/******/ if(installedModules[moduleId]) {
20/******/ return installedModules[moduleId].exports;
21/******/ }
22/******/ // Create a new module (and put it into the cache)
23/******/ var module = installedModules[moduleId] = {
24/******/ i: moduleId,
25/******/ l: false,
26/******/ exports: {}
27/******/ };
28/******/
29/******/ // Execute the module function
30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31/******/
32/******/ // Flag the module as loaded
33/******/ module.l = true;
34/******/
35/******/ // Return the exports of the module
36/******/ return module.exports;
37/******/ }
38/******/
39/******/
40/******/ // expose the modules object (__webpack_modules__)
41/******/ __webpack_require__.m = modules;
42/******/
43/******/ // expose the module cache
44/******/ __webpack_require__.c = installedModules;
45/******/
46/******/ // define getter function for harmony exports
47/******/ __webpack_require__.d = function(exports, name, getter) {
48/******/ if(!__webpack_require__.o(exports, name)) {
49/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50/******/ }
51/******/ };
52/******/
53/******/ // define __esModule on exports
54/******/ __webpack_require__.r = function(exports) {
55/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57/******/ }
58/******/ Object.defineProperty(exports, '__esModule', { value: true });
59/******/ };
60/******/
61/******/ // create a fake namespace object
62/******/ // mode & 1: value is a module id, require it
63/******/ // mode & 2: merge all properties of value into the ns
64/******/ // mode & 4: return value when already ns object
65/******/ // mode & 8|1: behave like require
66/******/ __webpack_require__.t = function(value, mode) {
67/******/ if(mode & 1) value = __webpack_require__(value);
68/******/ if(mode & 8) return value;
69/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70/******/ var ns = Object.create(null);
71/******/ __webpack_require__.r(ns);
72/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74/******/ return ns;
75/******/ };
76/******/
77/******/ // getDefaultExport function for compatibility with non-harmony modules
78/******/ __webpack_require__.n = function(module) {
79/******/ var getter = module && module.__esModule ?
80/******/ function getDefault() { return module['default']; } :
81/******/ function getModuleExports() { return module; };
82/******/ __webpack_require__.d(getter, 'a', getter);
83/******/ return getter;
84/******/ };
85/******/
86/******/ // Object.prototype.hasOwnProperty.call
87/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88/******/
89/******/ // __webpack_public_path__
90/******/ __webpack_require__.p = "";
91/******/
92/******/
93/******/ // Load entry module and return exports
94/******/ return __webpack_require__(__webpack_require__.s = 0);
95/******/ })
96/************************************************************************/
97/******/ ({
98
99/***/ "./src/index.js":
100/*!**********************!*\
101 !*** ./src/index.js ***!
102 \**********************/
103/*! no static exports found */
104/***/ (function(module, exports, __webpack_require__) {
105
106"use strict";
107eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\n__webpack_require__(/*! ./sass/index.scss */ \"./src/sass/index.scss\");\n\nvar _init = __webpack_require__(/*! ./js/init */ \"./src/js/init.js\");\n\nvar _init2 = _interopRequireDefault(_init);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar printJS = _init2.default.init;\n\nif (typeof window !== 'undefined') {\n window.printJS = printJS;\n}\n\nexports.default = printJS;\n\n//# sourceURL=webpack://printJS/./src/index.js?");
108
109/***/ }),
110
111/***/ "./src/js/browser.js":
112/*!***************************!*\
113 !*** ./src/js/browser.js ***!
114 \***************************/
115/*! no static exports found */
116/***/ (function(module, exports, __webpack_require__) {
117
118"use strict";
119eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nvar Browser = {\n // Firefox 1.0+\n isFirefox: function isFirefox() {\n return typeof InstallTrigger !== 'undefined';\n },\n // Internet Explorer 6-11\n isIE: function isIE() {\n return navigator.userAgent.indexOf('MSIE') !== -1 || !!document.documentMode;\n },\n // Edge 20+\n isEdge: function isEdge() {\n return !Browser.isIE() && !!window.StyleMedia;\n },\n // Chrome 1+\n isChrome: function isChrome() {\n var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;\n\n return !!context.chrome;\n },\n // At least Safari 3+: \"[object HTMLElementConstructor]\"\n isSafari: function isSafari() {\n return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || navigator.userAgent.toLowerCase().indexOf('safari') !== -1;\n },\n // IOS Chrome\n isIOSChrome: function isIOSChrome() {\n return navigator.userAgent.toLowerCase().indexOf('crios') !== -1;\n }\n};\n\nexports.default = Browser;\n\n//# sourceURL=webpack://printJS/./src/js/browser.js?");
120
121/***/ }),
122
123/***/ "./src/js/functions.js":
124/*!*****************************!*\
125 !*** ./src/js/functions.js ***!
126 \*****************************/
127/*! no static exports found */
128/***/ (function(module, exports, __webpack_require__) {
129
130"use strict";
131eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nexports.addWrapper = addWrapper;\nexports.capitalizePrint = capitalizePrint;\nexports.collectStyles = collectStyles;\nexports.addHeader = addHeader;\nexports.cleanUp = cleanUp;\nexports.isRawHTML = isRawHTML;\n\nvar _modal = __webpack_require__(/*! ./modal */ \"./src/js/modal.js\");\n\nvar _modal2 = _interopRequireDefault(_modal);\n\nvar _browser = __webpack_require__(/*! ./browser */ \"./src/js/browser.js\");\n\nvar _browser2 = _interopRequireDefault(_browser);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction addWrapper(htmlData, params) {\n var bodyStyle = 'font-family:' + params.font + ' !important; font-size: ' + params.font_size + ' !important; width:100%;';\n return '<div style=\"' + bodyStyle + '\">' + htmlData + '</div>';\n}\n\nfunction capitalizePrint(obj) {\n return obj.charAt(0).toUpperCase() + obj.slice(1);\n}\n\nfunction collectStyles(element, params) {\n var win = document.defaultView || window;\n\n // String variable to hold styling for each element\n var elementStyle = '';\n\n // Loop over computed styles\n var styles = win.getComputedStyle(element, '');\n\n Object.keys(styles).map(function (key) {\n // Check if style should be processed\n if (params.targetStyles.indexOf('*') !== -1 || params.targetStyle.indexOf(styles[key]) !== -1 || targetStylesMatch(params.targetStyles, styles[key])) {\n if (styles.getPropertyValue(styles[key])) elementStyle += styles[key] + ':' + styles.getPropertyValue(styles[key]) + ';';\n }\n });\n\n // Print friendly defaults (deprecated)\n elementStyle += 'max-width: ' + params.maxWidth + 'px !important;' + params.font_size + ' !important;';\n\n return elementStyle;\n}\n\nfunction targetStylesMatch(styles, value) {\n for (var i = 0; i < styles.length; i++) {\n if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.indexOf(styles[i]) !== -1) return true;\n }\n return false;\n}\n\nfunction addHeader(printElement, params) {\n // Create the header container div\n var headerContainer = document.createElement('div');\n\n // Check if the header is text or raw html\n if (isRawHTML(params.header)) {\n headerContainer.innerHTML = params.header;\n } else {\n // Create header element\n var headerElement = document.createElement('h1');\n\n // Create header text node\n var headerNode = document.createTextNode(params.header);\n\n // Build and style\n headerElement.appendChild(headerNode);\n headerElement.setAttribute('style', params.headerStyle);\n headerContainer.appendChild(headerElement);\n }\n\n printElement.insertBefore(headerContainer, printElement.childNodes[0]);\n}\n\nfunction cleanUp(params) {\n // If we are showing a feedback message to user, remove it\n if (params.showModal) _modal2.default.close();\n\n // Check for a finished loading hook function\n if (params.onLoadingEnd) params.onLoadingEnd();\n\n // If preloading pdf files, clean blob url\n if (params.showModal || params.onLoadingStart) window.URL.revokeObjectURL(params.printable);\n\n // If a onPrintDialogClose callback is given, execute it\n if (params.onPrintDialogClose) {\n var event = 'mouseover';\n\n if (_browser2.default.isChrome() || _browser2.default.isFirefox()) {\n // Ps.: Firefox will require an extra click in the document to fire the focus event.\n event = 'focus';\n }\n var handler = function handler() {\n // Make sure the event only happens once.\n window.removeEventListener(event, handler);\n\n params.onPrintDialogClose();\n };\n\n window.addEventListener(event, handler);\n }\n}\n\nfunction isRawHTML(raw) {\n var regexHtml = new RegExp('<([A-Za-z][A-Za-z0-9]*)\\\\b[^>]*>(.*?)</\\\\1>');\n return regexHtml.test(raw);\n}\n\n//# sourceURL=webpack://printJS/./src/js/functions.js?");
132
133/***/ }),
134
135/***/ "./src/js/html.js":
136/*!************************!*\
137 !*** ./src/js/html.js ***!
138 \************************/
139/*! no static exports found */
140/***/ (function(module, exports, __webpack_require__) {
141
142"use strict";
143eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _functions = __webpack_require__(/*! ./functions */ \"./src/js/functions.js\");\n\nvar _print = __webpack_require__(/*! ./print */ \"./src/js/print.js\");\n\nvar _print2 = _interopRequireDefault(_print);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = {\n print: function print(params, printFrame) {\n // Get the DOM printable element\n var printElement = document.getElementById(params.printable);\n\n // Check if the element exists\n if (!printElement) {\n window.console.error('Invalid HTML element id: ' + params.printable);\n return;\n }\n\n // Clone the target element including its children (if available)\n params.printableElement = cloneElement(printElement, params);\n\n // Add header\n if (params.header) {\n (0, _functions.addHeader)(params.printableElement, params);\n }\n\n // Print html element contents\n _print2.default.send(params, printFrame);\n }\n};\n\n\nfunction cloneElement(element, params) {\n // Clone the main node (if not already inside the recursion process)\n var clone = element.cloneNode();\n\n // Loop over and process the children elements / nodes (including text nodes)\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = element.childNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var child = _step.value;\n\n // Check if we are skiping the current element\n if (params.ignoreElements.indexOf(child.id) !== -1) {\n continue;\n }\n\n // Clone the child element\n var clonedChild = cloneElement(child, params);\n\n // Attach the cloned child to the cloned parent node\n clone.appendChild(clonedChild);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n console.log(element.nodeType);\n // Get all styling for print element (for nodes of type element only)\n if (params.scanStyles && element.nodeType === 1) {\n clone.setAttribute('style', (0, _functions.collectStyles)(element, params));\n }\n\n // Check if the element needs any state processing (copy user input data)\n switch (element.tagName) {\n case 'SELECT':\n // Copy the current selection value to its clone\n clone.value = element.value;\n break;\n case 'CANVAS':\n // Copy the canvas content to its clone\n clone.getContext('2d').drawImage(element, 0, 0);\n break;\n }\n\n return clone;\n}\n\n//# sourceURL=webpack://printJS/./src/js/html.js?");
144
145/***/ }),
146
147/***/ "./src/js/image.js":
148/*!*************************!*\
149 !*** ./src/js/image.js ***!
150 \*************************/
151/*! no static exports found */
152/***/ (function(module, exports, __webpack_require__) {
153
154"use strict";
155eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _functions = __webpack_require__(/*! ./functions */ \"./src/js/functions.js\");\n\nvar _print = __webpack_require__(/*! ./print */ \"./src/js/print.js\");\n\nvar _print2 = _interopRequireDefault(_print);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = {\n print: function print(params, printFrame) {\n // Check if we are printing one image or multiple images\n if (params.printable.constructor !== Array) {\n // Create array with one image\n params.printable = [params.printable];\n }\n\n // Create printable element (container)\n params.printableElement = document.createElement('div');\n\n // Create all image elements and append them to the printable container\n params.printable.forEach(function (src) {\n // Create the image element\n var img = document.createElement('img');\n img.setAttribute('style', params.imageStyle);\n\n // Set image src with the file url\n img.src = src;\n\n // Create the image wrapper\n var imageWrapper = document.createElement('div');\n\n // Append image to the wrapper element\n imageWrapper.appendChild(img);\n\n // Append wrapper to the printable element\n params.printableElement.appendChild(imageWrapper);\n });\n\n // Check if we are adding a print header\n if (params.header) (0, _functions.addHeader)(params.printableElement, params);\n\n // Print image\n _print2.default.send(params, printFrame);\n }\n};\n\n//# sourceURL=webpack://printJS/./src/js/image.js?");
156
157/***/ }),
158
159/***/ "./src/js/init.js":
160/*!************************!*\
161 !*** ./src/js/init.js ***!
162 \************************/
163/*! no static exports found */
164/***/ (function(module, exports, __webpack_require__) {
165
166"use strict";
167eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _browser = __webpack_require__(/*! ./browser */ \"./src/js/browser.js\");\n\nvar _browser2 = _interopRequireDefault(_browser);\n\nvar _modal = __webpack_require__(/*! ./modal */ \"./src/js/modal.js\");\n\nvar _modal2 = _interopRequireDefault(_modal);\n\nvar _pdf = __webpack_require__(/*! ./pdf */ \"./src/js/pdf.js\");\n\nvar _pdf2 = _interopRequireDefault(_pdf);\n\nvar _html = __webpack_require__(/*! ./html */ \"./src/js/html.js\");\n\nvar _html2 = _interopRequireDefault(_html);\n\nvar _rawHtml = __webpack_require__(/*! ./raw-html */ \"./src/js/raw-html.js\");\n\nvar _rawHtml2 = _interopRequireDefault(_rawHtml);\n\nvar _image = __webpack_require__(/*! ./image */ \"./src/js/image.js\");\n\nvar _image2 = _interopRequireDefault(_image);\n\nvar _json = __webpack_require__(/*! ./json */ \"./src/js/json.js\");\n\nvar _json2 = _interopRequireDefault(_json);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar printTypes = ['pdf', 'html', 'image', 'json', 'raw-html'];\n\nexports.default = {\n init: function init() {\n var params = {\n printable: null,\n fallbackPrintable: null,\n type: 'pdf',\n header: null,\n headerStyle: 'font-weight: 300;',\n maxWidth: 800,\n font: 'TimesNewRoman',\n font_size: '12pt',\n honorMarginPadding: true,\n honorColor: false,\n properties: null,\n gridHeaderStyle: 'font-weight: bold; padding: 5px; border: 1px solid #dddddd;',\n gridStyle: 'border: 1px solid lightgray; margin-bottom: -1px;',\n showModal: false,\n onError: function onError(error) {\n throw error;\n },\n onLoadingStart: null,\n onLoadingEnd: null,\n onPrintDialogClose: null,\n onPdfOpen: null,\n onBrowserIncompatible: function onBrowserIncompatible() {\n return true;\n },\n modalMessage: 'Retrieving Document...',\n frameId: 'printJS',\n printableElement: null,\n documentTitle: 'Document',\n targetStyle: ['clear', 'display', 'width', 'min-width', 'height', 'min-height', 'max-height'],\n targetStyles: ['border', 'box', 'break', 'text-decoration'],\n ignoreElements: [],\n imageStyle: 'max-width: 100%;',\n repeatTableHeader: true,\n css: null,\n style: null,\n scanStyles: true,\n base64: false\n\n // Check if a printable document or object was supplied\n };var args = arguments[0];\n if (args === undefined) throw new Error('printJS expects at least 1 attribute.');\n\n // Process parameters\n switch (typeof args === 'undefined' ? 'undefined' : _typeof(args)) {\n case 'string':\n params.printable = encodeURI(args);\n params.fallbackPrintable = params.printable;\n params.type = arguments[1] || params.type;\n break;\n case 'object':\n params.printable = args.printable;\n params.base64 = typeof args.base64 !== 'undefined';\n params.fallbackPrintable = typeof args.fallbackPrintable !== 'undefined' ? args.fallbackPrintable : params.printable;\n params.fallbackPrintable = params.base64 ? 'data:application/pdf;base64,' + params.fallbackPrintable : params.fallbackPrintable;\n for (var k in params) {\n if (k === 'printable' || k === 'fallbackPrintable' || k === 'base64') continue;\n\n params[k] = typeof args[k] !== 'undefined' ? args[k] : params[k];\n }\n break;\n default:\n throw new Error('Unexpected argument type! Expected \"string\" or \"object\", got ' + (typeof args === 'undefined' ? 'undefined' : _typeof(args)));\n }\n\n // Validate printable\n if (!params.printable) throw new Error('Missing printable information.');\n\n // Validate type\n if (!params.type || typeof params.type !== 'string' || printTypes.indexOf(params.type.toLowerCase()) === -1) {\n throw new Error('Invalid print type. Available types are: pdf, html, image and json.');\n }\n\n // Check if we are showing a feedback message to the user (useful for large files)\n if (params.showModal) _modal2.default.show(params);\n\n // Check for a print start hook function\n if (params.onLoadingStart) params.onLoadingStart();\n\n // To prevent duplication and issues, remove any used printFrame from the DOM\n var usedFrame = document.getElementById(params.frameId);\n\n if (usedFrame) usedFrame.parentNode.removeChild(usedFrame);\n\n // Create a new iframe or embed element (IE prints blank pdf's if we use iframe)\n var printFrame = void 0;\n\n // Create iframe element\n printFrame = document.createElement('iframe');\n\n // Hide iframe\n printFrame.setAttribute('style', 'visibility: hidden; height: 0; width: 0; position: absolute;');\n\n // Set iframe element id\n printFrame.setAttribute('id', params.frameId);\n\n // For non pdf printing, pass an html document string to srcdoc (force onload callback)\n if (params.type !== 'pdf') {\n printFrame.srcdoc = '<html><head><title>' + params.documentTitle + '</title>';\n\n // Attach css files\n if (params.css) {\n // Add support for single file\n if (!Array.isArray(params.css)) params.css = [params.css];\n\n // Create link tags for each css file\n params.css.forEach(function (file) {\n printFrame.srcdoc += '<link rel=\"stylesheet\" href=\"' + file + '\">';\n });\n }\n\n printFrame.srcdoc += '</head><body></body></html>';\n }\n\n // Check printable type\n switch (params.type) {\n case 'pdf':\n // Check browser support for pdf and if not supported we will just open the pdf file instead\n if (_browser2.default.isFirefox() || _browser2.default.isEdge() || _browser2.default.isIE()) {\n try {\n console.info('PrintJS currently doesn\\'t support PDF printing in Firefox, Internet Explorer and Edge.');\n if (params.onBrowserIncompatible() === true) {\n var win = window.open(params.fallbackPrintable, '_blank');\n win.focus();\n if (params.onPdfOpen) params.onPdfOpen();\n }\n } catch (e) {\n params.onError(e);\n } finally {\n // Make sure there is no loading modal opened\n if (params.showModal) _modal2.default.close();\n if (params.onLoadingEnd) params.onLoadingEnd();\n }\n } else {\n _pdf2.default.print(params, printFrame);\n }\n break;\n case 'image':\n _image2.default.print(params, printFrame);\n break;\n case 'html':\n _html2.default.print(params, printFrame);\n break;\n case 'raw-html':\n _rawHtml2.default.print(params, printFrame);\n break;\n case 'json':\n _json2.default.print(params, printFrame);\n break;\n }\n }\n};\n\n//# sourceURL=webpack://printJS/./src/js/init.js?");
168
169/***/ }),
170
171/***/ "./src/js/json.js":
172/*!************************!*\
173 !*** ./src/js/json.js ***!
174 \************************/
175/*! no static exports found */
176/***/ (function(module, exports, __webpack_require__) {
177
178"use strict";
179eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _functions = __webpack_require__(/*! ./functions */ \"./src/js/functions.js\");\n\nvar _print = __webpack_require__(/*! ./print */ \"./src/js/print.js\");\n\nvar _print2 = _interopRequireDefault(_print);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = {\n print: function print(params, printFrame) {\n // Check if we received proper data\n if (_typeof(params.printable) !== 'object') {\n throw new Error('Invalid javascript data object (JSON).');\n }\n\n // Validate repeatTableHeader\n if (typeof params.repeatTableHeader !== 'boolean') {\n throw new Error('Invalid value for repeatTableHeader attribute (JSON).');\n }\n\n // Validate properties\n if (!params.properties || !Array.isArray(params.properties)) {\n throw new Error('Invalid properties array for your JSON data.');\n }\n\n // We will format the property objects to keep the JSON api compatible with older releases\n params.properties = params.properties.map(function (property) {\n return {\n field: (typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'object' ? property.field : property,\n displayName: (typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'object' ? property.displayName : property,\n columnSize: (typeof property === 'undefined' ? 'undefined' : _typeof(property)) === 'object' && property.columnSize ? property.columnSize + ';' : 100 / params.properties.length + '%;'\n };\n });\n\n // Create a print container element\n params.printableElement = document.createElement('div');\n\n // Check if we are adding a print header\n if (params.header) {\n (0, _functions.addHeader)(params.printableElement, params);\n }\n\n // Build the printable html data\n params.printableElement.innerHTML += jsonToHTML(params);\n\n // Print the json data\n _print2.default.send(params, printFrame);\n }\n};\n\n\nfunction jsonToHTML(params) {\n // Get the row and column data\n var data = params.printable;\n var properties = params.properties;\n\n // Create a html table\n var htmlData = '<table style=\"border-collapse: collapse; width: 100%;\">';\n\n // Check if the header should be repeated\n if (params.repeatTableHeader) {\n htmlData += '<thead>';\n }\n\n // Add the table header row\n htmlData += '<tr>';\n\n // Add the table header columns\n for (var a = 0; a < properties.length; a++) {\n htmlData += '<th style=\"width:' + properties[a].columnSize + ';' + params.gridHeaderStyle + '\">' + (0, _functions.capitalizePrint)(properties[a].displayName) + '</th>';\n }\n\n // Add the closing tag for the table header row\n htmlData += '</tr>';\n\n // If the table header is marked as repeated, add the closing tag\n if (params.repeatTableHeader) {\n htmlData += '</thead>';\n }\n\n // Create the table body\n htmlData += '<tbody>';\n\n // Add the table data rows\n for (var i = 0; i < data.length; i++) {\n // Add the row starting tag\n htmlData += '<tr>';\n\n // Print selected properties only\n for (var n = 0; n < properties.length; n++) {\n var stringData = data[i];\n\n // Support nested objects\n var property = properties[n].field.split('.');\n if (property.length > 1) {\n for (var p = 0; p < property.length; p++) {\n stringData = stringData[property[p]];\n }\n } else {\n stringData = stringData[properties[n].field];\n }\n\n // Add the row contents and styles\n htmlData += '<td style=\"width:' + properties[n].columnSize + params.gridStyle + '\">' + stringData + '</td>';\n }\n\n // Add the row closing tag\n htmlData += '</tr>';\n }\n\n // Add the table and body closing tags\n htmlData += '</tbody></table>';\n\n return htmlData;\n}\n\n//# sourceURL=webpack://printJS/./src/js/json.js?");
180
181/***/ }),
182
183/***/ "./src/js/modal.js":
184/*!*************************!*\
185 !*** ./src/js/modal.js ***!
186 \*************************/
187/*! no static exports found */
188/***/ (function(module, exports, __webpack_require__) {
189
190"use strict";
191eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nvar Modal = {\n show: function show(params) {\n // Build modal\n var modalStyle = 'font-family:sans-serif; ' + 'display:table; ' + 'text-align:center; ' + 'font-weight:300; ' + 'font-size:30px; ' + 'left:0; top:0;' + 'position:fixed; ' + 'z-index: 9990;' + 'color: #0460B5; ' + 'width: 100%; ' + 'height: 100%; ' + 'background-color:rgba(255,255,255,.9);' + 'transition: opacity .3s ease;';\n\n // Create wrapper\n var printModal = document.createElement('div');\n printModal.setAttribute('style', modalStyle);\n printModal.setAttribute('id', 'printJS-Modal');\n\n // Create content div\n var contentDiv = document.createElement('div');\n contentDiv.setAttribute('style', 'display:table-cell; vertical-align:middle; padding-bottom:100px;');\n\n // Add close button (requires print.css)\n var closeButton = document.createElement('div');\n closeButton.setAttribute('class', 'printClose');\n closeButton.setAttribute('id', 'printClose');\n contentDiv.appendChild(closeButton);\n\n // Add spinner (requires print.css)\n var spinner = document.createElement('span');\n spinner.setAttribute('class', 'printSpinner');\n contentDiv.appendChild(spinner);\n\n // Add message\n var messageNode = document.createTextNode(params.modalMessage);\n contentDiv.appendChild(messageNode);\n\n // Add contentDiv to printModal\n printModal.appendChild(contentDiv);\n\n // Append print modal element to document body\n document.getElementsByTagName('body')[0].appendChild(printModal);\n\n // Add event listener to close button\n document.getElementById('printClose').addEventListener('click', function () {\n Modal.close();\n });\n },\n close: function close() {\n var printFrame = document.getElementById('printJS-Modal');\n\n printFrame.parentNode.removeChild(printFrame);\n }\n};\n\nexports.default = Modal;\n\n//# sourceURL=webpack://printJS/./src/js/modal.js?");
192
193/***/ }),
194
195/***/ "./src/js/pdf.js":
196/*!***********************!*\
197 !*** ./src/js/pdf.js ***!
198 \***********************/
199/*! no static exports found */
200/***/ (function(module, exports, __webpack_require__) {
201
202"use strict";
203eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _print = __webpack_require__(/*! ./print */ \"./src/js/print.js\");\n\nvar _print2 = _interopRequireDefault(_print);\n\nvar _functions = __webpack_require__(/*! ./functions */ \"./src/js/functions.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = {\n print: function print(params, printFrame) {\n // Check if we have base64 data\n if (params.base64) {\n var bytesArray = Uint8Array.from(atob(params.printable), function (c) {\n return c.charCodeAt(0);\n });\n createBlobAndPrint(params, printFrame, bytesArray);\n return;\n }\n\n // Format pdf url\n params.printable = /^(blob|http)/i.test(params.printable) ? params.printable : window.location.origin + (params.printable.charAt(0) !== '/' ? '/' + params.printable : params.printable);\n\n // Get the file through a http request (Preload)\n var req = new window.XMLHttpRequest();\n req.responseType = 'arraybuffer';\n\n req.addEventListener('load', function () {\n // Check for errors\n if ([200, 201].indexOf(req.status) === -1) {\n (0, _functions.cleanUp)(params);\n params.onError(req.statusText);\n\n // Since we don't have a pdf document available, we will stop the print job\n return;\n }\n\n // Print requested document\n createBlobAndPrint(params, printFrame, req.response);\n });\n\n req.open('GET', params.printable, true);\n req.send();\n }\n};\n\n\nfunction createBlobAndPrint(params, printFrame, data) {\n // Pass response or base64 data to a blob and create a local object url\n var localPdf = new window.Blob([data], { type: 'application/pdf' });\n localPdf = window.URL.createObjectURL(localPdf);\n\n // Set iframe src with pdf document url\n printFrame.setAttribute('src', localPdf);\n\n _print2.default.send(params, printFrame);\n}\n\n//# sourceURL=webpack://printJS/./src/js/pdf.js?");
204
205/***/ }),
206
207/***/ "./src/js/print.js":
208/*!*************************!*\
209 !*** ./src/js/print.js ***!
210 \*************************/
211/*! no static exports found */
212/***/ (function(module, exports, __webpack_require__) {
213
214"use strict";
215eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _browser = __webpack_require__(/*! ./browser */ \"./src/js/browser.js\");\n\nvar _browser2 = _interopRequireDefault(_browser);\n\nvar _functions = __webpack_require__(/*! ./functions */ \"./src/js/functions.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar Print = {\n send: function send(params, printFrame) {\n // Append iframe element to document body\n document.getElementsByTagName('body')[0].appendChild(printFrame);\n\n // Get iframe element\n var iframeElement = document.getElementById(params.frameId);\n\n // Wait for iframe to load all content\n iframeElement.onload = function () {\n if (params.type === 'pdf') {\n performPrint(iframeElement, params);\n return;\n }\n\n // Get iframe element document\n var printDocument = iframeElement.contentWindow || iframeElement.contentDocument;\n if (printDocument.document) printDocument = printDocument.document;\n\n // Append printable element to the iframe body\n printDocument.body.appendChild(params.printableElement);\n\n // Add custom style\n if (params.type !== 'pdf' && params.style) {\n // Create style element\n var style = document.createElement('style');\n style.innerHTML = params.style;\n\n // Append style element to iframe's head\n printDocument.head.appendChild(style);\n }\n\n // If printing images, wait for them to load inside the iframe\n var images = printDocument.getElementsByTagName('img');\n\n if (images.length > 0) {\n loadIframeImages(images).then(function () {\n return performPrint(iframeElement, params);\n });\n } else {\n performPrint(iframeElement, params);\n }\n };\n }\n};\n\nfunction performPrint(iframeElement, params) {\n try {\n iframeElement.focus();\n\n // If Edge or IE, try catch with execCommand\n if (_browser2.default.isEdge() || _browser2.default.isIE()) {\n try {\n iframeElement.contentWindow.document.execCommand('print', false, null);\n } catch (e) {\n iframeElement.contentWindow.print();\n }\n } else {\n // Other browsers\n iframeElement.contentWindow.print();\n }\n } catch (error) {\n params.onError(error);\n } finally {\n (0, _functions.cleanUp)(params);\n }\n}\n\nfunction loadIframeImages(images) {\n var promises = [];\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = images[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var image = _step.value;\n\n promises.push(loadIframeImage(image));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return Promise.all(promises);\n}\n\nfunction loadIframeImage(image) {\n return new Promise(function (resolve) {\n var pollImage = function pollImage() {\n !image || typeof image.naturalWidth === 'undefined' || image.naturalWidth === 0 || !image.complete ? setTimeout(pollImage, 500) : resolve();\n };\n pollImage();\n });\n}\n\nexports.default = Print;\n\n//# sourceURL=webpack://printJS/./src/js/print.js?");
216
217/***/ }),
218
219/***/ "./src/js/raw-html.js":
220/*!****************************!*\
221 !*** ./src/js/raw-html.js ***!
222 \****************************/
223/*! no static exports found */
224/***/ (function(module, exports, __webpack_require__) {
225
226"use strict";
227eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _print = __webpack_require__(/*! ./print */ \"./src/js/print.js\");\n\nvar _print2 = _interopRequireDefault(_print);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = {\n print: function print(params, printFrame) {\n // Create printable element (container)\n params.printableElement = document.createElement('div');\n params.printableElement.setAttribute('style', 'width:100%');\n\n // Set our raw html as the printable element inner html content\n params.printableElement.innerHTML = params.printable;\n\n // Print html contents\n _print2.default.send(params, printFrame);\n }\n};\n\n//# sourceURL=webpack://printJS/./src/js/raw-html.js?");
228
229/***/ }),
230
231/***/ "./src/sass/index.scss":
232/*!*****************************!*\
233 !*** ./src/sass/index.scss ***!
234 \*****************************/
235/*! no static exports found */
236/***/ (function(module, exports, __webpack_require__) {
237
238eval("// extracted by mini-css-extract-plugin\n\n//# sourceURL=webpack://printJS/./src/sass/index.scss?");
239
240/***/ }),
241
242/***/ 0:
243/*!****************************!*\
244 !*** multi ./src/index.js ***!
245 \****************************/
246/*! no static exports found */
247/***/ (function(module, exports, __webpack_require__) {
248
249eval("module.exports = __webpack_require__(/*! ./src/index.js */\"./src/index.js\");\n\n\n//# sourceURL=webpack://printJS/multi_./src/index.js?");
250
251/***/ })
252
253/******/ })["default"];
254});
\No newline at end of file