File Editor
Directories:
.. (Back)
Files:
customizer.min.asset.php
customizer.min.js
Create New File
Create
Edit File: customizer.min.js
!function(e,t,i){var a=i(document);function p(e){e.find(".invalid").removeClass("invalid"),e.find(".jetpack-simple-payments-widget-title").add(".jetpack-simple-payments-products").add(".jetpack-simple-payments-add-product").add(".jetpack-simple-payments-edit-product").add(".jetpack-simple-payments-save-product").add(".jetpack-simple-payments-cancel-form").add(".jetpack-simple-payments-delete-product").attr("disabled","disabled"),e.find(".jetpack-simple-payments-form").show()}function n(e){e.find(".jetpack-simple-payments-widget-title").add(".jetpack-simple-payments-products").removeAttr("disabled"),e.find(".jetpack-simple-payments-form").hide()}function s(e,t){e.find(".jetpack-simple-payments-form-action").val(t).change()}function d(e){var t=e.find(".jetpack-simple-payments-form").is(":visible"),i=e.find(".jetpack-simple-payments-products").is(":visible"),a="edit"===e.find(".jetpack-simple-payments-form-action").val();t?e.find(".jetpack-simple-payments-save-product").add(".jetpack-simple-payments-cancel-form").removeAttr("disabled"):e.find(".jetpack-simple-payments-add-product").removeAttr("disabled"),t&&a&&e.find(".jetpack-simple-payments-delete-product").removeAttr("disabled"),i&&!t&&e.find(".jetpack-simple-payments-edit-product").removeAttr("disabled")}function c(e){e.find(".jetpack-simple-payments-add-product").add(".jetpack-simple-payments-edit-product").add(".jetpack-simple-payments-save-product").add(".jetpack-simple-payments-cancel-form").add(".jetpack-simple-payments-delete-product").attr("disabled","disabled")}a.ready((function(){a.on("widget-added",(function(a,m){m.is('[id*="jetpack_simple_payments_widget"]')&&function(a){var m=a.find("> .widget-inside > .form, > .widget-inside > form");m.find(".jetpack-simple-payments-add-product").on("click",function(e){return function(t){t.preventDefault(),p(e),s(e,"add")}}(m)),m.find(".jetpack-simple-payments-edit-product").on("click",function(e){return function(t){t.preventDefault(),p(e),s(e,"edit")}}(m)),m.find(".jetpack-simple-payments-image-fieldset .placeholder, .jetpack-simple-payments-image > img").on("click",function(e){return function(i){i.preventDefault();var a=e.find(".jetpack-simple-payments-image"),p=new t.media.view.MediaFrame.Select({title:"Choose Product Image",multiple:!1,library:{type:"image"},button:{text:"Choose Image"}});p.on("select",(function(){var t=p.state().get("selection").first().toJSON();e.find(".jetpack-simple-payments-image-fieldset .placeholder").hide(),a.find("img").attr("src",t.url).show(),e.find(".jetpack-simple-payments-image").show(),e.find(".jetpack-simple-payments-form-image-id").val(t.id).change()})),p.open()}}(m)),m.find(".jetpack-simple-payments-remove-image").on("click",function(e){return function(t){t.preventDefault(),e.find(".jetpack-simple-payments-image-fieldset .placeholder").show(),e.find(".jetpack-simple-payments-image").hide(),e.find(".jetpack-simple-payments-form-image-id").val("").change()}}(m)),m.find(".jetpack-simple-payments-save-product").on("click",function(a){return function(p){p.preventDefault();var m=a.find(".jetpack-simple-payments-form-product-id").val();if(function(e){e.find(".invalid").removeClass("invalid");var t=!1,i=e.find(".jetpack-simple-payments-form-product-title").val();i||(e.find(".jetpack-simple-payments-form-product-title").addClass("invalid"),t=!0);var a=e.find(".jetpack-simple-payments-form-product-price").val();(!a||isNaN(a)||parseFloat(a)<=0)&&(e.find(".jetpack-simple-payments-form-product-price").addClass("invalid"),t=!0);var p,n="JPY"===e.find(".jetpack-simple-payments-form-product-currency").val()?0:2,s=(p=a.split(".")).length>2?null:p[1]?p[1].length:0;(null===s||s>n)&&(e.find(".jetpack-simple-payments-form-product-price").addClass("invalid"),t=!0);var d=e.find(".jetpack-simple-payments-form-product-email").val(),c=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(d);return d&&c||(e.find(".jetpack-simple-payments-form-product-email").addClass("invalid"),t=!0),!t}(a)){c(a),a.find(".spinner").show();var o=t.ajax.post("customize-jetpack-simple-payments-button-save",{"customize-jetpack-simple-payments-nonce":e.settings.nonce["customize-jetpack-simple-payments"],customize_changeset_uuid:e.settings.changeset.uuid,params:{product_post_id:m,post_title:a.find(".jetpack-simple-payments-form-product-title").val(),post_content:a.find(".jetpack-simple-payments-form-product-description").val(),image_id:a.find(".jetpack-simple-payments-form-image-id").val(),currency:a.find(".jetpack-simple-payments-form-product-currency").val(),price:a.find(".jetpack-simple-payments-form-product-price").val(),multiple:a.find(".jetpack-simple-payments-form-product-multiple").is(":checked")?1:0,email:a.find(".jetpack-simple-payments-form-product-email").val()}});o.done((function(e){var t=a.find("select.jetpack-simple-payments-products"),p=t.find('option[value="'+m+'"]');p.length>0?p.text(e.product_post_title):(t.append(i("<option>",{value:e.product_post_id,text:e.product_post_title})),t.val(e.product_post_id).change()),a.find(".jetpack-simple-payments-products-fieldset").show(),a.find(".jetpack-simple-payments-products-warning").hide(),s(a,"clear"),n(a)})),o.fail((function(e){var t={post_title:"product-title",price:"product-price",email:"product-email"};e.forEach((function(e){Object.hasOwn(t,e.code)&&a.find(".jetpack-simple-payments-form-"+t[e.code]).addClass("invalid")})),d(a)}))}}}(m)),m.find(".jetpack-simple-payments-cancel-form").on("click",function(e){return function(t){t.preventDefault(),n(e),e.find(".jetpack-simple-payments-add-product, .jetpack-simple-payments-edit-product").attr("disabled","disabled"),s(e,"clear")}}(m)),m.find(".jetpack-simple-payments-delete-product").on("click",function(a){return function(p){if(p.preventDefault(),confirm(jpSimplePaymentsStrings.deleteConfirmation)){var d=parseInt(a.find(".jetpack-simple-payments-form-product-id").val(),10);d&&(c(a),a.find(".spinner").show(),t.ajax.post("customize-jetpack-simple-payments-button-delete",{"customize-jetpack-simple-payments-nonce":e.settings.nonce["customize-jetpack-simple-payments"],customize_changeset_uuid:e.settings.changeset.uuid,params:{product_post_id:d}}).done((function(){var e=a.find("select.jetpack-simple-payments-products")[0];e.remove(e.selectedIndex),e.dispatchEvent(new Event("change")),0===i(e).has("option").length&&(a.find(".jetpack-simple-payments-products-fieldset").hide(),a.find(".jetpack-simple-payments-products-warning").show()),s(a,"clear"),n(a)})))}}}(m)),m.find("select, input, textarea, checkbox").on("change input propertychange",_.debounce((function(){c(m)}),250))}(m)})),a.on("widget-synced widget-updated",(function(a,p){if(p.is('[id*="jetpack_simple_payments_widget"]')){a.preventDefault(),t.ajax.post("customize-jetpack-simple-payments-buttons-get",{"customize-jetpack-simple-payments-nonce":e.settings.nonce["customize-jetpack-simple-payments"],customize_changeset_uuid:e.settings.changeset.uuid}).done((function(e){var t=0;i(document).find("select.jetpack-simple-payments-products").each((function(a,p){var n=i(p);t=n.val(),n.find("option").remove(),n.append(i.map(e,(function(e){return i("<option>",{value:e.ID,text:e.post_title})}))),n.val(t)}))}));var n=p.find("> .widget-inside > .form, > .widget-inside > form");d(n),function(e){var t=parseInt(e.find(".jetpack-simple-payments-form-image-id").val(),10),i=e.find(".jetpack-simple-payments-form-image-src").val(),a=e.find(".jetpack-simple-payments-image-fieldset .placeholder"),p=e.find(".jetpack-simple-payments-image > img"),n=e.find(".jetpack-simple-payments-image");t&&i?(p.attr("src",i),a.hide(),n.show()):(a.show(),p.removeAttr("src"),n.hide())}(n)}}))}))}(wp.customize,wp,jQuery);
Save Changes
Rename File
Rename