Вход Регистрация
Файл: wordpress/wp-includes/js/wp-ajax-response.js
Строк: 105
<?php
var wpAjax jQuery.extend( {
    
unserialize: function( ) {
        var 
= {}, qppip;
        if ( !
) { return r; }
        
s.split('?'); if ( q[1] ) { q[1]; }
        
pp s.split('&');
        for ( 
i in pp ) {
            if ( 
jQuery.isFunction(pp.hasOwnProperty) && !pp.hasOwnProperty(i) ) { continue; }
            
pp[i].split('=');
            
r[p[0]] = p[1];
        }
        return 
r;
    },
    
parseAjaxResponse: function( xr) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission
        
var parsed = {}, re jQuery('#' r).empty(), err '';

        if ( 
&& typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) {
            
parsed.responses = [];
            
parsed.errors false;
            
jQuery('response'x).each( function() {
                var 
th jQuery(this), child jQuery(this.firstChild), response;
                
response = { actionth.attr('action'), whatchild.get(0).nodeNameidchild.attr('id'), oldIdchild.attr('old_id'), positionchild.attr('position') };
                
response.data jQuery'response_data'child ).text();
                
response.supplemental = {};
                if ( !
jQuery'supplemental'child ).children().each( function() {
                    
response.supplemental[this.nodeName] = jQuery(this).text();
                } ).
size() ) { response.supplemental false; }
                
response.errors = [];
                if ( !
jQuery('wp_error'child).each( function() {
                    var 
code jQuery(this).attr('code'), anErrorerrorDataformField;
                    
anError = { codecodemessagethis.firstChild.nodeValuedatafalse };
                    
errorData jQuery('wp_error_data[code="' code '"]'x);
                    if ( 
errorData ) { anError.data errorData.get(); }
                    
formField jQuery'form-field'errorData ).text();
                    if ( 
formField ) { code formField; }
                    if ( 
) { wpAjax.invalidateFormjQuery('#' ' :input[name="' code '"]' ).parents('.form-field:first') ); }
                    
err += '<p>' anError.message '</p>';
                    
response.errors.pushanError );
                    
parsed.errors true;
                } ).
size() ) { response.errors false; }
                
parsed.responses.pushresponse );
            } );
            if ( 
err.length ) { re.html'<div class="error">' err '</div>' ); }
            return 
parsed;
        }
        if ( 
isNaN(x) ) { return !re.html('<div class="error"><p>' '</p></div>'); }
        
parseInt(x,10);
        if ( -
== ) { return !re.html('<div class="error"><p>' wpAjax.noPerm '</p></div>'); }
        else if ( 
=== ) { return !re.html('<div class="error"><p>' wpAjax.broken  '</p></div>'); }
        return 
true;
    },
    
invalidateForm: function ( selector ) {
        return 
jQueryselector ).addClass'form-invalid' ).find('input:visible').change( function() { jQuery(this).closest('.form-invalid').removeClass'form-invalid' ); } );
    },
    
validateForm: function( selector ) {
        
selector jQueryselector );
        return !
wpAjax.invalidateFormselector.find('.form-required').filter( function() { return jQuery('input:visible'this).val() === ''; } ) ).size();
    }
}, 
wpAjax || { noPerm'You do not have permission to do that.'broken'An unidentified error has occurred.' } );

// Basic form validation
jQuery(document).ready( function($){
    $(
'form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );
});
?>
Онлайн: 0
Реклама