(function($) { "use strict"; /* ========================================================================== ieViewportFix - fixes viewport problem in IE 10 SnapMode and IE Mobile 10 ========================================================================== */ function ieViewportFix() { var msViewportStyle = document.createElement("style"); msViewportStyle.appendChild( document.createTextNode( "@-ms-viewport { width: device-width; }" ) ); if (navigator.userAgent.match(/IEMobile\/10\.0/)) { msViewportStyle.appendChild( document.createTextNode( "@-ms-viewport { width: auto !important; }" ) ); } document.getElementsByTagName("head")[0]. appendChild(msViewportStyle); } /* ========================================================================== exists - Check if an element exists ========================================================================== */ function exists(e) { return $(e).length > 0; } /* ========================================================================== isTouchDevice - return true if it is a touch device ========================================================================== */ function isTouchDevice() { return !!('ontouchstart' in window) || ( !! ('onmsgesturechange' in window) && !! window.navigator.maxTouchPoints); } /* ========================================================================== setDimensionsPieCharts ========================================================================== */ function setDimensionsPieCharts() { $('.pie-chart').each(function() { var $t = $(this), n = $t.parent().width(), r = $t.attr("data-barSize"); if (n < r) { r = n; } $t.css("height", r); $t.css("width", r); $t.css("line-height", r + "px"); $t.find("i").css({ "line-height": r + "px", "font-size": r / 3 }); }); } /* ========================================================================== animatePieCharts ========================================================================== */ function animatePieCharts() { if(typeof $.fn.easyPieChart !== 'undefined'){ $('.pie-chart:in-viewport').each(function() { var $t = $(this), n = $t.parent().width(), r = $t.attr("data-barSize"), l = "square"; if ($t.attr("data-lineCap") !== undefined) { l = $t.attr("data-lineCap"); } if (n < r) { r = n; } $t.easyPieChart({ animate: 1300, lineCap: l, lineWidth: $t.attr("data-lineWidth"), size: r, barColor: $t.attr("data-barColor"), trackColor: $t.attr("data-trackColor"), scaleColor: "transparent", onStep: function(from, to, percent) { $(this.el).find('.pie-chart-percent span').text(Math.round(percent)); } }); }); } } /* ========================================================================== animateMilestones ========================================================================== */ function animateMilestones() { $('.milestone:in-viewport').each(function() { var $t = $(this), n = $t.find(".milestone-value").attr("data-stop"), r = parseInt($t.find(".milestone-value").attr("data-speed"), 10); if (!$t.hasClass("already-animated")) { $t.addClass("already-animated"); $({ countNum: $t.find(".milestone-value").text() }).animate({ countNum: n }, { duration: r, easing: "linear", step: function() { $t.find(".milestone-value").text(Math.floor(this.countNum)); }, complete: function() { $t.find(".milestone-value").text(this.countNum); } }); } }); } /* ========================================================================== animateProgressBars ========================================================================== */ function animateProgressBars() { $('.progress-bar .progress-bar-outer:in-viewport').each(function() { var $t = $(this); if ($t.attr("data-progress-bar-outer-color") !== undefined) { $t.css("background-color", $t.attr("data-progress-bar-outer-color")); } if (!$t.hasClass("already-animated")) { $t.addClass("already-animated"); $t.animate({ width: $t.attr("data-width") + "%" }, 2000); } }); } /* ========================================================================== enableParallax ========================================================================== */ function enableParallax() { // vertical parallax if(typeof $.fn.parallax !== 'undefined'){ $('.parallax').each(function() { var $t = $(this); $t.addClass("parallax-enabled"); $t.parallax("49%", 0.3, false); }); } // horizontal parallax if(typeof $.fn.hparallax !== 'undefined'){ $('.horizontal-parallax').each(function() { var $t = $(this); $t.addClass("horizontal-parallax-enabled"); $t.hparallax(); }); } //animated parallax if(typeof $.fn.animatedparallax !== 'undefined'){ $('.animated-parallax').each(function() { var $t = $(this); $t.addClass("animated-parallax-enabled"); $t.animatedparallax(); }); } } /* ========================================================================== handleContactForm - validate and ajax submit contat form ========================================================================== */ function handleContactForm() { if(typeof $.fn.validate !== 'undefined'){ $('#contact-form').validate({ errorClass: 'validation-error', // so that it doesn't conflict with the error class of alert boxes rules: { name: { required: true }, email: { required: true, email: true }, subject: { required: true }, message: { required: true } }, messages: { name: { required: "Field is required!" }, email: { required: "Field is required!", email: "Please enter a valid email address" }, subject: { required: "Field is required!" }, message: { required: "Field is required!" } }, submitHandler: function(form) { var result; $(form).ajaxSubmit({ type: "POST", data: $(form).serialize(), url: "assets/php/send.php", success: function(msg) { if (msg === 'OK') { result = '
The message has been sent!
'; $('#contact-form').clearForm(); } else { result = '
' + msg + '
'; } $("#formstatus").html(result); }, error: function() { result = '
There was an error sending the message!
'; $("#formstatus").html(result); } }); } }); } } /* ========================================================================== handleMobileMenu ========================================================================== */ var MOBILEBREAKPOINT = 1250; function handleMobileMenu() { if ($(window).width() > MOBILEBREAKPOINT) { $("#mobile-menu").hide(); $("#mobile-menu-trigger").removeClass("mobile-menu-opened").addClass("mobile-menu-closed"); } else { if (!exists("#mobile-menu")) { $("#menu").clone().attr({ id: "mobile-menu", "class": "fixed" }).insertAfter("#header"); $("#mobile-menu > li > a, #mobile-menu > li > ul > li > a").each(function() { var $t = $(this); if ($t.next().hasClass('sub-menu') || $t.next().is('ul') || $t.next().is('.sf-mega')) { $t.append(''); } }); $(".mobile-menu-submenu-arrow").click(function(event) { var $t = $(this); if ($t.hasClass("mobile-menu-submenu-closed")) { $t.parent().siblings("ul").slideDown(300); $t.parent().siblings(".sf-mega").slideDown(300); $t.removeClass("mobile-menu-submenu-closed fa-angle-down").addClass("mobile-menu-submenu-opened fa-angle-up"); } else { $t.parent().siblings("ul").slideUp(300); $t.parent().siblings(".sf-mega").slideUp(300); $t.removeClass("mobile-menu-submenu-opened fa-angle-up").addClass("mobile-menu-submenu-closed fa-angle-down"); } event.preventDefault(); }); $("#mobile-menu li, #mobile-menu li a, #mobile-menu ul").attr("style", ""); } } } /* ========================================================================== showHideMobileMenu ========================================================================== */ function showHideMobileMenu() { $("#mobile-menu-trigger").click(function(event) { var $t = $(this), $n = $("#mobile-menu"); if ($t.hasClass("mobile-menu-opened")) { $t.removeClass("mobile-menu-opened").addClass("mobile-menu-closed"); $n.slideUp(300); } else { $t.removeClass("mobile-menu-closed").addClass("mobile-menu-opened"); $n.slideDown(300); } event.preventDefault(); }); } /* ========================================================================== handleAccordionsAndToogles ========================================================================== */ function handleAccordionsAndToogles() { // accordion $(".accordion .accordion-item").click(function(e) { e.preventDefault(); if($(this).next("div").is(":visible")){ $(this).removeClass('active').next("div").slideUp("slow"); } else { $('.accordion .accordion-item').removeClass('active'); $(".accordion .accordion-item-content").slideUp("slow"); $(this).addClass('active').next("div").slideToggle("slow"); } }); $(".accordion .accordion-item:eq(0)").trigger('click').addClass('active'); // toggle $(".toggle .toggle-item").click(function(e) { e.preventDefault(); $(this).toggleClass('active').next("div").slideToggle("slow"); }); $(".toggle .toggle-item:eq(0)").trigger('click').addClass('active'); } /* ========================================================================== handleBackToTop ========================================================================== */ function handleBackToTop() { $('#back-to-top').click(function(){ $('html, body').animate({scrollTop:0}, 'slow'); return false; }); } /* ========================================================================== showHidebackToTop ========================================================================== */ function showHidebackToTop() { if ($(window).scrollTop() > $(window).height() / 4 ) { $("#back-to-top").removeClass('gone'); $("#back-to-top").addClass('visible'); } else { $("#back-to-top").removeClass('visible'); $("#back-to-top").addClass('gone'); } } /* ========================================================================== handleVideoBackground ========================================================================== */ var min_w = 0, video_width_original = 1920, video_height_original = 1080, vid_ratio = 1920/1080; function handleVideoBackground() { $('.fullwidth-section .fullwidth-section-video').each(function(i){ var $sectionWidth = $(this).closest('.fullwidth-section').outerWidth(), $sectionHeight = $(this).closest('.fullwidth-section').outerHeight(); $(this).width($sectionWidth); $(this).height($sectionHeight); // calculate scale ratio var scale_h = $sectionWidth / video_width_original, scale_v = $sectionHeight / video_height_original, scale = scale_h > scale_v ? scale_h : scale_v; // limit minimum width min_w = vid_ratio * ($sectionHeight+20); if (scale * video_width_original < min_w) {scale = min_w / video_width_original;} $(this).find('video').width(Math.ceil(scale * video_width_original +2)); $(this).find('video').height(Math.ceil(scale * video_height_original +2)); }); } /* ========================================================================== handleSearch ========================================================================== */ function handleSearch() { $("#custom-search-button").click(function(e) { e.preventDefault(); if(!$("#custom-search-button").hasClass('open')) { $("#custom-search-form-container").fadeIn(200); } else { $("#custom-search-form-container").fadeOut(200); } }); $('#custom-search-form').append('x'); $('#custom-search-form-container a.custom-search-form-close').click(function(event){ event.preventDefault(); $('#custom-search-form-container').fadeOut(200); }); } /* ========================================================================== handleStickyHeader ========================================================================== */ var stickyHeader = false; var stickypoint = 1; if ($('body').hasClass('sticky-header')){ stickyHeader = true; } function handleStickyHeader() { var b = document.documentElement, e = false; function f() { window.addEventListener("scroll", function (h) { if (!e) { e = true; setTimeout(d, 0); } }, false); window.addEventListener("load", function (h) { if (!e) { e = true; setTimeout(d, 0); } }, false); } function d() { var h = c(); if (h >= stickypoint) { $('#header-old').addClass("stuck"); } else { $('#header-old').removeClass("stuck"); } e = false; } function c() { return window.pageYOffset || b.scrollTop; } f(); } /* ========================================================================== handleFullScreen ========================================================================== */ function handleFullScreen() { var x = $(window).height(); $('.fullscreen').css("height", x + "px"); } /* ========================================================================== When document is ready, do ========================================================================== */ $(document).ready(function() { // twitterFetcher // http://jasonmayes.com/projects/twitterApi/ if(typeof twitterFetcher !== 'undefined' && ($('.ewf_widget_latest_tweets').length > 0)) { $('.ewf_widget_latest_tweets').each(function(index){ var account_id = $('.ewf-tweet-list', this).attr('data-account-id'), items = $('.ewf-tweet-list', this).attr('data-items'), newID = 'ewf-tweet-list-' + index; $('.ewf-tweet-list', this).attr('id', newID); var config = { "id": account_id, "domId": newID, "maxTweets": items, "showRetweet": false, "showTime": false, "showUser": false }; twitterFetcher.fetch(config); }); } // Youtube video background // https://github.com/pupunzi/jquery.mb.YTPlayer if(typeof $.fn.mb_YTPlayer !== 'undefined'){ $('.player').mb_YTPlayer(); } // simplePlaceholder - polyfill for mimicking the HTML5 placeholder attribute using jQuery // https://github.com/marcgg/Simple-Placeholder/blob/master/README.md if(typeof $.fn.simplePlaceholder !== 'undefined'){ $('input[placeholder], textarea[placeholder]').simplePlaceholder(); } // Fitvids - fluid width video embeds // https://github.com/davatron5000/FitVids.js/blob/master/README.md if(typeof $.fn.fitVids !== 'undefined'){ $('.fitvids,.responsive-embed').fitVids(); } // Superfish - enhance pure CSS drop-down menus // http://users.tpg.com.au/j_birch/plugins/superfish/options/ if(typeof $.fn.superfish !== 'undefined'){ $('#menu').superfish({ delay: 500, animation: {opacity:'show',height:'show'}, speed: 100, cssArrows: true }); } // Throbber loading plugin var throbberContainer = document.getElementsByClassName('throbber-container'), throbber = Throbber({ color: "#000", size: 100, fade: 200 }), $fullWidthBanner = $('.fullwidthbanner'); if(throbberContainer.length) { throbber.appendTo(throbberContainer[0]).start(); } // Revolution Slider if(typeof $.fn.revolution !== 'undefined'){ $('.fullwidthbanner').revolution({ delay:9000, startwidth:1170, startWithSlide:0, fullScreenAlignForce:"off", autoHeight:"off", minHeight:"off", shuffle:"off", onHoverStop:"on", thumbWidth:100, thumbHeight:50, thumbAmount:3, hideThumbsOnMobile:"off", hideNavDelayOnMobile:1500, hideBulletsOnMobile:"off", hideArrowsOnMobile:"off", hideThumbsUnderResoluition:0, hideThumbs:0, hideTimerBar:"off", keyboardNavigation:"on", navigationType:"bullet", navigationArrows:"solo", navigationStyle:"round", navigationHAlign:"center", navigationVAlign:"bottom", navigationHOffset:0, navigationVOffset:50, soloArrowLeftHalign:"left", soloArrowLeftValign:"center", soloArrowLeftHOffset:50, soloArrowLeftVOffset:0, soloArrowRightHalign:"right", soloArrowRightValign:"center", soloArrowRightHOffset:50, soloArrowRightVOffset:0, touchenabled:"off", swipe_velocity:"0.7", swipe_max_touches:"1", swipe_min_touches:"1", drag_block_vertical:"false", parallax:"mouse", parallaxBgFreeze:"on", parallaxLevels:[10,7,4,3,2,5,4,3,2,1], parallaxDisableOnMobile:"off", stopAtSlide:-1, stopAfterLoops:-1, hideCaptionAtLimit:0, hideAllCaptionAtLilmit:0, hideSliderAtLimit:0, dottedOverlay:"none", spinned:"spinner4", fullWidth:"off", forceFullWidth:"off", fullScreen:"on", fullScreenOffsetContainer:"#topheader-to-offset", fullScreenOffset:"0px", panZoomDisableOnMobile:"off", simplifyAll:"off", shadow:0 }); if($fullWidthBanner.length){ $fullWidthBanner.bind("revolution.slide.onloaded",function (e) { throbber.stop(); $fullWidthBanner.css('visibility', 'visible'); }); } } // bxSlider - responsive slider // http://bxslider.com/options if(typeof $.fn.bxSlider !== 'undefined'){ $('.images-slider .slides').bxSlider({ mode: 'fade', // Type of transition between slides: 'horizontal', 'vertical', 'fade' speed: 500, // Slide transition duration (in ms) infiniteLoop: true, // If true, clicking "Next" while on the last slide will transition to the first slide and vice-versa. hideControlOnEnd: false, // If true, "Next" control will be hidden on last slide and vice-versa. Only used when infiniteLoop: false pager: false, // If true, a pager will be added pagerType: 'full', // If 'full', a pager link will be generated for each slide. If 'short', a x / y pager will be used (ex. 1/5) controls: true, // If true, "Next" / "Prev" controls will be added auto: true, // If true, slides will automatically transition pause: 4000, // The amount of time (in ms) between each auto transition autoHover: true, // Auto show will pause when mouse hovers over slider useCSS: false // If true, CSS transitions will be used for animations. False, jQuery animations. Setting to false fixes problem with jQuery 2.1.0 and mode:horizontal }); $('.images-slider-2 .slides').bxSlider({ mode: 'fade', // Type of transition between slides: 'horizontal', 'vertical', 'fade' speed: 500, // Slide transition duration (in ms) infiniteLoop: true, // If true, clicking "Next" while on the last slide will transition to the first slide and vice-versa. hideControlOnEnd: false, // If true, "Next" control will be hidden on last slide and vice-versa. Only used when infiniteLoop: false pager: true, // If true, a pager will be added pagerType: 'full', // If 'full', a pager link will be generated for each slide. If 'short', a x / y pager will be used (ex. 1/5) controls: false, // If true, "Next" / "Prev" controls will be added auto: true, // If true, slides will automatically transition pause: 4000, // The amount of time (in ms) between each auto transition autoHover: true, // Auto show will pause when mouse hovers over slider useCSS: false, // If true, CSS transitions will be used for animations. False, jQuery animations. Setting to false fixes problem with jQuery 2.1.0 and mode:horizontal pagerCustom: '#images-slider-2-pager' }); $('.testimonial-slider .slides').bxSlider({ mode: 'fade', // Type of transition between slides: 'horizontal', 'vertical', 'fade' speed: 500, // Slide transition duration (in ms) infiniteLoop: true, // If true, clicking "Next" while on the last slide will transition to the first slide and vice-versa. hideControlOnEnd: false, // If true, "Next" control will be hidden on last slide and vice-versa. Only used when infiniteLoop: false pager: true, // If true, a pager will be added pagerType: 'full', // If 'full', a pager link will be generated for each slide. If 'short', a x / y pager will be used (ex. 1/5) controls: true, // If true, "Next" / "Prev" controls will be added auto: true, // If true, slides will automatically transition pause: 4000, // The amount of time (in ms) between each auto transition autoHover: true, // Auto show will pause when mouse hovers over slider useCSS: false // If true, CSS transitions will be used for animations. False, jQuery animations. Setting to false fixes problem with jQuery 2.1.0 and mode:horizontal }); $('.clients-slider .slides').bxSlider({ mode: 'horizontal', // Type of transition between slides: 'horizontal', 'vertical', 'fade' speed: 30000, // Slide transition duration (in ms) infiniteLoop: true, // If true, clicking "Next" while on the last slide will transition to the first slide and vice-versa. hideControlOnEnd: false, // If true, "Next" control will be hidden on last slide and vice-versa. Only used when infiniteLoop: false pager: true, // If true, a pager will be added pagerType: 'full', // If 'full', a pager link will be generated for each slide. If 'short', a x / y pager will be used (ex. 1/5) controls: true, // If true, "Next" / "Prev" controls will be added auto: true, // If true, slides will automatically transition pause: 4000, // The amount of time (in ms) between each auto transition autoHover: true, // Auto show will pause when mouse hovers over slider useCSS: false, // If true, CSS transitions will be used for animations. False, jQuery animations. Setting to false fixes problem with jQuery 2.1.0 and mode:horizontal minSlides: 2, maxSlides: 5, slideWidth: 230, slideMargin: 10, ticker: true }); $('.features-slider .slides').bxSlider({ mode: 'horizontal', // Type of transition between slides: 'horizontal', 'vertical', 'fade' speed: 500, // Slide transition duration (in ms) infiniteLoop: true, // If true, clicking "Next" while on the last slide will transition to the first slide and vice-versa. hideControlOnEnd: false, // If true, "Next" control will be hidden on last slide and vice-versa. Only used when infiniteLoop: false pager: true, // If true, a pager will be added pagerType: 'full', // If 'full', a pager link will be generated for each slide. If 'short', a x / y pager will be used (ex. 1/5) controls: true, // If true, "Next" / "Prev" controls will be added auto: true, // If true, slides will automatically transition pause: 4000, // The amount of time (in ms) between each auto transition autoHover: true, // Auto show will pause when mouse hovers over slider useCSS: false, // If true, CSS transitions will be used for animations. False, jQuery animations. Setting to false fixes problem with jQuery 2.1.0 and mode:horizontal minSlides: 2, maxSlides: 4, slideWidth: 230, moveSlides: 1, slideMargin: 30 }); } // Magnific PopUp - responsive lightbox // http://dimsemenov.com/plugins/magnific-popup/documentation.html if(typeof $.fn.magnificPopup !== 'undefined'){ $('.magnificPopup').magnificPopup({ disableOn: 400, closeOnContentClick: true, type: 'image' }); $('.magnificPopup-gallery').magnificPopup({ disableOn: 400, type: 'image', gallery: { enabled: true } }); } // EasyTabs - tabs plugin // https://github.com/JangoSteve/jQuery-EasyTabs/blob/master/README.markdown if(typeof $.fn.easytabs !== 'undefined'){ $('.tabs-container').easytabs({ animationSpeed: 300, updateHash: false }); $('.vertical-tabs-container').easytabs({ animationSpeed: 300, updateHash: false }); } // gMap - embed Google Maps into your website; uses Google Maps v3 // http://labs.mario.ec/jquery-gmap/ if(typeof $.fn.gMap !== 'undefined'){ //handleGoogleMapHeight(); $('.google-map').each(function() { var $t = $(this), mapZoom = 15, mapAddress = $t.attr("data-address"), mapCaption = $t.attr("data-caption"), mapType = "ROADMAP", mapHeight = $t.attr("data-mapheight"), popUp = false; if ($t.attr("data-zoom") !== undefined) { mapZoom = parseInt($t.attr("data-zoom"),10); } if ($t.attr("data-mapHeight") !== undefined) { $t.css( "height", mapHeight+'px'); } if ($t.attr("data-maptype") !== undefined) { mapType = $t.attr("data-maptype"); } if ($t.attr("data-popup") !== undefined) { popUp = $t.data("popup"); } $t.gMap({ maptype: mapType, scrollwheel: false, zoom: mapZoom, markers: [{ address: mapAddress, html: mapCaption, popup: popUp }], controls: { panControl: true, zoomControl: true, mapTypeControl: true, scaleControl: false, streetViewControl: false, overviewMapControl: false } }); }); } // Isotope - portfolio filtering // http://isotope.metafizzy.co/beta/ if ((typeof $.fn.isotope !== 'undefined') && (typeof $.fn.imagesLoaded !== 'undefined') && ($('.portfolio-isotope').length > 0)) { // initialize isotope after images are loaded $('.portfolio-isotope').imagesLoaded( function() { var container = $('.portfolio-isotope'); container.isotope({ itemSelector: '.item', layoutMode: 'masonry', transitionDuration: '0.5s' }); $('.portfolio-filter li a').click(function () { $('.portfolio-filter li a').removeClass('active'); $(this).addClass('active'); var selector = $(this).attr('data-filter'); container.isotope({ filter: selector }); return false; }); $(window).resize(function () { container.isotope({ }); }); }); // Load More var portfolio_track_click = 0, portfolio_offset = 0, portfolio_items_loaded = 4; $('.load-more').click(function(event) { event.preventDefault(); $.ajax({ type: "POST", url: $(this).attr("data-file"), dataType: "html", cache: false, msg : '', success: function(data){ var items = $(data).filter('.item'), length = items.length, html = ''; if( length > 0 ){ if( portfolio_offset !== length ){ for( var i = 0; portfolio_offset < length && i < portfolio_items_loaded; portfolio_offset++, i++ ){ html += items.eq( portfolio_offset ).prop('outerHTML'); } $('.portfolio-isotope').append(html); $('.portfolio-isotope').imagesLoaded( function() { $(window).trigger( 'resize' ); $('.portfolio-isotope').isotope('reloadItems').isotope(); }); if( length <= portfolio_items_loaded || portfolio_offset === length ){ $('.load-more').text('No more Posts to show').css({"cursor":"default"}); } $('.magnificPopup-gallery').magnificPopup({ disableOn: 400, type: 'image', gallery: { enabled: true } }); } else { $('.load-more').text('No more Posts to show').css({"cursor":"default"}); } } else { $('.load-more').text('No more Posts to show').css({"cursor":"default"}); } } }); }); // } // ieViewportFix(); setDimensionsPieCharts(); animatePieCharts(); animateMilestones(); animateProgressBars(); if (!isTouchDevice()) { enableParallax(); } handleContactForm(); handleMobileMenu(); showHideMobileMenu(); handleAccordionsAndToogles(); handleBackToTop(); showHidebackToTop(); handleVideoBackground(); handleSearch(); if(stickyHeader && ($(window).width() > 1024)){ handleStickyHeader(); } handleFullScreen(); }); /* ========================================================================== When the window is scrolled, do ========================================================================== */ $(window).scroll(function() { animateMilestones(); animatePieCharts(); animateProgressBars(); showHidebackToTop(); if(stickyHeader && ($(window).width() > 1024)){ handleStickyHeader(); } }); /* ========================================================================== When the window is resized, do ========================================================================== */ $(window).resize(function() { handleMobileMenu(); handleVideoBackground(); if(stickyHeader && ($(window).width() > 1024)){ handleStickyHeader(); } handleFullScreen(); }); })(window.jQuery); // non jQuery scripts below