//fancybox jQuery(document).ready(function(){ jQuery(".modalka").fancybox({ padding: 0, }); jQuery("[data-fancybox]").fancybox({ loop: true, gutter: 30, buttons: [ "zoom", //"share", //"slideShow", //"fullScreen", "thumbs", "close" ], protect: true, transitionEffect: "circular", //слайдшоу slideShow: { autoStart: false, speed: 5000 }, lang: "ru", i18n: { ru: { CLOSE: "Закрыть", NEXT: "Вперед", PREV: "Назад", ERROR: "Ошибка загрузки.
Повторите запрос позднее.", PLAY_START: "Начать демонстрацию", PLAY_STOP: "Приостановить демонстрацию", FULL_SCREEN: "На полный экран", THUMBS: "Миниатюры", DOWNLOAD: "Скачать", SHARE: "Поделиться", ZOOM: "Увеличить" }, } }); }); //Замена заголовка в модальном окне $( ".modalka" ).click(function() { if ("item_name"){ $("#1 .mod_title").html($(this).attr("item_name")); $("#1 input[name=title]").attr("value", $(this).attr("item_name").replace(/<\/?[^>]+>/g,'')); } }); //Скрипт плавного перехода к нужному блоку $(document).ready(function(){ jQuery(".main__banner__page").on("click","a.down", function (event) { //отменяем стандартную обработку нажатия по ссылке event.preventDefault(); //забираем идентификатор бока с атрибута href var id = $(this).attr('href'), //узнаем высоту от начала страницы до блока на который ссылается якорь top = $(id).offset().top; //анимируем переход на расстояние - top за 1500 мс jQuery('body,html').animate({scrollTop: top}, 1500); }); }); //Кнопка наверх $(document).ready(function(){ /** При прокрутке страницы, показываем или срываем кнопку*/ $(window).scroll(function () { // Если отступ сверху больше 50px то показываем кнопку "Наверх" if ($(this).scrollTop() > 500) { $('#button-up').fadeIn(); } else { $('#button-up').fadeOut(); } }); /** При нажатии на кнопку мы перемещаемся к началу страницы */ $('#button-up').click(function () { $('body,html').animate({ scrollTop: 0 }, 500); return false; }); }); //Мобильное меню $(function(){ $('.menu ').slicknav({ label: 'МЕНЮ', prependTo:'.main__menu' }); }); //Слайдер slick http://kenwheeler.github.io/slick/ $(function(){ $('.slider__head').slick({ infinite: true, slidesToShow: 1, slidesToScroll: 1, dots: true, arrows : false, autoplay: true, pauseOnHover: false, pauseOnDotsHover: true, autoplaySpeed: 3600, fade: true, }); $('.slider__portfolio').slick({ infinite: true, slidesToShow: 3, slidesToScroll: 1, autoplay: true, autoplaySpeed: 3000, responsive: [{ breakpoint: 900, settings: { slidesToShow: 2, } },{ breakpoint: 600, settings: { slidesToShow: 1 } }] }); $('.slider__client').slick({ infinite: true, slidesToShow: 5, slidesToScroll: 1, autoplay: true, autoplaySpeed: 3000, responsive: [{ breakpoint: 1000, settings: { slidesToShow: 4, } },{ breakpoint: 800, settings: { slidesToShow: 3 } },{ breakpoint: 600, settings: { slidesToShow: 2 } },{ breakpoint: 500, settings: { slidesToShow: 1 } }] }); }); //замена контента по utm метке utm_replace // калалог заголовков и селекторов var content = { shadrinsk: [ { selector: '.head .logo a', content: 'Сваи Шадринск' }, { selector: '.footer .logo a', content: 'Сваи Шадринск' }, { selector: '.slide__head .title span', content: 'Шадринске' }, { selector: '.main__sert p span', content: 'Шадринск' } ], kurgan: [ { selector: '.head > .logo > a', content: 'Сваи Курган' }, { selector: '.footer > .logo > a', content: 'Сваи Курган' }, { selector: '.slide__head .title span', content: 'Кургане' }, { selector: '.main__sert p span', content: 'Курган' } ], }; // заменяет контент function replacer(content, utm) { if (utm in content) { for (i in content[utm]) { if(document.querySelector(content[utm][i]['selector'])!=null) {document.querySelector(content[utm][i]['selector']).innerHTML=content[utm][i]['content'];}; }; } else { console.log("Каталог контента не имеет такой utm метки"); }; }; // возвращает cookie с именем name, если есть, если нет, то undefined function getCookie(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; } // записывает utm в cookie на 30 дней function setCookie(utm) { var date = new Date(new Date().getTime() + (30*24*60*60*1000)); document.cookie = 'utm_replace=' + utm + '; path=/; expires=' + date.toUTCString(); }; // объединяет все функции в один алгоритм function replacerMain(content) { // check is there utm in url if (/utm_replace=([^&]*)/g.exec(document.URL)) { var utm = /utm_replace=([^&]*)/g.exec(document.URL)[1]; } else { var utm = null }; if (utm != null) { replacer(content, utm); setCookie(utm); } else if (getCookie('utm_replace') != undefined) { replacer(content, getCookie('utm_replace')); } else { console.log('utm_replace не нашел метку ни в URL, ни в cookie') }; }; replacerMain(content); //end замена контента по utm метке utm_replace