PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.12.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.12.3
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / assets / js / charitable.min.js

charitable.min.js in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.12.3, at assets/js/charitable.min.js

1 lines 11.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 CHARITABLE=window.CHARITABLE||{},function(t,e){var o=function(t){this.errors=[],this.pending_processes=[],this.form=t,this.pause_processing=!1,this.submit_processing=!1,this.total=0,this.prevent_scroll_to_top=!1;var o=this,n=e("body"),i=function(){return o.form.find(".charitable-terms-text").addClass("active"),!1},r=function(){e(this).closest("li").trigger("click").find("input[name=donation_amount]").prop("checked",!0).trigger("change"),o.form.off("focus","input.custom-donation-input",r),e(this).focus(),o.form.on("focus","input.custom-donation-input",r)},a=function(){n.trigger("charitable:form:amount:changed",o),n.trigger("charitable:form:total:changed",o)},s=function(){var t=o.unformat_amount(e(this).val());e.trim(t)>0&&e(this).val(o.format_amount(t)),a()},c=function(){var t=e(this).closest("li");t.hasClass("selected")||(t.parents(".charitable-donation-form").find(".donation-amount.selected").removeClass("selected"),t.addClass("selected").find("[name=donation_amount]").prop("checked",!0),t.hasClass("custom-donation-amount")&&t.find("input.custom-donation-input").focus(),a())},d=function(){var t=e(this).val();o.hide_inactive_payment_methods(),o.show_active_payment_methods(t),"square"!==t&&"square_core"!==t||setTimeout(function(){window.dispatchEvent(new Event("resize"))},100)},u=function(){e(this).parent().addClass("charitable-hidden")},l=function(t){var e=t.data.helper;return!e.submit_processing&&(e.submit_processing=!0,e.show_processing(),!1===e.validate()?(e.cancel_processing(),!1):!1===e.pause_processing&&(1!==e.form.data("use-ajax")||(_(e,function(){n.trigger("charitable:form:process",e)}),!1)))},_=function(t,e){t.waiting()?setTimeout(_,500,t,e):t.get_errors().length>0?t.cancel_processing():e()},f=function(t,o){var i=o.get_data();o.form;return i.action="make_donation",i.form_action=i.charitable_action,delete i.charitable_action,e.ajax({type:"POST",data:i,dataType:"json",url:CHARITABLE_VARS.ajaxurl,timeout:0,xhrFields:{withCredentials:!0},success:function(t){n.trigger("charitable:form:processed",[t,o]),t.success?_(o,function(){window.location.href=t.redirect_to}):(o.cancel_processing(t.errors),t.donation_id&&o.set_donation_id(t.donation_id))}}).fail(function(t,e,n){window.console&&window.console.log&&console.log(t),o.cancel_processing([CHARITABLE_VARS.error_unknown])}),!1};o.form.on("click",".donation-amount",c),o.form.on("focus","input.custom-donation-input",r),o.form.on("click",".charitable-terms-link",i),o.form.on("blur",".custom-donation-input",s),o.form.find(".donation-amount input:checked").each(function(){e(this).closest("li").addClass("selected")}),o.get_all_payment_methods().length&&(o.hide_inactive_payment_methods(),o.form.on("change","#charitable-gateway-selector input[name=gateway]",d)),o.form.on("click",".change-donation",u),o.form.on("submit",{helper:o},l),!1===CHARITABLE.forms_initialized&&(n.on("charitable:form:process",f),n.trigger("charitable:form:initialize",o),CHARITABLE.forms_initialized=!0),n.trigger("charitable:form:loaded",o)};o.prototype.get_input=function(t){return this.form.find("[name="+t+"]")},o.prototype.get_email=function(){return this.form.find("[name=email]").val()},o.prototype.is_recurring_donation=function(){var t=this.form.find("[name=recurring_donation]:checked, [name=recurring_donation][type=hidden]");return t.length&&"once"!==t.val()},o.prototype.get_suggested_amount=function(){return accounting.unformat(this.form.find("[name=donation_amount]:checked, input[type=hidden][name=donation_amount]").val(),CHARITABLE_VARS.currency_format_decimal_sep)},o.prototype.get_custom_amount=function(){var t=this.form.find(".charitable-donation-options.active input.custom-donation-input,.charitable-donation-options.active input.custom-donation-amount");return 0===t.length&&(t=this.form.find("input.custom-donation-input")),accounting.unformat(t.val(),CHARITABLE_VARS.currency_format_decimal_sep)},o.prototype.get_subtotal=function(){return this.get_suggested_amount()||this.get_custom_amount()},o.prototype.get_amount=function(){return this.total=this.get_subtotal(),this.form.trigger("charitable:form:get_amount",this),this.total},o.prototype.add_amount=function(t){this.total+=t},o.prototype.remove_amount=function(t){this.total-=t},o.prototype.get_description=function(){return this.form.find("[name=description]").val()||""},o.prototype.get_cc_number=function(){return this.form.find("#charitable_field_cc_number input").val()||""},o.prototype.get_cc_cvc=function(){return this.form.find("#charitable_field_cc_cvc input").val()||""},o.prototype.get_cc_expiry_month=function(){return this.form.find("#charitable_field_cc_expiration select.month").val()||""},o.prototype.get_cc_expiry_year=function(){return this.form.find("#charitable_field_cc_expiration select.year").val()||""},o.prototype.clear_cc_fields=function(){this.form.find("#charitable_field_cc_number input, #charitable_field_cc_name input, #charitable_field_cc_cvc input, #charitable_field_cc_expiration select").removeAttr("name")},o.prototype.get_payment_method=function(){return this.form.find("[type=hidden][name=gateway], [name=gateway]:checked").val()||""},o.prototype.get_all_payment_methods=function(){return this.form.find("#charitable-gateway-selector input[name=gateway]")},o.prototype.hide_inactive_payment_methods=function(){var t=this.get_payment_method(),e=this.form.find(".charitable-gateway-fields[data-gateway!="+t+"]");e.hide(),e.find("input[required],select[required],textarea[required]").attr("data-required",1).attr("required",!1)},o.prototype.show_active_payment_methods=function(t){t=t||this.get_payment_method();var e=this.form.find(".charitable-gateway-fields[data-gateway="+t+"]");e.show(),e.find("[data-required]").attr("required",!0)},o.prototype.format_amount=function(t,e){return void 0===e&&(e=""),accounting.formatMoney(t,{symbol:e,decimal:CHARITABLE_VARS.currency_format_decimal_sep,thousand:CHARITABLE_VARS.currency_format_thousand_sep,precision:CHARITABLE_VARS.currency_format_num_decimals,format:CHARITABLE_VARS.currency_format}).trim()},o.prototype.unformat_amount=function(t){var e=CHARITABLE_VARS.currency_format_decimal_sep;(t=String(t),"."!==e&&-1!==t.indexOf(".")&&-1===t.indexOf(e))&&(1!==(t.match(/\./g)||[]).length||/\.\d{3}$/.test(t)||(t=t.replace(".",e)));return Math.abs(parseFloat(accounting.unformat(t,e)))},o.prototype.add_error=function(t){this.errors.push(t)},o.prototype.get_errors=function(){return this.errors},o.prototype.get_error_message=function(){return this.errors.join(" ")},o.prototype.print_errors=function(t){var e=t||this.errors,o=e.length,n="",i=void 0===CHARITABLE_VARS.error_notice_donation_display?"top":CHARITABLE_VARS.error_notice_donation_display;0!==o&&(this.form.find(".charitable-form-errors").length&&this.form.find(".charitable-form-errors").remove(),n+='<div class="charitable-form-errors charitable-notice"><ul class="errors"><li>',n+=e.join("</li><li>"),n+="</li></ul></div>","bottom"===i?this.form.append(n):this.form.prepend(n))},o.prototype.clear_errors=function(){this.errors=[],this.form.find(".charitable-form-errors").length&&this.form.find(".charitable-form-errors").remove()},o.prototype.waiting=function(){return this.pending_processes.length>0},o.prototype.add_pending_process=function(t){var e=this.pending_processes.indexOf(t);return-1===e?this.pending_processes.push(t)-1:e},o.prototype.remove_pending_process=function(t){this.pending_processes.splice(t,1)},o.prototype.remove_pending_process_by_name=function(t){var e=this.pending_processes.indexOf(t);return-1!==e&&this.remove_pending_process(e)},o.prototype.show_processing=function(){this.form.find(".charitable-form-processing").show(),this.form.find('button[name="donate"]').hide()},o.prototype.hide_processing=function(){this.form.find(".charitable-form-processing").hide(),this.form.find('button[name="donate"]').show(),this.submit_processing=!1,this.pause_processing=!1},o.prototype.scroll_to_top=function(){if(this.prevent_scroll_to_top)this.prevent_scroll_to_top=!1;else{var t=this.form.parents(".charitable-modal");t.length?t.scrollTop(0):window.scrollTo(this.form.offset().left,this.form.offset().top)}},o.prototype.cancel_processing=function(t){this.hide_processing(),this.print_errors(t);var e=void 0===CHARITABLE_VARS.error_notice_donation_display?"top":CHARITABLE_VARS.error_notice_donation_display;""!==e&&"top"!==e||this.scroll_to_top(),this.form.trigger("charitable:form:cancelled",this)},o.prototype.set_donation_id=function(t){this.form.find("[name=ID]").val(t)},o.prototype.get_data=function(){return this.form.serializeArray().reduce(function(t,e){if("[]"===e.name.slice(-2)){var o=e.name.slice(0,-2);t.hasOwnProperty(o)||(t[o]=[]),t[o].push(e.value)}else t[e.name]=e.value;return t},{})},o.prototype.get_required_fields=function(){var t=this.form.find(".charitable-fieldset .required-field").not("#charitable-gateway-fields .required-field"),o=this.get_payment_method();if(""!==o){var n=this.form.find("[data-gateway="+o+"] .required-field");n.length&&(t=e.merge(t,n))}return t},o.prototype.subtotal_exceeds_maximum=function(){return""!==CHARITABLE_VARS.maximum_donation&&this.get_subtotal()>parseFloat(CHARITABLE_VARS.maximum_donation)},o.prototype.is_valid_amount=function(){var t=parseFloat(CHARITABLE_VARS.minimum_donation);return!this.subtotal_exceeds_maximum()&&(t>0||CHARITABLE_VARS.permit_0_donation?this.get_subtotal()>=t:this.get_subtotal()>t)},o.prototype.validate_amount=function(){return!1!==this.is_valid_amount()||(this.get_subtotal()>0&&this.subtotal_exceeds_maximum()?this.add_error(CHARITABLE_VARS.error_max_exceeded):this.add_error(CHARITABLE_VARS.error_invalid_amount),!1)},o.prototype.validate_required_fields=function(){var t=!0;return this.get_required_fields().each(function(){""===e(this).find("input, select, textarea").val()&&(t=!1)}),t||this.add_error(CHARITABLE_VARS.error_required_fields),t},o.prototype.validate=function(){return this.clear_errors(),this.validate_amount(),this.validate_required_fields(),this.form.trigger("charitable:form:validate",this),0===this.errors.length},t.Donation_Form=o}(CHARITABLE,jQuery),function(t,e){t.Toggle=function(){var o=function(){n(e(this)).addClass("charitable-hidden")},n=function(t){var o=t.data("charitable-toggle");return"."!==o[0]&&"#"!==o[0]&&(o="#"+o),e(o)},i=function(){e("[data-charitable-toggle]").each(o)};if(e("body").on("click","[data-charitable-toggle]",function(){var t=e(this),o=n(t);return o.toggleClass("charitable-hidden",t.is(":checkbox")?!t.is(":checked"):!1===o.hasClass("charitable-hidden")),!1}),t.content_loading)var r=setInterval(function(){!1===t.content_loading&&(i(),clearInterval(r))},500);return i}()}(CHARITABLE,jQuery),CHARITABLE.VersionCompare=function(t,e){if(typeof t+typeof(e=e||CHARITABLE_VARS.version)!="stringstring")return!1;for(var o=t.split("."),n=e.split("."),i=0,r=Math.max(o.length,n.length);i<r;i++){if(o[i]&&!n[i]&&parseInt(o[i])>0||parseInt(o[i])>parseInt(n[i]))return 1;if(n[i]&&!o[i]&&parseInt(n[i])>0||parseInt(o[i])<parseInt(n[i]))return-1}return 0},function(t,e){CHARITABLE.ResetSuggestedDonations=function(){if(e(".charitable-donation-options").length=0)return!1;e('ul.donation-amounts input[type="radio"]').each(function(){e(this).is(":checked")?e(this).closest("li").addClass("selected"):e(this).closest("li").removeClass("selected")})}}(CHARITABLE,jQuery),function(t){CHARITABLE.forms_initialized=!1,t(document).ready(function(){t("html").addClass("js");var e=[];t(".charitable-donation-form").each(function(){e.push(new CHARITABLE.Donation_Form(t(this)))}),CHARITABLE.Toggle(),CHARITABLE.ResetSuggestedDonations()})}(jQuery);