/*SCRIPT.JS*/ /*-------------------------------------------------------------------------------------------------------*/ /*This is main JS file that contains custom rules used in this template*/ /*-------------------------------------------------------------------------------------------------------*/ /* Template Name: PROJECT */ /* Version: 1.0 Initial Release*/ /* Build Date: */ /* Author: */ /* Website: */ /* Copyright: (C) */ /*------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------*/ /* TABLE OF CONTENTS: */ /*--------------------------------------------------------*/ /* 1. INIT 2. WINDOW LOAD 3. WINDOW RESIZE 4. WINDOW SCROLL 5. BACKGROUND 7. PAGE HEIGHT CALCULATE 8. SWIPER SLIDER */ /*--------------------------------------------------------*/ ;(function($, window, document, undefined) { "use strict"; /*============================*/ /* INIT */ /*============================*/ var swipers = [], vivus = [], slicks = [], 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); /** * * 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, documentHeight, $html, latestKnownScrollY, lastKnownScrollY, onEvent = window.addEventListener; pageCalculations = function(func){ winW = window.innerWidth; winH = window.innerHeight; winS = $(window).scrollTop(); documentHeight = $(document).height(), $html = $('html'); latestKnownScrollY = $(window).scrollTop(), lastKnownScrollY = latestKnownScrollY; if (!func) return; onEvent('load', func, true); // window onload onEvent('resize', func, true); // window resize //onEvent("orientationchange", func, false); // window orientationchange }// end pageCalculations pageCalculations(function(){ pageCalculations(); }); } pageCalculations(function(){ wpc_add_img_bg('.s-img-switch'); // pageHeightCalculate(); // pageOnlyFullHeight('.prague_filmstrip'); // pageOnlyFullHeight('.projects-detail-before-banner'); // pageOnlyFullHeight('.project-detail-fullscreen'); topFullBannerHeight(); // upFullWidthVideo(); // cirleFigure(); // testimonialsSliderHeight(); // comingSoonValue(); // filmstripSliderHeight(); // timelineImageHeight(); // Parallax.initialize(); }); /***********************************/ /* WINDOW LOAD */ /**********************************/ $(window).on('load', function() { // Preloader $(".loading").delay(700).fadeOut("slow"); }); /***********************************/ /* WINDOW RESIZE */ /**********************************/ $(window).on('resize', function() { }); /***********************************/ /* WINDOW SCROLL */ /**********************************/ $(window).on('scroll', function() { winS = $(window).scrollTop(); latestKnownScrollY = $(window).scrollTop(); lastKnownScrollY = latestKnownScrollY; }); /***********************************/ /* 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, $neighbor, $imgDataHidden, $imgDataSibling, _this; $(img_sel).each(function(){ _this = $(this); $imgDataHidden = _this.data('s-hidden'); $imgDataSibling = _this.data('s-sibling'); $parent = _this.closest( parent_sel ); $parent = $parent.length ? $parent : _this.parent(); if ($imgDataSibling) { $parent.addClass('s-back-sibling-switch'); $neighbor = _this.next(); $neighbor = $neighbor.length ? $neighbor : _this.next(); $neighbor.css( 'background-image' , 'url(' + this.src + ')' ).addClass('s-sibling-switch'); } else { $parent.css( 'background-image' , 'url(' + this.src + ')' ).addClass('s-back-switch'); } if ($imgDataHidden) { _this.css('visibility', 'hidden'); } else { _this.hide(); } }); } /***********************************/ /* TOP BANNER HEIGHT */ /**********************************/ function topFullBannerHeight() { var bannerFullWrapper = $('.top-banner.fullheight'), bannerFullContent = $('.top-banner.fullheight .content'), bannerFullContentHeight = $('.top-banner.fullheight .content').outerHeight(true); if(winH < bannerFullContentHeight) { bannerFullWrapper.css('min-height', bannerFullContentHeight); } else { bannerFullWrapper.css('min-height', winH); } } /***********************************/ /* PAGE HEIGHT CALCULATE */ /**********************************/ function pageHeightCalculate() { if($('.page-calculate.fullheight').length) { var pageCalculate = $('.page-calculate.fullheight'), pageCalculateContentHeight = $('.page-calculate.fullheight .page-calculate-content').outerHeight(true); if(winH < pageCalculateContentHeight) { pageCalculate.css('height', pageCalculateContentHeight); } else { pageCalculate.css('height', winH); } } } function pageOnlyFullHeight(wrapper) { var $wrapperHeight = $(wrapper); $wrapperHeight.outerHeight(winH); } /***********************************/ /* SWIPER SLIDER */ /**********************************/ function initSwiper() { var attrsToSize = { 'data-lg-slides': '1200', 'data-md-slides': '992', 'data-sm-slides': '768', 'data-xs-slides': '599' }; function parseSlidesAttrValue(value) { var parts = value.split(','); return { slidesPerView: parseInt(parts[0], 10), spaceBetween: parseInt(parts[1], 10) } } function createBreakpoints(container, attrsToSize) { var breakpointsObj = {}; $.each(attrsToSize, function(key, value) { if (container.attr(key)) { breakpointsObj[value] = parseSlidesAttrValue(container.attr(key)); } }); return breakpointsObj; } function setMousewheel(activeIndex, slidesNum, container) { if(activeIndex == slidesNum-1) { $(window).bind('mousewheel', function(event) { if (event.originalEvent.wheelDelta >= 0) { container.enableMousewheelControl(); } else { container.disableMousewheelControl(); } }); } else if(activeIndex == 0) { $(window).bind('mousewheel', function(event) { if (event.originalEvent.wheelDelta >= 0) { container.disableMousewheelControl(); } else { container.enableMousewheelControl(); } }); } } $('.swiper-container').each(function(index) { var that = $(this); var sliderIndex = 'swiper-unique-id-' + index; that.addClass(sliderIndex + ' initialized').attr('id', sliderIndex); that.find('.swiper-pagination').addClass('pagination-' + sliderIndex); if(that.find('.swiper-slide').length<=1) { $('.slider-click[data-pagination-rel="'+$t.data('pagination-rel')+'"]').addClass('disabled'); } var speedVar = parseInt(that.attr('data-speed'), 10); var loopVar = parseInt(that.attr('data-loop'),10); var autoPlayVar = parseInt(that.attr('data-autoplay'),10); var autoHeightVar = parseInt(that.attr('data-autoheight'),10); var centerVar = parseInt(that.attr('data-center'),10); var effectVar = that.attr('data-effect'); var mode = that.attr('data-mode'); var slidesPerViewVar = parseInt(that.attr('data-slides-per-view'), 10); var spaceBetweenVar = parseInt(that.attr('data-space-between'), 10); var mousewheelControlVar = parseInt(that.attr('data-mouse'), 10); if (isNaN(slidesPerViewVar)) { slidesPerViewVar = 'auto'; } swipers[sliderIndex] = new Swiper('.' + sliderIndex, { pagination: '.pagination-' + sliderIndex, paginationClickable: true, keyboardControl: true, // Set to true to enable navigation through slides using keyboard right and left (for horizontal mode), top and borrom (for vertical mode) keyboard arrows simulateTouch: true, //If true, Swiper will accept mouse events like touch events (click and drag to change slides) roundLengths: true, //Set to true to round values of slides widt h and height to prevent blurry texts on usual resolution screens (if you have such) autoplayDisableOnInteraction: false, grabCursor: false, watchSlidesProgress: true, speed: speedVar, loop: loopVar, autoplay: autoPlayVar, autoHeight: autoHeightVar, // Set to true and slider wrapper will adopt its height to the height of the currently active slide centeredSlides: true, mousewheelControl: true, effect: effectVar || 'slide', direction: mode || 'horizontal', slidesPerView: slidesPerViewVar, spaceBetween: spaceBetweenVar || 0, // Navigation arrows nextButton: '.swiper-button-next' , //CSS selector or HTML element of the element that will work like "next" button prevButton: '.swiper-button-prev' , //CSS selector or HTML element of the element that will work like "prev" button breakpoints: createBreakpoints(that, attrsToSize), onInit: function(swiper) { }, onSlideChangeEnd: function(swiper) { var activeIndex = swiper.activeIndex; if($('.projects-list-slider').length) { setMousewheel(activeIndex, swiper.slides.length, swiper); } }, onSlideChangeStart: function(swiper) { }, onSlideClick: function(swiper) {}, paginationBulletRender: function (swiper, index, className) { if($('.testimonials-swiper').length) { var newIndex = swiper.activeIndex + index; var newIndexAuthor = $(swiper.slides[newIndex]).find('.testimonials-author').html() || 'Guest'; return '' + newIndexAuthor + ''; } }, }); swipers[sliderIndex].update(); }); } $("a[href*='#']").click(function() { $('html, body').animate({ scrollTop: $($(this).attr('href')).offset().top }, 2000); }); })(jQuery, window, document);