; (function ($, window, document, undefined) { 'use strict'; var $window = $(window); // calendar var calendar = $('#mycalendar'); if (calendar.length) { calendar.monthly({ mode: 'event' }); } /*=================================*/ /* 01 - VARIABLES */ /*=================================*/ var swipers = [], winW, winH, winScr, _isresponsive, smPoint = 768, mdPoint = 992, lgPoint = 1200, addPoint = 1600, _ismobile = navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i), pageCalculateHeight; /*=================================*/ /* 02 - PAGE CALCULATIONS */ /*=================================*/ /** * * PageCalculations function * @since 1.0.0 * @version 1.0.1 * @var winW * @var winH * @var winS * @var pageCalculations * @var onEvent **/ if (typeof pageCalculations !== 'function') { var winW, winH, winS, pageCalculations, onEvent = window.addEventListener; pageCalculations = function (func) { winW = window.innerWidth; winH = window.innerHeight; winS = document.body.scrollTop; if (!func) return; onEvent('load', func, true); // window onload onEvent('resize', func, true); // window resize onEvent("orientationchange", func, false); // window orientationchange } pageCalculations(function () { pageCalculations(); }); } // pageCalculations function pageHeightCalculate() { if ($('.page-calculate.fullheight').length) { var pageCalculate = $('.page-calculate'), headerHeight = $('.header_top_bg').not('.header_trans-fixed').outerHeight() || 0, footerHeight = $('#footer').not('.fix-bottom').outerHeight() || 0; pageCalculate.height(winH - headerHeight - footerHeight); pageCalculateHeight = pageCalculate.height(); } } //start full width gallery var pswpElement = document.querySelectorAll('.pswp')[0]; var galleryItems = parseGalleryPhotoSwipe('.just-gallery'); function createGalleryItemTitle(title, desc) { var title = '
Something went wrong, try again!
').slideDown('slow'); } }); return false; }); $('.wpcf7').on('focus', '.wpcf7-not-valid', function () { $(this).removeClass('wpcf7-not-valid'); }); function initIsotop() { var isotope = $('.izotope-container'); if (isotope.length) { isotope.each(function () { var self = $(this); var layoutM = self.attr('data-layout') || 'masonry'; self.isotope({ itemSelector: '.item-single', layoutMode: layoutM, masonry: { columnWidth: '.item-single', gutterWidth: 30 } }); $(".filter ul ").on("click", 'li', function () { var that = $(this); $(".filter ul li").removeClass("active"); that.addClass("active"); var filterValue = that.attr("data-layout"); isotope.isotope({ filter: filterValue }); }); }); } var $container = $('.izotope-container-2'); if ($container.length) { $container.each(function () { var self = $(this); var layoutM = self.attr('data-layout') || 'masonry'; self.isotope({ itemSelector: '.full-single', layoutMode: layoutM, masonry: { columnWidth: '.full-single' } }); }); } } /*Calculate paddings for main wrapper*/ function calcPaddingMainWrapper() { if (!$("#footer.fix-bottom").length) { var paddValue = $('footer').outerHeight(); $('.main-wrapper').css('padding-bottom', paddValue); } } calcPaddingMainWrapper(); //fixed menu function addFixedHeader() { var topHeader = $('.header_top_bg.enable_fixed'), heightHeader = topHeader.height(); $window.on('scroll', function () { if ($window.scrollTop() > 0) { topHeader.addClass('fixed'); $('.main-wrapper').css('padding-top', heightHeader); } else { topHeader.removeClass('fixed'); $('.main-wrapper').css('padding-top', '0'); } }); } addFixedHeader(); // header social $('.napoli-top-social .social-icon').on("click", function () { var thisItem = $(this); var thisItemParent = thisItem.parent('.napoli-top-social'); var thisSocials = thisItemParent.find('.social'); thisItemParent.toggleClass('over'); thisSocials.toggleClass('active'); return false; }); // for woocommerce $('.add_to_cart_button').on('click', function () { $(document.body).trigger('wc_fragment_refresh'); }); function initFlexSlider() { var carusel = $('#carousel'); carusel.eventType = ('ontouchstart' in document.documentElement) ? 'touchstart' : 'click'; carusel.eventType = "click"; $('#slider').flexslider({ animation: "fade", controlNav: false, animationLoop: false, slideshow: false, sync: "#carousel" }) if (winW < 768) { carusel.flexslider({ animation: "slide", animationSpeed: 600, controlNav: false, animationLoop: true, direction: "horizontal", slideshow: true, itemWidth: 100, itemMargin: 1, mousewheel: true, move: 1, asNavFor: '#slider' }); } else { carusel.flexslider({ animation: "slide", animationSpeed: 600, controlNav: false, animationLoop: true, direction: "vertical", slideshow: false, itemWidth: 100, itemMargin: 1, mousewheel: true, move: 1, asNavFor: '#slider' }); } } if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { $('form').submit(function () { var required = $(this).find('[required]'); // change to [required] if not using true option as part of the attribute as it is not really needed. var error = false; for (var i = 0; i <= (required.length - 1); i++) { if (required[i].value == '' || !required[i].validity.valid) // tests that each required value does not equal blank, you could put in more stringent checks here if you wish. { required[i].style.backgroundColor = 'rgb(255,155,155)'; error = true; // if any inputs fail validation then the error variable will be set to true; } } if (error) // if error is true; { return false; // stop the form from being submitted. } }); } var $wpbDate = $(".wpb-date") if ($wpbDate.length) { $wpbDate.datetimepicker(); } var comingSoonElements = $('.coming-soon-descr li'); function comingSoonValue() { comingSoonElements.each(function () { var thisElement = $(this), text = thisElement.data('desktop'), mobileText = thisElement.data('mobile'); if ($window.width() < 768) { thisElement.text(mobileText); } else { thisElement.text(text); } }) } $('.gridrotate').gridrotator({ rows: 5, // number of columns columns: 9, w1200: { rows: 5, columns: 9 }, w992: { rows: 5, columns: 7 }, w510: { rows: 5, columns: 5 }, step: 7, maxStep: 7 }); /**********************************/ /*COUNTER coming SOON*/ /**********************************/ function getTimeRemaining(endtime) { var t = Date.parse(endtime) - Date.parse(new Date()); var seconds = Math.floor((t / 1000) % 60); var minutes = Math.floor((t / 1000 / 60) % 60); var hours = Math.floor((t / (1000 * 60 * 60)) % 24); var days = Math.floor(t / (1000 * 60 * 60 * 24)); return { 'total': t, 'days': days, 'hours': hours, 'minutes': minutes, 'seconds': seconds }; } function updateClock($clock, endTime, updateDays) { var t = getTimeRemaining(endTime); if (updateDays) { $clock.find('.count-days').text(t.days); } if (updateDays || t.minutes === 59) { $clock.find('.count-hours').text(('0' + t.hours).slice(-2)); } if (updateDays || t.seconds === 59) { $clock.find('.count-mins').text(('0' + t.minutes).slice(-2)); } $clock.find('.count-secs').text(('0' + t.seconds).slice(-2)); if (t.total <= 0) { clearInterval(timeinterval); } } var $comingSoon = $('.coming-soon'); if ($comingSoon.length) { $comingSoon.each(function () { var self = $(this), endTime = self.attr('data-end'), $mask_clock = self.find('.mask'); updateClock($mask_clock, endTime, true); var timeinterval = setInterval(function () { updateClock($mask_clock, endTime); }, 1000); }); } /* Infinite scroll */ function load_infinite_scroll() { // Load More Portfolio if (window.infinite_scroll) { var amount_images_per_page = parseInt(infinite_scroll.amount_images_per_page); // The maximum number of pages the current query can return. var countImages = parseInt(infinite_scroll.countImages); // The link of the next page of posts. var url_next_page = infinite_scroll.url_next_page; var maxPages = infinite_scroll.maxPages; var infinite_page = infinite_scroll.infinite_page; // wrapper selector var wrap_selector = '.gallery-wrap'; var pageNum = 1 $window.on('scroll', function () { if ($(document).height() - winH == $window.scrollTop() && pageNum < maxPages) { pageNum++; $.ajax({ url: url_next_page + '?infinite_page=' + (pageNum), type: "get", success: function (data) { var newElements = $(data).find('.izotope-container-2 .item-single'); var elems = []; newElements.each(function (i) { elems.push(this); }); $('.izotope-container-2').isotope('insert', elems); $('.izotope-container-2').find('img').on('load', function () { if (!window.enable_foxlazy) { wpc_add_img_bg('.s-img-switch'); } }); pageCalculations(); $('.gallery-item').magnificPopup({ gallery: { enabled: true }, mainClass: 'mfp-fade', fixedContentPos: false, type: 'image' }); newElements.find('img[data-lazy-src]').foxlazy(); pageNum++; } }); } }); } } load_infinite_scroll(); // initMultiscroll function multiscroll() { if ($('.multiscroll-slider').length) { $.fn.multiscroll.destroy(); initMultiscroll(); } } function initMultiscroll() { var winW = $window.width(), winH = $window.height(), mutiscrollWrapp = $('.multiscroll-slider'), multiscrollLeft = mutiscrollWrapp.find('.multiscroll-slider-left'), multiscrollRight = mutiscrollWrapp.find('.multiscroll-slider-right'), multiscrollHeight; if (mutiscrollWrapp.hasClass('fullheight')) { var headerHeight = $('.header_top_bg').not('.header_trans-fixed').outerHeight(); var footerHeight = $('#footer').not('.fix-bottom').outerHeight(); mutiscrollWrapp.height(winH - headerHeight - footerHeight); } multiscrollHeight = mutiscrollWrapp.height(); if ((winW > 0 && winW < 480) || (winW > 767 && winW < 992)) { multiscrollLeft.height(multiscrollHeight / 2); multiscrollRight.height(multiscrollHeight / 2); } else if ((winW > 991) || (winW > 479 && winW < 768)) { multiscrollLeft.height(multiscrollHeight); multiscrollRight.height(multiscrollHeight); } mutiscrollWrapp.multiscroll({ verticalCentered: false, scrollingSpeed: parseInt(mutiscrollWrapp.attr('data-speed'), 10), easing: 'easeInQuart', menu: false, navigation: false, loopBottom: parseInt(mutiscrollWrapp.attr('data-loop'), 10), loopTop: parseInt(mutiscrollWrapp.attr('data-loop'), 10), keyboardScrolling: parseInt(mutiscrollWrapp.attr('data-keyboard'), 10), touchSensitivity: 50, sectionSelector: '.ms-section', leftSelector: '.ms-left', rightSelector: '.ms-right' }); mutiscrollWrapp.find('.ms-section').removeClass('active'); mutiscrollWrapp.find('.ms-right .ms-section').last().addClass('active'); mutiscrollWrapp.find('.ms-left .ms-section').first().addClass('active'); } function multiScrollControls() { $('.scroll-btn.down').on('click', function () { $.fn.multiscroll.moveSectionDown(); }); $('.scroll-btn.up').on('click', function () { $.fn.multiscroll.moveSectionUp(); }); } function initThumbFlexSlider() { var winW = $window.width(), winH = $window.innerHeight(), innerWinH = $window.height(), thumbSliderWrapp = $('.thumb-slider-wrapp'), headerHeight = $('.header_top_bg').not('.header_trans-fixed').outerHeight(), footerHeight = $('#footer').not('.fix-bottom').outerHeight(); thumbSliderWrapp.innerHeight(winH - headerHeight - footerHeight); $('.main-thumb-slider').flexslider({ animation: "fade", animationSpeed: 600, controlNav: false, animationLoop: false, slideshow: false, sync: ".sub-thumb-slider" }) $('.sub-thumb-slider').flexslider({ animation: "slide", animationSpeed: 600, controlNav: false, animationLoop: true, direction: "horizontal", slideshow: false, itemWidth: 180, itemMargin: 5, mousewheel: true, asNavFor: '.main-thumb-slider' }); } $('.thumb-slider-wrapp-arrow').on('click', function () { $(this).toggleClass('active').parent().find('.sub-thumb-slider').toggleClass('active'); }) /* Share */ $('[data-share]').on('click', function () { var w = window, url = this.getAttribute('data-share'), title = '', w_pop = 600, h_pop = 600, scren_left = w.screenLeft != undefined ? w.screenLeft : screen.left, scren_top = w.screenTop != undefined ? w.screenTop : screen.top, width = w.innerWidth, height = w.innerHeight, left = ((width / 2) - (w_pop / 2)) + scren_left, top = ((height / 2) - (h_pop / 2)) + scren_top, newWindow = w.open(url, title, 'scrollbars=yes, width=' + w_pop + ', height=' + h_pop + ', top=' + top + ', left=' + left); if (w.focus) { newWindow.focus(); } return false; }); // for sound bg $('.napoli-sound-btn').on('click', function () { var $button = $(this); if ($button.hasClass('play')) { $button.next('audio').trigger('pause'); $button.removeClass('play'); } else { $button.next('audio').trigger('play'); $button.addClass('play'); } }) /* Copyright */ var $overlay = $('.napoli_copyright_overlay'); if ($overlay.length) { $(document).on('contextmenu', function (event) { event.preventDefault(); $overlay.css({ 'left': event.pageX, 'top': event.pageY, }).addClass('active'); }).on('click', function () { $overlay.removeClass('active').removeAttr('style'); }); } /*=================================*/ /* 03 - FUNCTION ON DOCUMENT READY */ /*=================================*/ $window.on('ready', function () { if ($('.full_screen_slider.disable_scroll').length) { $('html, body').addClass('overflow-hidden'); } }); /*=================================*/ /* 04 - FUNCTION ON PAGE LOAD */ /*=================================*/ $window.on('load', function () { // coming soon if (comingSoonElements.length) { comingSoonValue() } topMenu() // flexslider initFlexSlider(); bannerGallery(); // fix // --------------------------------- setTimeout(function () { $window.scroll(); }, 300); initSwiper(); initFullScreenSwiper(); initFlowSlider(); if ($('.multiscroll-slider').length) { initMultiscroll(); multiScrollControls(); } initThumbFlexSlider(); topBannerHeight(); calcPaddingMainWrapper(); // PORTFOLIO var $item = $('.item'); var $itemWidth = $('.item.wide, .item.wide-tall'); if ($('.portfolio.col-3').length && $window.width() > 991) { // $item.width(100 / 3 + '%'); $itemWidth.width(100 * 2 / 3 + '%'); } if ($('.portfolio.col-4').length && $window.width() > 991) { // $item.width(100 / 4 + '%'); $itemWidth.width(100 * 2 / 4 + '%'); } if ($('.portfolio.col-6').length && $window.width() > 991) { // $item.width(100 / 2 + '%'); $itemWidth.width(100 * 2 / 2 + '%'); } // fix initIsotop(); $("img[data-lazy-src]").foxlazy('', function () { initIsotop(); }); // GOOGLE MAP // ---------------------------------- //set your google maps parameters if ($('#google-map').length > 0) { var latitude = $('#google-map').attr("data-lat"), longitude = $('#google-map').attr("data-lng"), contentString = $('#google-map').attr("data-string"), map_zoom = parseInt($('#google-map').attr("data-zoom"), 10); //google map custom marker icon var marker_url = $('#google-map').attr("data-marker"); //we define here the style of the map var style = [{ "featureType": "all", "elementType": "labels.text.fill", "stylers": [{ "saturation": 36 }, { "color": "#000000" }, { "lightness": 40 }] }, { "featureType": "all", "elementType": "labels.text.stroke", "stylers": [{ "visibility": "on" }, { "color": "#000000" }, { "lightness": 16 }] }, { "featureType": "all", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "featureType": "administrative", "elementType": "geometry.fill", "stylers": [{ "color": "#000000" }, { "lightness": 20 }] }, { "featureType": "administrative", "elementType": "geometry.stroke", "stylers": [{ "color": "#000000" }, { "lightness": 17 }, { "weight": 1.2 }] }, { "featureType": "landscape", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 20 }] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 21 }] }, { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [{ "color": "#000000" }, { "lightness": 17 }] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{ "color": "#000000" }, { "lightness": 29 }, { "weight": 0.2 }] }, { "featureType": "road.arterial", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 18 }] }, { "featureType": "road.local", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 16 }] }, { "featureType": "transit", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 19 }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 17 }] }]; //set google map options var map_options = { center: new google.maps.LatLng(latitude, longitude), zoom: map_zoom, panControl: false, zoomControl: true, mapTypeControl: false, streetViewControl: false, mapTypeId: google.maps.MapTypeId.ROADMAP, scrollwheel: false, styles: style, } //inizialize the map var map = new google.maps.Map(document.getElementById('google-map'), map_options); //add a custom marker to the map var marker = new google.maps.Marker({ position: new google.maps.LatLng(latitude, longitude), map: map, visible: true, icon: marker_url, }); var infowindow = new google.maps.InfoWindow({ content: contentString }); google.maps.event.addListener(marker, 'click', function () { infowindow.open(map, marker); }); } }); /*=================================*/ /* 05 - FUNCTION ON PAGE RESIZE */ /*=================================*/ $window.on('resize', function () { if ($('.ytbg').length) { video_size(); } topMenu(); topBannerHeight(); bannerGallery(); initIsotop(); calcPaddingMainWrapper(); addFixedHeader(); // coming soon if (comingSoonElements.length) { comingSoonValue() } multiscroll(); if ($('.thumb-slider-wrapp').length) { initThumbFlexSlider(); } }); /*=================================*/ /* 06 - FUNCTION ON PAGE SCROLL */ /*=================================*/ $window.on('scroll', function () { var wh = $window.height(), st = $window.scrollTop(); if (st >= wh * 0.1) { $('.to-top').fadeIn(); } else { $('.to-top').fadeOut() } /**********************************/ /* SKILLS */ /**********************************/ var skills = $('.skills'); if (skills.length) { skills.not('.active').each(function () { var that = $(this); if ($window.scrollTop() >= that.offset().top - $window.height() * 1) { that.addClass('active'); that.find('.skill').each(function () { var $this = $(this); var procent = $this.attr('data-value'); $this.find('.active-line').css('width', procent + '%'); that.find('.counter').countTo(); }); } }); } }); /*=================================*/ /* 06 - FUNCTION ON PAGE orientationchange */ /*=================================*/ window.addEventListener("orientationchange", function () { multiscroll(); bannerGallery(); if ($('.thumb-slider-wrapp').length) { initThumbFlexSlider(); } }); window.addEventListener("orientationchange", function () { addFixedHeader(); }, false); function changeStateVideo(iframe_container,button,player,hover_enable,services){ var $this = $(button), iframe = iframe_container.find('iframe'); if (hover_enable) { iframe_container.on('mouseover',function(){ services == 'youtube' && player.playVideo(); $(this).addClass('play'); if (services != 'youtube') { if (iframe.data('src')) { iframe.attr('src',iframe.data('src')); } $this.addClass('start') .closest('.iframe-video').addClass('play'); } }); iframe_container.on('mouseout',function(){ services == 'youtube' && player.pauseVideo(); if (services != 'youtube') { if (iframe.data('src')) { iframe.attr('src','about:blank'); } $this.addClass('start') .closest('.iframe-video').addClass('play'); } $(this).removeClass('play'); }); return; } if ($this.hasClass('start')) { services == 'youtube' && player.pauseVideo(); if (iframe.data('src')) { iframe.attr('src','about:blank'); } $this.removeClass('start') .closest('.iframe-video').removeClass('play'); } else { services == 'youtube' && player.playVideo(); if (iframe.data('src')) { iframe.attr('src',iframe.data('src')); } $this.addClass('start') .closest('.iframe-video').addClass('play'); } iframe_container = ''; } // youtube video ready window.onYouTubeIframeAPIReady = function() { var player = [], $iframe_parent = [], $this, $button; // each all iframe $('iframe').each(function(i){ // get parent element $this = $(this); $iframe_parent[i] = $this.closest('.iframe-video.youtube'); // init video player player[i] = new YT.Player(this, { // callbacks events: { 'onReady': function(event){ // mute on/off if ( $iframe_parent[i].data('mute') ) { event.target.mute(); } }, 'onStateChange': function(event){ switch (event.data) { case 1: // start play //Exammple: console.log(player.getDuration()); //changeStateVideo($iframe_parent[i],$this[0], player[i],false,'youtube'); break; case 2: // pause break; case 3: // buffering break; case 0: // end video break; default: '-1' // not play } } } }); // hover play/pause video changeStateVideo($iframe_parent[i], this, player[i],true,'youtube') if ($iframe_parent[i].data('type-start') == 'hover') { } // click play/pause video if ($iframe_parent[i].data('type-start') == 'click') { $iframe_parent[i].find('.play-button').on('click', function(event){ event.preventDefault(); changeStateVideo($iframe_parent[i],this, player[i],false,'youtube') }); } // stop video $iframe_parent[i].find('.video-close-button').on('click',function(){ event.preventDefault(); player[i].stopVideo(); $iframe_parent[i].removeClass('play') .find('.play-button').removeClass('start'); }); }); } var $iframe_parent = []; $('.iframe-video:not(.youtube)').each(function(i){ $iframe_parent[i] = $(this); $('.play-button',$iframe_parent[i]).on('click',function(){ event.preventDefault(); changeStateVideo( $iframe_parent[i], this ) }); $iframe_parent[i].find('.video-close-button').on('click',function(){ event.preventDefault(); $iframe_parent[i].find('iframe').attr('src','about:blank'); $iframe_parent[i].removeClass('play') .find('.play-button').removeClass('start'); }); // hover play/pause video if ($iframe_parent[i].data('type-start') == 'hover') { changeStateVideo($iframe_parent[i], $iframe_parent[i].find('iframe')[0], false, true) } }); })(jQuery, window, document);