(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.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: "_layout/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 = 991;
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() / 2 ) {
$("#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").fadeIn();
$("#custom-search-button").addClass('open');
} else {
$("#custom-search-form").fadeOut();
$("#custom-search-button").removeClass('open');
}
});
}
/* ==========================================================================
handleStickyHeader
========================================================================== */
var stickyHeader = false;
var stickypoint = 500;
if ($('body').hasClass('sticky-header')){
stickyHeader = true;
}
stickypoint = $("#header-top").outerHeight() + $("#header-wrap").outerHeight() + 150;
function handleStickyHeader() {
var b = document.documentElement,
e = false;
function f() {
window.addEventListener("scroll", function (h) {
if (!e) {
e = true;
setTimeout(d, 250);
}
}, false);
window.addEventListener("load", function (h) {
if (!e) {
e = true;
setTimeout(d, 250);
}
}, false);
}
function d() {
var h = c();
if (h >= stickypoint) {
$('#header').addClass("stuck");
} else {
$('#header').removeClass("stuck");
}
e = false;
}
function c() {
return window.pageYOffset || b.scrollTop;
}
f();
}
/* ==========================================================================
handleSmoothScrolling
========================================================================== */
function handleSmoothScrolling() {
$('#menu a[href*=#]:not([href=#]), .slider-revolution a[href*=#]:not([href=#]), .sfl-menu a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 700);
return false;
}
}
});
}
/* ==========================================================================
handleMenuFromLeft
========================================================================== */
function handleMenuFromLeft() {
$(document).on('click', '.menu-collaps', function(event){
var navigation = $('.nav'),
$this = $(this);
event.preventDefault();
navigation.toggleClass('nav-open');
$this.hide();
$('#logo').addClass("hidden");
$('.sfl-menu').append('');
});
$(document).on('click', '.close-menu', function(event){
var $this = $(this),
$collaps = $('.menu-collaps');
event.preventDefault();
$this.closest('.nav').toggleClass('nav-open');
$('#logo').removeClass("hidden");
$collaps.show();
});
}
/* ==========================================================================
handleBlockInstagramLink
========================================================================== */
function handleBlockInstagramLink() {
$(".snapwidget-widget").contents().find("a").click(function(e) {
return false;
});
}
/* ==========================================================================
When document is ready, do
========================================================================== */
$(document).ready(function() {
ieViewportFix();
setDimensionsPieCharts();
animatePieCharts();
animateMilestones();
animateProgressBars();
if (!isTouchDevice()) {
enableParallax();
}
handleContactForm();
handleMobileMenu();
showHideMobileMenu();
handleAccordionsAndToogles();
handleBackToTop();
showHidebackToTop();
handleVideoBackground();
handleSearch();
if(stickyHeader && ($(window).width() > 1024)){
handleStickyHeader();
}
handleMenuFromLeft();
handleSmoothScrolling();
handleBlockInstagramLink();
});
/* ==========================================================================
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();
}
});
})(window.jQuery);
// non jQuery scripts below