const header = {
controller() {
$('.scroll-up').click(e => {
e.preventDefault();
$('html,body').animate({
scrollTop: 0
}, {
duration: 1250
});
});
$('.header .dropdown-toggle').click((e) => {
e.preventDefault();
$(e.currentTarget).toggleClass('active');
$('.header .compare').slideToggle();
});
}
},
bankItem = {
controller() {
$('.bank-item .show-more').click(function (e) {
e.preventDefault();
if (!$(this).hasClass('active')) {
$(this).text('Свернуть')
} else {
$(this).text('Подробнее')
}
$(this).toggleClass('active');
$(this).parent().find('.more').slideToggle();
});
}
};
function compare() {
$('#time').change(() => {
$('table th:nth-child(2),table td:nth-child(2)').toggle();
});
$('#percent').change(() => {
$('table th:nth-child(3),table td:nth-child(3)').toggle();
});
$('#sum').change(() => {
$('table th:nth-child(4),table td:nth-child(4)').toggle();
});
}
function stars() {
$('.write-comment .star').click(function () {
$('.write-comment .star').removeClass('active').each((index, item) => {
if (item == this) {
$(item).addClass('active');
return false;
}
$(item).addClass('active');
});
});
}
$(() => {
setTimeout(() => {
header.controller();
stars();
if ($('body').hasClass('page-template-compare')) {
compare();
}
jQuery(".slide").swipe({
swipe: function swipe(event, direction, distance, duration, fingerCount, fingerData) {
if (direction == 'left') jQuery(this).carousel('next');
if (direction == 'right') jQuery(this).carousel('prev');
},
allowPageScroll: "vertical"
});
if ($('body').hasClass('page-template-order')) {
let mask = $('input[type=tel]').attr('placeholder');
$("input[type=tel]").mask("+7 (999) 999-99-99");
}
}, 1000);
bankItem.controller();
});