"use strict"; $(document).ready(function () { // слайдер галерея $('.slot-gallery').slick({ slidesToShow: 4, slidesToScroll: 1, dots: false, arrows: true, prevArrow: '', nextArrow: '', responsive: [ { breakpoint: 768, settings: { slidesToShow: 2, } } ] }); // слайдер выигрышей $('.winning__body').slick({ slidesToShow: 2, slidesToScroll: 1, dots: true, dotsClass: 'winning__dots', arrows: false, autoplay: true, autoplaySpeed: 3000, responsive: [ { breakpoint: 992, settings: { slidesToShow: 1, } } ] }); /** * FAQ */ $('.faq__head').click(function () { $(this).parents('.faq__item').toggleClass('faq__item_open').find('.faq__body').slideToggle('fast'); }); /** * Поиск */ $('.search-form__toggle').click(function () { $('body').addClass('search-opened'); $('.search-form__main').fadeIn(300); }); $('.search-form__close').click(function () { $('body').removeClass('search-opened'); $('.search-form__main').fadeOut(300); }); /** * Звезды в форме комменариев */ $('.vote-rating__control').change(function () { var label = $('.vote-rating__control:checked').val(); $('.vote-rating__head').text(label); }); /** * Стрелка наверх */ $(window).scroll(function () { if ($(this).scrollTop() > 200) { $('#back-top').fadeIn(300); } else { $('#back-top').fadeOut(300); } }); $('#back-top a').click(function () { $('body,html').animate({ scrollTop: 0 }, 800); return false; }); /** * Iframe вместо изображения */ $('.slot__play-link').click(function (e) { e.preventDefault(); var parent = $(this).parents('.slot__play'); var width = parent.find('img').width(); var height = parent.find('img').height(); var src = $(this).data('src'); var iframe = ''; parent.html(iframe); }); /** * Скрыть уведомление про куки */ $('.cookie__btn').click(function (e) { e.preventDefault(); $(this).parents('.cookie').fadeOut(300); }); /** * Свернуть/развернуть характеристики */ $('.option__head').click(function () { $(this).parents('.option__item').toggleClass('option__item_open').find('.option__body').slideToggle(300); }); /** * Мобильное меню */ $('.nav-toggle').click(function () { $('html').toggleClass('menu-opened'); }); /** * Адаптив таблиц в контенте */ $('.article table').wrap("
"); /** * Плавная прокрутка по якорю */ $('.scroll-link').on('click', function (event) { event.preventDefault(); var target = $(this), url = target.attr('href'); $('html, body').animate({ scrollTop: $(url).offset().top - 30 }, 750); }); /** * Показ всей таблицы казино */ $('.top-wrap__more').on('click', function (event) { event.preventDefault(); if ($('.top-rating__collapsed').hasClass('active')) { $('.top-rating__collapsed').removeClass('active').slideUp('fast'); $(this).html($(this).data('max')); } else { $('.top-rating__collapsed').addClass('active').slideDown('fast'); $(this).html($(this).data('min')); } }) /** * Сворачивание дочерних страниц у казино */ if ($('.page-childs').length > 0) { hidePageChilds() $('.page-childs .more').click(function () { if ($(this).hasClass('clicked')) { $(this).removeClass('clicked').find('a').text('Ещё') hidePageChilds() } else { $(this).addClass('clicked').find('a').text('Скрыть') $('.page-childs li').show(); } return false; }); var cachedWidth = $(window).width(); $(window).resize(function () { if (!$('.page-childs .more').hasClass('clicked')) { var newWidth = $(window).width(); if (newWidth !== cachedWidth) { $('.page-childs .more').removeClass('clicked'); $('.page-childs li').not('.more').show(); hidePageChilds() } } }) } /** * Популярные казино месяца */ $('.collapse-toggler').click(function () { if ($(this).hasClass('active')) { $(this).removeClass('active'); $(this).next().fadeOut(200); } else { $(this).addClass('active'); $(this).next('.collapse').fadeIn(200); } return false; }); /** * Плавающий header для казино */ if ($('.casino-sticky-header').length>0) { $(window).scroll(function () { const top = $('.casino-welcome').height() + $('.casino-welcome').offset().top; if ($(this).scrollTop() >= top && !$('.casino-sticky-header').hasClass('active')) $('.casino-sticky-header').addClass('active') else if ($(this).scrollTop() < top && $('.casino-sticky-header').hasClass('active')) $('.casino-sticky-header').removeClass('active') }); //if ($('#wpadminbar').length>0) // $('.casino-sticky-header').css('top', $('#wpadminbar').height()); } /** * Промокоды */ $('.promocode__btn').click(function () { if ($(this).hasClass('active')) return false; $(this).addClass('active') const parent = $(this).closest('.promocode__item') parent.find('.promocode__status').hide() parent.find('.promocode__link').css('display', 'flex') $(this).html($(this).data('code')) copyTextToClipboard($(this).data('code')) showTooltip($(this), 'Промокод скопирован', '') return false; }); /** * Подписка емейл */ $('.subscribe__btn').click(function () { $(this).prop('disabled', true); showTooltip('.subscribe__group', 'Отправка...', '') var data = { action: 'subscribe', nonce_code: myajax.nonce, email: $('.subscribe__control').val(), }; $.post(myajax.url, data, function (response) { if (response == 1) { showTooltip('.subscribe__group', 'Подписка оформлена', '') $('.subscribe__control').val('') } else { showTooltip('.subscribe__group', 'Ошибка отправки', 'error') } }); $(this).prop('disabled', false); return false; }); const breakpoint = window.matchMedia('(max-width: 991px)') $('.main-menu__item_parent>a').click(function() { if (breakpoint.matches === true) { let parent = $(this).parent(); if (parent.hasClass('main-menu__item_active')) { parent.removeClass('main-menu__item_active'); } else { parent.addClass('main-menu__item_active'); } return false; } }); }); function hidePageChilds() { $('.page-childs .more').removeClass('active') if ($('.page-childs ul').height() > 45) { $('.page-childs .more').addClass('active'); while ($('.page-childs ul').height() > 45) { $('.page-childs li:visible:not(.more)').last().hide(); } } } function fallbackCopyTextToClipboard(text) { var textArea = document.createElement("textarea"); textArea.value = text; // Avoid scrolling to bottom textArea.style.top = "0"; textArea.style.left = "0"; textArea.style.position = "fixed"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'successful' : 'unsuccessful'; } catch (err) { console.error('Fallback: Oops, unable to copy', err); } document.body.removeChild(textArea); } function copyTextToClipboard(text) { if (!navigator.clipboard) { fallbackCopyTextToClipboard(text); return; } navigator.clipboard.writeText(text).then(function () { }, function (err) { console.error('Async: Could not copy text: ', err); }); } function showTooltip(parent, text, classname) { if (typeof parent != "object") parent = $(parent) parent.find('.tooltip').remove() parent.append('
' + text + '
') parent.find('.tooltip').fadeIn('fast') setTimeout(function () { parent.find('.tooltip').fadeOut('fast', () => parent.find('.tooltip').remove()); }, 2000) } document.querySelectorAll('.js-copy-link-promocode').forEach(btn => { btn.onclick = function(e) { e.preventDefault() btn.disabled = true navigator.clipboard.writeText(btn.querySelector('.js-code').innerHTML); let alert = document.createElement('div') alert.className = 'promocode-alert' alert.innerHTML = 'Скопировано' btn.appendChild(alert) setTimeout(()=>{alert.remove();btn.disabled = false}, 500) } })