const mobileWidth = 480; var windowHeight = $(window).height(); function isMobile() { return $(window).width() < mobileWidth; } function initXForm() { $('.xInput').addClass("idleField"); $('.xInput').focus(function() { $(this).removeClass("idleField").addClass("focusField"); if (this.value == this.defaultValue){ this.value = ''; } if(this.value != this.defaultValue){ this.select(); } }); $('.xInput').blur(function() { $(this).removeClass("focusField").addClass("idleField"); if (this.value == '') { this.value = (this.defaultValue ? this.defaultValue : ''); } }); } function afterItemUpdate() { $(".hasOver").mouseenter(function(){ $(this).addClass("over"); }); $(".hasOver").mouseleave(function(){ $(this).removeClass("over"); }); } window.dataLayerManager = { sendEvent: function(event, category, action, label, value, non_interaction) { var dlParams = { 'event': event, 'gtm-event-category': category, 'gtm-event-action': action, 'gtm-event-label': label, 'gtm-event-value': value, 'gtm-non-interaction': non_interaction }; dataLayer.push(dlParams); } }; (function( func ) { $.fn.addClass = function() { // replace the existing function on $.fn func.apply( this, arguments ); // invoke the original function this.trigger('classChanged'); // trigger the custom event return this; // retain jQuery chainability } })($.fn.addClass); // pass the original function as an argument (function( func ) { $.fn.removeClass = function() { func.apply( this, arguments ); this.trigger('classChanged'); return this; } })($.fn.removeClass); $(document).ready(function() { $('.topSearch form .close, .topSearch .searchIco').click(function() { var el = $(this).parents('.topSearch'); el.toggleClass('open'); if (el.hasClass('open')) { el.find('.search').focus(); } }); $("body").on("focus", ".floatInput input, .floatInput textarea", function() { $(this).parents('.floatInput').addClass('up'); }); $("body").on("blur", ".floatInput input, .floatInput textarea", function() { if ($(this).val()=='') { $(this).parents('.floatInput').removeClass('up'); } else { $(this).parents('.floatInput').addClass('up'); } }); $("body").on("input", ".floatInput input, .floatInput textarea", function() { if ($(this).val()=='') { $(this).parents('.floatInput').removeClass('up'); } else { $(this).parents('.floatInput').addClass('up'); } }); $("body").on("classChanged", ".floatInput input, .floatInput textarea", function() { if ($(this).hasClass('error')) { $(this).parents('.floatInput').addClass('error'); } else { $(this).parents('.floatInput').removeClass('error'); } }); var scrollPos = 0; $(window).scroll(function(){ var st = $(this).scrollTop(); var bodyHeight = $('body').height(); console.log(bodyHeight); if (st > scrollPos && ( (st + windowHeight) < (bodyHeight - 500)) ) { $('.bottomFloat').addClass('show'); } else { $('.bottomFloat').removeClass('show'); } scrollPos = st; if ($(this).scrollTop() > 116) { $('body').addClass('fixed'); } else { $('body').removeClass('fixed'); } }); $('.variantSelector select').change(function() { var item_id = $(this).parents('.variantSelector').attr('data-item-id'); configurationUpdate(item_id); }); function configurationUpdate(item_id) { var ids = []; $('.variantSelector select').each(function() { var name = $(this).attr('name'); var id = $(this).children(":selected").attr("id"); ids.push(id); console.log(name); }); console.log(ids); $.ajax({ url: "/templates/ajax_calcConfigurationData.phtml", data: { item_id: item_id, ids: ids }, type: 'GET', cache: false, async: true, dataType: 'json', success: function(data) { $('.price .textPrice').html(data.textPrice); $('.btnBlock .add').attr('data-configuration', ids); let url = new URL('https://www.fratellibarri.ru/'+$('.btnBlock .add').attr('href')); var searchParams = new URLSearchParams(url.search); searchParams.set('configuration', ids); for (let p of searchParams) { console.log(p); } $('.btnBlock .add').attr('href', '/case/add/?'+searchParams.toString()); // console.log(data); } }); } $(".searchBtn, .mobSearch .close").click(function() { console.log('a'); var section = $('section.mobSearch'); if (section.hasClass('closed')) { section.removeClass('closed'); // $('body').addClass('blend'); section.find('input[type="text"]').focus(); } else { section.addClass('closed'); $('body').find('.mobSearchOverlay').remove(); // $('body').removeClass('blend'); } }); $(".jumper").click(function() { var label = $(this).attr('label'); var offset = $(this).attr('offset'); var body = $("html, body"); var element = $("#"+label); var position = element.offset().top - offset; body.animate({scrollTop:position}, '500', 'swing'); }); $("body").on("click", ".price .na.req", function(){ $('#sumNa').remove(); var el = $('#sumNa'); var item_id = $(this).parents('.item').attr('id'); var hint = $(this).attr('hint'); var left = $(this).offset().left; var top = $(this).offset().top; if (!el.length) { el = $(this).append("
"+hint+"
"); $('#sumNa').addClass('opened'); } // el.css('left', left+'px'); // el.css('top', top+'px'); }); $("body").on("click", "#sumNa > div", function() { var item_id = $(this).parents('.item').attr('id'); if (item_id == undefined) { item_id = $(this).parents('.row').attr('data-id'); } window.location.href='/case/add/?item_id='+item_id; }); $(document).mouseup(function (e){ // событие клика по веб-документу var div = $("#sumNa"); // тут указываем ID элемента if (!div.is(e.target) // если клик был не по нашему блоку && div.has(e.target).length === 0) { // и не по его дочерним элементам div.hide(); // скрываем его } }); var mql = window.matchMedia('all and (max-width: 700px)'); if (mql.matches) { $('body').addClass('is_mobile'); // размер окна 480px или меньше } else { $('body').removeClass('is_mobile'); // нет, размер окна более 480px } initXForm(); $("#topMenu li").mouseenter(function(){ $(this).addClass("over"); }); $("#topMenu li").mouseleave(function(){ $(this).removeClass("over"); }); $(".hasOver").mouseenter(function(){ $(this).addClass("over"); }); $(".hasOver").mouseleave(function(){ $(this).removeClass("over"); }); $(".buyCert").click(function() { var id = $(this).attr('id'); $.fancybox({ 'padding' : 20, 'transitionIn' : 'none', 'transitionOut' : 'none', 'href' : '/components/buy_cert.phtml?item_id='+id, 'type' : 'ajax' }); }); $(".fbImageGroup").fancybox({ openEffect : 'none', closeEffect : 'none' }); $(".mobileMenuBtn").click(function() { var el = $(this).parent('.topMenu'); if (el.hasClass('opened')) { $('body').removeClass('menuOpened'); /* if (el.hasClass('l2')) { el.removeClass('l2'); el.addClass('l1'); } else if (el.hasClass('l1')) { el.removeClass('l1'); } else { el.removeClass('opened'); } */ el.removeClass('l2'); el.removeClass('l1'); el.removeClass('opened'); el.find('.mBlk.opened').removeClass('opened'); } else { $('body').addClass('menuOpened'); el.addClass('opened'); } }); $(".contacts h2").click(function() { var el = $(this).parents('li'); if (el.hasClass('opened')) { el.removeClass('opened'); $(this).find('i').removeClass('fa-angle-up'); $(this).find('i').addClass('fa-angle-down'); } else { el.addClass('opened'); $(this).find('i').removeClass('fa-angle-down'); $(this).find('i').addClass('fa-angle-up'); } }); $("#callBack").click(function() { $.fancybox({ 'padding' : 20, 'transitionIn' : 'none', 'transitionOut' : 'none', 'href' : '/components/ajax_callback.phtml', 'type' : 'ajax' }); }); $(".searchForm input").focus(function(){ var txt = 'ПОИСК'; if ($(this).val()==txt) { $(this).val(''); } }) $(".searchForm input").blur(function(){ var txt = 'ПОИСК'; if ($(this).val()=='') { $(this).val(txt); } }) var txt = 'ПОИСК'; var searchControl = $(".searchForm input[type='text']"); if (searchControl.val()=='') { searchControl.val(txt); } function currentSlide( current ) { $(".current_slide").text(current + " of " + $("#slides").slides("status","total") ); } $("#indexSlider").slidesjs({ width: 744, height: 478, play: { active: true, // [boolean] Generate the play and stop buttons. // You cannot use your own buttons. Sorry. effect: "fade", // [string] Can be either "slide" or "fade". interval: 5000, // [number] Time spent on each slide in milliseconds. auto: true, // [boolean] Start playing the slideshow on load. swap: false, // [boolean] show/hide stop and play buttons pauseOnHover: false, // [boolean] pause a playing slideshow on hover restartDelay: 2500 // [number] restart delay on inactive slideshow }, navigation: { active: false } }); $(".contacts_get").click(function() { var addr = $(this).attr('addr'); var type = $(this).attr('type'); $(".dCont").addClass("hidden"); $("#map_"+addr).removeClass("hidden"); $("#descr_"+addr+"_"+type).removeClass("hidden"); return false; }); $(".btn.reserve").click(function() { var id = $(this).attr('id'); window.location.href='/reserve/r-'+id; return false; }); $(".lb li").click(function() { $(".lb li.selected").each(function() { $(this).removeClass('selected'); }); }); $(".cb li, .lb li").click(function() { if ($(this).hasClass('selected')) { $(this).removeClass('selected'); } else { $(this).addClass('selected'); } var isNew = ""; if ($(this).parents("ul").hasClass('new')) { isNew = 'new/'; } var query = ""; var npp=0; $(".cb li.selected").each(function() { query = query + 'ids['+$(this).attr('id')+']=1'+'&'; npp++; }); $(".lb li.selected").each(function() { query = query + 'ids['+$(this).attr('id')+']=1'+'&'; npp++; }); query = query.substring(0, query.length - 1) var alias = ""; $(".list li.selected").each(function() { alias = $(this).attr('alias'); }); var xUrl = "/jewellery/"+isNew+alias+"?"+query; // params = $.extend($.url().param(), params); // alert(url); $.ajax({ url: xUrl, cache: false, success: function(html) { $("#itemsBody").html(html); afterItemUpdate(); history.pushState(null, null, xUrl); }, error: function() { alert('error!'); } }); return false; }); $(".nav ul.display li").click(function() { var view=""; if ($(this).hasClass('list')) { view = 'list'; } else { view = 'grid'; } $.ajax({ url: "/setSession.phtml?view="+view, cache: false, success: function(html) { window.location.reload(); }, error: function() { alert('error!'); } }); return false; }); $(".cities ul li").click(function() { var self = $(this); var id=$(this).attr('id'); $.fancybox({ 'padding' : 20, 'transitionIn' : 'none', 'transitionOut' : 'none', 'href' : "/templates/ajax_contacts.phtml?id="+id, 'type' : 'ajax' }); /* $.ajax({ url: "/templates/ajax_contacts.phtml?id="+id, cache: false, success: function(html) { self.find(".cityDetail").html(html); }, error: function() { alert('error!'); } }); */ }); $(".fancybox").fancybox(); /* $('body') .on('movestart', function(e) { // If the movestart is heading off in an upwards or downwards // direction, prevent it so that the browser scrolls normally. if ((e.distX > e.distY && e.distX < -e.distY) || (e.distX < e.distY && e.distX > -e.distY)) { e.preventDefault(); } }); */ $('.index .next') .jcarouselControl({ target: '+=1' }); $('.index .prev') .jcarouselControl({ target: '-=1' }); $(".groupsMenu li").click(function() { var zone = $(this).attr('zone'); $('.groupsMenu li').removeClass('selected'); $(this).addClass('selected'); if (zone==0) { $('.itemsPreview li').css('display', 'block'); } else { $('.itemsPreview li').css('display', 'none'); $('.itemsPreview li[zone="'+zone+'"]').css('display', 'block'); } }); function showAjaxItem(id) { if (!$(".ajax_container").hasClass('ajax_container')) { $("body").append("
"); } $.ajax({ url: '/templates/ajax_item.phtml', data: {item_id: id}, cache: false, success: function(html) { $(".ajax_container").html(html); var root_id = $(".ajax_container #itemInfo").attr('root_id'); var el = $(".goodItems li[id='"+root_id+"']").next(); var next_id = el.attr('id'); $(".ajax_container .next").attr("id", next_id); if (next_id==undefined) { $(".ajax_container .next").css('display', 'none'); } else { $(".ajax_container .next").css('display', 'block'); } var el = $(".goodItems li[id='"+root_id+"']").prev(); var prev_id = el.attr('id'); $(".ajax_container .prev").attr("id", prev_id); if (prev_id==undefined) { $(".ajax_container .prev").css('display', 'none'); } else { $(".ajax_container .prev").css('display', 'block'); } var url = $(".ajax_container #itemInfo").attr('url'); window.history.replaceState(null, null, url); }, error: function() { alert('error!'); } }); } /* $("body").on('click', '.store_info', function() { var id = $(this).parents('.item').attr('id'); showAjaxItem(id); }); */ $("body").on('click', '.ajax_container .close', function() { var url = $(".goodItems").attr('currentUrl'); window.history.replaceState(null, null, url); $('.ajax_container').remove(); }); $("body").on('click', '.ajax_container .next, .ajax_container .prev, .variant', function() { var id = $(this).attr('id'); showAjaxItem(id); return false; }); if (isMobile()) { $('.index .bans').slick({ dots: true, arrows: true, infinite: false, speed: 300, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 3000, }); $('#lineMenu .phones').slick({ dots: true, arrows: true, infinite: true, speed: 300, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 3000, }); $('.bxSliderBox .goodItems').slick({ dots: true, arrows: true, infinite: true, speed: 300, slidesToShow: 1, slidesToScroll: 1, }); $('.bxSliderBox .zoneItems').slick({ dots: true, infinite: true, speed: 300, slidesToShow: 1, slidesToScroll: 1, }); $('.itemSliderBox .goodItems').slick({ dots: true, arrows: false, infinite: true, speed: 300, slidesToShow: 1, slidesToScroll: 1, centerMode: false, centerPadding: '60px', }); $('.interiorSlider').slick({ dots: true, arrows: false, infinite: true, speed: 300, slidesToShow: 1, slidesToScroll: 1, }); } else { $('.bxSliderBox .zoneItems').slick({ dots: true, infinite: true, speed: 300, slidesToShow: 3, slidesToScroll: 1, }); $('.itemSliderBox .goodItems').slick({ dots: true, infinite: true, speed: 300, slidesToShow: 4, slidesToScroll: 1, centerMode: false, centerPadding: '60px', responsive: [ { breakpoint: 1024, settings: { slidesToShow: 3, slidesToScroll: 3, } }, ] }); $('.interiorSlider').slick({ dots: true, infinite: true, speed: 300, slidesToShow: 3, slidesToScroll: 1, }); } $(".content .leftColumn").stick_in_parent(); $('.sText .buttons .btn').click(function() { $(this).parents('.sText').toggleClass('opened'); $(this).css('display', 'none'); }); $('#footer .c span').click(function() { $(this).parents('.c').toggleClass('opened'); }); $(".topBan > div > .close").click(function() { $(".topBan").animate({height: 0}, 600); $.cookie('topBan_4', 'show', { expires: 1, path: '/' }); return false; }); $("#cookiesBanner .btn").click(function() { $("#cookiesBanner").animate({height: 0, bottom: -150}, 600); $.cookie('cookiesBan', 'show', { expires: 1, path: '/' }); return false; }); $(".is_mobile #header .topMenu > section > ul > li.catalog_item > a, .is_mobile #header .topMenu > section > ul > li.hasNext > a").click(function() { var el = $(this).parents("nav.topMenu"); if (el.hasClass('l1')) { el.removeClass('l1'); } else { el.addClass('l1'); } return false; }); $("#header nav.topMenu > section > ul > li.catalog_item .submenu ul.three_columns .mBlk > b").click(function() { var el = $(this).parents("nav.topMenu"); el.removeClass('l1'); el.addClass('l2'); var el2 = $(this).parents(".mBlk"); if (el2.hasClass('opened')) { el2.removeClass('opened'); } else { el2.addClass('opened'); } return false; }); $(".items #itemInfo .gInfo .seeLink").click(function() { var el = $('#seeInSalonPopup'); if (el.hasClass('opened')) { el.removeClass('opened'); } else { el.addClass('opened'); } }); $(document).mouseup(function (e){ // событие клика по веб-документу var div = $("#seeInSalonPopup"); // тут указываем ID элемента if (!div.is(e.target) // если клик был не по нашему блоку && div.has(e.target).length === 0) { // и не по его дочерним элементам div.removeClass('opened'); // скрываем его } }); $("body").on("click", ".makeMail2", function() { var xlsType=$(this).attr("type"); var order_id=$(this).attr("order_id"); $("#orderEditDialog").dialog('close'); $.fancybox({ 'padding' : 20, 'transitionIn' : 'none', 'transitionOut' : 'none', 'href' : '/forms/mail_comm_form2.phtml?order_id='+order_id+'&type='+xlsType, 'type' : 'ajax' }); return false; }); $('.onCheaperForm').click(function() { var item_id = $(this).attr('item_id'); $.fancybox({ 'padding' : 20, 'transitionIn' : 'none', 'transitionOut' : 'none', 'href' : '/forms/cheaperForm.phtml?item_id='+item_id, 'type' : 'ajax' }); }); $('.priceOrder').click(function() { var order = $(this).attr('order'); $.ajax({ url: "/setSession.phtml?priceOrder="+order, cache: false, success: function(html) { window.location.reload(); }, error: function() { alert('error!'); } }); }) $(".goodItems .item").click(function() { console.log('click'); }); $(".dropdown").click(function() { var el = $(this); if (el.hasClass('show')) { el.removeClass('show'); el.find('.dropdown-menu').removeClass('show'); } else { el.addClass('show'); el.find('.dropdown-menu').addClass('show'); } }); $(".tdButtons .showAR").click(function(e) { // var file = $(this).attr('file'); var item_id = $(this).parents('.tdButtons').attr('item_id'); showAR(item_id); }); $('.slickPages .slickPageItem').click(function() { $(this).addClass('slick-current').siblings().removeClass('slick-current'); var id = $(this).attr('data-id'); $('.slickGallery').slick('slickGoTo', id); }) $(".tdButtons .show3d").click(function(e) { var item_id = $(this).parents('.tdButtons').attr('item_id'); if ($('#container3d').hasClass('loaded')) { $('#container3d').removeClass('hidden'); $('#gallery').addClass('hidden'); } else { $.ajax({ url: "/components/ajax_3dmodelViewer.phtml?item_id="+item_id, type: 'GET', cache: false, async: false, success: function(html) { $('#container3d .is_container').html(html); $('#container3d').removeClass('hidden'); $('#gallery').addClass('hidden'); $('#gallery').addClass('loading'); document.querySelector("#container3d model-viewer").addEventListener('load', (event) => { $('#container3d').addClass('loaded'); $('#gallery').removeClass('loading'); }); } }); } }); $("#container3d .closeBtn").click(function(e) { if (!$('#container3d').hasClass('hidden')) { $('#container3d').addClass('hidden'); $('#gallery').removeClass('hidden'); } }); /* if ( $(".goodItems").length) { var qty = $(".goodItems").attr('data-qty'); if (qty > 0) { $('.h1Addon').html('(более '+qty+' товаров)'); } } */ }); function showAR(item_id) { if ($('#container3d').hasClass('loaded')) { var modelViewer = document.querySelector("#container3d model-viewer"); if (modelViewer.canActivateAR) { modelViewer.activateAR(); } else { arNotSupport(item_id); } } else { $.ajax({ url: "/components/ajax_3dmodelViewer.phtml?item_id="+item_id, type: 'GET', cache: false, async: false, success: function(html) { $('#container3d .is_container').html(html); $('#container3d').removeClass('hidden'); $('#gallery').addClass('hidden'); $('#gallery').addClass('loading'); document.querySelector("#container3d model-viewer").addEventListener('load', (event) => { $('#container3d').addClass('loaded'); $('#gallery').removeClass('loading'); var modelViewer = document.querySelector("#container3d model-viewer"); if (modelViewer.canActivateAR) { modelViewer.activateAR(); } else { arNotSupport(item_id); } }); } }); } } function arNotSupport(item_id) { $.fancybox({ 'padding':20, 'transitionIn':'none', 'transitionOut':'none', 'href':'/forms/arPageQRCode.phtml?item_id='+item_id, 'type':'ajax' }); return false; }