OwlCyberSecurity - MANAGER
Edit File: give-sequoia-template.js
!function(e){window.sequoiaTemplateL10n;const t=window.sequoiaTemplateOptions,i=e(".give-embed-form"),a=e(".advance-btn",i),n=e(".back-btn"),o=e(".give-form-navigator .title"),r=e("#give-payment-mode-select");let s=!1;const{wp:c}=window.parent;c&&c.data&&i.on("click",(function(){const e=window.frameElement.closest(".wp-block").getAttribute("data-block");c.data.dispatch("core/block-editor").selectBlock(e)}));const l=window.formNavigator={currentStep:"enabled"===t.introduction.enabled?0:1,animating:!1,firstFocus:!1,goToStep:a=>{const n=d[a].title?e(d[a].selector).height()+50:e(d[a].selector).height(),r=d[l.currentStep].title?e(d[l.currentStep].selector).height()+50:e(d[l.currentStep].selector).height();n>r?e(".give-form-templates").css("min-height",`${n+123}px`):setTimeout((function(){e(".give-form-templates").css("min-height",`${n+123}px`)}),200),e(".step-tracker").removeClass("current"),e('.step-tracker[data-step="'+a+'"]').addClass("current"),"disabled"===t.introduction.enabled?(3===e(".step-tracker").length&&e(".step-tracker").remove(),1===(a=a>0?a:1)?e(".back-btn",i).hide():e(".back-btn",i).show(),e(".give-form-navigator",i).addClass("nav-visible"),e(d[a].selector).css("padding-top","50px")):0===a?(e(".give-form-navigator",i).removeClass("nav-visible"),e(d[a].selector).css("padding-top","")):(e(".give-form-navigator",i).addClass("nav-visible"),e(d[a].selector).css("padding-top","50px"),S()),d[a].title&&o.text(d[a].title);const s=d.map(((e,t)=>t===a||t===l.currentStep?null:e.selector)).filter(Boolean).join(", ");if(e(s).hide(),l.currentStep!==a){const t="slide-in-right slide-in-left slide-out-right slide-out-left",i=l.currentStep<a?"left":"right",n=l.currentStep<a?"right":"left";e(d[l.currentStep].selector).removeClass(t).addClass(`slide-out-${i}`),e(d[a].selector).show().removeClass(t).addClass(`slide-in-${n}`)}l.currentStep=a,setTimeout((function(){if(_(),!l.firstFocus&&"disabled"===t.introduction.enabled)return l.firstFocus=!0;d[l.currentStep].firstFocus&&e(d[l.currentStep].firstFocus).trigger("focus")}),200)},init:()=>{d.forEach((t=>{void 0!==t.setup&&t.setup(),e(t.selector).css("position","absolute")})),a.on("click",(function(e){e.preventDefault(),l.forward()})),n.on("click",(function(e){e.preventDefault(),l.back()})),e(".step-tracker").on("click",(function(t){t.preventDefault(),l.goToStep(parseInt(e(t.target).attr("data-step")))})),function(){let t=0;window.requestAnimationFrame((function i(){const a=e(d[l.currentStep].selector);var n;t!==e(a).outerHeight()&&(n=e(a).outerHeight(),!1===s?e(".form-footer").css("transition","margin-top 0.2s ease"):e(".form-footer").css("transition",""),e(".form-footer").css("margin-top",`${n}px`),t=e(a).outerHeight()),window.requestAnimationFrame(i)}))}(),e(".give-fee-recovery-donors-choice").parent().hasClass("give-form")&&e("#give_checkout_user_info").after(e(".give-fee-recovery-donors-choice")),l.goToStep(Give.fn.getParameterByName("showDonationProcessingError")||Give.fn.getParameterByName("showFailedDonationError")?2:0)},back:()=>{const e=0!==l.currentStep?l.currentStep-1:0;l.goToStep(e),l.currentStep=e},forward:()=>{const e=null!==l.currentStep?l.currentStep+1:1;l.goToStep(e),l.currentStep=e}},d=[{id:"introduction",title:null,selector:".give-section.introduction",label:t.introduction.donate_label,showErrors:!1,tabOrder:[".introduction .advance-btn",".step-tracker"]},{id:"choose-amount",title:t.payment_amount.header_label,selector:".give-section.choose-amount",label:t.payment_amount.next_label,showErrors:!1,tabOrder:["select.give-cs-select-currency","input.give-amount-top",".give-donation-levels-wrap button",".give-recurring-period",".give-recurring-donors-choice-period",".give_fee_mode_checkbox",".choose-amount .advance-btn",".step-tracker",".back-btn"],firstFocus:".give-default-level",setup:()=>{const t=e(".give-donation-level-btn").length;1===t?e(".give-donation-levels-wrap").attr("style","display: none!important;"):t%2==0&&t<6&&e(".give-donation-levels-wrap").css("grid-template-columns","repeat(2, minmax(0, 1fr))"),e("#give-amount").on("blur",(function(){Give.form.fn.isValidDonationAmount(e("form"))?e(".advance-btn").attr("disabled",!1):e(".advance-btn").attr("disabled",!0)})),e(".give-donation-level-btn").each((function(){if(e(this).attr("has-tooltip"))return;const t=e(this).attr("value"),i=e(this).text(),a=e("form"),n=Give.form.fn.getInfo("currency_symbol",a),o=Give.form.fn.getInfo("currency_position",a);if("custom"!==t){const i="before"===o?`<div class="currency currency--before">${n}</div>${t}`:`${t}<div class="currency currency--after">${n}</div>`;e(this).html(i)}if("custom"!==t&&i!==("before"===o?n+t:t+n)){const t=document.createElement("span");t.classList.add("give-tooltip","hint--top","hint--bounce"),i.length<50&&t.classList.add("narrow"),t.style.width="100%",t.setAttribute("aria-label",i.length<50?i:i.substr(0,50)+"..."),e(this).wrap(t),e(this).attr("has-tooltip",!0)}}))}},{id:"payment",title:t.payment_information.header_label,label:t.payment_information.checkout_label,selector:".give-section.payment",showErrors:!0,tabOrder:[".payment input, .payment a, .payment button, .payment select, .payment multiselect, .payment textarea, .payment .button",".give-submit",".step-tracker",".back-btn"],firstFocus:"#give-first",setup:()=>{e(".give-section.payment").on("click",".give-cancel-login, .give-checkout-register-cancel",k),e(".give-section.payment").on("click touchend",'input[name="give_login_submit"]',(function(){e('input[name="give_login_submit"] + .give-loading-animation').removeClass("give-loading-animation").addClass("sequoia-loader spinning")})),window.give_global_vars.purchase_loading="",e(".give_error").each((function(){u(e(this))})),w({container:"#give-anonymous-donation-wrap label",label:"#give-anonymous-donation-wrap label",input:"#give-anonymous-donation"}),w({container:".give-recurring-donors-choice",label:".give-recurring-donors-choice label",input:'input[name="give-recurring-period"]'}),w({container:".give-fee-recovery-donors-choice",label:".give-fee-message-label-text",input:'input[name="give_fee_mode_checkbox"]'}),w({container:".give-activecampaign-fieldset",label:".give-activecampaign-optin-label",input:".give-activecampaign-optin-input"}),w({container:".give-mailchimp-fieldset",label:".give-mc-message-text",input:'input[name="give_mailchimp_signup"]'}),w({container:".give-constant-contact-fieldset",label:".give-constant-contact-fieldset span",input:'input[name="give_constant_contact_signup"]'}),w({container:"#give_terms_agreement",label:"#give_terms_agreement label",input:'input[name="give_agree_to_terms"]'}),e("body.give-form-templates").on("click touchend",'form.give-form input[name="give-purchase"].give-submit',(function(){e("#give-purchase-button + .give-loading-animation").removeClass("give-loading-animation").addClass("sequoia-loader"),e("form").get(0).checkValidity()&&e(".sequoia-loader").addClass("spinning")})),e("body.give-form-templates").on("click touchend","#give_error_invalid_donation_maximum",(function(){l.goToStep(1)})),e("body.give-form-templates").on("click touchend","#give_error_invalid_donation_amount",(function(){l.goToStep(1)})),e("#give-gateway-radio-list li").each((function(){let t;switch(e("input",this).val()){case"manual":t="fas fa-tools";break;case"offline":t="fas fa-wallet";break;case"paypal":t="fab fa-paypal";break;case"stripe":case"stripe_checkout":case"paypalpro_payflow":case"paypal-commerce":t="far fa-credit-card";break;case"stripe_sepa":case"stripe_ach":case"stripe_ideal":case"stripe_becs":t="fas fa-university";break;case"stripe_google_pay":t="fab fa-google";break;case"stripe_apple_pay":t="fab fa-apple";break;default:t="fas fa-hand-holding-heart"}e(this).append(`<i class="${t}"></i>`)})),f(),b(),new window.MutationObserver((function(t){t.forEach((function(t){if(t.addedNodes)for(let i=0;i<t.addedNodes.length;i++){const a=t.addedNodes[i];if(e(a).find(".give_error").length>0&&(u(e(a).find(".give_error")),S()),e(a).children().hasClass("give_errors")&&(e(a).parent().hasClass("donation-errors")||e(a).children(".give_errors").each((function(){u(e(this))})),S()),e(a).hasClass("give_errors")&&!e(a).parent().hasClass("donation-errors")&&(u(e(a)),e(".sequoia-loader").removeClass("spinning"),S()),"give_tributes_address_state"===e(a).attr("id")){const t=e(a).attr("placeholder");e(a).prepend(`<option selected disabled>${t}</option>`)}if("give_tributes_address_state"===e(a).attr("name")&&e(a).attr("class").includes("give-input")&&e(a).attr("placeholder",e(a).siblings("label").text().trim()),e(a).attr("id")&&e(a).attr("id").includes("give-checkout-login-register")&&(g(),b()),e(a).prop("tagName")&&"select"===e(a).prop("tagName").toLowerCase()){const t=e(a).attr("placeholder");t&&e(a).prepend(`<option value="" disabled selected>${t}</option>`)}e(a).find(".required[placeholder]").length&&p(Array.from(e(a).get(0).querySelectorAll(".required[placeholder]")))}}))})).observe(document.body,{childList:!0,subtree:!0,attributes:!1,characterData:!1})}}];function p(e){e.map((function(e){"*"!==e.placeholder.trim().slice(-1)&&(e.placeholder=`${e.placeholder.trim()}*`)}))}function u(t){e(t).parent().hasClass("give-stripe-payment-request-button")||(0===e(".donation-errors").length&&e(".payment").prepend('<div class="donation-errors"></div>'),setTimeout((function(){void 0===typeof e(".donation-errors").html()||e(".donation-errors").html().includes(e(t).html())?e(t).remove():e(t).appendTo(".donation-errors")}),1))}function g(){const t=function(t){e(t.target).is("input")&&(e(t.target).hasClass("give-disabled")||e(t.target).closest("label").toggleClass("checked"))};e('[id*="give-register-account-fields"]').off("click",t).on("click",t)}function f(){e("#give-ffm-section").off("click",m).on("click",m),e("#give-ffm-section input").each((function(){switch(e(this).prop("type")){case"checkbox":e(this).prop("checked")?e(this).parent().addClass("checked"):e(this).parent().removeClass("checked");break;case"radio":e(this).prop("checked")?e(this).parent().addClass("selected"):e(this).parent().removeClass("selected")}}))}function m(t){if(e(t.target).is("input"))switch(e(t.target).prop("type")){case"checkbox":e(t.target).closest("label").toggleClass("checked");break;case"radio":e(t.target).closest("label").addClass("selected"),e(t.target).parent().siblings().removeClass("selected")}}function v(){0===e("#donate-fieldset").length&&e(".give-section.payment").append('<fieldset id="donate-fieldset"></fieldset>'),[".give-constant-contact-fieldset",".give-activecampaign-fieldset",".give-mailchimp-fieldset","#give_terms_agreement",".give-donation-submit"].forEach((function(t){0===e(`#donate-fieldset ${t}`).length||e(`#donate-fieldset ${t}`).html()!==e(`#give_purchase_form_wrap ${t}`).html()&&void 0!==e(`#give_purchase_form_wrap ${t}`).html()?(e(`#donate-fieldset ${t}`).remove(),e("#donate-fieldset").append(e(`#give_purchase_form_wrap ${t}`))):e(`#give_purchase_form_wrap ${t}`).remove()})),e("li.give-gateway-option-selected").after(e("#give_purchase_form_wrap"));const t="gateway-"+e(".give-gateway-option-selected input").attr("value").replace("_","-");e("#give_purchase_form_wrap").attr("class",t)}function h(t,i){e(t).each((function(){if(""!==e(this).html()&&!1===e(this).html().includes(`<i class="fas fa-${i}"></i>`)){const t="rtl"===e("html").attr("dir")?"padding-right":"padding-left";e(this).prepend(`<i class="fas fa-${i}"></i>`),e(this).children("input, selector").each((function(){e(this).attr("style",t+": 33px!important;")}))}}))}function b(){h("#give-first-name-wrap","user"),h("#give-email-wrap","envelope"),h("#give-company-wrap","building"),h("#date_field-wrap","calendar-alt"),h("#url_field-wrap","globe"),h("#phone_field-wrap","phone"),h("#give-phone-wrap","phone"),h("#email_field-wrap","envelope")}function _(){e("select, button, input, textarea, multiselect, a").attr("tabindex",-1),d[l.currentStep].tabOrder.forEach(((t,i)=>{e(t).attr("tabindex",i+1)}))}function y(){const t=document.querySelectorAll('[data-field-type="checkbox"] input'),i=document.querySelectorAll('[data-field-type="radio"] input');Array.from(t).forEach((e=>{const t=`#${e.getAttribute("id")}`,i=`label[for=${e.getAttribute("id")}]`;w({container:i,label:i,input:t})})),Array.from(i).forEach((t=>{const i=`#${t.getAttribute("id")}`;!function({label:t,input:i}){!0===e(i).prop("checked")&&e(t).addClass("active"),e(document).on("click",t,(function(t){"INPUT"!==t.target.nodeName&&(e(t.target.parentElement).find("label").not(t.target).removeClass("active"),e(t.target).toggleClass("active"))}))}({label:`label[for=${t.getAttribute("id")}]`,input:i})}))}function w({container:t,label:i,input:a}){!0===e(a).prop("checked")&&e(t).addClass("active"),e(document).on("click",i,(function(i){"INPUT"!==i.target.nodeName&&e(t).toggleClass("active")}))}function k(){e("#give_error_must_log_in").remove()}function C(){e('select option[selected="selected"][value=""]').length>0&&e('select option[selected="selected"][value=""]').each((function(){e(this).parent().siblings("label").length&&(e(this).text(e(this).parent().siblings("label").text().replace("*","").trim()),e(this).attr("disabled",!0))}))}function S(){"parentIFrame"in window&&window.parentIFrame.sendMessage({action:"giveScrollIframeInToView"})}l.init(),r.length&&"none"!==r.css("display")?(v(),e(document).on("give_gateway_loaded",(function(){setTimeout(_,200),v(),y(),g(),f(),b(),C(),e("#give_purchase_form_wrap").slideDown(200,(function(){s=!1}))})),e(document).on("Give:onPreGatewayLoad",(function(){s=!0,e("#give_purchase_form_wrap").slideUp(200)})),e(document).on("Give:onPreGatewayLoad",(function(){const t=["give_error_test_mode"];e(".give_errors, .give_notices, .give_error").each((function(){t.includes(e(this).attr("id"))||e(this).slideUp(200,(function(){e(this).remove()}))}))}))):e("#give_purchase_form_wrap").addClass("give-single-gateway-wrap"),e(document).on("give_gateway_loaded",(function(t,i,a){2===l.currentStep&&e(".give-form-templates").css("min-height","");const n=e(`#${a}`);if(n.parent().hasClass("give-embed-form")){const t={action:"give_cancel_login",form_id:n.find('[name="give-form-id"]').val()};e.post(Give.fn.getGlobalVar("ajaxurl"),t,(function(t){const i=n.find("[id^=give-checkout-login-register]");i.length&&t.fields.includes("give_checkout_user_info")&&n.find("#give_checkout_user_info").remove(),i.replaceWith(e.parseJSON(t.fields)),i.css({display:"block"}),n.find(".give-submit-button-wrap").show()})).done((function(){window.give_fl_trigger(),b()}))}})),y(),C(),g(),f(),b(),p(Array.from(document.querySelectorAll(".give-form .required[placeholder]")))}(jQuery),document.addEventListener("readystatechange",(function(e){if("complete"!==e.target.readyState)return;const t=document.querySelectorAll('[data-field-type="checkbox"] input'),i=document.querySelectorAll('[data-field-type="radio"] input'),a=e=>{e.checked?e.parentElement.classList.add("active"):e.parentElement.classList.remove("active")};t.forEach(a),i.forEach(a)}));