Skip to content

Instantly share code, notes, and snippets.

@Hellek
Created March 5, 2019 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hellek/7b99be6b2b73f24f7dbfb900927a71dd to your computer and use it in GitHub Desktop.
Save Hellek/7b99be6b2b73f24f7dbfb900927a71dd to your computer and use it in GitHub Desktop.
<script type="text/javascript">
var maxKoeff = 1;
//Функция проверяет активен ли чекбокс мультипоездки и делает нужные переключения в старой части кода
function checkMultiTravelInOldCode() {
if ($('[data-type="multi-polis"]').hasClass('active')) {
$('#travel_type_block').find('[rel="207"]').addClass('active');
$('#travel_type_block').find('[rel="206"]').removeClass('active');
} else {
$('#travel_type_block').find('[rel="207"]').removeClass('active');
$('#travel_type_block').find('[rel="206"]').addClass('active');
}
}
//Функция используется 2 раза - после успешного AJAX и после клика на чекбокс многократной поездки
function toggleHTMLForMultiTravel() {
var $multiPolisCheckbox = $("[data-type='multi-polis']");
var $radioUSD = $('#currency_block').find('[rel="205"]');
var $radioEUR = $('#currency_block').find('[rel="204"]');
var $radioPokritieSumArr = $('#polis_summ_block').find('.radio-el:not([rel="218"])');
var $radio35000 = $('#polis_summ_block').find('.radio-el[rel="218"]');
if (isMultiTravel()) { //Проверка на многократную поездку
$radioUSD.addClass('multi--hidden'); //Скрываем радио-кнопку валюту-доллары
$radioPokritieSumArr.addClass('multi--hidden'); //Скрываем все радио-кнопки сумм покрытий, кроме 35000
if (!$radioEUR.hasClass('active')) { //Если активный был доллар, то убираем у него активность и задаем
$radioUSD.removeClass('active'); // ее для евро
$radioEUR.addClass('active');
}
if (!$radio35000.hasClass('active')) { //Если активной была любая сумма покрытия кроме 35000, то
$radioPokritieSumArr.removeClass('active'); // убираем у нее активность и задаем ее для 35000
$radio35000.addClass('active');
}
} else {
$radioUSD.removeClass('multi--hidden'); //Показываем радио-кнопку валюту-доллары
$radioPokritieSumArr.removeClass('multi--hidden'); //Показываем все радио-кнопки сумм покрытий
}
//Функция проверяет, многократная ли поездка
function isMultiTravel() {
return $multiPolisCheckbox.hasClass('active');
}
}
function hideUnusedCurrency(){
// console.log('hideUnusedCurrency');
var currentMobileActive = '';
var activeCurrency = $('#currency_block .radio-el.active').attr('rel')*1;
var minPokritie = $('#currency_block .radio-el.active').data('min-value')*1;
var pokritieEnable = false;
$('.select_destination').each(function(){
var limit = $(this).find('option:selected').data('enable-limit');
if(typeof(limit) != 'undefined' ){
minPokritie = 0;
pokritieEnable = true;
}
});
if(typeof(activeCurrency)!='undefined'){
var counter0 = 0;
$('#polis_summ_block .radio-el[data-active-currency]').removeClass('active');
$('#polis_summ_block .radio-el[data-active-currency]').each(function(){
var dataCurrency = $(this).data('active-currency');
var curValue = $(this).text().replace(' ', '')*1;
if((dataCurrency.indexOf(activeCurrency) >= 0 && minPokritie<curValue) || pokritieEnable){
if(counter0 == 1){
$(this).show().addClass('cur-founded active');
}else{
$(this).show().addClass('cur-founded');
}
counter0++;
}else{
$(this).hide().removeClass('active');
}
});
var counter = 0;
$('#polis_summ_block_mobile .radio-el-mobile[data-active-currency]').removeClass('active');
$('#polis_summ_block_mobile .radio-el-mobile[data-active-currency]').each(function(){
var dataCurrency = $(this).data('active-currency');
var curValue = $(this).text().replace(' ', '')*1;
if((dataCurrency.indexOf(activeCurrency) >= 0 && minPokritie<curValue) || pokritieEnable){
if(counter == 0){
$(this).show().addClass('cur-founded active');
}else{
$(this).show().addClass('cur-founded');
}
counter++;
}else{
$(this).hide().removeClass('active');
}
});
}
// console.log('Pocritie enable :' +pokritieEnable);
}
$(document).ready(function() {
$('body').on('click','[data-type="multi-polis"]',function(){
if($(this).hasClass('active')){
$('.period-v2:eq(0)').hide();
$('.period-v1:eq(0)').show();
}else{
$('.period-v1:eq(0)').hide();
$('.period-v2:eq(0)').show();
}
});
hideUnusedCurrency();
$(document).on('click','#currency_block .radio-el',function(){
setTimeout(function(){
hideUnusedCurrency();
},100);
});
function takeCountriesParams(){
var arCountryIds = [];
$(".real_country_block .select_destination_wrap:not('.hidden_country_item')").each(function(){
var $elem = $(this).find('select.select_destination');
arCountryIds.push($elem.val());
});
console.log('ID:'+ arCountryIds);
var arPostData = {
"COUNTRY_IDS" : arCountryIds,
"TRAVEL_TYPE_ID" : $("#travel_type_block .active").attr("rel"),
"POLIS_SUMM_ID" : $("#polis_summ_block .active").attr("rel"),
"CURRENCY_ID" : $("#currency_block .active").attr("rel"),
}
$.ajax({
url: "/local/components/ispi/polis_calculator/ajax/change_destination.php",
type: "POST",
data: arPostData,
dataType: 'json',
timeout: 10000,
success: function(jsondata, response) {},
error: function(a, reason) {
}
}).done(function(jsondata, response){
//Скрываем годовую поездку, если у страны ее нет
if (jsondata.COUNTRY_HAS_MULTI_TRAVEL !== true) {
$('#multi-polis_checkbox').css('display', 'none');
} else {
$('#multi-polis_checkbox').css('display', 'block');
}
$("#travel_type_block").html(jsondata.result.TRAVEL_TYPE_HTML);
//$("#currency_block").html(jsondata.result.CURRENCY_HTML);
$("#polis_summ_block").html(jsondata.result.POLIS_SUMM_HTML);
$("#polis_summ_block_mobile").html(jsondata.result.POLIS_SUMM_HTML_MOBILE);
if( $(".radio-el-mobile").length > 1 ){
$(".radio-mobile .prev").addClass("disable");
$(".radio-mobile .next").removeClass("disable");
}
else{
$(".radio-mobile .prev").addClass("disable");
$(".radio-mobile .next").addClass("disable");
}
if(jsondata.result.DATE_PERIOD_HTML.length>0){
$(".period-v1").html(jsondata.result.DATE_PERIOD_HTML);
}
window.ws_datepicker_obj.init();
$(".valid-date").mask("99.99.9999");
hideUnusedCurrency();
toggleHTMLForMultiTravel();
sendForm("Y");
});
return false;
}
$(document).on("change",".destination",function(){
$(".jq-selectbox__select").removeClass("calculator_error");
var UpdateDataFlag = false
$(".destination").each(function(){
if($(this).val()!=0){
UpdateDataFlag = true;
}
});
if(UpdateDataFlag){
takeCountriesParams();
}
});
$(document).on("click",".spriteDelete",function(){
$(this).parent().next(".example").addClass("hidden_country_item");
$(this).parent().addClass("hidden_country_item");
$(this).parent().find('select').val("0");
$(this).parent().find('.jq-selectbox__select-text').html("Выберите...");
$(this).parent().find('.jq-selectbox__select-text').css("color","#000");
$('.destination').styler('destroy');
$('.destination').styler();
var UpdateDataFlag = false
$(".destination").each(function(){
if($(this).val()!=0){
UpdateDataFlag = true;
}
});
if(UpdateDataFlag){
takeCountriesParams();
}
});
//Эта часть кода мертвая, так как #travel_type_block закоментирован, но участвует в логике
$(document).on("click","#travel_type_block .radio-el",function(){
console.log('СРАБОТАЛ');
if($(this).parent().hasClass('radio'))
$(this).parent().find('.radio-el').removeClass('active');
else
$(this).parent().parent().find('.radio-el').removeClass('active');
$(this).addClass('active');
$(".real_country_block .select_destination_wrap:not('.hidden_country_item')").each(function(){
var $elem = $(this).find('select.select_destination');
arCountryIds.push($elem.val());
});
console.log('ID2: '+arCountryIds);
var arPostData = {
"TRAVEL_TYPE_ID" : $(this).attr("rel"),
"COUNTRY_IDS" : arCountryIds,
}
$.ajax({
url: "/local/components/ispi/polis_calculator/ajax/change_travel_type.php",
type: "POST",
data: arPostData,
dataType: 'json',
timeout: 10000,
success: function(jsondata, response) {},
error: function(a, reason) {}
}).done(function(jsondata, response){
$("#currency_block").html(jsondata.result.CURRENCY_HTML);
$("#polis_summ_block").html(jsondata.result.POLIS_SUMM_HTML);
$(".period-v1").html(jsondata.result.DATE_PERIOD_HTML)
$("#polis_summ_block_mobile").html(jsondata.result.POLIS_SUMM_HTML_MOBILE);
if($(".radio-el-mobile").length>1){
$(".radio-mobile .prev").addClass("disable");
$(".radio-mobile .next").removeClass("disable");
}
else{
$(".radio-mobile .prev").addClass("disable");
$(".radio-mobile .next").addClass("disable");
}
window.ws_datepicker_obj.init();
$(".valid-date").mask("99.99.9999");
});
hideUnusedCurrency();
return false;
});
$(".country_add").click(function (){
$(".hidden_country_item ").each(function(index){
if((index == 0)||(index == 1)){
$(this).removeClass("hidden_country_item");
if($(this).hasClass("example")){
if($(window).width()>1023){
$(this).show();
}
}
else{
$(this).show();
}
}
});
//SHV - закомментировал, тк тормозит работа
// $('.destination').styler('destroy');
// $('.destination').styler();
});
$(".minus").click(function(){
var new_value = $(this).parent().find('span').html()*1-1;
if( new_value >= 0 )
$(this).parent().find('span').html( new_value );
if($(this).next().attr("rel") == 223){
if($(this).next().html() > 0){
$(".aditional_params_checkbox ").each(function(index){
if($(this).attr("rel") == 208){
$(this).parent().addClass("hidden_aditional_param_item");
$(this).removeClass("active");
}
});
}
else{
$(".aditional_params_checkbox ").each(function(index){
if($(this).attr("rel") == 208){
$(this).parent().removeClass("hidden_aditional_param_item");
}
});
}
}
});
$(".plus").click(function(){
$(".calculator_span_error").removeClass("calculator_span_error");
var new_value = $(this).parent().find('span').html()*1+1;
if( new_value >= 0 )
$(this).parent().find('span').html( new_value );
if($(this).prev().attr("rel") == 223){
if($(this).prev().html() > 0){
$(".aditional_params_checkbox ").each(function(index){
if($(this).attr("rel") == 208){
$(this).parent().addClass("hidden_aditional_param_item");
$(this).removeClass("active");
}
});
}
else{
$(".aditional_params_checkbox ").each(function(index){
if($(this).attr("rel") == 208){
$(this).parent().removeClass("hidden_aditional_param_item");
}
});
}
}
});
$(document).on("click", "#submit-btn-first-step span", function(){
sendForm();
});
if($('.destination').length > 0){
$('.destination').styler({
onSelectOpened:function() {
$(this).find('input[type="search"]').focus();
}
});
}
$(document).on("change",".date input",function(){
$(this).removeClass("calculator_error");
var removeErrorFlag = true;
$(".date input").each(function(){
if($(this).val().length == 0){
removeErrorFlag = false;
}
});
if(removeErrorFlag){
$("#days_count").removeClass("calculator_error");
}
sendForm("Y");
});
$(document).on("change","#days_count",function(){
$(this).removeClass("calculator_error");
sendForm("Y");
});
//ТЕСТ1
$(document).on("change",".dataAge",function(){
$(this).removeClass("calculator_error");
sendForm("Y");
});
$(document).on("click",".del-input",function(){
sendForm("Y");
});
$(".example span").click(function(){
$(this).parent("p").prev("div").find("select").val($(this).attr("rel"));
$(this).parent("p").prev("div").find("select").next('.jq-selectbox__select').find(".jq-selectbox__select-text").html($(this).html());
$(this).parent("p").prev("div").find("select").next('.jq-selectbox__select').find(".jq-selectbox__select-text").css("color","#000");
var UpdateDataFlag = false
$(".destination").each(function(){
if($(this).val()!=0){
UpdateDataFlag = true;
}
});
if(UpdateDataFlag){
takeCountriesParams();
}
});
$('.radio-mobile .prev').click(function(){
var $cur = $(this).parent().find('.radio-el-mobile.active');
if( $cur.prevAll(".radio-el-mobile:visible").length > 0 ){
$(this).parent().find('.radio-el-mobile').removeClass('active');
var prevElms = $cur.prevAll(".radio-el-mobile:visible");
if(prevElms.length && prevElms.length>=1){
//console.dir(prevElms);
$(prevElms[0]).addClass('active');
}
var selected = $cur.prev().attr('data-elid');
}
if( $cur.prevAll(".radio-el-mobile:visible").length < 2 ){
$('.radio-mobile .prev').addClass('disable');
}
if( $cur.nextAll(".radio-el-mobile:visible").length >= 0 ){
$('.radio-mobile .next').removeClass('disable');
}
$("#polis_summ_block .radio-el").each(function(index,value){
$(this).removeClass("active");
if($(this).attr("rel") == $('.radio-mobile .next').parent().find('.radio-el-mobile.active').attr("rel")){
$(this).addClass("active");
}
});
});
$('.radio-mobile .next').click(function(){
var $cur = $(this).parent().find('.radio-el-mobile.active');
if( $cur.nextAll(".radio-el-mobile:visible").length > 0 ){
$(this).parent().find('.radio-el-mobile').removeClass('active');
var nextElms = $cur.nextAll(".radio-el-mobile:visible");
if(nextElms.length && nextElms.length>=1){
$(nextElms[0]).addClass('active');
}
var selected = $cur.next().attr('data-elid');
}
if( $cur.nextAll(".radio-el-mobile:visible").length < 2 ){
$('.radio-mobile .next').addClass('disable');
}
if( $cur.prevAll(".radio-el-mobile:visible").length >= 0 ){
$('.radio-mobile .prev').removeClass('disable');
}
$("#polis_summ_block .radio-el").each(function(index,value){
$(this).removeClass("active");
if($(this).attr("rel") == $('.radio-mobile .next').parent().find('.radio-el-mobile.active').attr("rel")){
$(this).addClass("active");
}
});
});
});
function sendForm(ajax){
ajax = ajax || "N";
//Проверим выбрана ли мультипоездка и подтвердим выбор в старой части кода
checkMultiTravelInOldCode();
var errors = [];
$(".calculator_error").removeClass("calculator_error");
$(".calculator_span_error").removeClass("calculator_span_error");
var arPeopleCountersIDs = [];
var arPeopleCountersValues = [];
var arPeopleAges = [];
var PeopleCount = 0;
$(".polis_people_counter").each(function(){
arPeopleCountersIDs.push($(this).attr("rel"));
arPeopleCountersValues.push($(this).html());
PeopleCount = PeopleCount + parseInt($(this).html());
});
if(PeopleCount == 0){
$(".polis_people_counter").addClass("calculator_span_error");
errors.push("Не выбрано количество человек");
}else{
$('[name="dataAge"]').each(function(){
arPeopleAges[arPeopleAges.length] = $(this).val();
})
}
var arPolisSumItems = [];
$("#polis_summ_block .radio-el").each(function(){
arPolisSumItems.push($(this).attr("rel"));
});
var arAditionalParamsIDs = [];
var arAditionalParamsValues = [];
// debugger;
$(".aditional_params_checkbox").each(function(){
if($(this).hasClass("active")){
arAditionalParamsValues.push("Y");
}
else{
arAditionalParamsValues.push("N");
}
arAditionalParamsIDs.push($(this).attr("rel"));
});
var multiple = false;
if($("[data-type='multi-polis']").hasClass("active")){
// var daysCount = $("#multiple_days_count .active").attr("rel");
//ORIGINAL берет value option, а не его текст с числом дней
//var daysCount = $('#multiple_days_count').val();
//SHV
var daysCount = parseInt($('#multiple_days_count').children(':selected').text());
var daysCountPrice = parseInt($('#multiple_days_count').children(':selected').attr('data-price'));
console.log('Многоразовая поездка');
console.log('количество дней = '+daysCount);
multiple = true;
}
else{
console.log('одноразовая поездка');
var daysCount = $("#days_count").val();
if(daysCount == 0 && ajax == "N"){
$("#days_count").addClass("calculator_error");
$("#ui-there").add("#ui-back").add("#ui-days").effect('bounce');
errors.push("Не выбрано количество дней поездки");
}
}
// Оригинал
// var CountryErrorFlag = true;
// var arCountryIds = [];
// $(".destination").each(function(){
// arCountryIds.push($(this).val());
// if($(this).val()!=0){
// CountryErrorFlag = false;
// }
// });
var CountryErrorFlag = true;
var arCountryIds = [];
$("select.destination").not('#multiple_days_count').each(function(){
arCountryIds.push($(this).val());
if($(this).val()!=0){
CountryErrorFlag = false;
}
});
//ТЕСТ2
if($("[name=dataAge]").val().length == 0){
if(ajax == "N"){
$("[name=dataAge]").addClass("calculator_error");
$("#ui-ages").effect('bounce');
}
errors.push("Не выбран возраст");
}
if(CountryErrorFlag){
if(ajax == "N"){
$(".jq-selectbox__select").addClass("calculator_error");
$("#ui-where").effect('bounce');
}
errors.push("Не выбрана страна поездки");
}
if($("[name=date_from]").val().length == 0 && !multiple){
if(ajax == "N"){
$("[name=date_from]").addClass("calculator_error");
}
errors.push("Не выбраны дата начала поездки");
}
if($("[name=date_from_multiple]").val().length == 0 && multiple){
if(ajax == "N"){
$("[name=date_from]").addClass("calculator_error");
}
errors.push("Не выбраны дата начала поездки");
}
if($("[name=date_to]").val().length == 0 && !multiple){
if(ajax == "N"){
$("[name=date_to]").addClass("calculator_error");
}
errors.push("Не выбрана дата конца поездки");
}
var travelTypeFullList = [];
$("#travel_type_block .radio-el").each(function(){
travelTypeFullList.push($(this).attr("rel"));
});
var currencyFullList = [];
$("#currency_block .radio-el").each(function(){
currencyFullList.push($(this).attr("rel"));
});
//alert(errors);
//alert($("#polis_summ_block .active").attr("rel"));
if(errors.length == 0){
//Удаляем пустые возраста - svh
// console.log(arPeopleAges);
for (var i = 0; i < arPeopleAges.length; i++) {
if (arPeopleAges[i] == 0) {
arPeopleAges.splice(i, 1);
}
}
//В этом месте выводится daysCount неверное так как берется value из селекта 210 211 и тд
// console.log('daysCount ='+daysCount);
var daysCountForPHP = '';
switch (daysCount) {
case 30:
daysCountForPHP = 'PROPERTY_TARIF_30_VALUE';
break;
case 45:
daysCountForPHP = 'PROPERTY_TARIF_45_VALUE';
break;
case 60:
daysCountForPHP = 'PROPERTY_TARIF_60_VALUE';
break;
case 90:
daysCountForPHP = 'PROPERTY_TARIF_90_VALUE';
break;
case 120:
daysCountForPHP = 'PROPERTY_TARIF_120_VALUE';
break;
case 180:
daysCountForPHP = 'PROPERTY_TARIF_180_VALUE';
break;
}
//shv добавил в массив стоимость для выбранного количества дней для многократной
//Начало! Один блок кода
var arResultData = {
"COUNTRY_IDS" : arCountryIds,
"TRAVEL_TYPE_ID" : $("#travel_type_block .active").attr("rel"),
"TRAVEL_TYPE_FULL_LIST" : travelTypeFullList,
"CURRENCY_ID" : $("#currency_block .active").attr("rel"),
"CURRENCY_FULL_LIST" : currencyFullList,
"CURRENT_POLIS_SUMM_ID" : $("#polis_summ_block .active").attr("rel"),
"POLIS_SUMM_ID" : arPolisSumItems,
"PEOPLE_COUNTERS_IDS" : arPeopleCountersIDs,
"PEOPLE_COUNTERS_VALUES" : arPeopleCountersValues,
"ADITIONAL_POLIS_PARAMS_IDS" : arAditionalParamsIDs,
"ADITIONAL_POLIS_PARAMS_VALUES" : arAditionalParamsValues,
"DAYS_COUNT" : daysCount,
"AGES" : arPeopleAges,
"DAYS_COUNT_PRICE": daysCountPrice,
"DAYS_COUNT_FOR_PHP": daysCountForPHP
}
if ($("#travel_type_block .active").attr("rel") === '207') {
arResultData['DATE_FROM'] = $("[name=date_from_multiple]").val();
arResultData['DATE_TO'] = '';
} else if($("#travel_type_block .active").attr("rel") === '206') {
arResultData['DATE_FROM'] = $("[name=date_from]").val();
arResultData['DATE_TO'] = $("[name=date_to]").val();
}
//Конец! Один блок кода
arResultData.IS_AJAX = ajax;
var arPostData = {
"FORM_RESULT" : arResultData,
}
console.log('Перед AJAX');
console.log(arResultData);
console.log(arPostData);
addToLocalStorageInfo(); // Выполним добавление инфы в локальное хранилище перед AJAX
$.ajax({
url: "/",
type: "POST",
data: arPostData,
dataType: 'html',
timeout: 10000,
success: function(jsondata, response) {},error: function(a, reason) {}
}).done(function(jsondata, response){
//Проверка типа поездки (отображать/скрыть годовую поездку)
// $.ajax({
// url: "/local/components/ispi/polis_calculator/ajax/check_multi_travel.php",
// type: "POST",
// data: arPostData,
// dataType: 'html',
// timeout: 10000,
// success: function(jsondata1, response1) {},error: function(a1, reason1) {}
// }).done(function(jsondata1, response1){
// if (jsondata1 === 'both_types') {
// $('#multi-polis_checkbox').css('display', 'block');
// } else if (jsondata1 === 'one_type') {
// $('#multi-polis_checkbox').css('display', 'none');
// $('#multi-polis_checkbox').removeClass('active');
// $('.period-v2.row.active').css('display', 'none');
// $('.period-v1.row.active').css('display', 'block');
// sendForm('Y');
// }
// }).fail(function(jsondata1, response1){
// console.log('Что-то пошло не так при AJAX main');
// });
if(ajax == "N"){
$("#calculator-step").html(jsondata);
} else if(ajax =="Y"){
jsondata = jsondata*1;
if(jsondata>0){
$('.calc-form-title .large').text(jsondata+' руб.');
$('.calc-form-title').show();
}else{
$('.calc-form-title').hide;
$('.calc-form-title .large').text('');
}
}
toggleHTMLForMultiTravel();
}).fail(function(jsondata, response){
console.log('Что-то пошло не так при AJAX chief');
});
return false;
}
else{
if(ajax == "N"){
$(".error_form_field").remove();
}
}
return false;
}
</script>
<section class="sec-content container step_2_id">
<div id="calc" class="calc">
<!-- Старый код -->
<!-- <div class="calc-step row" style="display: none;">
<div class="calc-step-bl active col"><span class="num">1.</span><span class="desc">Рассчитайте<br>стоимость полиса</span><i class="sprite sprite-icon-arrow-right-red"></i></div>
<div class="calc-step-bl col"><span class="num">2.</span><span class="desc">Выберите<br>программу страхования</span><i class="sprite sprite-icon-arrow-right-grey"></i></div>
<div class="calc-step-bl col"><span class="num">3.</span><span class="desc">Заполните паспортные<br>данные и оплатите полис</span></div>
</div> -->
<div class="calc-form-title" style="display:none;">
<div class="large">234 руб.</div>предварительный расчет на 1 человека
</div>
<div class="calc-form">
<!-- форма без шагов, требует доработки логики -->
<div class="row">
<div class="s1-col-9 col">
</div>
<div class="s1-col-9 col">
<div class="form-group">
<div class="period-v1 row active">
<div class="s1-col-5 col">
<p class="label" id='ui-there'>Туда:</p>
<div class="date">
<input id="date_1_1" type="text" class="form-control valid-date" name="date_from" placeholder="дд.мм.гггг" autocomplete=off>
</div>
</div>
<div class="s1-col-5 col">
<p class="label" id='ui-back'>Обратно:</p>
<div class="date">
<input id="date_2_1" type="text" class="form-control valid-date" name="date_to" placeholder="дд.мм.гггг" autocomplete=off>
</div>
</div>
<div class="s1-col-2 col">
<p class="label" id='ui-days'>Кол-во дней:</p>
<input id="days_count" type="text" class="form-control valid-days" name="days" placeholder="">
</div>
</div>
<!-- блок - Многоразовая поездка -->
<div class="period-v2 row active" style="display: none;">
<div class="s1-col-4 col">
<p class="label">Туда:</p>
<div class="date">
<input id="date_1" type="text" class="form-control valid-date" name="date_from_multiple" placeholder="дд.мм.гггг">
</div>
</div>
<div class="s1-col-5 col">
<p class="label">Период:</p>
<div class="select_destination_wrap">
<select class="destination select_destination first_select" data-search="true" id="multiple_days_count">
<option data-price='600' value="210">30 дней</option>
<option data-price='650' value="211">45 дней</option>
<option data-price='760' value="212">60 дней</option>
<option data-price='1090' value="213">90 дней</option>
<option data-price='1435' value="214">120 дней</option>
<option data-price='1580' value="215">180 дней</option>
<!-- <option value="" selected> дней</option> -->
<!-- <option value=""> дней</option> -->
</select>
</div>
</div>
</div>
<script>console.log('Эта if часть')</script>
<!-- добавить логику к элементу -->
<!-- <div id="multi-polis_checkbox_wrapper"> -->
<div id='multi-polis_checkbox' class="checkbox" tabindex='0' data-type="multi-polis" style="">Годовой полис</div>
</div>
<!-- </div> -->
</div>
</div>
<div class="row">
<div class="s1-col-9 col">
<div class="form-group">
<p class="label" id='ui-ages'>Кто летит:</p>
<div class="add-passenger-editable">
<input id='gataAgeSh' class="dataAge" data-age="" placeholder="Возраст" type="text" maxlength="2" name="dataAge"/>
<span class="del-input" tabindex='0' onclick="deleteTourist(this);"></span>
</div>
<div style='display: none' class="add-passenger" tabindex='0' onclick="addTourist(this);">
Добавить туриста
</div>
</div>
</div>
<div class="s1-col-9 col">
<div class="form-group">
<p class="label">
<span class="popover">Валюта полиса:<i class="sprite sprite-icon-ask"><span>Выберите покрытие в Евро, если планируете посетить любую из стран Шенген</span></i></span>
</p>
<div class="radio" id="currency_block">
<div rel="204" class="radio-el active" tabindex='0' data-min-value="27">EUR</div>
<div rel="205" class="radio-el" tabindex='0' data-min-value="30">USD</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="s1-col-9 col">
<div class="form-group">
<p class="label">
<span class="popover">Дополнительные параметры:<i class="sprite sprite-icon-ask"><span>Отметьте ниже, если планируете заниматься активным отдыхом или у вас есть дисконт карта ЭКСПЕРТ ГРУПП</span></i></span>
</p>
<div class="checkbox aditional_params_checkbox" tabindex='0' rel="208">
<span class="popover">Планирую заниматься Активным отдыхом </span>
</div>
<div class="checkbox aditional_params_checkbox" tabindex='0' rel="209"><span class="popover">Не гражданин Российской федерации</span></div><br>
<div class="checkbox aditional_params_checkbox" tabindex='0' rel="6313"><span class="popover">Дисконтная карта</span></div><br>
</div>
</div>
<div class="s1-col-9 col">
<div class="form-group">
<p class="label">
<span class="popover">Сумма страхового покрытия<i class="sprite sprite-icon-ask"><span>Минимальная страховая сумма по полису должна превышать 2 млн. рублей по курсу ЦБ</span></i></span>
</p>
<div class="radio row" id="polis_summ_block">
<div rel="218" class="radio-el" tabindex='0' data-active-currency='[204,205]'>35 000</div>
<div rel="6290" class="radio-el active" tabindex='0' data-active-currency="[204,205]">40 000</div>
<div rel="219" class="radio-el" tabindex='0' data-active-currency='[204,205]'>50 000</div>
<div rel="220" class="radio-el" tabindex='0' data-active-currency='[204,205]'>100 000</div>
</div>
</div>
</div>
</div>
<div class="calc-form-step-1" >
<div class="row" style="display: none;">
<div class="s1-col-1 col country_block">
<p class="label">Куда едем?</p>
<div class="select_destination_wrap">
<!-- Добавление стран -->
<!-- <i class="sprite sprite-icon-plus-green country_add"></i> -->
<p class="example hidden_country_item">Например: <span rel="392">Финляндия</span>, <span rel="415">Шенген</span>, </p>
<p class="example hidden_country_item">Например: <span rel="392">Финляндия</span>, <span rel="415">Шенген</span>, </p>
<p class="example hidden_country_item">Например: <span rel="392">Финляндия</span>, <span rel="415">Шенген</span>, </p>
</div>
<div class="s1-col-2 col">
<p class="label"><span class="popover">Тип поездки:<i class="sprite sprite-icon-ask"><span>Какая то подсказка для Тип поездки:</span></i></span></p>
<div class="radio" id="travel_type_block">
<div rel="206" class="radio-el active">Одноразовая</div>
<div rel="207" class="radio-el">Многократная на год</div>
</div>
</div>
<div class="s1-col-3 col">
<p class="label">Валюта полиса:</p>
<div class="radio" id="currency_block">
<div rel="204" class="radio-el active" data-min-value="27">EUR <i class="sprite sprite-icon-eur"></i></div>
<div rel="205" class="radio-el" data-min-value="30">USD <i class="sprite sprite-icon-usd"></i></div>
</div>
</div>
</div>
<div class="period-v1 row active" style="display:none;">
<div class="s1-col-4 col">
<p class="label">Период поездки:</p>
<div class="date">
<input id="date_1_1" type="text" class="form-control valid-date" name="date_from" placeholder="дд.мм.гггг">
</div>
<span>по</span>
<div class="date">
<input id="date_2_1" type="text" class="form-control valid-date" name="date_to" placeholder="дд.мм.гггг">
</div>
</div>
<div class="s1-col-5 col">
<p class="label">Кол-во дней:</p>
<input id="days_count" type="text" class="form-control valid-days" name="days" placeholder="">
</div>
</div>
<div class="row" style="display: none;">
<div class="s1-col-7 col">
<p class="label">Кол-во застрахованных человек в полисе:</p>
<div class="row">
<div class="one-third col">
<p class="before-input">( от 0 лет до 63 лет )</p>
<div class="pm-btn">
<i class="minus sprite sprite-icon-minus-green"></i>
<span class='polis_people_counter' rel="221">
1 </span><i class="plus sprite sprite-icon-plus-green-2"></i>
</div>
</div>
<div class="one-third col">
<p class="before-input">( от 64 лет до 73 лет )</p>
<div class="pm-btn">
<i class="minus sprite sprite-icon-minus-green"></i>
<span class='polis_people_counter' rel="222">
0 </span><i class="plus sprite sprite-icon-plus-green-2"></i>
</div>
</div>
<div class="one-third col">
<p class="before-input">( от 74 лет до 100 лет )</p>
<div class="pm-btn">
<i class="minus sprite sprite-icon-minus-green"></i>
<span class='polis_people_counter' rel="223">
0 </span><i class="plus sprite sprite-icon-plus-green-2"></i>
</div>
</div>
</div>
</div>
<div class="s1-col-8 col">
<p class="label"><span class="popover">Сумма страхового покрытия<i class="sprite sprite-icon-ask"><span>Подсказка для Сумма страхового покрытия</span></i></span></p>
<div class="radio row radio-desktop" id="polis_summ_block">
<div class="col">
<div rel="218" class="radio-el active" data-active-currency="[204,205]">35 000</div>
</div>
<div class="col">
<div rel="6290" class="radio-el" data-active-currency='[204,205]'>40 000</div>
<div rel="219" class="radio-el" data-active-currency='[204,205]'>50 000</div>
<div rel="220" class="radio-el" data-active-currency='[204,205]'>100 000</div>
</div>
</div>
<div class="radio-mobile row">
<div class="" id="polis_summ_block_mobile">
<div class="radio-el-mobile active " rel="218" data-elid="35 000" data-active-currency="[204,205]">35 000</div>
<div class="radio-el-mobile " rel="6290" data-elid="40 000" data-active-currency="[204,205]">40 000</div>
<div class="radio-el-mobile " rel="219" data-elid="50 000" data-active-currency="[204,205]">50 000</div>
<div class="radio-el-mobile " rel="220" data-elid="100 000" data-active-currency="[204,205]">100 000</div>
</div>
<div class="prev disable"></div>
<div class="next "></div>
</div>
</div>
</div>
<div class="row margin-class" style="display: none;">
<p class="label"><span class="popover">Дополнительные параметры:<i class="sprite sprite-icon-ask"><span>Подсказка для Дополнительные параметры:</span></i></span></p>
<div class="s1-col-9 col">
<div class="checkbox aditional_params_checkbox" rel="209"><span class="popover">Не гражданин Российской федерации</span></div>
</div>
<div class="s1-col-9 col">
<div class="checkbox aditional_params_checkbox" rel="6313"><span class="popover">Дисконтная карта</span></div>
</div>
</div>
<div class="submit-bl margin-class">
<div class="submit-btn" id="submit-btn-first-step"><span class="btn btn-default btn-large" style="font-weight: 700;" tabindex="0">рассчитать полис</span></div>
<div class="submit-txt" style="display: none;">Страхование и ассистанс от <i class="sprite sprite-logo-renesans"></i></div>
</div>
</div>
</div>
</div>
</section>
</div>
<style>
.page-top .sec-content:after {
background: url("/upload/iblock/ed0/ed0ae30f5d125e9d3ac98e482518aabd.png") !important;
background-repeat: no-repeat !important;
background-position: 0 !important;
}
/*Изменяет шапку, используя параметр компонента - нельзя переносить в style.css*/
.page-top:before {
background-image: url(/local/templates/expert/images/bg/header-bg.jpg);
}
</style>
<script>
$(document).on('ready', function() {
// Убираем стиль, по завершению загрузки страницы - для инпута страны
$('.sh_show').removeClass('sh_show');
});
//AJAX по изменению состояния дополнительных параметров
$('div.form-group').on('click', "div.checkbox.aditional_params_checkbox", setTimeoutForAjax);
$('div.form-group').on('click', ".radio-el", setTimeoutForAjax);
function setTimeoutForAjax() {
setTimeout(sendAfterChange, 30);
function sendAfterChange() {
sendForm('Y');
}
}
</script>
<style>
.sprite-icon-plus-green{
right: -25px !important;
}
span {
position: relative;
}
.success:after,
.error:after {
position: absolute;
right: 4px;
color: green;
content: '\2713';
}
.success:after {
color: green;
content: '\2713';
}
.error:after {
color: red;
top: -2px;
content: '\2717';
}
.btn:focus {
outline: -webkit-focus-ring-color auto 5px !important;
}
.multi--hidden {
display: none;
}
</style>
<!-- / Content --> <!-- / Page top --> <!-- Page bottom Ответы на вопросы-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#FIELD_YOUR_NAME_1").bind("input", function(event) {
var out = "";
var str = this.value;
for (var i = 0; i < str.length; i++) {
if (/[А-Яа-я]/.test(str.charAt(i))) {
out = out.concat(str.charAt(i));
}
}
this.value = out;
});
$("#contactform").submit(function(){
$.ajax({
url: $(this).attr("action"),
type: $(this).attr("method"),
data: $(this).serialize(),
dataType: 'json',
timeout: 10000,
success: function(jsondata, response) {
$(".error_form_field").remove();
$(".success_form_field").remove();
$('.wrong').removeClass('wrong');
if(jsondata.errors){
$.each( jsondata.errors.IS_REQUIRED_FIELDS_CODE , function( index, value ) {
$(value).before("<p class='error_form_field'>Не заполнено обязательное поле: "+jsondata.errors.IS_REQUIRED_FIELDS[index]+"</p>");
$(value).addClass('wrong');
});
}
if(jsondata.result){
$.each( jsondata.result , function( index, value ) {
$(value).remove();
});
$("#contactform_modal_header").after("<p class='success_form_field'>В ближайшее время с вами свяжется оператор</p>");
$("#contactform_modal_header").html("Ваша заявка принята");
$("#contactform input[type=submit]").remove();
setTimeout(closeRecallModal, 3000);
}
//console.log(jsondata.result);
},
error: function(a, reason) {
}
});
return false;
});
});
function closeRecallModal(){
$('#recall-modal').removeClass('active');
$('#recall-modal .modal-inner').removeClass('top');
$('#recall-modal .modal-inner').removeClass('bot');
return false;
}
//функция запрещающая ввод английских букв и цифр
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment