function fixCkeBug() { var ckeId = $('#cke_pastebin'); if (ckeId.length > 0) { ckeId.removeAttr('style'); } } function renderDayCircles() { var sectors = $('.days .day .sector'); sectors.each(function (index, element) { var number = $(element).data('number'); var selector = '.days .day .sector[data-number="' + number + '"]'; var angle = 360 / sectors.length * number; new Sektor(selector, { size: 200, arc: true, angle: angle, sectorColor: '#1968a8', circleColor: 'rgba(0,0,0,0.1)', fillCircle: false, stroke: 11 }); }); } function moving_anchors_slow() { // var height_top = $('.header-fixed').height() + $('#row_menu').height() - 10; var height_top = $('.header-fixed').height(); $("#menu_items").on("click", "a", function (event) { if (!$(this).hasClass('not_change')) { if (!$(this).hasClass("active")) { $("#menu_items a.active").removeClass("active"); $(this).addClass("active"); } event.preventDefault(); var id = $(this).attr('href'); var top = $(id).offset().top; $('body,html').animate({ scrollTop: top - height_top }, 500); } }); } function initializePriceTabs() { var activeTab = $('.price .tabs .tab.active'); var activeContentSelector = activeTab.length > 0 ? activeTab.data('content') : $('.price .tab-content :first-child'); $(activeContentSelector).addClass('active'); $('.price .tabs .tab').on('click', function (event) { $('.price .tabs .tab.active, .price .tab-content > div.active').removeClass('active'); var contentSelector = $(event.currentTarget).data('content'); $(event.currentTarget).addClass('active'); $(contentSelector).addClass('active'); }); } function changeActiveMenuTab() { var scrollPosition = $(document).scrollTop(); var height_top = $('.header-fixed').outerHeight(true) + $('#row_menu').outerHeight(true); if ($(window).width() > 1250) { $('#menu_items a:not(.mobile_show)').each(function () { var currentLink = $(this); if (!currentLink.hasClass('not_change')) { var refElement = $(currentLink.attr("href")); if ((refElement.position().top - height_top) <= scrollPosition && (refElement.position().top + refElement.height()) > scrollPosition) { $('#menu_items a').removeClass("active"); currentLink.addClass("active"); } } }); } } function toggleBossComment() { $('.boss-comment .comment-block').toggleClass('full'); } function showPhotos() { $.fancybox.open($('.photo .photo-container a'), { thumbs: { autoStart: true } }); } function togglePriceHint(hintIcon) { var mobileHint = $(hintIcon).next('.mobile-hint'); mobileHint.toggleClass('hidden'); } function setActiveUsefulInfoTab(newTab) { var popupContent = newTab.closest('.fancybox-content'); var tabWrapper = popupContent.find('.tabs-wrapper'); popupContent.find('.tab.active, .tab-content > div.active').removeClass('active'); var contentSelector = newTab.data('content'); newTab.addClass('active'); popupContent.find('.tab-content > div' + contentSelector).addClass('active'); // Update page number var paginationBlock = popupContent.find('.tab-pagination'); if (paginationBlock.length > 0) { paginationBlock.find('.tab-pagination__current-number').text(newTab.index() + 1); } // Scroll tab wrapper var wrapperVisibleArea = { left: tabWrapper.scrollLeft(), right: tabWrapper.scrollLeft() + tabWrapper.width() }; var newTabSidePosition = { left: newTab.position().left, rigth: newTab.position().left + newTab.outerWidth(), }; if (newTabSidePosition.left >= wrapperVisibleArea.left && newTabSidePosition.rigth <= wrapperVisibleArea.right) { // do nothing } else { switch (true) { case newTabSidePosition.left < wrapperVisibleArea.left: tabWrapper.scrollLeft(newTabSidePosition.left); break; case newTabSidePosition.rigth > wrapperVisibleArea.right: tabWrapper.scrollLeft(newTabSidePosition.rigth - tabWrapper.width()); break; } } } $(document).ready(function () { var date_list = $('.list_season_block ul li').length; if (date_list > 4) $('.list_season_block').addClass('more'); $('body').on('click', '.list_season_block ul li', function (event) { if (!$(event.currentTarget).hasClass('individual')) { var text = $(event.currentTarget).find('.period').text(); $('.season.period_block .value').text(text); var datePrice = $(event.currentTarget).data('datePrice'); $('.info_about_tour .price_mob .price-number').text(datePrice); var hikeId = $(event.currentTarget).data('hikeId'); var dateId = $(event.currentTarget).data('dateId'); $('.info_about_tour .price button.button_mob_callback').attr('onclick', `showTourRequestForm(${hikeId}, ${dateId}, {goalId: 'ORDER-2'});`); } $(event.currentTarget).parents('.list_season_block').hide(); showTourRequestForm(hikeId, dateId, {goalId: 'ORDER-2'}); }); $('body').on('click', '.hike-dates .date-row .btn_zakaz', function () { var button = $(this); var id = button.data('id'); var date_id = button.data('date-id'); showTourRequestForm(id, date_id, { ymGoal: 'ORDER-3', gaGoal: 'zayavka-iz-srokov-puteshestviya' }); return false; }); /*Открытие и закрытие блока с датами при клике*/ $('body').on('click', '.period_block .value', function () { $(this).parent().find('.list_season_block').toggle(); if ($(this).hasClass('open-date')) { $('body').removeClass('open-dates'); } else { $('body').addClass('open-dates'); } $(this).toggleClass('open-date'); }); /*//Открытие и закрытие блока с датами при клике*/ /*Закрытие блока с датами при клике вне данного блока*/ $('body').on('mouseup touchend', function (e) { var cont_sub_cat = $('.list_season_block'); if (!cont_sub_cat.is(e.target) && cont_sub_cat.has(e.target).length === 0 && !($(e.target).hasClass('open-date'))) { $('.list_season_block').hide(); $('.period_block .value').removeClass('open-date'); $('body').removeClass('open-dates'); } }); /*Закрытие блока с датами при клике вне данного блока*/ fixCkeBug(); new Swiper('.swiper_container_bunners', { autoHeight: true, navigation: { nextEl: '.swiper-button-next-bunners-right', prevEl: '.swiper-button-prev-bunners-left', }, loop: true, on: { tap: function () { $('.list_season_block').hide(); $('.period_block .value').removeClass('open-date'); $('body').removeClass('open-dates'); } } }); new Swiper('.club-team .team.style_count_more .swiper-container', { slidesPerView: 3, navigation: { prevEl: '#team-slider-prev-arrow', nextEl: '#team-slider-next-arrow', }, breakpoints: { 992: { slidesPerView: 1 }, 1250: { slidesPerView: 2 }, } }); new Swiper('.gid_manager_wrap .swiper-container', { slidesPerView: 1, spaceBetween: 30, navigation: { prevEl: '.manager_mob .icon-Arrow-l-l', nextEl: '.manager_mob .icon-Arrow-l-R', }, breakpoints: { 992: { slidesPerView: 1 }, }, }); new Swiper('.photo_slider_mob .swiper-container', { slidesPerView: 1.3, spaceBetween: 20, breakpoints: { 768: { slidesPerView: 1.3 }, } }); new Swiper('#reviews .swiper-container', { slidesPerView: 1, pagination: { el: '#reviews .swiper-pagination', type: 'fraction', }, autoHeight: true, navigation: { nextEl: '#reviews .swiper-button-next', prevEl: '#reviews .swiper-button-prev', }, }); if($('.gid_manager_wrap .swiper-container .swiper-slide').length == 1) { $('.gid_manager_wrap .icon-Arrow-l-l').addClass('d_none'); $('.gid_manager_wrap .icon-Arrow-l-R').addClass('d_none'); } $('.gid_manager_wrap .tabs_content').removeClass('active'); renderDayCircles(); moving_anchors_slow(); initializePriceTabs(); $('.photo .photo-container a').fancybox(); if ($(document).width() <= 768) { var activeContent = $('.route .tabs .tab.active').data('content'); $(activeContent).addClass('active'); $('.route .tabs .tab').on('click', function (event) { $('.route .tabs .tab.active, .route .tab-content > div.active').removeClass('active'); var contentSelect = $(event.currentTarget).data('content'); $(event.currentTarget).addClass('active'); $(contentSelect).addClass('active'); }); $('.includes .tabs_mob .title').on('click', function () { $(this).parents('.includes').find('.active').removeClass('active'); $(this).parents('.includes').find('[data-tabs_mob="' + $(this).data('content') + '"]').addClass('active'); $(this).addClass('active'); }); } $('.show_contact_form').on('click', function () { var tour_name = $(this).data('tour'); $.fancybox.open({ type: 'ajax', src: "/hikes/get_manager_form", opts: { afterShow: function (instance, current) { var secur = false; $('.contact_form_ajax').find('input.tour_name').val(tour_name); $("body").on('click touchend', '.tabs_menu div', function () { if (!$(this).hasClass("active")) { var i = $(this).index(); $(".tabs_menu div.active").removeClass("active"); $(".tabs .info").hide().removeClass("active").find('input').val(''); $(this).addClass("active"); $($(".tabs").children(".info")[i]).fadeIn(500).addClass("active"); } }); $('body').on('input keyup', '.contact_form_ajax .content_form .input_contact_for_js', function (e) { if ($(".form_contact_input").val() !== "" && $(".questions_textarea_form_contact").val() !== "" && ($('.tabs .info').hasClass("active") == true && $(".tabs .active .form_contact_input").val() !== "")) { $(".send_button_form_contact").fadeIn(500).removeClass("button_form_contact_block"); secur = true; } else { $(".send_button_form_contact").fadeIn(500).addClass("button_form_contact_block"); secur = false; } }); $("body").on("touchend click", '.send_button_form_contact', function () { if (secur == true) { var form = $(this).parents('form'); var data = form.serializeArray(); $.post( '/common/add_feedback', data, function (result) { if (result) { $(".wrapper_form_content_contact").addClass("display_none"); $(".thanks_for_feedback_contact").removeClass("display_none"); $(".contact_form_ajax").addClass("contact_form_ajax_send"); } }, 'json' ); } }); } } }); return false; }); /*Табы во всплывающем окне для блока Полезная информация*/ $(".hikes_datail .item_info .name_link, .hikes_datail .item_info i").on("click", function () { var activeData = $(this).parents('.item_info').data('type_icon'); var content = $('.block-info').html(); $.fancybox.open({ type: "html", content: content, opts: { afterShow: function (instance, current) { var activeTab = $('.fancybox-container .block-info-ajax .tab[data-content="#' + activeData + '"]'); setActiveUsefulInfoTab(activeTab); $('.fancybox-container .block-info-ajax .tab').on('click', function (event) { setActiveUsefulInfoTab($(event.currentTarget)); }); if ($(document).width() <= 1300) { current.$content.find('.tab-content').swipe({ swipeLeft: () => { var nextTab = current.$content.find('.tab.active').next(); if (nextTab.length > 0) { setActiveUsefulInfoTab(nextTab); } }, swipeRight: () => { var prevTab = current.$content.find('.tab.active').prev(); if (prevTab.length > 0) { setActiveUsefulInfoTab(prevTab); } } }); current.$content.find('.tab-pagination__arrow').on('click', (event) => { var activeTab = current.$content.find('.tab.active'); switch (true) { case $(event.currentTarget).hasClass('tab-pagination__arrow_prev'): setActiveUsefulInfoTab(activeTab.prev()); break; case $(event.currentTarget).hasClass('tab-pagination__arrow_next'): setActiveUsefulInfoTab(activeTab.next()); break; } }); } }, touch: false } }); }); /*//Табы во всплывающем окне для блока Полезная информация*/ $(document).on('click', function (event) { if ($(event.target).hasClass('hint')) { var mobileHint = $(event.target).next('.mobile-hint'); $('.mobile-hint').not(mobileHint).addClass('hidden'); } else { $('.mobile-hint').addClass('hidden'); } if ( $(event.target).hasClass('hint') || $(event.target).hasClass('date-row__info__hint_mobile__text') || $(event.target).parent().hasClass('date-row__info__hint_mobile__text') ) { // do nothing } else { $('.hint.active').removeClass('active'); } }); $('ul.tabs_title').on('click', 'li:not(.active)', function() { $(this) .addClass('active').siblings().removeClass('active') .closest('div.tabs_gid_manager').find('div.tabs_content').removeClass('active').eq($(this).index()).addClass('active'); }); }); $(document).on('scroll', function () { if ($(document).width() > 1250) { changeActiveMenuTab(); } });