1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/public/build/assets/payment-0ace5bfa.js

10 lines
2.3 KiB
JavaScript
Raw Normal View History

2023-09-26 00:24:51 +02:00
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/class s{constructor(e,t){this.shouldDisplayTerms=e,this.shouldDisplaySignature=t,this.termsAccepted=!1,this.submitting=!1}handleMethodSelect(e){document.getElementById("company_gateway_id").value=e.dataset.companyGatewayId,document.getElementById("payment_method_id").value=e.dataset.gatewayTypeId,this.shouldDisplaySignature&&!this.shouldDisplayTerms&&(this.signaturePad&&this.signaturePad.isEmpty()&&alert("Please sign"),this.displayTerms(),document.getElementById("accept-terms-button").addEventListener("click",()=>{this.termsAccepted=!0,this.submitForm()})),!this.shouldDisplaySignature&&this.shouldDisplayTerms&&(this.displaySignature(),document.getElementById("signature-next-step").addEventListener("click",()=>{document.querySelector('input[name="signature"').value=this.signaturePad.toDataURL(),this.submitForm()})),this.shouldDisplaySignature&&this.shouldDisplayTerms&&(this.displaySignature(),document.getElementById("signature-next-step").addEventListener("click",()=>{this.displayTerms(),document.getElementById("accept-terms-button").addEventListener("click",()=>{document.querySelector('input[name="signature"').value=this.signaturePad.toDataURL(),this.termsAccepted=!0,this.submitForm()})})),!this.shouldDisplaySignature&&!this.shouldDisplayTerms&&this.submitForm()}submitForm(){this.submitting=!0,document.getElementById("payment-form").submit()}displayTerms(){document.getElementById("displayTermsModal").removeAttribute("style")}displaySignature(){document.getElementById("signature-next-step").disabled=!0,document.getElementById("displaySignatureModal").removeAttribute("style");const t=new SignaturePad(document.getElementById("signature-pad"),{penColor:"rgb(0, 0, 0)"});t.onEnd=function(){document.getElementById("signature-next-step").disabled=!1},this.signaturePad=t}handle(){document.querySelectorAll(".dropdown-gateway-button").forEach(e=>{e.addEventListener("click",()=>{this.submitting||this.handleMethodSelect(e)})})}}const i=document.querySelector('meta[name="require-invoice-signature"]').content,a=document.querySelector('meta[name="show-invoice-terms"]').content;new s(!!+i,!!+a).handle();