; (function($, window, document, undefined) { 'use strict'; /*============================*/ /* 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); /*========================*/ /* 02 - PAGE CALCULATIONS */ /*========================*/ function pageCalculations() { winW = $(window).width(); winH = $(window).height(); } /*=================================*/ /* 03 - FUNCTION ON DOCUMENT READY */ /*=================================*/ pageCalculations(); /*============================*/ /* 04 - FUNCTION ON PAGE LOAD */ /*============================*/ $(window).load(function() { initSwiper(); }); /*==============================*/ /* 05 - FUNCTION ON PAGE RESIZE */ /*==============================*/ function resizeCall() { pageCalculations(); $('.swiper-container.initialized[data-slides-per-view="responsive"]').each(function() { var thisSwiper = swipers['swiper-' + $(this).attr('id')], $t = $(this), slidesPerViewVar = updateSlidesPerView($t), centerVar = thisSwiper.params.centeredSlides; thisSwiper.params.slidesPerView = slidesPerViewVar; thisSwiper.reInit(); if (!centerVar) { var paginationSpan = $t.find('.pagination span'); var paginationSlice = paginationSpan.hide().slice(0, (paginationSpan.length + 1 - slidesPerViewVar)); if (paginationSlice.length <= 1 || slidesPerViewVar >= $t.find('.swiper-slide').length) $t.addClass('pagination-hidden'); else $t.removeClass('pagination-hidden'); paginationSlice.show(); } }); } if (!_ismobile) { $(window).resize(function() { resizeCall(); }); } else { window.addEventListener("orientationchange", function() { resizeCall(); }, false); } /*=====================*/ /* 06 - SWIPER SLIDERS */ /*=====================*/ function initSwiper() { var initIterator = 0; $('.swiper-container').each(function() { var $t = $(this); var index = 'swiper-unique-id-' + initIterator; $t.addClass('swiper-' + index + ' initialized').attr('id', index); $t.find('.pagination').addClass('pagination-' + index); var autoPlayVar = parseInt($t.attr('data-autoplay'), 10); var mode = $t.attr('data-mode'); var slidesPerViewVar = $t.attr('data-slides-per-view'); if (slidesPerViewVar == 'responsive') { slidesPerViewVar = updateSlidesPerView($t); } else slidesPerViewVar = parseInt(slidesPerViewVar, 10); var loopVar = parseInt($t.attr('data-loop'), 10); var speedVar = parseInt($t.attr('data-speed'), 10); var centerVar = parseInt($t.attr('data-center'), 10); swipers['swiper-' + index] = new Swiper('.swiper-' + index, { speed: speedVar, pagination: '.pagination-' + index, loop: loopVar, paginationClickable: true, autoplay: autoPlayVar, slidesPerView: slidesPerViewVar, keyboardControl: true, calculateHeight: true, simulateTouch: true, roundLengths: true, centeredSlides: centerVar, mode: mode || 'horizontal', onInit: function(swiper) { $t.find('.swiper-slide').addClass('active'); }, onSlideChangeEnd: function(swiper) { var activeIndex = (loopVar === 1) ? swiper.activeLoopIndex : swiper.activeIndex; }, onSlideChangeStart: function(swiper) { $t.find('.swiper-slide.active').removeClass('active'); } }); swipers['swiper-' + index].reInit(); if ($t.attr('data-slides-per-view') == 'responsive') { var paginationSpan = $t.find('.pagination span'); var paginationSlice = paginationSpan.hide().slice(0, (paginationSpan.length + 1 - slidesPerViewVar)); if (paginationSlice.length <= 1 || slidesPerViewVar >= $t.find('.swiper-slide').length) $t.addClass('pagination-hidden'); else $t.removeClass('pagination-hidden'); paginationSlice.show(); } if ($t.find('.default-active').length) { swipers['swiper-' + index].swipeTo($t.find('.swiper-slide').index($t.find('.default-active')), 0); } initIterator++; }); } function updateSlidesPerView(swiperContainer) { if (winW >= addPoint) return parseInt(swiperContainer.attr('data-add-slides'), 10); else if (winW >= lgPoint) return parseInt(swiperContainer.attr('data-lg-slides'), 10); else if (winW >= mdPoint) return parseInt(swiperContainer.attr('data-md-slides'), 10); else if (winW >= smPoint) return parseInt(swiperContainer.attr('data-sm-slides'), 10); else return parseInt(swiperContainer.attr('data-xs-slides'), 10); } //swiper arrows $('.swiper-arrow-left').on('click', function() { swipers['swiper-' + $(this).parent().attr('id')].swipePrev(); }); $('.swiper-arrow-right').on('click', function() { swipers['swiper-' + $(this).parent().attr('id')].swipeNext(); }); $('.swiper-outer-left').on('click', function() { swipers['swiper-' + $(this).parent().find('.swiper-container').attr('id')].swipePrev(); }); $('.swiper-outer-right').on('click', function() { swipers['swiper-' + $(this).parent().find('.swiper-container').attr('id')].swipeNext(); }); $(window).on('resize', function() { if ($('.ytbg').length) { video_size(); } topBannerHeight(); }); function video_size() { var height = $('.ytbg').width() * 0.55; $('.ytbg').closest('.wpb_wrapper').css('height', height + 'px'); } if ($('.ytbg').length) { video_size(); } if ($('.wpb_wrapper .hero-slider .slide').length) { if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { $('.hero-slider .slide').closest('.wpb_wrapper').css('margin', '0 15px') } else { $('.hero-slider .slide').closest('.wpb_wrapper').css('margin', '0 50px') } } $('.mb_YTPPlaypause').live('click', function() { $(this).toggleClass("active"); }); $("iframe:not([src*=soundcloud])").each(function(index) { $(this).wrap("
"); }); // page transitions $(".animsition").animsition({ inClass: 'fade-in', outClass: 'fade-out', inDuration: 2000, outDuration: 800, loading: true, loadingParentElement: 'body', //animsition wrapper element loadingClass: 'animsition-loading', unSupportCss: ['animation-duration', '-webkit-animation-duration', '-o-animation-duration'], overlay: false, overlayClass: 'animsition-overlay-slide', overlayParentElement: 'body' }); // if element visible // --------------------------------- $.fn.isVisible = function() { var st = $(window).scrollTop(), wh = $(window).height(), tt = $(this).offset().top, th = $(this).height(), r; if (st + wh >= tt && tt + th >= st) { r = 1 } else { r = 0 } return r; }; // smooth scroll // --------------------------------- $('.sscroll').click(function() { var ti = $(this).attr('href'), tt = $(ti).offset().top - 100; $('html, body').animate({ scrollTop: tt }, 600); return false; }); // scroll to top // --------------------------------- $(window).scroll(function() { var wh = $(window).height(), st = $(window).scrollTop(); if (st >= wh * 0.1) { $('.to-top').fadeIn(); } else { $('.to-top').fadeOut() } }); $('.to-top').click(function() { $('html, body').animate({ scrollTop: 0 }, 600); return false; }); // parallax $.stellar({ horizontalScrolling: false, responsive: true }); // stellar fix - bg position on load if ($('[data-stellar-background-ratio]').length > 0) { setTimeout(function() { var st = $(window).scrollTop(); $(window).scrollTop(st + 1); setTimeout(function() { $(window).scrollTop(st) }, 200) }, 200); }; if ($('.hero-inner').length) { $(window).resize(function() { var hh = $('header').height(); var hi = $('.hero-inner').height() / 2; }).resize(); } // MOBILE NAVIGATION $('.mob-nav').click(function() { $(this).toggleClass('active'); $(this).find('i').toggleClass('fa-bars fa-times'); $('#topmenu').slideToggle(); $('body, html').toggleClass('no-scroll'); return false; }); // side links $('.side-link').each(function() { var e = $(this); var h = Math.round(e.height()); if ((h % 2) == 1) { e.css({ height: '+=1' }) } }); // Hero slider // --------------------------------- if ($('.hero-slider').length) { $(window).resize(function() { $('.hero-slider .slide').height('800px').width('100%'); }).resize(); $('.hero-slider').flexslider({ animation: "slide", pauseOnAction: true, animationLoop: true, slideshow: true, slideshowSpeed: 7000, animationSpeed: 600, controlNav: true, directionNav: false }); } // YT Background // --------------------------------- $('.ytbg').YTPlayer({ showYTLogo: false, optimizeDisplay: true }); // equal-height columns $('.equal-height [class*="col-"]').matchHeight({ byRow: false }); /**/ $('.equal-height .wpb_wrapper').matchHeight({ byRow: false }); /**/ // responsive videos // --------------------------------- $('.video-container').fitVids(); // image slider // --------------------------------- $('.img-slider').flexslider({ animation: "slide", smoothHeight: true, pauseOnAction: false, controlNav: false, directionNav: true, prevText: "", nextText: "" }); $('.flex-direction-nav a').click(function(ev) { ev.stopPropagation(); }); // BLOG // --------------------------------- $(window).load(function() { $('.blog').imagesLoaded(function() { $('.blog').shuffle({ "itemSelector": ".post" }); // fix setTimeout(function() { $('.blog').shuffle('shuffle'); }, 200); }); topBannerHeight(); calcPaddingMainWrapper(); }); $('.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 }); // PORTFOLIO // --------------------------------- $(window).load(function() { if ($('.portfolio.col-3').length) { $('.item').width(100 / 3 + '%'); $('.item.wide, .item.wide-tall').width(100 * 2 / 3 + '%'); } if ($('.portfolio.col-4').length) { $('.item').width(100 / 4 + '%'); $('.item.wide, .item.wide-tall').width(100 * 2 / 4 + '%'); } $('.portfolio .wpb_wrapper').shuffle({ "itemSelector": ".item", "delimeter": ' ' }); // fix setTimeout(function() { $(window).resize(); }, 200); }); // spaces between items $('.portfolio[data-space]').each(function() { var space = $(this).data('space'); $(this).find('.item-link').css({ 'margin': space }); $('.portfolio').css({ 'margin-left': -space + 'px', 'margin-right': -space + 'px' }); }); // FILTER $('.filter ul li').click(function() { var filter = $(this).data('group'); $('.portfolio .wpb_wrapper').shuffle('shuffle', filter); $('.filter ul li').removeClass('active'); $(this).addClass('active'); }); // banner with gallery // --------------------------------- function bannerGallery() { var w1 = $(window).width(); var itemsArray = $('.banner-gallery .banner-list li'); var imgWidth = $('.banner-gallery .banner-list li').height(); var contentLeft; var contentRight; if (w1 > 1200) { contentLeft = $(itemsArray[9]).width() + $(itemsArray[10]).width(); contentRight = $(itemsArray[16]).width() + $(itemsArray[17]).width(); $('.banner-gallery .content-wrap').css({ 'top': imgWidth + 'px', 'height': imgWidth * 3 + 'px', 'left': contentLeft + 'px', 'right': contentRight + 'px' }); } else if (w1 > 767) { contentLeft = $(itemsArray[7]).width(); contentRight = $(itemsArray[13]).width(); $('.banner-gallery .content-wrap').css({ 'top': imgWidth + 'px', 'height': imgWidth * 3 + 'px', 'left': contentLeft + 'px', 'right': contentRight + 'px' }); } else if (w1 <= 767) { $('.banner-gallery .content-wrap').css({ 'top': imgWidth + 'px', 'left': 0 + 'px', 'right': 0 + 'px', 'height': imgWidth * 3 + 'px' }); } } bannerGallery(); $(window).on('resize', function() { bannerGallery(); topBannerHeight(); calcPaddingMainWrapper(); }); $(window).load(function() { bannerGallery(); // fix // --------------------------------- setTimeout(function() { $(window).scroll(); }, 300); }); // toggles // --------------------------------- $('.toggle .toggle-title').click(function() { $(this).next('.toggle-content').slideToggle(200); $(this).parent('.toggle').toggleClass('active'); return false; }); // IMAGE POPUP // --------------------------------- // single $('.popup-image').magnificPopup({ type: 'image', mainClass: 'mfp-fade', removalDelay: 300, closeOnContentClick: true, fixedContentPos: false, fixedBgPos: false }); // gallery mode $('.gallery-item').magnificPopup({ gallery: { enabled: true }, mainClass: 'mfp-fade', fixedContentPos: false, type: 'image' }); // YOUTUBE, VIMEO, GOOGLE MAPS POPUP // --------------------------------- $('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({ type: 'iframe', mainClass: 'mfp-fade', disableOn: 0, preloader: false, removalDelay: 300, fixedContentPos: false }); // GALLERY POPUP // --------------------------------- // for portfolio $('.popup-gallery').magnificPopup({ delegate: '.filtered a', mainClass: 'mfp-fade', gallery: { enabled: true }, fixedContentPos: false, type: 'image' }); // single gallery $('.popup-single-gallery').each(function() { $(this).magnificPopup({ delegate: 'a', mainClass: 'mfp-fade', gallery: { enabled: true }, fixedContentPos: false, type: 'image' }); }); // AJAX CONTACT FORM // --------------------------------- $('#contact form').submit(function() { var url = $(this).attr('action'); // get information from contact form var name = $('[name=name]').val(); var email = $('[name=email]').val(); var message = $('[name=message]').val(); // send information to contact.php $.ajax({ type: "POST", url: url, data: { name: name, email: email, message: message }, success: function(response) { // response from contact.php $('.contact-message').html(response).slideDown(500); }, error: function() { // error message $('.contact-message').html('

Something went wrong, try again!

').slideDown('slow'); } }); return false; }); // GOOGLE MAP // ---------------------------------- //set your google maps parameters $(window).load(function() { 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); }); } }); $('.wpcf7').on('focus', '.wpcf7-not-valid', function() { $(this).removeClass('wpcf7-not-valid'); }); /***********************************/ /* BACKGROUND*/ /**********************************/ //sets child image as a background function wpc_add_img_bg(img_sel, parent_sel) { if (!img_sel) { console.info('no img selector'); return false; } var $parent, $imgDataHidden, _this; $(img_sel).each(function() { _this = $(this); $imgDataHidden = _this.data('s-hidden'); $parent = _this.closest(parent_sel); $parent = $parent.length ? $parent : _this.parent(); $parent.css('background-image', 'url(' + this.src + ')').addClass('s-back-switch'); if ($imgDataHidden) { _this.css('visibility', 'hidden'); } else { _this.hide(); } }); } $(window).on('load', function() { // wpc_add_img_bg('.s-img-switch'); wpc_add_img_bg('.s-img-switch', '.s-back-switch'); if ($('.izotope-container').length) { var $container = $('.izotope-container'); $('.izotope-container').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 } }); }); } if ($('.izotope-container-2').length) { var $container = $('.izotope-container-2'); $('.izotope-container-2').each(function() { var self = $(this); var layoutM = self.attr('data-layout') || 'masonry'; self.isotope({ itemSelector: '.full-single', layoutMode: layoutM, masonry: { columnWidth: '.full-single' } }); }); } }); window.addEventListener("orientationchange", function() { bannerGallery(); }); $(window).on('resize', function() { if ($('.izotope-container').length) { var $container = $('.izotope-container'); $('.izotope-container').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 } }); }); } if ($('.izotope-container-2').length) { var $container = $('.izotope-container-2'); $('.izotope-container-2').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() { var paddValue = $('footer').outerHeight(); $('.main-wrapper').css('padding-bottom', paddValue); } calcPaddingMainWrapper(); /*Full height banner*/ function topBannerHeight() { var bannerHeight = $(window).height() - $('footer').outerHeight(); $('.full-height').css('min-height', (bannerHeight - $('header').closest('.col-xs-12').outerHeight()) + 'px'); $('.full-height-hard').css('height', (bannerHeight - $('header').closest('.col-xs-12').outerHeight()) + 'px'); var fullHeight = $('.top-banner.full-height').outerHeight(); var heightContentBanner = $('.top-banner.full-height .content').outerHeight(); var minheightContentBanner = heightContentBanner + 100; $('.top-banner.full-height .content').css('top', (fullHeight - heightContentBanner) / 2 + 'px'); if (fullHeight < minheightContentBanner) { $('.top-banner.full-height').css('min-height', minheightContentBanner + 'px'); $('.top-banner.full-height .content').css('top', (minheightContentBanner - heightContentBanner) / 2 + 'px'); } } topBannerHeight(); var pswpElement = document.querySelectorAll('.pswp')[0]; var galleryItems = parseGalleryPhotoSwipe('.just-gallery'); function createGalleryItemTitle(title, desc) { var title = '

' + title + '

'; if (desc) { title += '
' + desc + '
' } return title; } function parseGalleryPhotoSwipe(gallerySelector) { var items = []; $(gallerySelector).children().each(function() { var size = $(this).attr('data-size').split('x'); items.push({ src: $(this).attr('href'), w: parseInt(size[0], 10), h: parseInt(size[1], 10), title: createGalleryItemTitle( $(this).children('img').attr('alt'), $(this).attr('data-desc') ) }); }); return items; } var isJustify = $('.gallery-boxed').length ? 'justify' : 'nojustify'; $(".just-gallery").justifiedGallery({ rowHeight: 200, margins: 3, captions: false, lastRow: isJustify }).on('jg.complete', function (e) { $(this).sliphover({ target: 'img', caption: 'alt', duration: 'fast', withLink: false, backgroundColor: 'rgba(19,19,19,.3)' }); }); var currentImg; $('.just-gallery img').on({ 'mouseenter':function(){ currentImg = $(this); } }); $('body').on('click', '.sliphover-container', function () { currentImg.parent('a').trigger('click'); }); var optionsGallery = { closeOnScroll: false, shareEl: false, clickToCloseNonZoomable: false, history: false } var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, galleryItems, optionsGallery); $('.just-gallery').children().on('click', function(e) { optionsGallery.index = $(this).index(); gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, galleryItems, optionsGallery); gallery.init(); e.preventDefault(); }); $('.js-contact-form').submit(function(e) { $('.ajax-loader').show(); var url = 'mail.php', form = this; $(form).find('[name="fields[code]"]').remove(); function result(class_key, data) { setTimeout(function() { $('.ajax-loader').hide(); $('.ajax-result').find(class_key).show().text(data); }, 500); } $.ajax({ type: "POST", url: url, data: $(form).serialize(), }) .done(function(data) { result('.success', data); }).error(function(data) { result('.error', data); }) e.preventDefault(); }); })(jQuery, window, document);