You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.9 KiB
104 lines
2.9 KiB
$(function() {
|
|
var $info_dialog = $('#info_dialog');
|
|
|
|
$('form.ajax-form').each(function() {
|
|
var $form = $(this);
|
|
var $block = $form.parent('div.dialog-block');
|
|
var $captcha_refresh = $('.js-captcha-refresh', $form);
|
|
|
|
var ajax_options = {
|
|
dataType: 'json',
|
|
timeout: 30000,
|
|
cache: false,
|
|
|
|
beforeSubmit: function() {
|
|
$('input', $form).attr('disabled', 'disabled');
|
|
$('button', $form).attr('disabled', 'disabled');
|
|
$('textarea', $form).attr('disabled', 'disabled');
|
|
},
|
|
|
|
complete: function(data) {
|
|
console.log('complete');
|
|
$('input', $form).removeAttr('disabled');
|
|
$('button', $form).removeAttr('disabled');
|
|
$('textarea', $form).removeAttr('disabled');
|
|
},
|
|
|
|
success: function(data) {
|
|
if (data['message']) {
|
|
$info_dialog.html(data['message']['msg']);
|
|
$info_dialog.dialog({
|
|
title: data['message']['title'] || 'Сообщение'
|
|
});
|
|
|
|
setTimeout(function() { $info_dialog.dialog('close') }, 3000);
|
|
|
|
$block.dialog('close');
|
|
}
|
|
|
|
$('.errors', $form).html(data['form_errors']);
|
|
$('.errors', $form).show();
|
|
|
|
$captcha_refresh.trigger('click');
|
|
|
|
if (data['success']) {
|
|
$(':input', $form).val('');
|
|
$('.errors', $form).html('');
|
|
}
|
|
}
|
|
};
|
|
|
|
$form.ajaxForm(ajax_options);
|
|
});
|
|
|
|
///
|
|
|
|
$('a#feedback_link').click(function() {
|
|
$('#feedback_dialog').dialog({
|
|
modal: true,
|
|
width: 520,
|
|
resizable: false
|
|
});
|
|
return false;
|
|
});
|
|
|
|
///
|
|
|
|
$('.js-captcha-refresh').click(function() {
|
|
$form = $(this).parents('form');
|
|
|
|
var refresh_url = $(this).attr('href');
|
|
|
|
$.getJSON(refresh_url, {}, function(data) {
|
|
$('img.captcha', $form).attr('src', data['image_url']);
|
|
$('#id_captcha_0', $form).val(data['key']);
|
|
$('#id_captcha_1:input', $form).val('');
|
|
});
|
|
|
|
return false;
|
|
});
|
|
});
|
|
|
|
// tabs
|
|
$(function () {
|
|
$('div.tabs').each(function() {
|
|
var tabs_block = $(this);
|
|
var $divs = tabs_block.children('div');
|
|
var $nav = $('ul.tab-nav > li > a', tabs_block);
|
|
|
|
$divs.hide().filter(':first').show();
|
|
|
|
$nav.click(function () {
|
|
$divs.hide();
|
|
$divs.filter(this.hash).show();
|
|
$nav.removeClass('selected');
|
|
$(this).addClass('selected');
|
|
return false;
|
|
});
|
|
|
|
if (window.location.hash)
|
|
$('ul.tab-nav > li > a[href=' + window.location.hash + ']', tabs_block).click();
|
|
else
|
|
$nav.filter(':first').click();
|
|
});
|
|
});
|
|
|