@hgsj/vue-print-directive 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/print.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hgsj/vue-print-directive",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "A Vue.js plugin for printing HTML elements",
5
5
  "main": "print.js",
6
6
  "scripts": {
package/print.js CHANGED
@@ -1 +1 @@
1
- function a(){var z=['string','directive','text','removeChild','value','myIframe','checkbox','outerHTML','log','appendChild','object','248EOqBHb','prototype','selected','343791CqOuXQ','<style>','dom','contentWindow','8WURhfF','nodeType','OPTION','print','$print','body','input','removeAttribute','extend','textarea','position:absolute;width:0;height:0;top:-10px;left:-10px;','close','{display:none;}</style>','3671830GhErqQ','innerHTML','4447323CaOZrX','length','.no-print','children','checked','select','addEventListener','document','$el','tagName','contentDocument','3163miawLq','querySelector','4123938ivHIHX','open','querySelectorAll','nodeName','isDOM','type','setAttribute','1802820ykKlym','style','options','onload','toPrint','select-one','style,link','noPrint','4202988RTBtnt','install','err'];a=function(){return z;};return a();}var o=b;function b(c,d){var e=a();return b=function(f,g){f=f-0x82;var h=e[f];return h;},b(c,d);}(function(c,d){var m=b,e=c();while(!![]){try{var f=-parseInt(m(0xbf))/0x1*(-parseInt(m(0x9e))/0x2)+parseInt(m(0x88))/0x3+-parseInt(m(0x90))/0x4+parseInt(m(0xb2))/0x5+-parseInt(m(0xc1))/0x6+parseInt(m(0xa1))/0x7+parseInt(m(0xa5))/0x8*(parseInt(m(0xb4))/0x9);if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0x820e4));const Print=function(c,d){var n=b;if(!(this instanceof Print))return new Print(c,d);this[n(0x8a)]=this[n(0xad)]({'noPrint':n(0xb6)},d),typeof c===n(0x93)?this[n(0xa3)]=document[n(0xc0)](c):(this[n(0x85)](c),this[n(0xa3)]=this[n(0x85)](c)?c:c[n(0xbc)]),this['init']();};Print[o(0x9f)]={'init':function(){var c=this['getStyle']()+this['getHtml']();this['writeIframe'](c);},'extend':function(c,d){for(var e in d){c[e]=d[e];}return c;},'getStyle':function(){var p=o,c='',d=document[p(0x83)](p(0x8e));for(var e=0x0;e<d['length'];e++){c+=d[e]['outerHTML'];}return c+=p(0xa2)+(this[p(0x8a)][p(0x8f)]?this[p(0x8a)][p(0x8f)]:'.no-print')+p(0xb1),c;},'getHtml':function(){var q=o,c=document[q(0x83)](q(0xab)),d=document[q(0x83)]('textarea'),e=document[q(0x83)](q(0xb9));for(var f=0x0;f<c['length'];f++){if(c[f][q(0x86)]==q(0x99)||c[f][q(0x86)]=='radio')c[f][q(0xb8)]==!![]?c[f][q(0x87)](q(0xb8),'checked'):c[f][q(0xac)](q(0xb8));else c[f][q(0x86)]==q(0x95)?c[f][q(0x87)](q(0x97),c[f][q(0x97)]):c[f][q(0x87)](q(0x97),c[f][q(0x97)]);}for(var g=0x0;g<d[q(0xb5)];g++){d[g][q(0x86)]==q(0xae)&&(d[g][q(0xb3)]=d[g]['value']);}for(var h=0x0;h<e[q(0xb5)];h++){if(e[h]['type']==q(0x8d)){var j=e[h][q(0xb7)];for(var l in j){j[l][q(0xbd)]==q(0xa7)&&(j[l][q(0xa0)]==!![]?j[l][q(0x87)](q(0xa0),q(0xa0)):j[l][q(0xac)](q(0xa0)));}}}return this['dom'][q(0x9a)];},'writeIframe':function(c){var r=o,d,e,g=document['createElement']('iframe'),h=document[r(0xaa)][r(0x9c)](g);g['id']=r(0x98),g[r(0x87)](r(0x89),r(0xaf)),d=h[r(0xa4)]||h[r(0xbe)],e=h[r(0xbe)]||h[r(0xa4)][r(0xbb)],e[r(0x82)](),e['write'](c),e[r(0xb0)]();var i=this;g[r(0x8b)]=function(){var s=r;i[s(0x8c)](d),setTimeout(function(){var t=s;document[t(0xaa)][t(0x96)](g);},0x64);};},'toPrint':function(c){var v=o;try{setTimeout(function(){var u=b;c['focus']();try{!c[u(0xbb)]['execCommand'](u(0xa8),![],null)&&c['print']();}catch(d){c['print']();}c['close']();},0xa);}catch(d){console[v(0x9b)](v(0x92),d);}},'isDOM':typeof HTMLElement==='object'?function(c){return c instanceof HTMLElement;}:function(c){var w=o;return c&&typeof c===w(0x9d)&&c[w(0xa6)]===0x1&&typeof c[w(0x84)]===w(0x93);}};const MyPlugin={};MyPlugin[o(0x91)]=function(c,d){var x=o;c['print']=Print,c[x(0x9f)][x(0xa9)]=Print,c[x(0x94)](x(0xa8),{'bind':function(e,f){var y=x;e[y(0xba)]('click',function(){Print(f['value']||e);});}});};export default MyPlugin;
1
+ const Print=function(t,e){if(!(this instanceof Print))return new Print(t,e);this.options=this.extend({noPrint:".no-print",type:"html",text:""},e),"string"==typeof t?this.dom=document.querySelector(t):(this.isDOM(t),this.dom=this.isDOM(t)?t:t.$el),this.init()},MyPlugin=(Print.prototype={init:function(){var t=this.getStyle()+("text"===this.options.type?this.getTextHtml():this.getHtml());this.writeIframe(t)},extend:function(t,e){for(var n in e)t[n]=e[n];return t},getStyle:function(){for(var t="",e=document.querySelectorAll("style,link"),n=0;n<e.length;n++)t+=e[n].outerHTML;return t+="<style>"+(this.options.noPrint||".no-print")+"{display:none;}</style>"},getHtml:function(){for(var t=document.querySelectorAll("input"),e=document.querySelectorAll("textarea"),n=document.querySelectorAll("select"),o=0;o<t.length;o++)"checkbox"==t[o].type||"radio"==t[o].type?1==t[o].checked?t[o].setAttribute("checked","checked"):t[o].removeAttribute("checked"):(t[o].type,t[o].setAttribute("value",t[o].value));for(var i=0;i<e.length;i++)"textarea"==e[i].type&&(e[i].innerHTML=e[i].value);for(var r=0;r<n.length;r++)if("select-one"==n[r].type){var c,l=n[r].children;for(c in l)"OPTION"==l[c].tagName&&(1==l[c].selected?l[c].setAttribute("selected","selected"):l[c].removeAttribute("selected"))}return this.dom.outerHTML},getTextHtml:function(){var t="";return this.options&&"string"==typeof this.options.text&&this.options.text?t=this.options.text:this.dom&&(t=this.dom.innerText||this.dom.textContent||""),"<style>@media print{body{margin:0;}pre{font-family:Consolas, 'Courier New', monospace;font-size:12px;line-height:1.25;white-space:pre-wrap;word-break:break-word;}}</style><pre>"+(t=String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"))+"</pre>"},writeIframe:function(t){var e,n=document.createElement("iframe"),o=document.body.appendChild(n),i=(n.id="myIframe",n.setAttribute("style","position:absolute;width:0;height:0;top:-10px;left:-10px;"),e=o.contentWindow||o.contentDocument,(o=o.contentDocument||o.contentWindow.document).open(),o.write(t),o.close(),this);n.onload=function(){i.toPrint(e),setTimeout(function(){document.body.removeChild(n)},100)}},toPrint:function(e){try{setTimeout(function(){e.focus();try{e.document.execCommand("print",!1,null)||e.print()}catch(t){e.print()}e.close()},10)}catch(t){console.log("err",t)}},isDOM:"object"==typeof HTMLElement?function(t){return t instanceof HTMLElement}:function(t){return t&&"object"==typeof t&&1===t.nodeType&&"string"==typeof t.nodeName}},{});MyPlugin.install=function(t,e){t.prototype.$print=Print};export default MyPlugin;