'use strict'; var mobileViewport = 992; var isSafari = navigator.userAgent.indexOf("Safari") > -1; var isChrome = navigator.userAgent.indexOf('Chrome') > -1; if((isSafari) && (isChrome)) { isSafari = false; } $(document).ready(function(){ OwlCarousel(); $('.blur-area').blurArea(); $('.ws-action').windowScrollAction(); checkboxes(); afternavHeight(); activeBookmark(); magnificLightbox(); priceSlider(); BSTabsActions(); heroSearchSections(); $('.quantity-selector').quantitySelector(); autocomplete(); searchResultsCollapse(); comingSoonCountdown(); smoothScroll(); if($(window).width() > mobileViewport) { YouTubeVideo(); stickySidebars(); } if($(window).width() < mobileViewport) { mobileFilters(); } }); googleMaps(); function smoothScroll() { var scroll = new SmoothScroll('a[data-scroll]'); } function YouTubeVideo() { var $video = $('#youtube-video'); if($video.length) { $video.YTPlayer({ fitToBackground: true, videoId: $video.data('video-id'), events: { onReady: function() { $video.data('ytPlayer').player.mute(); } } }); $(document).on('scroll', function(){ videoScroll(); }); function videoScroll() { var fraction = 0.75, player = $video.data('ytPlayer').player, videoHeight = $video.height(), videoOffsetTop = $video.offset().top, windowScrollY = window.scrollY; if(windowScrollY > (videoHeight + videoOffsetTop) *fraction) { player.pauseVideo(); } else { player.playVideo(); } } } } function OwlCarousel() { $('.owl-carousel').each( function() { var $carousel = $(this); $carousel.owlCarousel({ // dots : false, // items : $carousel.data("items"), slideBy : $carousel.data("slideby"), center : $carousel.data("center"), loop : $carousel.data("loop"), margin : $carousel.data("margin"), autoplay : $carousel.data("autoplay"), autoplayTimeout : $carousel.data("autoplay-timeout"), navText : [ '', '' ], responsive: { 0 : { items: 1, dots: true, nav: false }, 992 : { items: $carousel.data("items"), dots: false, nav : $carousel.data("nav") } } }); }); } function stickySidebars() { $('.sticky-col').stick_in_parent({ parent: $('#sticky-parent') }); $('.sticky-cols').stick_in_parent({ parent: $('.sticky-parent') }); } function mobileFilters() { if($('#mobileFilters').length) { $(document).on('scroll', function(){ filtersScroll(); }); } function filtersScroll() { var filters = $('#mobileFilters'); var footer = $('#mainFooter'); if(filters.offset().top + filters.height() > footer.offset().top - 10 || !$(document).scrollTop()) { filters.removeClass('active'); } else { filters.addClass('active'); } if($(document).scrollTop + window.innerHeight > footer.offset().top) { filters.addClass('active'); } } } function checkboxes() { $('.icheck, .iradio').iCheck({ checkboxClass: 'icheck', radioClass: 'iradio' }); } function googleMaps() { if($('.google-map').length) { window.initMap = function() { $('.google-map').gmap(); } } else { window.initMap = function() { return; } } } function afternavHeight() { $('.afternav-height').each(function(){ var $mainNav = $('#main-nav'), mainNavHeight = $mainNav.height(), height = $(window).height() - mainNavHeight; $(this).css('height', height); }); } function activeBookmark() { $('.theme-search-results-item-bookmark').each(function(index, el){ $(el).on('click', function(e){ e.preventDefault(); $(this).toggleClass('active'); }); }); } function magnificLightbox() { $('.magnific-gallery').each(function(index, el){ $(el).magnificPopup({ delegate: 'a', type: 'image', gallery: { enabled: true, navigateByImgClick: true, preload: [0,1] } }) }); $('.magnific-gallery-link').each(function(index , value){ var gallery = $(this); var galleryImages = $(this).data('items').split(','); var items = []; for(var i=0;i

%D

روز' + '

%H

ساعت
' + '

%M

دقیه
' + '

%S

ثانیه
' )); }); } $('.mobile-picker').each(function(i, item){ if(!isSafari) { $(item).attr('type', 'text'); $(item).val($(item).attr('value')); $(item).on('focus', function(){ $(item).attr('type', 'date'); }); $(item).on('blur', function(){ $(item).attr('type', 'text'); }); } });