Вход Регистрация
Файл: concrete5.7.5.6/concrete/js/build/core/app/ajax-request/form.js
Строк: 72
<?php
/**
 * Base search class for AJAX forms in the UI
 */

!function(global, $) {
    
'use strict';

    function 
ConcreteAjaxForm($formoptions) {
        var 
my this;
        
options options || {};
        
options = $.extend({
            
'beforeSubmit'my.before,
            
'complete'my.complete,
            
'data': {}
        }, 
options);
        
my.$form $form;
        
ConcreteAjaxRequest.call(myoptions);
        return 
my.$form;
    }

    
ConcreteAjaxForm.prototype Object.create(ConcreteAjaxRequest.prototype);

    
ConcreteAjaxForm.prototype.execute = function() {
        var 
my this,
            
options my.options,
            
successCallback options.success,
            
errorCallback options.error;

        
my.$form.ajaxForm({
            
typeoptions.type,
            
dataoptions.data,
            
urloptions.url,
            
dataTypeoptions.dataType,
            
beforeSubmit: function() {
                
options.beforeSubmit(my);
            },
            
error: function(r) {
                
my.error(rmyerrorCallback);
            },
            
success: function(r) {
                
my.success(rmysuccessCallback);
            },
            
complete: function() {
                
options.complete(my);
            }
        });
    }

    
ConcreteAjaxForm.prototype.error = function(rmycallback) {
        
ConcreteAjaxRequest.prototype.error(rmy);
        if (
callback) {
            
callback(r);
        }
    }

    
ConcreteAjaxForm.prototype.success = function(rmycallback) {
        if (
my.validateResponse(r)) {
            if (
callback) {
                
callback(r);
            } else {
                
// if we get a success function passed through, we use it. Otherwise we use the standard
                
ConcreteEvent.publish('AjaxFormSubmitSuccess', {responserformmy.$form.attr('data-dialog-form')});
                if (
r.redirectURL) {
                    
window.location.href r.redirectURL;
                } else {
                    if (
my.$form.attr('data-dialog-form')) {
                        
jQuery.fn.dialog.closeTop();
                    }
                    
ConcreteAlert.notify({
                        
'message'r.message,
                        
'title'r.title
                    
});
                }
            }
        }
    }

    
// jQuery Plugin
    
$.fn.concreteAjaxForm = function(options) {
        return $.
each($(this), function(iobj) {
            new 
ConcreteAjaxForm($(this), options);
        });
    }

    global.
ConcreteAjaxForm ConcreteAjaxForm;

}(
this, $);
?>
Онлайн: 1
Реклама