-
+ A4AF82D8BD6E716E5180B9164E6D688FA382A5722E0A1298FB1E081F305A447A70A3119E645E7E2F578D511A743F7B46A9352913FE4F0F5524A4588A2E98A85Amp-wp/wp-includes/js/wp-ajax-response.js(0 . 0)(1 . 60)
132972 wpAjax = jQuery.extend( {
132973 unserialize: function( s ) {
132974 var r = {}; if ( !s ) { return r; }
132975 var q = s.split('?'); if ( q[1] ) { s = q[1]; }
132976 var pp = s.split('&');
132977 for ( var i in pp ) {
132978 if ( jQuery.isFunction(pp.hasOwnProperty) && !pp.hasOwnProperty(i) ) { continue; }
132979 var p = pp[i].split('=');
132980 r[p[0]] = p[1];
132981 }
132982 return r;
132983 },
132984 parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission
132985 var parsed = {};
132986 var re = jQuery('#' + r).html('');
132987 if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) {
132988 parsed.responses = [];
132989 parsed.errors = false;
132990 var err = '';
132991 jQuery('response', x).each( function() {
132992 var th = jQuery(this);
132993 var child = jQuery(this.firstChild);
132994 var response = { action: th.attr('action'), what: child.get(0).nodeName, id: child.attr('id'), oldId: child.attr('old_id'), position: child.attr('position') };
132995 response.data = jQuery( 'response_data', child ).text();
132996 response.supplemental = {};
132997 if ( !jQuery( 'supplemental', child ).children().each( function() {
132998 response.supplemental[this.nodeName] = jQuery(this).text();
132999 } ).size() ) { response.supplemental = false }
133000 response.errors = [];
133001 if ( !jQuery('wp_error', child).each( function() {
133002 var code = jQuery(this).attr('code');
133003 var anError = { code: code, message: this.firstChild.nodeValue, data: false };
133004 var errorData = jQuery('wp_error_data[code="' + code + '"]', x);
133005 if ( errorData ) { anError.data = errorData.get(); }
133006 var formField = jQuery( 'form-field', errorData ).text();
133007 if ( formField ) { code = formField; }
133008 if ( e ) { wpAjax.invalidateForm( jQuery('#' + e + ' :input[name="' + code + '"]' ).parents('.form-field:first') ); }
133009 err += '<p>' + anError.message + '</p>';
133010 response.errors.push( anError );
133011 parsed.errors = true;
133012 } ).size() ) { response.errors = false; }
133013 parsed.responses.push( response );
133014 } );
133015 if ( err.length ) { re.html( '<div class="error">' + err + '</div>' ); }
133016 return parsed;
133017 }
133018 if ( isNaN(x) ) { return !re.html('<div class="error"><p>' + x + '</p></div>'); }
133019 x = parseInt(x,10);
133020 if ( -1 == x ) { return !re.html('<div class="error"><p>' + wpAjax.noPerm + '</p></div>'); }
133021 else if ( 0 === x ) { return !re.html('<div class="error"><p>' + wpAjax.broken + '</p></div>'); }
133022 return true;
133023 },
133024 invalidateForm: function ( selector ) {
133025 return jQuery( selector ).addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } );
133026 },
133027 validateForm: function( selector ) {
133028 selector = jQuery( selector );
133029 return !wpAjax.invalidateForm( selector.find('.form-required').andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]') ).size();
133030 }
133031 }, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'An unidentified error has occurred.' } );