; (function($, window, document, undefined) { "use strict"; /*================*/ /* 01 - VARIABLES */ /*================*/ var swipers = [], winW, winH, winScr, $container, _isresponsive, xsPoint = 451, 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 */ /*========================*/ if (typeof pageCalculations !== 'function') { var $win, winW, winH, winS, pageCalculations; pageCalculations = function (func){ $win = $(window); winW = $win.width(); winH = $win.height(); winS = $win.scrollTop(); if (func) { $win .on('load',function(){ func(); }) .on('resize',function(){ func(); }); window.addEventListener("orientationchange", function() { func(); }, false); } } pageCalculations(function(){ pageCalculations(); }); } /*=================================*/ /* 04 - SWIPER SLIDER */ /*=================================*/ 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 centerVar = parseInt($t.attr('data-center'), 10); var simVar = ($t.closest('.circle-description-slide-box').length) ? false : true; 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); 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: simVar, centeredSlides: centerVar, roundLengths: true, mode: mode || 'horizontal', onInit: function(swiper) { var length_slide = $('.swiper-wrapper.left-push-swiper').find('.swiper-slide').length; if (!loopVar) { $('.prev-push-left').hide(); } }, onSlideChangeEnd: function(swiper) { var activeIndex = (loopVar === 1) ? swiper.activeLoopIndex : swiper.activeIndex; }, onSlideChangeStart: function(swiper) { $t.find('.swiper-slide.active').removeClass('active'); var activeIndex = (loopVar === 1) ? swiper.activeLoopIndex : swiper.activeIndex, data_Bg = $t.find('.swiper-slide-active').attr('data-bg'); var length_slide = $('.swiper-wrapper.left-push-swiper').find('.swiper-slide').length; if (activeIndex == length_slide - 1) { $('.next-push-left').hide(); } else { if (activeIndex == 0) { $('.prev-push-left').hide(); } else { $('.prev-push-left').show(); } $('.next-push-left').show(); } }, onSlideClick: function(swiper) { } }); swipers['swiper-' + index].reInit(); if (!centerVar) { 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(); } } initIterator++; }); } $('.slide-prev').on('click', function() { swipers['swiper-' + $(this).closest('.slider-wrap').find('.swiper-container').attr('id')].swipePrev(); return false; }); $('.slide-next').on('click', function() { swipers['swiper-' + $(this).closest('.slider-wrap').find('.swiper-container').attr('id')].swipeNext(); return false; }); $('.next-push-left').on('click', function() { swipers['swiper-' + $(this).closest('.slider-wrap').find('.swiper-container').attr('id')].swipeNext(); return false; }); 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); } /*=================================*/ /* 05 - RESPONSIVE MENU */ /*=================================*/ $('.nav-menu-icon a').on('click', function() { if ($('.navigation').hasClass('slide-menu')) { $('.navigation').removeClass('slide-menu'); $(this).removeClass('active'); } else { $('.navigation').addClass('slide-menu'); $(this).addClass('active'); } return false; }); $('.close-menu').on('click', function() { $('.navigation').removeClass('slide-menu'); $('.close-menu').removeClass('active'); $('body').removeClass('act'); return false; }); $('#dl-menu').dlmenu({ animationClasses: { classin: 'dl-animate-in-2', classout: 'dl-animate-out-2' } }); $('.nav-menu-icon').on('click', function() { }); /** Right Menu **/ if( $(window).width() >= 993 ) { $('.second-menu').on('click' , function(){ $('.right-menu').addClass('slides'); $('.close-right-menu').addClass('active'); $('body').addClass('act'); $(this).hide(200); return false; }); $('.close-right-menu').on('click' , function(){ $('.right-menu').removeClass('slides'); $('.close-right-menu').removeClass('active'); $('.second-menu').show(500); $('body').removeClass('act'); return false; }); } /** Header style 2 **/ if( $(window).width() >= 993 ) { $('.nav-button').on('click', function() { $(this).hide(); $('.nav-button-close').addClass('active'); $('.header-style-2').find('.navigation').show(); }); $('.nav-button-close').on('click', function() { $(this).removeClass('active'); $('.nav-button').show(); $('.header-style-2').find('.navigation').hide(); }); } /*=================================*/ /* 06 - BG BLOCK */ /*=================================*/ // bg banner $('.bg-banner-max').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-banner-max').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-banner-min').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-banner-min').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); // bg post $('.bg-post-max').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-post-max').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-post').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-post').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-post-min').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-post-min').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-post-middle').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-post-middle').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); // bg team $('.bg-team').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-team').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-team-max').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-team-max').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); //bg portfolio $('.bg-portfolio-long').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-portfolio-long').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-portfolio-max').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-portfolio-max').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-portfolio-min').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-portfolio-min').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-portfolio-contain').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-portfolio-contain').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-portfolio-v1-max').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-portfolio-v1-max').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-portfolio-v1-min').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-portfolio-v1-min').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-portfolio-v1-middle').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-portfolio-v1-middle').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); //bg food $('.bg-food').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-food').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); //bg project $('.bg-project').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-project').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-project-middle').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-project-middle').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-project-max').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-project-max').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); //bg category $('.bg-category').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-category').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-project-furniture').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-project-furniture').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-banner-about').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-banner-about').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-photography-item').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-photography-item').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-photography-showcase').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-photography-showcase').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-photography-contact').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-photography-contact').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); $('.bg-photography-bg-contact').each(function() { var bgSrc = $(this).attr('src'); $(this).parent().addClass('background-photography-bg-contact').css({ 'background-image': 'url(' + bgSrc + ')' }); $(this).hide(); }); /*=================================*/ /* 07 - MASONRY */ /*=================================*/ function masonry() { $('.portfolio').masonry({ itemSelector: '.item', columnWidth: '.item' }); } pageCalculations(function(){ masonry(); }); /*=================================*/ /* 08 - GOOGLE MAP */ /*=================================*/ if ($('.wpc-map').length) { $('.wpc-map').each(function() { initialize(this); }); } function initialize(_this) { var stylesArray = { //style 1 'style-1': [{ "featureType": "landscape", "stylers": [{ "hue": "#FFBB00" }, { "saturation": 43.400000000000006 }, { "lightness": 37.599999999999994 }, { "gamma": 1 }] }, { "featureType": "road.highway", "stylers": [{ "hue": "#FFC200" }, { "saturation": -61.8 }, { "lightness": 45.599999999999994 }, { "gamma": 1 }] }, { "featureType": "road.arterial", "stylers": [{ "hue": "#FF0300" }, { "saturation": -100 }, { "lightness": 51.19999999999999 }, { "gamma": 1 }] }, { "featureType": "road.local", "stylers": [{ "hue": "#FF0300" }, { "saturation": -100 }, { "lightness": 52 }, { "gamma": 1 }] }, { "featureType": "water", "stylers": [{ "hue": "#0078FF" }, { "saturation": -13.200000000000003 }, { "lightness": 2.4000000000000057 }, { "gamma": 1 }] }, { "featureType": "poi", "stylers": [{ "hue": "#00FF6A" }, { "saturation": -1.0989010989011234 }, { "lightness": 11.200000000000017 }, { "gamma": 1 }] }] }; var styles, map, marker, infowindow, lat = $(_this).attr("data-lat"), lng = $(_this).attr("data-lng"), contentString = $(_this).attr("data-string"), image = $(_this).attr("data-marker"), styles_attr = $(_this).attr("data-style"), zoomLevel = parseInt($(_this).attr("data-zoom"), 10), myLatlng = new google.maps.LatLng(lat, lng); // style_1 if (styles_attr == 'style-1') { styles = stylesArray[styles_attr]; } // custom if (typeof hawa_style_map != 'undefined' && styles_attr == 'custom') { styles = hawa_style_map; } // or default style var styledMap = new google.maps.StyledMapType(styles, { name: "Styled Map" }); var mapOptions = { zoom: zoomLevel, disableDefaultUI: true, center: myLatlng, scrollwheel: false, mapTypeControlOptions: { mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style'] } }; map = new google.maps.Map(_this, mapOptions); map.mapTypes.set('map_style', styledMap); map.setMapTypeId('map_style'); infowindow = new google.maps.InfoWindow({ content: contentString }); marker = new google.maps.Marker({ position: myLatlng, map: map, icon: image }); google.maps.event.addListener(marker, 'click', function() { infowindow.open(map, marker); }); } /*=================================*/ /* 09 - COLOR BG */ /*=================================*/ var colorThief = new ColorThief(); /*=================================*/ /* 10 - PAGE SCROLL */ /*=================================*/ function scroll_bottom() { $(".scroll-bottom").mPageScroll2id(); }; /*=================================*/ /* 11 - CATEGORY LIST */ /*=================================*/ $('.list-category li').on('mouseenter', function() { var index_el = $(this).index(), index_li; $(".list-image").each(function(i) { $(this).find('li:eq(' + index_el + ')').css({ 'opacity': '1', 'visibility': 'visible' }); }); }).on('mouseleave', function() { $(".list-image").find('li').css({ 'opacity': '0', 'visibility': 'hidden' }); }); // List Category hover effect $(".list-category li").on('mouseenter', function() { $(".list-category li").find(".img-categ-list").removeClass('active'); $(this).find(".img-categ-list").addClass('active'); }); /*=================================*/ /* 12 - ACTIVE MENU ITEM */ /*=================================*/ var current_url = location.href; $('.navigation li').removeClass('active'); $('.navigation a').each(function() { if (this.href == current_url) { $(this).parents('li').addClass('active'); } }); /*=================================*/ /* 13 - ANIMSITION */ /*=================================*/ if ($(".animsition").length) { $(".animsition").animsition({ inClass: 'zoom-in-sm', outClass: 'zoom-out-sm', inDuration: 1000, outDuration: 1000, linkElement: '.animsition-link', // e.g. linkElement : 'a:not([target="_blank"]):not([href^=#])' loading: true, loadingParentElement: 'body', loadingClass: 'animsition-loading', unSupportCss: ['animation-duration', '-webkit-animation-duration', '-o-animation-duration' ], overlay: false, overlayClass: 'animsition-overlay-slide', overlayParentElement: 'body' }); } /*=================================*/ /* 14 - COLOR PAGE */ /*=================================*/ $('.conf-button').on('mouseenter', function() { if ($('.style-page').hasClass('slide-left')) { $('.style-page').removeClass('slide-left'); $('.conf-button span').removeClass('act'); } else { $('.style-page').addClass('slide-left'); $('.conf-button span').addClass('act'); } return false; }); $('.style-page').on('mouseleave', function() { $('.style-page').removeClass('slide-left'); $('.conf-button span').removeClass('act'); return false; }); $('.entry').on('click', function() { var prevTheme = $('body').attr('data-color'); var newTheme = $(this).attr('data-color'); if ($(this).hasClass('active')) return false; $(this).parent().find('.active').removeClass('active'); $(this).addClass('active'); $('body').attr('data-color', newTheme); $('img').each(function() { $(this).attr("src", $(this).attr("src").replace(prevTheme + '/', newTheme + '/')); }); $('.map-canvas').attr('data-marker', $('.map-canvas').attr('data-marker').replace(prevTheme + '/', newTheme + '/')); localStorage.setItem("color", newTheme); }); var localStorageThemeVar = localStorage.getItem('color'); $('.entry[data-color="' + localStorageThemeVar + '"]').click(); /*=================================*/ /* 15 - IZOTOPE */ /*=================================*/ var izotope_portfolio = function () { var $container = $('.izotope-container'); $container.each(function() { var layout = $(this).attr('data-layout'); if ( layout ) { $container.isotope({ itemSelector: '.item', layoutMode: layout, columnWidth: '.item' }); } else { $container.isotope({ itemSelector: '.item', layoutMode: 'masonry', masonry: { columnWidth: '.item' } }); } $('#filters').on('click', '.but', function() { var izotope_container = $('.izotope-container'); $('#filters .but').removeClass('activbut'); $(this).addClass('activbut'); var filterValue = $(this).attr('data-filter'); $container.isotope({filter: filterValue}); return false; }); }); } /*=================================*/ /* 16 - MAGMIFIC POPUP */ /*=================================*/ if ($('.popup-gallery').length) { $('.popup-gallery').magnificPopup({ delegate: '.view-item', type: 'image', removalDelay: 100, tLoading: 'Loading image #%curr%...', mainClass: 'mfp-fade', closeBtnInside: false, closeMarkup: '', gallery: { enabled: true, }, callbacks: { beforeOpen: function() { this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure animated ' + this.st.el.attr('data-effect')); }, open: function() { $('.mfp-close').append('Close').on('click', function() { $.magnificPopup.close(); }); } } }); } /*=================================*/ /* 17 - SCROLL TOP */ /*=================================*/ var offset = 300, offset_opacity = 1200, scroll_top_duration = 700, $back_to_top = $('#scroll-top, #click-scroll-top'); $back_to_top.hide(); //hide or show the "back to top" link $(window).scroll(function(){ if ( $(this).scrollTop() > 500 ) { $back_to_top.fadeIn(); } else { $back_to_top.fadeOut(); } }); //smooth scroll to top $back_to_top.on('click', function(event){ event.preventDefault(); $('body,html').animate({ scrollTop: 0 , }, scroll_top_duration ); }); /*=================================*/ /* 18 - ANIMATION BLOG */ /*=================================*/ (function() { $('.post').viewportChecker({ classToAdd: 'visible', offset: 100 }); }()) var wow = new WOW( { offset: 0, // distance to the element when triggering the animation (default is 0) mobile: true, // trigger animations on mobile devices (default is true) live: true, // act on asynchronously loaded content (default is true) callback: function(box) { // the callback is fired every time an animation is started // the argument that is passed in is the DOM node being animated }, scrollContainer: null // optional scroll container selector, otherwise use window } ); wow.init(); /*=================================*/ /* 19 - SLIDER HOVER ANIMATION */ /*=================================*/ var arrow_next = $('.arrow-slider-next'), container_slider = arrow_next.closest('.container-slider'), slider_item = container_slider.find('.slide-item'); arrow_next.mouseenter(function() { container_slider.addClass('slider-next'); }).mouseleave(function() { container_slider.removeClass('slider-next'); }); arrow_next.on('click', function() { container_slider.find('.slide-item-next .slide-item-bg').animate({ 'width': '108%' }, 1500, function() { var $first = $('.slide-item').first(); container_slider.find('.content-slider').append( $first ); $('.slide-item').addClass('slide-item-far').removeClass('slide-item-active').removeClass('slide-item-next'); $('.slide-item').first().addClass('slide-item-active').removeClass('slide-item-far'); $('.slide-item').eq(1).addClass('slide-item-next').removeClass('slide-item-far'); $('.slide-item .slide-item-bg').last().css('width','15%'); }); }); /*============================*/ /* WINDOW LOAD */ /*============================*/ $(window).on('load', function() { $("#site-loader").delay(1000).fadeOut("slow"); initSwiper(); scroll_bottom(); izotope_portfolio(); $('.portfolio-item.portfolio-style-2').find('.img-portf').each(function() { var img = $(this).find('img'), color_ar = colorThief.getColor(img[0]); img.next('.hover-portf').css({ 'background-color': 'rgba(' + color_ar[0] + ',' + color_ar[1] + ',' + color_ar[2] + ',.6)' }); }); }); /*============================*/ /* WINDOW 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); thisSwiper.params.slidesPerView = slidesPerViewVar; thisSwiper.reInit(); 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); } /*============================*/ /* WINDOW SCROLL */ /*============================*/ $(window).scroll(function() { // Scroll discover var scroll_top = $(window).scrollTop(), scroll_discover = $('.scroll-discover'); if (scroll_top > 200) { scroll_discover.addClass('active'); } else { scroll_discover.removeClass('active'); } //Animation portfolio var windowHeight = $(window).height(); $('.portfolio-item').each(function() { var blockHeight = $(this).height(); var wScroll = $(this).offset().top - $(window).scrollTop() - windowHeight + blockHeight; if( wScroll < 0 && ( wScroll * (-1) < blockHeight ) ) { var el = $(this).find('.detail-portf-item').find('.content-detail-portfolio'); el.css('top', (wScroll * (.4)) + 'px') } }); // Counters line if ($('.counters-line').length) { $('.counters-line').not('.animated').each(function() { if ($(window).scrollTop() >= $(this).offset().top - $(window).height() * 0.5) { $(this).addClass('animated').find('.timer').countTo(); } }); } // Link Portfolio scroll and hover var scroll_top = $(window).scrollTop(), link_next_portfolio = $(".link-next-portfolio"); if (scroll_top > 100) { link_next_portfolio.css("opacity", '.3'); link_next_portfolio.on('mouseenter', function() { $(this).css("opacity", "1"); }).on('mouseleave', function() { $(this).css("opacity", ".3"); }); } else { link_next_portfolio.css("opacity", '1'); } }); /*============================*/ /* Сommet for custom function */ /*============================*/ })(jQuery, window, document);