; (function($, window, document, undefined) { "use strict"; // calendar var calendar = $('#mycalendar'); if (calendar.length) { // expression calendar.monthly({ mode: 'event' //jsonUrl: 'events.json', //dataType: 'json' // xmlUrl: 'events.xml' }); } $('.container').fitVids(); /*============================*/ /* INIT */ /*============================*/ var swipers = [], 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, 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 }; // end pageCalculations pageCalculations(function() { pageCalculations(); }); } /***********************************/ /* MENU*/ /**********************************/ function overflow() { var $body = $("body"); if ($(window).width() <= 992) { if ($('nav').hasClass('slide-menu')) { $body.addClass("overflow"); } else { $body.removeClass("overflow"); } } } function notactive() { var notactive = 0; $('.menu .menu-item').each(function() { if ($(this).hasClass('active')) { notactive++; } }); if (notactive === 0) { $('.menu .current_page_item').addClass('active'); } } notactive(); $('.questroom-nav-menu-icon a').on('click', function() { var $nav = $('nav'); if ($nav.hasClass('slide-menu')) { $nav.removeClass('slide-menu'); $(this).removeClass('active'); $('.style2 nav').css({ 'overflow': 'hidden' }); } else { $nav.addClass('slide-menu'); $(this).addClass('active'); setTimeout(function() { $('.style2 nav').css({ 'overflow': 'visible' }); }, 500); } overflow(); return false; }); $('.menu-item-has-children').each(function() { $(this).find('> a').after(''); }); $('.menu-item a').on('click', function() { if ($('.questroom-navigation.style2').length && $(window).width() > 992) { overflow(); } else { $('nav.slide-menu').removeClass('slide-menu'); $('.questroom-nav-menu-icon a').removeClass('active'); overflow(); } }); $('.menu-item-has-children i').on('click', function() { $(this).parent().toggleClass('open').find('> .sub-menu').slideToggle(); $('.menu-item a, .menu-item i').css('opacity', '0.6'); $(this).css('opacity', '1').parent().find('a').css('opacity', '1'); if (!$('.menu > .menu-item-has-children').hasClass('open')) { $('.menu-item a, .menu-item i').css('opacity', '1'); } else if (!$(this).parent().hasClass('open')) { $(this).css('opacity', '0.6').parent().find('a').css('opacity', '0.6'); if ($(this).parent().parent().parent().hasClass('open')) { $(this).parent().parent().parent().find('> i').css('opacity', '1').parent().find('a').css('opacity', '1'); } else if ($('.menu .open').length) { var i = 0; $('.menu .open').each(function() { if (i === 0) { if ($(this).find('.open').length) { $(this).find('.open a').css('opacity', '1').parent().find('> i').css('opacity', '1'); } else { $(this).find('a').css('opacity', '1').parent().find('> i').css('opacity', '1'); } } i++; }); } } }); /***********************************/ /* 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(); } }); } wpc_add_img_bg('.s-img-switch'); function sampleHeight() { if ($('.single-quest-section .contact-info').length && $(window).width() > 768) { $('.equal-h').css('height', 'auto').equalHeights(); } else { $('.equal-h').css('height', 'auto'); } } sampleHeight(); /*=================================*/ /* SWIPER SLIDER */ /*=================================*/ function initSwiper() { var swipers = {}; 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; } $('.swiper-container').each(function(index) { var $t = $(this); var sliderIndex = 'swiper-unique-id-' + index; $t.addClass(sliderIndex + ' initialized').attr('id', sliderIndex); $t.find('.swiper-pagination').addClass('pagination-' + sliderIndex); var autoPlayVar = $t.attr('data-autoplay'); var mode = $t.attr('data-mode'); var slidesPerViewVar = parseInt($t.attr('data-slides-per-view'), 10); var loopVar = $t.attr('data-loop'); var speedVar = parseInt($t.attr('data-speed'), 10); var centerVar = $t.attr('data-center'); var effect = $t.attr('data-effect'); var spaceBetweenVar = parseInt($t.attr('data-space-between'), 10); var dataHeight = $t.attr('data-height'); //Swiper height (in px) Setting this parameter will make Swiper not responsive if (isNaN(slidesPerViewVar)) { slidesPerViewVar = 'auto'; } swipers[sliderIndex] = new Swiper('.' + sliderIndex, { speed: speedVar, pagination: '.pagination-' + sliderIndex, loop: loopVar, paginationClickable: true, autoplay: autoPlayVar, slidesPerView: slidesPerViewVar, 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 autoHeight: true, // Set to true and slider wrapper will adopt its height to the height of the currently active slide 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 width and height to prevent blurry texts on usual resolution screens (if you have such) centeredSlides: centerVar, effect: effect || 'slide', height: dataHeight || '', direction: mode || 'horizontal', autoplayDisableOnInteraction: false, spaceBetween: spaceBetweenVar || 0, preventClicks: false, // 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 grabCursor: true, breakpoints: createBreakpoints($t, attrsToSize), onInit: function(swiper) { // $t.find('.swiper-slide').css('height', '50px').equalHeights(); if ($('.image-equal').length) { $t.find('.image-equal').css('height', 'auto').equalHeights(); } if ($t.find('.post-item').length) { hoverwidth(); $t.find('.post-item').addClass('back-hover'); $t.find('.post-item.swiper-slide-active').addClass('hover').removeClass('back-hover'); } }, onSlideChangeEnd: function(swiper) { hoverwidth(); if ($t.find('.post-item').length) { $t.find('.post-item.swiper-slide-active').addClass('hover').removeClass('back-hover'); } }, onSlideChangeStart: function(swiper) { hoverwidth(); if ($t.find('.post-item').length) { $t.find('.post-item').removeClass('hover').addClass('back-hover'); } }, onClick: function(swiper) {} }); swipers[sliderIndex].update(); }); } var galleryTop = new Swiper('.gallery-top', { spaceBetween: 10 }); var galleryThumbs = new Swiper('.gallery-thumbs', { spaceBetween: 10, centeredSlides: true, slidesPerView: 'auto', touchRatio: 0.2, slideToClickedSlide: true }); galleryTop.params.control = galleryThumbs; galleryThumbs.params.control = galleryTop; /*=====================*/ /* SHARE POPUP */ /*=====================*/ $('[data-share]').on('click', function() { var w = window, url = $(this).attr('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).width(), height = $(w).height(), 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; }); var $shareSocial = $('.share-social'); if ($shareSocial.length) { $shareSocial.each(function() { var wrap = $(this); wrap.find('span').each(function() { $(this).on('mouseover touch', function() { wrap.find('span').addClass('unhover'); $(this).removeClass('unhover').addClass('hover'); }); $(this).on('mouseout ', function() { $(this).removeClass('hover'); wrap.find('span').removeClass('unhover'); }); }); }); } // questroom-social-list var $questroom = $('.questroom-social-list'); if ($questroom.length) { $questroom.each(function() { var wrap = $(this); wrap.find('a').each(function() { $(this).on('mouseover touch', function() { wrap.find('a').addClass('unhover'); $(this).removeClass('unhover').addClass('hover'); }); $(this).on('mouseout ', function() { $(this).removeClass('hover'); wrap.find('a').removeClass('unhover'); }); }); }); } /***********************************/ /* QUESTS LIST */ /**********************************/ /***********************************/ /* POSTS LIST */ /**********************************/ var $blogIndex = $('.blog-index'); if ($blogIndex.length) { $blogIndex.isotope({ itemSelector: '.blog-post-wrap', layoutMode: 'masonry', masonry: { columnWidth: '.blog-post-wrap', percentPosition: true } }); } // hoverwidth function hoverwidth() { $('.quest-list-wrapper').each(function() { var desck = $(this).attr('data-desk'), tablet = $(this).attr('data-tablet'), widthdesk = (100 / desck) + (100 / desck) / 2, widthtablet = (100 / tablet) + (100 / tablet) / 2; if ($(window).width() > 768) { $(this).find('.post-item.slider').css('width', (100 / desck) + '%'); $(this).find('.post-item.swiper-slide-active').css('width', widthdesk + '%'); } else if ($(window).width() < 769 && $(window).width() > 599) { $(this).find('.post-item.slider').css('width', (100 / tablet) + '%'); $(this).find('.post-item.swiper-slide-active').css('width', widthtablet + '%'); } else { $(this).find('.post-item.swiper-slide-active').css('width', '100%'); } }); } // stars function complexity_star() { if ($('.complexity').length) { var svg = ""; $('.complexity').each(function() { if (!$(this).find('svg').length) { $(this).find('p').after(svg).after(svg).after(svg).after(svg).after(svg); } }) } } complexity_star(); function ajax_load_more(nextLink, classparent, classitem, pageNum) { $.ajax({ url: nextLink, type: "get", success: function(data) { var newElements = $(data).find(classparent); var elems = []; newElements.each(function(i) { elems.push(this); }); $(classitem).isotope('insert', elems); $(classitem).find('img').on('load', function() { wpc_add_img_bg('.s-img-switch'); }); if ($(classitem).find('.complexity').length) { complexity_star(); } nextLink = nextLink.replace(/\/page\/[0-9]?/, '/page/' + pageNum); } }); } /* Infinite scroll */ function load_infinite_scroll() { if (window.questroom_post) { // Load More Portfolio if (questroom_post.infinite_scroll) { var maxPages = parseInt(questroom_post.maxPages); // The link of the next page of posts. var nextLink = questroom_post.nextLink; var pageNum = parseInt(questroom_post.startPage) + 1; $(window).on('scroll', function() { if ($(document).height() - winH === $(window).scrollTop() && pageNum <= maxPages) { ajax_load_more(nextLink, '.posts-list-infinity .post-item-isotope', '.posts-list', pageNum); pageNum++; } }); } } } load_infinite_scroll(); /***********************************/ /* TABS */ /**********************************/ var $tabsHeader = $('.tabs-header'); if ($tabsHeader.length) { $tabsHeader.each(function() { var tab = $(this); tab.find('li').on('click', function() { var index_el = $(this).index(); tab.find('li').removeClass('active'); $(this).addClass('active'); $(this).closest('.tabs').find('.tabs-item').removeClass('active').eq(index_el).addClass('active'); }); }) } /***********************************/ /* FORM SUBSCRIBE STYLE */ /**********************************/ if ($('.wpcf7[role="form"]').length) { $('.wpcf7[role="form"] input[type="submit"]').each(function() { $(this).wrap('
'); }); } var $singlePost = $('.single-post form input[type="submit"]'); if ($singlePost.length) { $singlePost.each(function() { $(this).wrap('
'); }); } var $questRoomEmpty = $('#questroom-empty-result form input[type="submit"]') if ($questRoomEmpty.length) { $questRoomEmpty.each(function() { $(this).wrap('
'); }); } /***********************************/ /* FORM REQUIRED FIX FOR IOS */ /**********************************/ $('form').on('submit', function() { var required = $('[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.border = '1px solid 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. } if ($('[aria-required="true"]').length) { var required = $('[aria-required="true"]'); 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.border = '1px solid 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. } } }); /*==============================*/ /* 01 - Fullpage Slider */ /*==============================*/ var $jsScrollOn = $('.jsScrollOn'); if ($jsScrollOn.length) { /* Custom scrolling enabled */ $jsScrollOn.fullpage({ menu: '#menu', autoScrolling: true, // + lockAnchors: false, fitToSection: true, // + scrollBar: true, scrollingSpeed: 500, scrollOverflow: true, navigation: true, loopBottom: true, loopTop: true, fadingEffect: true, animateAnchor: true, afterRender: function() {}, afterSlideLoad: function() {} }); } /***********************************/ /* PAGINATION FOR FULLPAGE SLIDER */ /**********************************/ function counterPagination() { var $fpNav = $('#fp-nav'); if ($fpNav.length) { $fpNav.find('a').each(function(index) { if ((index + 1) < 10) { $(this).html('0' + (index + 1)); } else { $(this).html((index + 1)); } }); } } function paginationActive() { var num = $('#fp-nav').find('a.active').html(); $('.active-num').html(num); } $('#fp-nav').find('a').on('click', function() { setTimeout(paginationActive, 500); }); if ($('.jsScrollOn').length) { counterPagination(); paginationActive(); } // Load More Posts if (window.load_more_blog_post) { var pageNum = parseInt(load_more_blog_post.startPage) + 1; // The maximum number of pages the current query can return. var max = parseInt(load_more_blog_post.maxPage); // The link of the next page of posts. var nextLink = load_more_blog_post.nextLink; //button click $('.load-more').on('click', function(e) { var $btn = $(this).parent(); if (pageNum <= max) { ajax_load_more(nextLink, '.blog-index .blog-post-wrap', '.blog-index', pageNum); pageNum++; if (pageNum === (max + 1)) { $btn.hide('fast'); } } return false; }); } function padding_for_menu() { if ($('.multipage.no_vc').length) { var pad = $('.questroom-header').height(); $('body').css('padding-top', pad); } } /***********************************/ /* WINDOW SCROLL */ /**********************************/ $(window).on('scroll', function() { if ($('.jsScrollOn').length) { paginationActive(); } }); /***********************************/ /* WINDOW LOAD */ /**********************************/ $(window).on('load', function() { $('#loading').fadeOut(1000); initSwiper(); padding_for_menu(); // AOS.init({ // easing: 'ease-out-back', // animation: 1000 // }); var $googleMap = $('#google-map'); if ($googleMap.length) { $googleMap.each(function() { questroom_initialize_map(this); }); } }); /***********************************/ /* WINDOW RESIZE */ /**********************************/ $(window).on('resize', function() { initSwiper(); overflow(); sampleHeight(); padding_for_menu(); }); /***********************************/ /* WINDOW ORIENTATION CHANGE */ /**********************************/ $(window).on("orientationchange", function() { initSwiper(); overflow(); sampleHeight(); padding_for_menu(); }); window.questroom_initialize_map = function(_this) { var $googleMap = $('#google-map'); var latitude = $googleMap.attr("data-lat"), longitude = $googleMap.attr("data-lng"), map_zoom = parseInt($googleMap.attr("data-zoom"), 10); //google map custom marker icon var marker_url = $googleMap.attr("data-marker"); var style; var styleMap = $(_this).attr("data-style"); // default style map if (styleMap === 'style-1') { style = [{ "stylers": [{ "visibility": "simplified" }] }, { "stylers": [{ "color": "#131314" }] }, { "featureType": "water", "stylers": [{ "color": "#131313" }, { "lightness": 7 }] }, { "elementType": "labels.text.fill", "stylers": [{ "visibility": "on" }, { "lightness": 50 }] }]; } // custom style map if (typeof questroom_style_map !== 'undefined' && styleMap === 'custom') { style = questroom_style_map; } //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 }); }; })(jQuery, window, document);