; (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(); initFslider() aboutFix(); newsFix(); $('.preloader').fadeOut(500); }); /*==============================*/ /* 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 ($('.custom_slider').length) { reinitCustomSlider(); } } 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 slidesPerViewVar = $t.attr('data-slides-per-view'); if (slidesPerViewVar == 'responsive') { slidesPerViewVar = updateSlidesPerView($t); } else slidesPerViewVar = parseInt(slidesPerViewVar, 10); var mode = $t.attr('data-mode'); 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; var qVal = $t.find('.swiper-slide-active').attr('data-val'); $t.find('.swiper-slide[data-val="' + qVal + '"]').addClass('active'); }, 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(); } 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(); }); /*=====================*/ /* OTHER */ /*=====================*/ //Flexslider function initFslider() { $('.flexslider').flexslider({ animation: "slide", directionNav: false, controlNav: false }); } $(window).on('resize', function () { if (winW >= 992) { $('nav', '.bottom-header').css({ display: 'block' }); } else if (winW < 992) { $('nav', '.bottom-header').css({ display: 'none' }); } aboutFix(); newsFix(); }); //mobile menu $('.burger-icon').on('click', function () { $(this).toggleClass('active'); $('nav', '.bottom-header').slideToggle(); }); //background fix $('.s-back-switch').each(function () { var $imgSrc = $(this).find('.s-img-switch').hide().attr('src'); $(this).css('background-image', 'url(' + $imgSrc + ')'); }); function aboutFix() { var heights = $(".about .content").map(function () { return $(this).outerHeight(); }).get(); var maxHeight = Math.max.apply(null, heights); $('.about .img, .about .content').outerHeight(maxHeight); } function newsFix() { if (winW >= 992) { var heights = $(".news-col .swiper-container,.news-col .text-wrap").map(function () { return $(this).outerHeight(); }).get(); var maxHeight = Math.max.apply(null, heights); $('.news-col, .news-col .text-wrap').outerHeight(maxHeight); } else if (winW < 992) { $('.news-col, .news-col .text-wrap').css('height', '100%'); } } //accordion $('.faq-accordion').on('click', '.panel-title', function () { var self = $(this); var panelWrap = self.parent(); panelWrap.find('.panel-collapse').slideToggle('200'); self.toggleClass('active'); panelWrap.siblings().find('.panel-collapse').slideUp('200'); panelWrap.siblings().find('.panel-title').removeClass('active'); }); //Magnific Popup $('.cut_video_btn').magnificPopup({ type: 'iframe' // this overrides default type }); //mobile menu $('.menu > li').on('click', function (e) { var self = $(this); self.siblings().find('> .submenu').slideUp(200); setTimeout(function () { if (self.has('.submenu')) { self.find('> .submenu').slideToggle(200); } }, 200); }); //google map function initialize() { var myLatlng = new google.maps.LatLng(6.452821, 3.420136); var mapOptions = { zoom: 15, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP, disableDefaultUI: true } var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); //=====Initialise Default Marker var marker = new google.maps.Marker({ position: myLatlng, map: map, title: 'Heirs Holdings', visible: true }); //=====Eventlistener for InfoWindow google.maps.event.addListener(marker, 'click', function () { infowindow.open(map, marker); }); } if (typeof google != "undefined") { google.maps.event.addDomListener(window, 'load', initialize); } })(jQuery, window, document);