$(document).ready(function(){ if ($(".menu-top [href]")) { $(".menu-top [href]").each(function() { if (this.href == window.location.href) { $(this).addClass("current-link"); } }); } if ($(".menu-course [href]")) { $(".menu-course [href]").each(function() { if (this.href == window.location.href) { $(this).addClass("act"); } }); } //scroll to id $('a[href*="#"]') .not('[href="#"]') .not('[href="#0"]') .click(function(event) { if ( location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname ) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); if (target.length && this.dataset.toggle !== "tab") { event.preventDefault(); $('html, body').animate({ scrollTop: target.offset().top }, 700, function() { var $target = $(target); $target.focus(); if ($target.is(":focus")) { return false; } else { $target.attr('tabindex','-1'); $target.focus(); }; }); } } }); // slider partner $('.partner-log').slick({ infinite: true, slidesToShow: 4, slidesToScroll: 1, autoplay: true, prevArrow: '
', nextArrow: '
', responsive: [ { breakpoint: 1240, settings: { slidesToShow: 3, slidesToScroll: 1, } }, { breakpoint: 960, settings: { slidesToShow: 2, slidesToScroll: 1, } }, { breakpoint: 440, settings: { slidesToShow: 1, slidesToScroll: 1, } }, ], }); $('.slider').slick({ arrows: false, adaptiveHeight: true, autoplay: true, autoplaySpeed: 3000, dots: true, customPaging: function(slider, i) { // this example would render "tabs" with titles return ''; }, }); // slider courses $(window).on('load resize orientationchange', function() { $('#courses-slider-home').each(function(){ var $carousel = $(this); /* Initializes a slick carousel only on mobile screens */ // slick on mobile if ($(window).width() > 721) { if ($carousel.hasClass('slick-initialized')) { $carousel.slick('unslick'); } } // else if ($(window).width() < 1171 && $(window).width() > 690){ // //if (!$carousel.hasClass('slick-initialized')) { // $carousel.slick({ // mobileFirst: true, // rows: 2, // slidesPerRow: 2, // prevArrow: '
', // nextArrow: '
', // }); // //} // } else{ if (!$carousel.hasClass('slick-initialized')) { $carousel.slick({ mobileFirst: true, rows: 2, slidesPerRow: 1, prevArrow: '
', nextArrow: '
', }); } } }); }); $(window).on('load resize orientationchange', function() { $('#courses-slider-courses').each(function(){ var $carousel = $(this); if ($(window).width() > 721) { if ($carousel.hasClass('slick-initialized')) { $carousel.slick('unslick'); } } else{ if (!$carousel.hasClass('slick-initialized')) { $carousel.slick({ mobileFirst: true, slidesToShow: 1, slidesToScroll: 1, prevArrow: '
', nextArrow: '
', }); } } }); }); // slider news $(window).on('load resize orientationchange', function() { $('.news-slider').each(function(){ var $carousels = $(this); /* Initializes a slick carousel only on mobile screens */ // slick on mobile if ($(window).width() > 721) { if ($carousels.hasClass('slick-initialized')) { $carousels.slick('unslick'); } } else{ if (!$carousels.hasClass('slick-initialized')) { $carousels.slick({ slidesToShow: 1, slidesToScroll: 1, mobileFirst: true, prevArrow: '
', nextArrow: '
', }); } } }); }); // lightbox // if ($('a[data-imagelightbox="lightbox"]')) { // $('a[data-imagelightbox="lightbox"]') // .imageLightbox( // { // overlay: true, // button: true, // arrows: true // } // ); // } // reg-more open $('#registration-button').click( function () { $('.reg-more').addClass('jazda'); $(this).css('display', 'none'); }); // menu mobile open $('.menu-ham').click( function () { $('.menu').toggleClass('menu-open'); }); // send registration // $("form").submit(function(e) { // e.preventDefault(); // var formData = new FormData(this); // $.ajax({ // url: "send.php", // type: 'POST', // data: formData, // beforeSend: function() { // $('.reg-more').removeClass('jazda'); // $('html, body').animate({ // scrollTop: $('#rejestracja').offset().top // }, 1000); // $('#registration-button').css('display', 'flex'); // }, // success: function (data) { // $("form")[0].reset(); // $('#send-data').text(data); // }, // cache: false, // contentType: false, // processData: false // }); // }); // ajax data for comment const commentList = document.querySelector('.comments-list'); if (commentList){ commentList.addEventListener('click', function (e) { if (e.target.classList.contains('show-data')) { let id = e.target.getAttribute('data-id'); var data = { action: 'get-comment-data', id: id, }; $.ajax({ // you can also use $.post here url : 'https://www.akademiatanca.com.pl/at/wp-admin/admin-ajax.php', // AJAX handler data : data, type : 'POST', beforeSend : function ( xhr ) { e.target.textContent = 'Ładuję'; }, success : function( data ){ if( data ) { let divData = e.target.nextSibling.nextSibling; divData.innerHTML = data; } else { let divData = e.target.nextSibling.nextSibling; divData.innerHTML = 'wystąpił błąd'; } } }).done(function() { e.target.style.display = 'none'; }); } }); } // display success info for comment var $hash = window.location.hash; var successCommentDiv = document.querySelector('.success-comment'); if ($hash == '#success') { if (successCommentDiv) { successCommentDiv.textContent = 'Twoje ogłoszenie zostanie opublikowane po akceptacji moderatora.'; } } // add info about no record for courses for you var div = document.querySelector('.mbt60 .list-coures .singup-table .container-sec h2'); if (div) { var next = div.nextElementSibling; if (!next) { var newElement = document.createElement('p'); newElement.classList.add('success-comment'); newElement.innerHTML = 'Nic nie znaleźliśmy'; div.parentNode.insertBefore( newElement, div.nextSibling ); } } // menu course var viewportWidth = window.innerWidth || document.documentElement.clientWidth; var ul = document.querySelector('.menu-course .container-sec ul'); if (ul){ ul.addEventListener('click', function (e) { if (viewportWidth < 997) { if (!ul.classList.contains('open')) { e.preventDefault(); ul.classList.add('open'); } } }); } var nav = document.querySelector('.dances-tabs ul'); if (nav){ nav.addEventListener('click', function (e) { if (viewportWidth < 997) { e.preventDefault(); nav.classList.toggle('open'); nav.insertBefore(e.target.parentNode, nav.firstChild); } }); } var active = document.querySelector('.dances-tabs ul .active'); if(active){ if (viewportWidth < 997) { nav.insertBefore(active, nav.firstChild); } } var body = document.querySelector('body'); if (body) { body.addEventListener('click', function (e) { if (!e.target.classList.contains('menu-course-target')) { if (viewportWidth < 997) { if(ul){ if (ul.classList.contains('open')) { ul.classList.remove('open'); } } } } if (!e.target.classList.contains('pos-dances-target')) { if (viewportWidth < 997) { if(nav){ if (nav.classList.contains('open')) { nav.classList.remove('open'); } } } } }); } $(".menu-course [href]").each(function() { if (this.href == window.location.href) { $(this).addClass("act"); var act = document.querySelector('.menu-course .container-sec ul li a.act'); if (act) { if (viewportWidth < 997) { ul.insertBefore(act.parentNode, ul.firstChild); } } } }); function setMinHeightForCourseTop() { var dancesTabs = document.querySelector('.dances-tabs'); if (dancesTabs) { var dancesTabsHeight = dancesTabs.offsetHeight; var courseTop = $('.course-top'); var minHeight = dancesTabsHeight + 120; courseTop.each( function() { $( this ).css('min-height', minHeight + 'px'); }); } } setMinHeightForCourseTop(); var resizeTimer; $(window).on('resize', function(e) { clearTimeout(resizeTimer); resizeTimer = setTimeout(function() { setMinHeightForCourseTop(); }, 250); }); });