Last active
August 29, 2015 14:05
-
-
Save sa2kasov/f724ab42760c311d1599 to your computer and use it in GitHub Desktop.
Что с моим заказом?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
//Исходное состояние кнопки | |
$('#buttonWrapper').click(function(){ | |
$(this).hide(); | |
$('#whatWithMyOrder').css({height: '200px'}); | |
$('#whatWithMyOrder form').show(); | |
$('input[name="order_id"]').focus(); | |
$('input[name="captcha"]').focus(function(){ | |
$('input[name="order_id"]').unbind('focus'); | |
}); | |
$('.sidebar').css({marginTop: '130px'}); | |
}); | |
//Обновление captch'и при клике по ней | |
$('#whatWithMyOrder img.captcha').click(function(){ | |
$(this).attr('src', function(){ | |
return ('/captcha/captcha.php?' + Math.round(Math.random(1000, 9999) * 10000)); | |
}); | |
}); | |
//Запрет на набор не цифровых символов для поля "№ заказа" | |
$('input[name="order_id"]').keyup(function(e){ | |
if(!/^\d*$/.test($(this).val())) | |
$(this).val($(this).val().slice(0, $(this).val().length - 1)); | |
}); | |
$('input[name="order_id"]').change(function(e){ | |
if(!/^\d*$/.test($(this).val())) | |
$(this).val(null); | |
}); | |
//Обработчик кнопки "Узнать" | |
$('#toKnow').click(function(){ | |
//Проверка на заполненность полей "№ заказа" и "Капчи" | |
if($('input[name="order_id"]').val().length < 4){ | |
$('input[name="order_id"]').css({boxShadow: '0 0 5px #F00'}); | |
$('input[name="order_id"]').focus(); | |
return false; | |
} | |
else | |
$('input[name="order_id"]').css('box-shadow', 'none'); | |
if($('input[name="captcha"]').val().length < 4){ | |
$('input[name="captcha"]').css({boxShadow: '0 0 5px #F00'}); | |
$('input[name="captcha"]').focus(); | |
return false; | |
} | |
else | |
$('input[name="captcha"]').css('box-shadow', 'none'); | |
//Запрос на получение информации о заказе | |
$('#whatWithMyOrderResponse').load( | |
'/catalog1/catalog2/catalog3/catalog4/catalog5/catalog6/order.info.request.php', | |
{ | |
order_id: $('input[name="order_id"]').val(), | |
captcha: $('input[name="captcha"]').val() | |
}, | |
function(data, textStatus){ | |
if(data){ | |
$('#whatWithMyOrder form').hide(''); | |
$(this).show('fast'); | |
if($('div').is('#orderResponse')){ | |
$('#whatWithMyOrder').animate({height: '310px'}); | |
$('.sidebar').animate({marginTop: '160px'}); | |
} | |
} | |
else | |
return false; | |
} | |
); | |
}); | |
}); | |
//Кнопка "Спасибо" | |
function thanks(){ | |
$('#whatWithMyOrder').animate({height: '100px'}); | |
$('.sidebar').animate({marginTop: '30px'}); | |
$('#whatWithMyOrderResponse, #buttonWrapper').toggle(); | |
//Очистка полей | |
$('input[name="order_id"]').val(null); | |
$('input[name="captcha"]').val(null); | |
//Смена капчи | |
$('#whatWithMyOrder img.captcha').click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment