diff --git a/dist/print.min.css.map b/dist/print.min.css.map index 7951766..b59f706 100644 --- a/dist/print.min.css.map +++ b/dist/print.min.css.map @@ -1 +1 @@ -{"version":3,"sources":["print.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"print.min.css","sourcesContent":["/*\n * Print.js\n * http://printjs.crabbly.com\n * Version: 1.0.10\n *\n * Copyright 2016 Rodrigo Vieira (@crabbly)\n * Released under the MIT license\n * https://github.com/crabbly/Print.js/blob/master/LICENSE\n */\n\n/* === Print Modal === */\n\n.printModal {\n font-family:sans-serif;\n display:flex;\n text-align:center;\n font-weight:300;\n font-size:30px;\n left:0;\n top:0;\n position:absolute;\n color: #0460B5;\n width: 100%;\n height: 100%;\n background-color:rgba(255, 255, 255, 0.91);\n}\n\n/* === Print Modal Close Button === */\n.printClose {\n position:absolute;\n right:10px;\n top:10px;'\n}\n\n.printClose:before {\n content: \"\\00D7\";\n font-family: \"Helvetica Neue\", sans-serif;\n font-weight: 100;\n line-height: 1px;\n padding-top: 0.5em;\n display: block;\n font-size: 2em;\n text-indent: 1px;\n overflow: hidden;\n height: 1.25em;\n width: 1.25em;\n text-align: center;\n cursor: pointer;\n}\n\n/* === Print Modal Spinner */\n.printSpinner {\n margin-top: 3px;\n margin-left: -40px;\n position: absolute;\n display: inline-block;\n width: 25px;\n height: 25px;\n border: 2px solid #0460B5;\n border-radius: 50%;\n animation: spin 0.75s infinite linear;\n}\n.printSpinner::before, .printSpinner::after {\n left: -2px;\n top: -2px;\n display: none;\n position: absolute;\n content: '';\n width: inherit;\n height: inherit;\n border: inherit;\n border-radius: inherit;\n}\n\n.printSpinner, .printSpinner::before, .printSpinner::after {\n display: inline-block;\n border-color: transparent;\n border-top-color: #0460B5;\n animation-duration: 1.2s;\n}\n.printSpinner::before {\n transform: rotate(120deg);\n}\n.printSpinner::after {\n transform: rotate(240deg);\n}\n\n/* Keyframes for the animation */\n@keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["print.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"print.min.css","sourcesContent":["/*\n * Print.js\n * http://printjs.crabbly.com\n * Version: 1.0.11\n *\n * Copyright 2016 Rodrigo Vieira (@crabbly)\n * Released under the MIT license\n * https://github.com/crabbly/Print.js/blob/master/LICENSE\n */\n\n/* === Print Modal === */\n\n.printModal {\n font-family:sans-serif;\n display:flex;\n text-align:center;\n font-weight:300;\n font-size:30px;\n left:0;\n top:0;\n position:absolute;\n color: #0460B5;\n width: 100%;\n height: 100%;\n background-color:rgba(255, 255, 255, 0.91);\n}\n\n/* === Print Modal Close Button === */\n.printClose {\n position:absolute;\n right:10px;\n top:10px;'\n}\n\n.printClose:before {\n content: \"\\00D7\";\n font-family: \"Helvetica Neue\", sans-serif;\n font-weight: 100;\n line-height: 1px;\n padding-top: 0.5em;\n display: block;\n font-size: 2em;\n text-indent: 1px;\n overflow: hidden;\n height: 1.25em;\n width: 1.25em;\n text-align: center;\n cursor: pointer;\n}\n\n/* === Print Modal Spinner */\n.printSpinner {\n margin-top: 3px;\n margin-left: -40px;\n position: absolute;\n display: inline-block;\n width: 25px;\n height: 25px;\n border: 2px solid #0460B5;\n border-radius: 50%;\n animation: spin 0.75s infinite linear;\n}\n.printSpinner::before, .printSpinner::after {\n left: -2px;\n top: -2px;\n display: none;\n position: absolute;\n content: '';\n width: inherit;\n height: inherit;\n border: inherit;\n border-radius: inherit;\n}\n\n.printSpinner, .printSpinner::before, .printSpinner::after {\n display: inline-block;\n border-color: transparent;\n border-top-color: #0460B5;\n animation-duration: 1.2s;\n}\n.printSpinner::before {\n transform: rotate(120deg);\n}\n.printSpinner::after {\n transform: rotate(240deg);\n}\n\n/* Keyframes for the animation */\n@keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/dist/print.min.js b/dist/print.min.js index 438833f..91d9e8d 100644 --- a/dist/print.min.js +++ b/dist/print.min.js @@ -1 +1 @@ -!function e(t,r,a){function n(o,s){if(!r[o]){if(!t[o]){var d="function"==typeof require&&require;if(!s&&d)return d(o,!0);if(i)return i(o,!0);var p=new Error("Cannot find module '"+o+"'");throw p.code="MODULE_NOT_FOUND",p}var l=r[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return n(r?r:e)},l,l.exports,e,t,r,a)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;o'+e+""}function n(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},s=e("./browser"),d=["pdf","html","image","json"],p={printable:null,type:"pdf",header:null,maxWidth:800,font:"TimesNewRoman",font_size:"12pt",honorMarginPadding:!0,honorColor:!1,properties:null,showModal:!1,modalMessage:"Retrieving Document...",frameId:"printJS",border:!0,htmlData:""},l=void 0,m=void 0,c=void 0;t.exports=function(){if(void 0===arguments[0])return window.console.error("printJS expects at least 1 attribute."),!1;var e=new h(arguments);switch(l="max-width: "+e.params.maxWidth+"px !important;"+e.params.font_size+" !important;",m="font-family:"+e.params.font+" !important; font-size: "+e.params.font_size+" !important; width:100%;",c="font-weight:300;",e.params.type){case"pdf":if(s.isFirefox()){var t=window.open(e.params.printable,"_blank");t.focus(),e.params.showModal&&e.disablePrintModal()}else e.pdf();break;case"image":e.image();break;case"html":e.html();break;case"json":e.json();break;default:throw new Error("Invalid print type. Available types are: pdf, html, image and json.")}};var h=function(){var e=arguments[0],t=this;switch(t.params=n({},p),o(e[0])){case"string":t.params.printable=encodeURI(e[0]),t.params.type=e[1]||p.type;break;case"object":t.params.printable=e[0].printable,t.params.type=e[0].type||p.type,t.params.frameId=e[0].frameId||p.frameId,t.params.header=e[0].header||p.header,t.params.maxWidth=e[0].maxWidth||p.maxWidth,t.params.font=e[0].font||p.font,t.params.font_size=e[0].font_size||p.font_size,t.params.honorMarginPadding="undefined"!=typeof e[0].honorMarginPadding?e[0].honorMarginPadding:p.honorMarginPadding,t.params.properties=e[0].properties||p.properties,t.params.showModal="undefined"!=typeof e[0].showModal?e[0].showModal:p.showModal,t.params.modalMessage=e[0].modalMessage||p.modalMessage;break;default:throw new Error('Unexpected argument type! Expected "string" or "object", got '+o(e[0]))}t.validateInput(),t.params.showModal&&t.showModal();var r=document.getElementById(t.params.frameId);r&&r.parentNode.removeChild(r),s.isIE()&&"pdf"===t.params.type?(t.printFrame=document.createElement("embed"),t.printFrame.setAttribute("type","application/pdf"),t.printFrame.setAttribute("style","width:0px;height:0px;")):(t.printFrame=document.createElement("iframe"),t.printFrame.setAttribute("style","display:none;")),t.printFrame.setAttribute("id",t.params.frameId),"pdf"!==t.params.type&&(t.printFrame.srcdoc="")};h.prototype.pdf=function(){var e=this;e.params.showModal&&!s.isIE()?!function(){var t=document.createElement("img");t.src=e.params.printable;var r=new Promise(function(e,r){function a(){t.complete&&(window.clearInterval(n),e("PrintJS: PDF loaded. Read to print."))}var n=setInterval(a,100)});r.then(function(t){e.printFrame.setAttribute("src",e.params.printable),e.print()})}():(e.printFrame.setAttribute("src",e.params.printable),e.print())},h.prototype.image=function(){function e(){var e=document.createElement("div");if(e.setAttribute("style","width:100%"),s.isFirefox()){var a=document.createElement("canvas");a.setAttribute("width",t.width),a.setAttribute("height",t.height);var n=a.getContext("2d");n.drawImage(t,0,0),t.setAttribute("src",a.toDataURL("JPEG",1))}e.appendChild(t),r.params.header&&r.addHeader(e),r.params.htmlData=e.outerHTML,r.print()}var t=document.createElement("img");t.setAttribute("style","width:100%;"),t.src=this.params.printable;var r=this;if(s.isIE())e();else{var a=new Promise(function(e,r){function a(){t.complete&&(window.clearInterval(n),e("PrintJS: Image loaded. Read to print."))}var n=setInterval(a,100)});a.then(function(t){e()})}},h.prototype.html=function(){var e=document.getElementById(this.params.printable);if(!e)return window.console.error("Invalid HTML element id: "+this.params.printable),!1;var t=document.createElement("div");t.appendChild(e.cloneNode(!0)),t.setAttribute("style","display:none;"),t.setAttribute("id","printJS-html"),e.parentNode.appendChild(t),t=document.getElementById("printJS-html"),t.setAttribute("style",this.collectStyles(t)+"margin:0 !important;");var r=t.children;this.loopNodesCollectStyles(r),this.params.header&&this.addHeader(t),t.parentNode.removeChild(t),this.params.htmlData=a(t.innerHTML),this.print()},h.prototype.json=function(){if("object"!==o(this.params.printable))throw new Error("Invalid javascript data object (JSON).");if(!this.params.properties||"object"!==o(this.params.properties))throw new Error("Invalid properties array for your JSON data.");var e="";this.params.header&&(e+='

'+this.params.header+"

"),e+=this.jsonToHTML(),this.params.htmlData=a(e),this.print()},h.prototype.print=function(){function e(){if(a.focus(),s.isIE()&&"pdf"!==r.params.type)try{a.contentWindow.document.execCommand("print",!1,null)}catch(e){a.contentWindow.print()}else a.contentWindow.print();r.params.showModal&&r.disablePrintModal()}function t(){"undefined"==typeof a.print?setTimeout(function(){t()},1e3):(a.print(),setTimeout(function(){a.parentNode.removeChild(a)},2e3))}var r=this;document.getElementsByTagName("body")[0].appendChild(r.printFrame);var a=document.getElementById(r.params.frameId);s.isIE()&&"pdf"===r.params.type?t():r.printFrame.onload=function(){if("pdf"===r.params.type)e();else{var t=a.contentWindow||a.contentDocument;t.document&&(t=t.document),t.body.innerHTML=r.params.htmlData,e()}}},h.prototype.collectStyles=function(e){var t=document.defaultView||window,r=[],a="";if(t.getComputedStyle){r=t.getComputedStyle(e,"");for(var n=0;n';r+='
';for(var a=0;a'+i(t[a])+"
";r+="";for(var n=0;n'+e[n][t[o]]+"";r+=""}return r+=""},h.prototype.validateInput=function(){if(!this.params.printable)throw new Error("Missing printable information.");if(!this.params.type||"string"!=typeof this.params.type||d.indexOf(this.params.type.toLowerCase())===-1)throw new Error("Invalid print type. Available types are: pdf, html, image and json.")},h.prototype.showModal=function(){var e="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;",t=document.createElement("div");t.setAttribute("style",e),t.setAttribute("id","printJS-Modal");var r=document.createElement("div");r.setAttribute("style","display:table-cell; vertical-align:middle; padding-bottom:100px;");var a=document.createElement("div");a.setAttribute("class","printClose"),a.setAttribute("id","printClose"),r.appendChild(a);var n=document.createElement("span");n.setAttribute("class","printSpinner"),r.appendChild(n);var i=document.createTextNode(this.params.modalMessage);r.appendChild(i),t.appendChild(r),document.getElementsByTagName("body")[0].appendChild(t);var o=this;document.getElementById("printClose").addEventListener("click",function(){o.disablePrintModal()})},h.prototype.disablePrintModal=function(){var e=document.getElementById("printJS-Modal");e.parentNode.removeChild(e)}},{"./browser":1}],3:[function(e,t,r){"use strict";window.printJS=e("./js/print")},{"./js/print":2}]},{},[3]); \ No newline at end of file +!function e(t,r,a){function n(o,s){if(!r[o]){if(!t[o]){var d="function"==typeof require&&require;if(!s&&d)return d(o,!0);if(i)return i(o,!0);var p=new Error("Cannot find module '"+o+"'");throw p.code="MODULE_NOT_FOUND",p}var l=r[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return n(r?r:e)},l,l.exports,e,t,r,a)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;o'+e+""}function n(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},s=e("./browser"),d=["pdf","html","image","json"],p={printable:null,type:"pdf",header:null,maxWidth:800,font:"TimesNewRoman",font_size:"12pt",honorMarginPadding:!0,honorColor:!1,properties:null,showModal:!1,modalMessage:"Retrieving Document...",frameId:"printJS",border:!0,htmlData:""},l=void 0,m=void 0,c=void 0;t.exports=function(){if(void 0===arguments[0])return window.console.error("printJS expects at least 1 attribute."),!1;var e=new h(arguments);switch(l="max-width: "+e.params.maxWidth+"px !important;"+e.params.font_size+" !important;",m="font-family:"+e.params.font+" !important; font-size: "+e.params.font_size+" !important; width:100%;",c="font-weight:300;",e.params.type){case"pdf":if(s.isFirefox()){var t=window.open(e.params.printable,"_blank");t.focus(),e.params.showModal&&e.disablePrintModal()}else e.pdf();break;case"image":e.image();break;case"html":e.html();break;case"json":e.json();break;default:throw new Error("Invalid print type. Available types are: pdf, html, image and json.")}};var h=function(){var e=arguments[0],t=this;switch(t.params=n({},p),o(e[0])){case"string":t.params.printable=encodeURI(e[0]),t.params.type=e[1]||p.type;break;case"object":t.params.printable=e[0].printable,t.params.type=e[0].type||p.type,t.params.frameId=e[0].frameId||p.frameId,t.params.header=e[0].header||p.header,t.params.maxWidth=e[0].maxWidth||p.maxWidth,t.params.font=e[0].font||p.font,t.params.font_size=e[0].font_size||p.font_size,t.params.honorMarginPadding="undefined"!=typeof e[0].honorMarginPadding?e[0].honorMarginPadding:p.honorMarginPadding,t.params.properties=e[0].properties||p.properties,t.params.showModal="undefined"!=typeof e[0].showModal?e[0].showModal:p.showModal,t.params.modalMessage=e[0].modalMessage||p.modalMessage;break;default:throw new Error('Unexpected argument type! Expected "string" or "object", got '+o(e[0]))}t.validateInput(),t.params.showModal&&t.showModal();var r=document.getElementById(t.params.frameId);r&&r.parentNode.removeChild(r),s.isIE()&&"pdf"===t.params.type?(t.printFrame=document.createElement("embed"),t.printFrame.setAttribute("type","application/pdf"),t.printFrame.setAttribute("style","width:0px;height:0px;")):(t.printFrame=document.createElement("iframe"),t.printFrame.setAttribute("style","display:none;")),t.printFrame.setAttribute("id",t.params.frameId),"pdf"!==t.params.type&&(t.printFrame.srcdoc="")};h.prototype.pdf=function(){var e=this;e.params.showModal&&!s.isIE()?!function(){var t=document.createElement("img");t.src=e.params.printable;var r=new Promise(function(e,r){function a(){t.complete&&(window.clearInterval(n),e("PrintJS: PDF loaded. Read to print."))}var n=setInterval(a,100)});r.then(function(t){e.printFrame.setAttribute("src",e.params.printable),e.print()})}():(e.printFrame.setAttribute("src",e.params.printable),e.print())},h.prototype.image=function(){function e(){var e=document.createElement("div");if(e.setAttribute("style","width:100%"),s.isFirefox()){var a=document.createElement("canvas");a.setAttribute("width",t.width),a.setAttribute("height",t.height);var n=a.getContext("2d");n.drawImage(t,0,0),t.setAttribute("src",a.toDataURL("JPEG",1))}e.appendChild(t),r.params.header&&r.addHeader(e),r.params.htmlData=e.outerHTML,r.print()}var t=document.createElement("img");t.setAttribute("style","width:100%;"),t.src=this.params.printable;var r=this;if(s.isIE())e();else{var a=new Promise(function(e,r){function a(){t.complete&&(window.clearInterval(n),e())}var n=setInterval(a,100)});a.then(function(){e()})}},h.prototype.html=function(){var e=document.getElementById(this.params.printable);if(!e)return window.console.error("Invalid HTML element id: "+this.params.printable),!1;var t=document.createElement("div");t.appendChild(e.cloneNode(!0)),t.setAttribute("style","display:none;"),t.setAttribute("id","printJS-html"),e.parentNode.appendChild(t),t=document.getElementById("printJS-html"),t.setAttribute("style",this.collectStyles(t)+"margin:0 !important;");var r=t.children;this.loopNodesCollectStyles(r),this.params.header&&this.addHeader(t),t.parentNode.removeChild(t),this.params.htmlData=a(t.innerHTML),this.print()},h.prototype.json=function(){if("object"!==o(this.params.printable))throw new Error("Invalid javascript data object (JSON).");if(!this.params.properties||"object"!==o(this.params.properties))throw new Error("Invalid properties array for your JSON data.");var e="";this.params.header&&(e+='

'+this.params.header+"

"),e+=this.jsonToHTML(),this.params.htmlData=a(e),this.print()},h.prototype.print=function(){function e(){if(a.focus(),s.isIE()&&"pdf"!==r.params.type)try{a.contentWindow.document.execCommand("print",!1,null)}catch(e){a.contentWindow.print()}else a.contentWindow.print();r.params.showModal&&r.disablePrintModal()}function t(){"undefined"==typeof a.print?setTimeout(function(){t()},1e3):(a.print(),setTimeout(function(){a.parentNode.removeChild(a)},2e3))}var r=this;document.getElementsByTagName("body")[0].appendChild(r.printFrame);var a=document.getElementById(r.params.frameId);s.isIE()&&"pdf"===r.params.type?t():r.printFrame.onload=function(){if("pdf"===r.params.type)e();else{var t=a.contentWindow||a.contentDocument;t.document&&(t=t.document),t.body.innerHTML=r.params.htmlData,e()}}},h.prototype.collectStyles=function(e){var t=document.defaultView||window,r=[],a="";if(t.getComputedStyle){r=t.getComputedStyle(e,"");for(var n=0;n';r+='
';for(var a=0;a'+i(t[a])+"
";r+="";for(var n=0;n'+e[n][t[o]]+"";r+=""}return r+=""},h.prototype.validateInput=function(){if(!this.params.printable)throw new Error("Missing printable information.");if(!this.params.type||"string"!=typeof this.params.type||d.indexOf(this.params.type.toLowerCase())===-1)throw new Error("Invalid print type. Available types are: pdf, html, image and json.")},h.prototype.showModal=function(){var e="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;",t=document.createElement("div");t.setAttribute("style",e),t.setAttribute("id","printJS-Modal");var r=document.createElement("div");r.setAttribute("style","display:table-cell; vertical-align:middle; padding-bottom:100px;");var a=document.createElement("div");a.setAttribute("class","printClose"),a.setAttribute("id","printClose"),r.appendChild(a);var n=document.createElement("span");n.setAttribute("class","printSpinner"),r.appendChild(n);var i=document.createTextNode(this.params.modalMessage);r.appendChild(i),t.appendChild(r),document.getElementsByTagName("body")[0].appendChild(t);var o=this;document.getElementById("printClose").addEventListener("click",function(){o.disablePrintModal()})},h.prototype.disablePrintModal=function(){var e=document.getElementById("printJS-Modal");e.parentNode.removeChild(e)}},{"./browser":1}],3:[function(e,t,r){"use strict";window.printJS=e("./js/print")},{"./js/print":2}]},{},[3]); \ No newline at end of file diff --git a/dist/print.min.js.map b/dist/print.min.js.map index 28d2967..2d3a7c3 100644 --- a/dist/print.min.js.map +++ b/dist/print.min.js.map @@ -1 +1 @@ -{"version":3,"names":[],"mappings":"","sources":["print.min.js"],"sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o= 0\n\n// At least Safari 3+: \"[object HTMLElementConstructor]\"\n// let isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0\n\n// Edge 20+\n// let isEdge = !isIE && !!window.StyleMedia\n\n// Chrome 1+\n// let isChrome = !!window.chrome && !!window.chrome.webstore\n\n},{}],2:[function(require,module,exports){\n'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.PrintJS = undefined;\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 ? \"symbol\" : typeof obj; };\n\nexports.print = print;\n\nvar _browser = require('./browser');\n\nvar browser = _interopRequireWildcard(_browser);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nvar printTypes = ['pdf', 'html', 'image', 'json'];\n\nvar defaultParams = {\n printable: null,\n type: 'pdf',\n header: null,\n maxWidth: 800,\n font: 'TimesNewRoman',\n font_size: '12pt',\n honorMarginPadding: true,\n honorColor: false,\n properties: null,\n showModal: false,\n modalMessage: 'Retrieving Document...',\n frameId: 'printJS',\n border: true,\n htmlData: ''\n};\n\nvar printFriendlyElement = void 0,\n bodyStyle = void 0,\n headerStyle = void 0;\n\nfunction print() {\n // check if a printable document or object was supplied\n if (arguments[0] === undefined) {\n window.console.error('printJS expects at least 1 attribute.');\n return false;\n }\n\n // instantiate print object\n var printJS = new PrintJS(arguments);\n\n // print friendly defaults\n printFriendlyElement = 'max-width: ' + printJS.params.maxWidth + 'px !important;' + printJS.params.font_size + ' !important;';\n bodyStyle = 'font-family:' + printJS.params.font + ' !important; font-size: ' + printJS.params.font_size + ' !important; width:100%;';\n headerStyle = 'font-weight:300;';\n\n // check printable type\n switch (printJS.params.type) {\n case 'pdf':\n // firefox doesn't support iframe printing, we will just open the pdf file instead\n if (browser.isFirefox()) {\n console.log('PrintJS doesn\\'t support PDF printing in Firefox.');\n var win = window.open(printJS.params.printable, '_blank');\n win.focus();\n // make sure there is no loading modal opened\n if (printJS.params.showModal) printJS.disablePrintModal();\n } else {\n printJS.pdf();\n }\n break;\n case 'image':\n printJS.image();\n break;\n case 'html':\n printJS.html();\n break;\n case 'json':\n printJS.json();\n break;\n default:\n // throw invalid type error\n throw new Error('Invalid print type. Available types are: pdf, html, image and json.');\n }\n}\n\n// printJS class\nvar PrintJS = exports.PrintJS = function PrintJS() {\n var args = arguments[0];\n\n var print = this;\n\n print.params = extend({}, defaultParams);\n\n switch (_typeof(args[0])) {\n case 'string':\n print.params.printable = encodeURI(args[0]);\n print.params.type = args[1] || defaultParams.type;\n break;\n\n case 'object':\n print.params.printable = args[0].printable;\n print.params.type = args[0].type || defaultParams.type;\n print.params.frameId = args[0].frameId || defaultParams.frameId;\n print.params.header = args[0].header || defaultParams.header;\n print.params.maxWidth = args[0].maxWidth || defaultParams.maxWidth;\n print.params.font = args[0].font || defaultParams.font;\n print.params.font_size = args[0].font_size || defaultParams.font_size;\n print.params.honorMarginPadding = typeof args[0].honorMarginPadding !== 'undefined' ? args[0].honorMarginPadding : defaultParams.honorMarginPadding;\n print.params.properties = args[0].properties || defaultParams.properties;\n print.params.showModal = typeof args[0].showModal !== 'undefined' ? args[0].showModal : defaultParams.showModal;\n print.params.modalMessage = args[0].modalMessage || defaultParams.modalMessage;\n break;\n\n default:\n throw new Error('Unexpected argument type! Expected \"string\" or \"object\", got ' + _typeof(args[0]));\n }\n\n // some validation\n print.validateInput();\n\n // check if showing feedback to user (useful for large files)\n if (print.params.showModal) {\n print.showModal();\n }\n\n // to prevent duplication and issues, remove print.printFrame from DOM, if it exists\n var usedFrame = document.getElementById(print.params.frameId);\n\n if (usedFrame) {\n usedFrame.parentNode.removeChild(usedFrame);\n }\n\n // create a new iframe or embed element (IE prints blank pdf's if we use iframe)\n if (browser.isIE() && print.params.type === 'pdf') {\n // create embed element\n print.printFrame = document.createElement('embed');\n print.printFrame.setAttribute('type', 'application/pdf');\n\n // hide embed\n print.printFrame.setAttribute('style', 'width:0px;height:0px;');\n } else {\n // create iframe element\n print.printFrame = document.createElement('iframe');\n\n // hide iframe\n print.printFrame.setAttribute('style', 'display:none;');\n }\n\n // set element id\n print.printFrame.setAttribute('id', print.params.frameId);\n\n // for non pdf printing, pass empty html document to srcdoc (force onload callback)\n if (print.params.type !== 'pdf') print.printFrame.srcdoc = '';\n};\n\nPrintJS.prototype.pdf = function () {\n var print = this;\n\n // if showing feedback to user, pre load pdf files (hacky)\n // since we will be using promises, we can't use this feature in IE\n if (print.params.showModal && !browser.isIE()) {\n (function () {\n var pdfObject = document.createElement('img');\n pdfObject.src = print.params.printable;\n\n var pdf = new Promise(function (resolve, reject) {\n var loadPDF = setInterval(checkPDFload, 100);\n\n function checkPDFload() {\n if (pdfObject.complete) {\n window.clearInterval(loadPDF);\n resolve('PrintJS: PDF loaded. Read to print.');\n }\n }\n });\n\n pdf.then(function (result) {\n console.log(result);\n // set iframe src with pdf document url\n print.printFrame.setAttribute('src', print.params.printable);\n\n // print pdf document\n print.print();\n });\n })();\n } else {\n // set iframe src with pdf document url\n print.printFrame.setAttribute('src', print.params.printable);\n\n // print pdf\n print.print();\n }\n};\n\nPrintJS.prototype.image = function () {\n // create the image element\n var img = document.createElement('img');\n img.setAttribute('style', 'width:100%;');\n\n // set image src with image file url\n img.src = this.params.printable;\n\n // assign `this` to a variable, to be used within the promise\n var print = this;\n\n // if browser isn't IE, load image using promises\n if (!browser.isIE()) {\n var loadImage = new Promise(function (resolve, reject) {\n var loadPrintableImg = setInterval(checkImgLoad, 100);\n\n function checkImgLoad() {\n if (img.complete) {\n window.clearInterval(loadPrintableImg);\n resolve('PrintJS: Image loaded. Read to print.');\n }\n }\n });\n\n loadImage.then(function (result) {\n console.log(result);\n printImage();\n });\n } else {\n printImage();\n }\n\n function printImage() {\n // create wrapper\n var printableElement = document.createElement('div');\n printableElement.setAttribute('style', 'width:100%');\n\n // to prevent firefox from not loading images within iframe, we can use base64-encoded data URL of images pixel data\n if (browser.isFirefox()) {\n // let's make firefox happy\n var canvas = document.createElement('canvas');\n canvas.setAttribute('width', img.width);\n canvas.setAttribute('height', img.height);\n var context = canvas.getContext('2d');\n context.drawImage(img, 0, 0);\n\n // reset img src attribute with canvas dataURL\n img.setAttribute('src', canvas.toDataURL('JPEG', 1.0));\n }\n\n printableElement.appendChild(img);\n\n // add header if any\n if (print.params.header) {\n print.addHeader(printableElement);\n }\n\n // store html data\n print.params.htmlData = printableElement.outerHTML;\n\n // print image\n print.print();\n }\n};\n\nPrintJS.prototype.html = function () {\n // get HTML printable element\n var printElement = document.getElementById(this.params.printable);\n\n // check if element exists\n if (!printElement) {\n window.console.error('Invalid HTML element id: ' + this.params.printable);\n\n return false;\n }\n\n // make a copy of the printElement to prevent DOM changes\n var printableElement = document.createElement('div');\n printableElement.appendChild(printElement.cloneNode(true));\n\n // add cloned element to DOM, to have DOM element methods available. It will also be easier to colect styles\n printableElement.setAttribute('style', 'display:none;');\n printableElement.setAttribute('id', 'printJS-html');\n printElement.parentNode.appendChild(printableElement);\n\n // update printableElement variable with newly created DOM element\n printableElement = document.getElementById('printJS-html');\n\n // get main element styling\n printableElement.setAttribute('style', this.collectStyles(printableElement) + 'margin:0 !important;');\n\n // get all children elements\n var elements = printableElement.children;\n\n // get styles for all children elements\n this.loopNodesCollectStyles(elements);\n\n // add header if any\n if (this.params.header) {\n this.addHeader(printableElement);\n }\n\n // remove DOM printableElement\n printableElement.parentNode.removeChild(printableElement);\n\n // store html data\n this.params.htmlData = addWrapper(printableElement.innerHTML);\n\n // print html element contents\n this.print();\n};\n\nPrintJS.prototype.json = function () {\n // check if we received proper data\n if (_typeof(this.params.printable) !== 'object') {\n throw new Error('Invalid javascript data object (JSON).');\n }\n\n // check if properties were provided\n if (!this.params.properties || _typeof(this.params.properties) !== 'object') {\n throw new Error('Invalid properties array for your JSON data.');\n }\n\n // variable to hold html string\n var htmlData = '';\n\n // check print has header\n if (this.params.header) {\n htmlData += '

' + this.params.header + '

';\n }\n\n // function to build html templates for json data\n htmlData += this.jsonToHTML();\n\n // store html data\n this.params.htmlData = addWrapper(htmlData);\n\n // print json data\n this.print();\n};\n\nPrintJS.prototype.print = function () {\n var print = this;\n\n // append iframe element to document body\n document.getElementsByTagName('body')[0].appendChild(print.printFrame);\n\n // get iframe element\n var printJS = document.getElementById(print.params.frameId);\n\n // if printing pdf in IE\n if (browser.isIE() && print.params.type === 'pdf') {\n finishPrintPdfIe();\n } else {\n // wait for iframe to load all content\n print.printFrame.onload = function () {\n if (print.params.type === 'pdf') {\n finishPrint();\n } else {\n // get iframe element document\n var printDocument = printJS.contentWindow || printJS.contentDocument;\n if (printDocument.document) printDocument = printDocument.document;\n\n // inject printable html into iframe body\n printDocument.body.innerHTML = print.params.htmlData;\n\n finishPrint();\n }\n };\n }\n\n function finishPrint() {\n // print iframe document\n printJS.focus();\n\n // if IE, try catch with execCommand\n if (browser.isIE() && print.params.type !== 'pdf') {\n try {\n printJS.contentWindow.document.execCommand('print', false, null);\n } catch (e) {\n printJS.contentWindow.print();\n }\n } else {\n printJS.contentWindow.print();\n }\n\n // if showing feedback to user, remove processing message (close modal)\n if (print.params.showModal) {\n print.disablePrintModal();\n }\n }\n\n function finishPrintPdfIe() {\n // wait until pdf is ready to print\n if (typeof printJS.print === 'undefined') {\n setTimeout(function () {\n finishPrintPdfIe();\n }, 1000);\n } else {\n printJS.print();\n\n // remove embed (just because it isn't 100% hidden when using h/w = 0)\n setTimeout(function () {\n printJS.parentNode.removeChild(printJS);\n }, 2000);\n }\n }\n};\n\nPrintJS.prototype.collectStyles = function (element) {\n var win = document.defaultView || window;\n\n var style = [];\n\n // string variable to hold styling for each element\n var elementStyle = '';\n\n if (win.getComputedStyle) {\n // modern browsers\n style = win.getComputedStyle(element, '');\n\n for (var i = 0; i < style.length; i++) {\n // styles including\n var targetStyles = ['border', 'float', 'box'];\n // exact\n var targetStyle = ['clear', 'display', 'width', 'min-width', 'height', 'min-height', 'max-height'];\n\n // optinal - include margin and padding\n if (this.params.honorMarginPadding) {\n targetStyle.push('margin', 'padding');\n }\n\n // optinal - include color\n if (this.params.honorColor) {\n targetStyle.push('color');\n }\n\n for (var s = 0; s < targetStyle.length; s++) {\n if (style[i].indexOf(targetStyles[s]) !== -1 || style[i].indexOf(targetStyle[s]) === 0) {\n elementStyle += style[i] + ':' + style.getPropertyValue(style[i]) + ';';\n }\n }\n }\n } else if (element.currentStyle) {\n // IE\n style = element.currentStyle;\n\n for (var name in style) {\n if (style.indexOf('border') !== -1 && style.indexOf('color') !== -1) {\n elementStyle += name + ':' + style[name] + ';';\n }\n }\n }\n\n // add printer friendly\n elementStyle += printFriendlyElement;\n\n return elementStyle;\n};\n\nPrintJS.prototype.loopNodesCollectStyles = function (elements) {\n for (var n = 0; n < elements.length; n++) {\n var currentElement = elements[n];\n\n // Form Printing - check if is element Input\n var tag = currentElement.tagName;\n if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') {\n // save style to variable\n var textStyle = this.collectStyles(currentElement);\n\n // remove INPUT element and insert a text node\n var parent = currentElement.parentNode;\n\n // get text value\n var textNode = tag === 'SELECT' ? document.createTextNode(currentElement.options[currentElement.selectedIndex].text) : document.createTextNode(currentElement.value);\n\n // create text element\n var textElement = document.createElement('div');\n textElement.appendChild(textNode);\n\n // add style to text\n textElement.setAttribute('style', textStyle);\n\n // add text\n parent.appendChild(textElement);\n\n // remove input\n parent.removeChild(currentElement);\n } else {\n // get all styling for print element\n currentElement.setAttribute('style', this.collectStyles(currentElement));\n }\n\n // check if more elements in tree\n var children = currentElement.children;\n\n if (children.length) {\n this.loopNodesCollectStyles(children);\n }\n }\n};\n\nPrintJS.prototype.addHeader = function (printElement) {\n // create header element\n var headerElement = document.createElement('h1');\n\n // create header text node\n var headerNode = document.createTextNode(this.params.header);\n\n // build and style\n headerElement.appendChild(headerNode);\n headerElement.setAttribute('style', headerStyle);\n\n printElement.insertBefore(headerElement, printElement.childNodes[0]);\n};\n\nPrintJS.prototype.jsonToHTML = function () {\n var data = this.params.printable;\n var properties = this.params.properties;\n\n var htmlData = '
';\n\n // header\n htmlData += '
';\n\n for (var a = 0; a < properties.length; a++) {\n htmlData += '
' + capitalizePrint(properties[a]) + '
';\n }\n\n htmlData += '
';\n\n // create html data\n for (var i = 0; i < data.length; i++) {\n htmlData += '
';\n }\n\n htmlData += '
';\n }\n\n htmlData += '
';\n\n return htmlData;\n};\n\nPrintJS.prototype.validateInput = function () {\n if (!this.params.printable) {\n throw new Error('Missing printable information.');\n }\n\n if (!this.params.type || typeof this.params.type !== 'string' || printTypes.indexOf(this.params.type.toLowerCase()) === -1) {\n throw new Error('Invalid print type. Available types are: pdf, html, image and json.');\n }\n};\n\nPrintJS.prototype.showModal = function () {\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(this.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 var print = this;\n document.getElementById('printClose').addEventListener('click', function () {\n print.disablePrintModal();\n });\n};\n\nPrintJS.prototype.disablePrintModal = function () {\n var printFrame = document.getElementById('printJS-Modal');\n\n printFrame.parentNode.removeChild(printFrame);\n};\n\nfunction addWrapper(htmlData) {\n return '
' + htmlData + '
';\n}\n\n// update default print.params with user input\nfunction extend(a, b) {\n for (var key in b) {\n if (b.hasOwnProperty(key)) {\n a[key] = b[key];\n }\n }\n\n return a;\n}\n\n// capitalize string\nfunction capitalizePrint(string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\n},{\"./browser\":1}],3:[function(require,module,exports){\n'use strict';\n\nvar _print = require('./js/print');\n\nwindow.printJS = _print.print; /*\n * Print.js\n * http://printjs.crabbly.com\n * Version: 1.0.10\n *\n * Copyright 2016 Rodrigo Vieira (@crabbly)\n * Released under the MIT license\n * https://github.com/crabbly/Print.js/blob/master/LICENSE\n */\n\n},{\"./js/print\":2}]},{},[3]);\n"],"file":"print.min.js","sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"names":[],"mappings":"","sources":["print.min.js"],"sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o= 0\n\n // At least Safari 3+: \"[object HTMLElementConstructor]\"\n // let isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0\n\n // Edge 20+\n // let isEdge = !isIE && !!window.StyleMedia\n\n // Chrome 1+\n // let isChrome = !!window.chrome && !!window.chrome.webstore\n\n};\n\n},{}],2:[function(require,module,exports){\n'use strict';\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 ? \"symbol\" : typeof obj; };\n\nvar browser = require('./browser');\n\nvar printTypes = ['pdf', 'html', 'image', 'json'];\n\nvar defaultParams = {\n printable: null,\n type: 'pdf',\n header: null,\n maxWidth: 800,\n font: 'TimesNewRoman',\n font_size: '12pt',\n honorMarginPadding: true,\n honorColor: false,\n properties: null,\n showModal: false,\n modalMessage: 'Retrieving Document...',\n frameId: 'printJS',\n border: true,\n htmlData: ''\n};\n\nvar printFriendlyElement = void 0,\n bodyStyle = void 0,\n headerStyle = void 0;\n\nmodule.exports = function () {\n // check if a printable document or object was supplied\n if (arguments[0] === undefined) {\n window.console.error('printJS expects at least 1 attribute.');\n return false;\n }\n\n // instantiate print object\n var printJS = new PrintJS(arguments);\n\n // print friendly defaults\n printFriendlyElement = 'max-width: ' + printJS.params.maxWidth + 'px !important;' + printJS.params.font_size + ' !important;';\n bodyStyle = 'font-family:' + printJS.params.font + ' !important; font-size: ' + printJS.params.font_size + ' !important; width:100%;';\n headerStyle = 'font-weight:300;';\n\n // check printable type\n switch (printJS.params.type) {\n case 'pdf':\n // firefox doesn't support iframe printing, we will just open the pdf file instead\n if (browser.isFirefox()) {\n console.log('PrintJS doesn\\'t support PDF printing in Firefox.');\n var win = window.open(printJS.params.printable, '_blank');\n win.focus();\n // make sure there is no loading modal opened\n if (printJS.params.showModal) printJS.disablePrintModal();\n } else {\n printJS.pdf();\n }\n break;\n case 'image':\n printJS.image();\n break;\n case 'html':\n printJS.html();\n break;\n case 'json':\n printJS.json();\n break;\n default:\n // throw invalid type error\n throw new Error('Invalid print type. Available types are: pdf, html, image and json.');\n }\n};\n\n// printJS class\nvar PrintJS = function PrintJS() {\n var args = arguments[0];\n\n var print = this;\n\n print.params = extend({}, defaultParams);\n\n switch (_typeof(args[0])) {\n case 'string':\n print.params.printable = encodeURI(args[0]);\n print.params.type = args[1] || defaultParams.type;\n break;\n\n case 'object':\n print.params.printable = args[0].printable;\n print.params.type = args[0].type || defaultParams.type;\n print.params.frameId = args[0].frameId || defaultParams.frameId;\n print.params.header = args[0].header || defaultParams.header;\n print.params.maxWidth = args[0].maxWidth || defaultParams.maxWidth;\n print.params.font = args[0].font || defaultParams.font;\n print.params.font_size = args[0].font_size || defaultParams.font_size;\n print.params.honorMarginPadding = typeof args[0].honorMarginPadding !== 'undefined' ? args[0].honorMarginPadding : defaultParams.honorMarginPadding;\n print.params.properties = args[0].properties || defaultParams.properties;\n print.params.showModal = typeof args[0].showModal !== 'undefined' ? args[0].showModal : defaultParams.showModal;\n print.params.modalMessage = args[0].modalMessage || defaultParams.modalMessage;\n break;\n\n default:\n throw new Error('Unexpected argument type! Expected \"string\" or \"object\", got ' + _typeof(args[0]));\n }\n\n // some validation\n print.validateInput();\n\n // check if showing feedback to user (useful for large files)\n if (print.params.showModal) {\n print.showModal();\n }\n\n // to prevent duplication and issues, remove print.printFrame from DOM, if it exists\n var usedFrame = document.getElementById(print.params.frameId);\n\n if (usedFrame) {\n usedFrame.parentNode.removeChild(usedFrame);\n }\n\n // create a new iframe or embed element (IE prints blank pdf's if we use iframe)\n if (browser.isIE() && print.params.type === 'pdf') {\n // create embed element\n print.printFrame = document.createElement('embed');\n print.printFrame.setAttribute('type', 'application/pdf');\n\n // hide embed\n print.printFrame.setAttribute('style', 'width:0px;height:0px;');\n } else {\n // create iframe element\n print.printFrame = document.createElement('iframe');\n\n // hide iframe\n print.printFrame.setAttribute('style', 'display:none;');\n }\n\n // set element id\n print.printFrame.setAttribute('id', print.params.frameId);\n\n // for non pdf printing, pass empty html document to srcdoc (force onload callback)\n if (print.params.type !== 'pdf') print.printFrame.srcdoc = '';\n};\n\nPrintJS.prototype.pdf = function () {\n var print = this;\n\n // if showing feedback to user, pre load pdf files (hacky)\n // since we will be using promises, we can't use this feature in IE\n if (print.params.showModal && !browser.isIE()) {\n (function () {\n var pdfObject = document.createElement('img');\n pdfObject.src = print.params.printable;\n\n var pdf = new Promise(function (resolve, reject) {\n var loadPDF = setInterval(checkPDFload, 100);\n\n function checkPDFload() {\n if (pdfObject.complete) {\n window.clearInterval(loadPDF);\n resolve('PrintJS: PDF loaded. Read to print.');\n }\n }\n });\n\n pdf.then(function (result) {\n console.log(result);\n // set iframe src with pdf document url\n print.printFrame.setAttribute('src', print.params.printable);\n\n // print pdf document\n print.print();\n });\n })();\n } else {\n // set iframe src with pdf document url\n print.printFrame.setAttribute('src', print.params.printable);\n\n // print pdf\n print.print();\n }\n};\n\nPrintJS.prototype.image = function () {\n // create the image element\n var img = document.createElement('img');\n img.setAttribute('style', 'width:100%;');\n\n // set image src with image file url\n img.src = this.params.printable;\n\n // assign `this` to a variable, to be used within the promise\n var print = this;\n\n // if browser isn't IE, load image using promises\n if (!browser.isIE()) {\n var loadImage = new Promise(function (resolve, reject) {\n var loadPrintableImg = setInterval(checkImgLoad, 100);\n\n function checkImgLoad() {\n if (img.complete) {\n window.clearInterval(loadPrintableImg);\n resolve();\n console.log('PrintJS: Image loaded. Read to print.');\n }\n }\n });\n\n loadImage.then(function () {\n printImage();\n });\n } else {\n printImage();\n }\n\n function printImage() {\n // create wrapper\n var printableElement = document.createElement('div');\n printableElement.setAttribute('style', 'width:100%');\n\n // to prevent firefox from not loading images within iframe, we can use base64-encoded data URL of images pixel data\n if (browser.isFirefox()) {\n // let's make firefox happy\n var canvas = document.createElement('canvas');\n canvas.setAttribute('width', img.width);\n canvas.setAttribute('height', img.height);\n var context = canvas.getContext('2d');\n context.drawImage(img, 0, 0);\n\n // reset img src attribute with canvas dataURL\n img.setAttribute('src', canvas.toDataURL('JPEG', 1.0));\n }\n\n printableElement.appendChild(img);\n\n // add header if any\n if (print.params.header) {\n print.addHeader(printableElement);\n }\n\n // store html data\n print.params.htmlData = printableElement.outerHTML;\n\n // print image\n print.print();\n }\n};\n\nPrintJS.prototype.html = function () {\n // get HTML printable element\n var printElement = document.getElementById(this.params.printable);\n\n // check if element exists\n if (!printElement) {\n window.console.error('Invalid HTML element id: ' + this.params.printable);\n\n return false;\n }\n\n // make a copy of the printElement to prevent DOM changes\n var printableElement = document.createElement('div');\n printableElement.appendChild(printElement.cloneNode(true));\n\n // add cloned element to DOM, to have DOM element methods available. It will also be easier to colect styles\n printableElement.setAttribute('style', 'display:none;');\n printableElement.setAttribute('id', 'printJS-html');\n printElement.parentNode.appendChild(printableElement);\n\n // update printableElement variable with newly created DOM element\n printableElement = document.getElementById('printJS-html');\n\n // get main element styling\n printableElement.setAttribute('style', this.collectStyles(printableElement) + 'margin:0 !important;');\n\n // get all children elements\n var elements = printableElement.children;\n\n // get styles for all children elements\n this.loopNodesCollectStyles(elements);\n\n // add header if any\n if (this.params.header) {\n this.addHeader(printableElement);\n }\n\n // remove DOM printableElement\n printableElement.parentNode.removeChild(printableElement);\n\n // store html data\n this.params.htmlData = addWrapper(printableElement.innerHTML);\n\n // print html element contents\n this.print();\n};\n\nPrintJS.prototype.json = function () {\n // check if we received proper data\n if (_typeof(this.params.printable) !== 'object') {\n throw new Error('Invalid javascript data object (JSON).');\n }\n\n // check if properties were provided\n if (!this.params.properties || _typeof(this.params.properties) !== 'object') {\n throw new Error('Invalid properties array for your JSON data.');\n }\n\n // variable to hold html string\n var htmlData = '';\n\n // check print has header\n if (this.params.header) {\n htmlData += '

' + this.params.header + '

';\n }\n\n // function to build html templates for json data\n htmlData += this.jsonToHTML();\n\n // store html data\n this.params.htmlData = addWrapper(htmlData);\n\n // print json data\n this.print();\n};\n\nPrintJS.prototype.print = function () {\n var print = this;\n\n // append iframe element to document body\n document.getElementsByTagName('body')[0].appendChild(print.printFrame);\n\n // get iframe element\n var printJS = document.getElementById(print.params.frameId);\n\n // if printing pdf in IE\n if (browser.isIE() && print.params.type === 'pdf') {\n finishPrintPdfIe();\n } else {\n // wait for iframe to load all content\n print.printFrame.onload = function () {\n if (print.params.type === 'pdf') {\n finishPrint();\n } else {\n // get iframe element document\n var printDocument = printJS.contentWindow || printJS.contentDocument;\n if (printDocument.document) printDocument = printDocument.document;\n\n // inject printable html into iframe body\n printDocument.body.innerHTML = print.params.htmlData;\n\n finishPrint();\n }\n };\n }\n\n function finishPrint() {\n // print iframe document\n printJS.focus();\n\n // if IE, try catch with execCommand\n if (browser.isIE() && print.params.type !== 'pdf') {\n try {\n printJS.contentWindow.document.execCommand('print', false, null);\n } catch (e) {\n printJS.contentWindow.print();\n }\n } else {\n printJS.contentWindow.print();\n }\n\n // if showing feedback to user, remove processing message (close modal)\n if (print.params.showModal) {\n print.disablePrintModal();\n }\n }\n\n function finishPrintPdfIe() {\n // wait until pdf is ready to print\n if (typeof printJS.print === 'undefined') {\n setTimeout(function () {\n finishPrintPdfIe();\n }, 1000);\n } else {\n printJS.print();\n\n // remove embed (just because it isn't 100% hidden when using h/w = 0)\n setTimeout(function () {\n printJS.parentNode.removeChild(printJS);\n }, 2000);\n }\n }\n};\n\nPrintJS.prototype.collectStyles = function (element) {\n var win = document.defaultView || window;\n\n var style = [];\n\n // string variable to hold styling for each element\n var elementStyle = '';\n\n if (win.getComputedStyle) {\n // modern browsers\n style = win.getComputedStyle(element, '');\n\n for (var i = 0; i < style.length; i++) {\n // styles including\n var targetStyles = ['border', 'float', 'box'];\n // exact\n var targetStyle = ['clear', 'display', 'width', 'min-width', 'height', 'min-height', 'max-height'];\n\n // optinal - include margin and padding\n if (this.params.honorMarginPadding) {\n targetStyle.push('margin', 'padding');\n }\n\n // optinal - include color\n if (this.params.honorColor) {\n targetStyle.push('color');\n }\n\n for (var s = 0; s < targetStyle.length; s++) {\n if (style[i].indexOf(targetStyles[s]) !== -1 || style[i].indexOf(targetStyle[s]) === 0) {\n elementStyle += style[i] + ':' + style.getPropertyValue(style[i]) + ';';\n }\n }\n }\n } else if (element.currentStyle) {\n // IE\n style = element.currentStyle;\n\n for (var name in style) {\n if (style.indexOf('border') !== -1 && style.indexOf('color') !== -1) {\n elementStyle += name + ':' + style[name] + ';';\n }\n }\n }\n\n // add printer friendly\n elementStyle += printFriendlyElement;\n\n return elementStyle;\n};\n\nPrintJS.prototype.loopNodesCollectStyles = function (elements) {\n for (var n = 0; n < elements.length; n++) {\n var currentElement = elements[n];\n\n // Form Printing - check if is element Input\n var tag = currentElement.tagName;\n if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') {\n // save style to variable\n var textStyle = this.collectStyles(currentElement);\n\n // remove INPUT element and insert a text node\n var parent = currentElement.parentNode;\n\n // get text value\n var textNode = tag === 'SELECT' ? document.createTextNode(currentElement.options[currentElement.selectedIndex].text) : document.createTextNode(currentElement.value);\n\n // create text element\n var textElement = document.createElement('div');\n textElement.appendChild(textNode);\n\n // add style to text\n textElement.setAttribute('style', textStyle);\n\n // add text\n parent.appendChild(textElement);\n\n // remove input\n parent.removeChild(currentElement);\n } else {\n // get all styling for print element\n currentElement.setAttribute('style', this.collectStyles(currentElement));\n }\n\n // check if more elements in tree\n var children = currentElement.children;\n\n if (children.length) {\n this.loopNodesCollectStyles(children);\n }\n }\n};\n\nPrintJS.prototype.addHeader = function (printElement) {\n // create header element\n var headerElement = document.createElement('h1');\n\n // create header text node\n var headerNode = document.createTextNode(this.params.header);\n\n // build and style\n headerElement.appendChild(headerNode);\n headerElement.setAttribute('style', headerStyle);\n\n printElement.insertBefore(headerElement, printElement.childNodes[0]);\n};\n\nPrintJS.prototype.jsonToHTML = function () {\n var data = this.params.printable;\n var properties = this.params.properties;\n\n var htmlData = '
';\n\n // header\n htmlData += '
';\n\n for (var a = 0; a < properties.length; a++) {\n htmlData += '
' + capitalizePrint(properties[a]) + '
';\n }\n\n htmlData += '
';\n\n // create html data\n for (var i = 0; i < data.length; i++) {\n htmlData += '
';\n }\n\n htmlData += '
';\n }\n\n htmlData += '
';\n\n return htmlData;\n};\n\nPrintJS.prototype.validateInput = function () {\n if (!this.params.printable) {\n throw new Error('Missing printable information.');\n }\n\n if (!this.params.type || typeof this.params.type !== 'string' || printTypes.indexOf(this.params.type.toLowerCase()) === -1) {\n throw new Error('Invalid print type. Available types are: pdf, html, image and json.');\n }\n};\n\nPrintJS.prototype.showModal = function () {\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(this.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 var print = this;\n document.getElementById('printClose').addEventListener('click', function () {\n print.disablePrintModal();\n });\n};\n\nPrintJS.prototype.disablePrintModal = function () {\n var printFrame = document.getElementById('printJS-Modal');\n\n printFrame.parentNode.removeChild(printFrame);\n};\n\nfunction addWrapper(htmlData) {\n return '
' + htmlData + '
';\n}\n\n// update default print.params with user input\nfunction extend(a, b) {\n for (var key in b) {\n if (b.hasOwnProperty(key)) {\n a[key] = b[key];\n }\n }\n\n return a;\n}\n\n// capitalize string\nfunction capitalizePrint(string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\n},{\"./browser\":1}],3:[function(require,module,exports){\n'use strict';\n\n/*\n * Print.js\n * http://printjs.crabbly.com\n * Version: 1.0.11\n *\n * Copyright 2016 Rodrigo Vieira (@crabbly)\n * Released under the MIT license\n * https://github.com/crabbly/Print.js/blob/master/LICENSE\n */\n\nwindow.printJS = require('./js/print');\n\n},{\"./js/print\":2}]},{},[3]);\n"],"file":"print.min.js","sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/js/print.js b/src/js/print.js index fef8b69..2f07721 100644 --- a/src/js/print.js +++ b/src/js/print.js @@ -193,13 +193,13 @@ PrintJS.prototype.image = function () { function checkImgLoad () { if (img.complete) { window.clearInterval(loadPrintableImg) - resolve('PrintJS: Image loaded. Read to print.') + resolve() } } }) - loadImage.then(function (result) { - console.log(result) + loadImage.then(function () { + console.log('PrintJS: Image loaded. Read to print.') printImage() }) } else {