WordPress/wp-includes/js/wp-ajax-response.min.js
Sergey Biryukov b65d83b872 External Libraries: Further fix jQuery deprecations in WordPress core.
This includes many minor adjustments to a wide array of core files to replace shorthands with full declarations.

Follow-up to [50001], [50270], [50367].

Props Clorith, hellofromTonya, peterwilsoncc, adamsilverstein, aristath.
See #51812.
Built from https://develop.svn.wordpress.org/trunk@50420


git-svn-id: http://core.svn.wordpress.org/trunk@50031 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-23 19:45:04 +00:00

2 lines
2.0 KiB
JavaScript

/*! This file is auto-generated */
window.wpAjax=jQuery.extend({unserialize:function(e){var r,t,n,a,i={};if(!e)return i;for(n in t=(e=(r=e.split("?"))[1]?r[1]:e).split("&"))"function"==typeof t.hasOwnProperty&&!t.hasOwnProperty(n)||(i[(a=t[n].split("="))[0]]=a[1]);return i},parseAjaxResponse:function(a,e,i){var o={},e=jQuery("#"+e).empty(),s="";return a&&"object"==typeof a&&a.getElementsByTagName("wp_ajax")?(o.responses=[],o.errors=!1,jQuery("response",a).each(function(){var e=jQuery(this),r=jQuery(this.firstChild),n={action:e.attr("action"),what:r.get(0).nodeName,id:r.attr("id"),oldId:r.attr("old_id"),position:r.attr("position")};n.data=jQuery("response_data",r).text(),n.supplemental={},jQuery("supplemental",r).children().each(function(){n.supplemental[this.nodeName]=jQuery(this).text()}).length||(n.supplemental=!1),n.errors=[],jQuery("wp_error",r).each(function(){var e=jQuery(this).attr("code"),r={code:e,message:this.firstChild.nodeValue,data:!1},t=jQuery('wp_error_data[code="'+e+'"]',a);t&&(r.data=t.get()),(t=jQuery("form-field",t).text())&&(e=t),i&&wpAjax.invalidateForm(jQuery("#"+i+' :input[name="'+e+'"]').parents(".form-field:first")),s+="<p>"+r.message+"</p>",n.errors.push(r),o.errors=!0}).length||(n.errors=!1),o.responses.push(n)}),s.length&&e.html('<div class="error">'+s+"</div>"),o):isNaN(a)?!e.html('<div class="error"><p>'+a+"</p></div>"):-1===(a=parseInt(a,10))?!e.html('<div class="error"><p>'+wpAjax.noPerm+"</p></div>"):0!==a||!e.html('<div class="error"><p>'+wpAjax.broken+"</p></div>")},invalidateForm:function(e){return jQuery(e).addClass("form-invalid").find("input").one("change wp-check-valid-field",function(){jQuery(this).closest(".form-invalid").removeClass("form-invalid")})},validateForm:function(e){return e=jQuery(e),!wpAjax.invalidateForm(e.find(".form-required").filter(function(){return""===jQuery("input:visible",this).val()})).length}},wpAjax||{noPerm:"Sorry, you are not allowed to do that.",broken:"Something went wrong."}),jQuery(document).ready(function(e){e("form.validate").on("submit",function(){return wpAjax.validateForm(e(this))})});