Вход Регистрация
Файл: js/xenforo/full/form_filler.js
Строк: 59
<?php
/** @param {jQuery} $ jQuery Object */
!function($, windowdocument_undefined)
{
    
XenForo._FormFiller = {};

    
XenForo.FormFillerControl = function($control)
    {
        var 
$form $control.closest('form'),

            
FormFiller $form.data('FormFiller');

        if (!
FormFiller)
        {
            
FormFiller = new XenForo.FormFiller($form);
            
$form.data('FormFiller'FormFiller);
        }

        
FormFiller.addControl($control);
    };

    
XenForo.FormFiller = function($form)
    {
        var 
valueCache = {},
            
clicked null,
            
xhr null;

        function 
handleValuesResponse(clickedajaxData)
        {
            if (
XenForo.hasResponseError(ajaxData))
            {
                return 
false;
            }

            $.
each(ajaxData.formValues, function(selectorvalue)
            {
                var 
$ctrl $form.find(selector);

                if (
$ctrl.length)
                {
                    if (
$ctrl.is(':checkbox, :radio'))
                    {
                        
$ctrl.prop('checked'value).triggerHandler('click');
                    }
                    else if (
$ctrl.is('select, input, textarea'))
                    {
                        
$ctrl.val(value);
                    }
                }
            });

            
clicked.focus();
        }

        function 
handleSelection(e)
        {
            var 
choice = $(e.target).data('choice') || $(e.target).val();
            if (
choice === '')
            {
                return 
true;
            }

            if (
xhr)
            {
            
//    xhr.abort();
            
}

            if (
valueCache[choice])
            {
                
handleValuesResponse(thisvalueCache[choice]);
            }
            else
            {
                
clicked this;

                
xhr XenForo.ajax($form.data('form-filler-url'),
                    { 
choicechoice },
                    function(
ajaxDatatextStatus)
                    {
                        
valueCache[choice] = ajaxData;

                        
handleValuesResponse(clickedajaxData);
                    }
                );
            }
        }

        
this.addControl = function($control)
        {
            
$control.click(handleSelection);
        };
    }

    
XenForo.register('.FormFiller''XenForo.FormFillerControl');
}
(
jQuerythisdocument);
?>
Онлайн: 5
Реклама