$(document).ready(function(){ /*nw-promo-slider*/ var $nwPromo = $('.nw-promo-slider'); if($nwPromo.length){ $nwPromo.owlCarousel({ nav: true, dots: true, loop: true, margin:0, responsive:{ 0:{ items:1 } } }); } /*nw-photo-slider*/ function nwPhotoSlider() { var $nw = $('.nw-photo-slider'); if ($nw.find('img').length > 1) { $nw.owlCarousel({ margin: 0, loop: false, /*autoWidth:true,*/ center: true, items: 1, nav: true, dots: false, onInitialized: callback1, onChanged: callback2 }); } else { $nw.addClass('owl-loaded'); } function callback1(event) { var item = event.item.index; console.log(this); /*counter after initialized*/ var currentItem = (item ? item - $(event.target).find('.cloned').length/2 : 0) + 1; var items = event.item.count; $(event.target).append('
'+ currentItem + ''+ '/' +items+ '
'); if ($('.product-info__main').length){ $(event.target).closest('.product-info__main').find('.product-visual__count').text(items); } /*set total width of slides*/ var $owlItems = $(event.target).find('.owl-item'); var countTotal = $owlItems.length; var totalWidthItems = 0; for(var i = 0; i < countTotal; i++){ totalWidthItems += $owlItems.eq(i).outerWidth(); } $(event.target).find('.owl-stage').css('width',totalWidthItems); } function callback2(event) { var items = event.item.count; var item = event.item.index; var cloned = $(event.target).find('.cloned').length; //var currentItem = (item ? item - cloned/2 : 0) + 1; var currentItem; if(item < cloned/2){ currentItem = items - (cloned/2 - item) + 1; } else if (item) { currentItem = (item - cloned/2) + 1; } else { currentItem = 1; } $(event.target).find('.slide-counter').html(''+ currentItem + '' + '/' +items) } } /*modal window*/ //var popupLink = $('a[href="#details-popup"]'); /* var popupLink = $('a.nw-collections__float'); if ( popupLink.length) { popupLink.fancybox({ wrapCSS: 'fancybox-details', padding: 0, openEffect: 'none', closeEffect: 'none', beforeLoad: function() { $.ajax() $('.nw-photo-slider').imagesLoaded( function() { if($('.nw-photo-slider').length){ nwPhotoSlider(); } }); } }); } */ var popupLink = $('a.nw-collections__float'); if ( popupLink.length) { popupLink.click( function(){ _this = $(this); $.post( _this.attr('href'), { prod_id: _this.attr('rel') }, function(data) { var url = _this.attr('href'); if( url != window.location ){ window.history.pushState( null, null, url ); } $("#details-popup").html( data ); $('.nw-photo-slider').imagesLoaded( function() { if($('.nw-photo-slider').length){ nwPhotoSlider(); } $.fancybox({ href: '#details-popup', wrapCSS: 'fancybox-details', padding: 0, openEffect: 'none', closeEffect: 'none', beforeClose: function() { var str = window.location.href; strArray = str.split("/"); len = strArray.length; last_url = str.split("/")[len-1]; new_url = str.replace( last_url, '' ); window.history.pushState( null, null, new_url ); } }); }); } ); return false; } ); } /* function openProd( prod_id ) { $('a.nw-collections__float[rel="'+prod_id+'"]').click(); } */ if ( typeof prod_id !== 'undefined' ) { $('a.nw-collections__float[rel="'+prod_id+'"]').click(); } /*nw-goods-slider*/ var $nwGoods = $('.nw-goods-slider'); if($nwGoods.length){ $nwGoods.owlCarousel({ loop:false, nav: true, dots: false, slideBy: 3, responsive:{ 0:{ items:4 }, 1240:{ items:5 }, 1540:{ items:6 }, 1840:{ items:7 } } }); } /*modal window*/ var popup = $('.fancybox-open'); if (popup.length) { popup.fancybox({ wrapCSS: 'fancybox-modal', padding: 0, openEffect: 'none', closeEffect: 'none' }); } if ( $('#callback-popup #forms').length > 0 ) { if ( ( $('#callback-popup #forms .error').html().length > 0 ) || !$('#callback-popup #forms').length ) { $('a[href="#callback-popup"]').click(); } } }); $(window).load(function () { /*equalHeight nw-rubrics*/ var rubricsList = $('.nw-rubrics__list'); if(rubricsList.length){ rubricsList.find('.nw-rubrics__title').equalHeight({ amount: 4, resize: true }); rubricsList.find('.nw-rubrics__content').equalHeight({ amount: 4, resize: true }); } /*equalHeight nw-rubrics end*/ /*equalHeight nw-rubrics*/ var collectionsList = $('.nw-collections__list'); if(collectionsList.length){ collectionsList.find('.nw-collections__float').equalHeight({ amount: 8, resize: true }); } /*equalHeight nw-rubrics end*/ /*equalHeight recomend_slider*/ var collectionsList = $('.owl-stage'); if(collectionsList.length){ collectionsList.find('.nw-collections__float').equalHeight({ amount: collectionsList.find('.nw-collections__float').length, resize: true }); } /*equalHeight recomend_slider end*/ /*hover effect*/ //$('.nw-rubrics__float').hover(function () { // var titleHeight = $(this).find('.nw-rubrics__title').outerHeight(true); // var btnHeight = $(this).find('.nw-rubrics__btn').outerHeight(true); // $(this).find('.nw-rubrics__container').stop().animate({ // 'top': -titleHeight // }, 300); // $(this).find('.nw-rubrics__btn').stop().animate({ // 'margin-top': -btnHeight // }, 300); //}, function () { // $(this).find('.nw-rubrics__container').stop().animate({ // 'top': 0 // }, 300); // $(this).find('.nw-rubrics__btn').stop().animate({ // 'margin-top': 0 // }, 300) //}); /*hover effect end*/ /*video fancybox*/ $(".video-preview").fancybox({ maxWidth : 800, maxHeight : 700, fitToView : false, width : '70%', height : '70%', autoSize : false, closeClick : false, openEffect : 'none', closeEffect : 'none' }); /*video fancybox end*/ $('.js-go-top').on('click', function(event) { $('html,body').animate({ scrollTop: 0 }, 800); return false; }); });