abbott_2024_event/Line/assets/javascript/pages/invoice-demo.min.js

3 lines
1.5 KiB
JavaScript

"use strict";function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,n){for(var i=0;i<n.length;i++){var t=n[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function _createClass(e,n,i){return n&&_defineProperties(e.prototype,n),i&&_defineProperties(e,i),e}var InvoiceDemo=function(){function e(){_classCallCheck(this,e),this.worker="",this.init()}return _createClass(e,[{key:"init",value:function(){this.generateInvoice(),this.handleUpdate(),this.handleDownload()}},{key:"generateInvoice",value:function(){var e=html2pdf(),n=document.getElementById("invoice"),i=$(n),t=i.parent(),o=i.data("id"),a=$("<img />");e.from(n).toImg().then(function(){i.css("display","none"),a.prop("alt",o).prop("src",e.prop.img.src).addClass("invoice-img").css("max-width","".concat(i.outerWidth(),"px")),t.append(a)}),this.worker=e}},{key:"savePdf",value:function(){var e=document.getElementById("invoice"),n=$(e).data("id");this.worker.from(e).toPdf().save(n)}},{key:"handleUpdate",value:function(){var i=this,t=$("#invoice");$("#update-invoice").on("click",function(e){var n=$(".invoice-img");t.css("display","").find(".invoice-body").append("<hr />"),n.remove(),i.generateInvoice()})}},{key:"handleDownload",value:function(){var n=this;$("#download-pdf").on("click",function(e){e.preventDefault(),n.savePdf()})}}]),e}();$(document).on("theme:init",function(){new InvoiceDemo});
//# sourceMappingURL=../../sourcemaps/pages/invoice-demo.min.js.map