mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
10 lines
2.2 KiB
JavaScript
Vendored
10 lines
2.2 KiB
JavaScript
Vendored
/**
|
|
* 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.shouldDisplaySignature=e,this.shouldDisplayTerms=t,this.termsAccepted=!1}submitForm(){document.getElementById("approve-form").submit()}displaySignature(){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}displayTerms(){document.getElementById("displayTermsModal").removeAttribute("style")}handle(){document.getElementById("signature-next-step").disabled=!0,document.getElementById("close-button").addEventListener("click",()=>{const e=document.getElementById("approve-button");e&&(e.disabled=!1)}),document.getElementById("approve-button").addEventListener("click",()=>{console.log("accepted "),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.displaySignature(),document.getElementById("signature-next-step").addEventListener("click",()=>{document.querySelector('input[name="signature"').value=this.signaturePad.toDataURL(),this.submitForm()})),!this.shouldDisplaySignature&&this.shouldDisplayTerms&&(this.displayTerms(),document.getElementById("accept-terms-button").addEventListener("click",()=>{this.termsAccepted=!0,this.submitForm()})),!this.shouldDisplaySignature&&!this.shouldDisplayTerms&&this.submitForm()})}}const n=document.querySelector('meta[name="require-purchase_order-signature"]').content,i=document.querySelector('meta[name="show-purchase_order-terms"]').content;new s(!!+n,!!+i).handle();
|