"use strict"; var $ = jQuery; //Form Stylization function formStylization(){ var radio = 'input[type="radio"]', checkbox = 'input[type="checkbox"]'; $(radio).wrap('
').closest('.new-radio').append(''); $(checkbox).wrap('
').closest('.new-checkbox').append(''); $(checkbox + ':checked').parent('.new-checkbox').addClass('checked'); $(radio + ':checked').parent('.new-radio').addClass('checked'); $(checkbox + ':disabled').closest('.checkbox').addClass('disabled'); $(radio + ':disabled').closest('.radio').addClass('disabled'); $('body').on('click', function(){ $(radio).parent('.new-radio').removeClass('checked'); $(radio + ':checked').parent('.new-radio').addClass('checked'); $(checkbox).parent('.new-checkbox').removeClass('checked'); $(checkbox + ':checked').parent('.new-checkbox').addClass('checked'); $(radio).closest('.radio').removeClass('disabled'); $(checkbox).closest('.checkbox').removeClass('disabled'); $(radio + ':disabled').closest('.radio').addClass('disabled'); $(checkbox + ':disabled').closest('.checkbox').addClass('disabled'); }); if($.fn.selectpicker){ $('select:not(".without-styles")').selectpicker(); } } //Main Menu function mainMenu(){ var menu = $('#main-menu'), link = $('#main-menu a, .go-section'), url = window.location.href, hash = url.substring(url.indexOf('#')), homeId = 'home'; link.on('click', function(e){ var $this = $(this), id = $this.attr('href').split('#').pop(), duration = 1; e.preventDefault(); if (!$('#' + id).length) { console.log('No such section!'); return false; } link.removeClass('active'); animateFinish(); $('.section.active [data-out-animation]').each(function(){ var $this = $(this); if ($this.data('outAnimationDelay')){ if ($this.data('outAnimationDelay') >= duration) { duration = $this.data('outAnimationDelay'); } } }); if (!$this.hasClass('open')) { link.removeClass('open'); menu.find('[href="#'+ id +'"]').addClass('active').addClass('open'); $('body').find('.preloader').delay(duration + 500).fadeIn(400, function() { $('.section').removeClass('active'); $('#' + id).addClass('active'); $(this).fadeOut(400); setTimeout(function(){ contentScroll(); animateStart(); }, 0); document.location.hash = '#' + id; }); } else { $('body').find('.preloader').delay(duration + 500).fadeIn(400, function() { link.removeClass('open'); $('.section').removeClass('active'); $('#' + homeId).addClass('active'); $(this).fadeOut(400); setTimeout(function(){ contentScroll(); animateStart(); }, 0); document.location.hash = '#' + homeId; }); } }); if (hash != '#') $('[href="'+ hash +'"]').trigger('click'); } //Animate Start function animateStart(){ var activeSection = $('.section.active'); $('[data-animation]').each(function(){ var $this = $(this), animation = 'fadeIn', delay = 1; if ($this.data('animation')){ animation = $this.data('animation'); } if ($this.data('animationDelay')){ delay = $this.data('animationDelay'); } if ($this.closest('.section').hasClass('active')){ $this.css('animation-delay', delay + 'ms').addClass('animated').addClass(animation); } }); } //Animate Finish function animateFinish(){ var activeSection = $('.section.active'), duration = 1; $('[data-out-animation]').each(function(){ var $this = $(this), animation = 'fadeIn', outAnimation = 'fadeOut', delay = 1, outDelay = 1; if ($this.data('animation')){ animation = $this.data('animation'); } if ($this.data('outAnimation')){ outAnimation = $this.data('outAnimation'); } if ($this.data('animationDelay')){ delay = $this.data('animationDelay'); } if ($this.data('outAnimationDelay')){ outDelay = $this.data('outAnimationDelay'); } $this.css('animation-delay', delay + 'ms'); if ($this.closest('.carousel')) { var carousel = $this.closest('.carousel'), carouselAnimate = 'zoomIn'; if (carousel.data('carouselAnimation')){ carouselAnimate = carousel.data('carouselAnimation'); } $this.removeClass(carouselAnimate); } if ($this.closest('.section').hasClass('active')){ if (outDelay >= duration) { duration = outDelay; } $this.removeClass(animation).addClass(outAnimation); if ($this.data('outAnimationDelay')){ $this.css('animation-delay', outDelay + 'ms'); } else { $this.css('animation-delay', '1ms'); } } else { $this.removeClass(animation).removeClass(outAnimation).removeAttr('style', 'animation-delay'); } }); } //Carousels function carousels(){ var carouselBox = $('.carousel-box'); carouselBox.each(function(){ var thisBox = $(this), carousel = $(this).find('.carousel'), animation = 'zoomIn', animationOut = 'zoomOut', items = {0 : {items : 1}, 768 : { items : 3}}; if (thisBox.data('carouselAnimation')){ animation = thisBox.data('carouselAnimation'); } if (thisBox.data('carouselOutAnimation')){ animationOut = thisBox.data('carouselOutAnimation'); } carousel.owlCarousel({ loop : true, margin : 20, pullDrag : false, responsiveClass : true, responsive : items, mouseDrag : false, touchDrag : false, navRewind : false, dots : false }).touchwipe({ wipeLeft: function(){ thisBox.find('.carousel-controls .next').trigger('click'); }, wipeRight: function(){ thisBox.find('.carousel-controls .prev').trigger('click'); }, preventDefaultEvents: false }); carousel.closest('.carousel-box').on('click', '.nav-item', function(e){ var item = carousel.find('.owl-item .item'); e.preventDefault(); item.css('animation-delay', '1ms'); item.each(function(){ var $this = $(this); if ($this.data('animation')){ $this.removeClass($this.data('animation')); } $this.addClass(animationOut); }); var event = 'next'; if ($(this).hasClass('prev')) { event = 'prev'; } setTimeout(function(){ carousel.trigger(event + '.owl.carousel'); }, 400); setTimeout(function(){ item.removeClass(animationOut).addClass(animation); }, 800); }); }); } //Google Map function initialize(){ var mapCanvas = $('.map-canvas'); mapCanvas.each(function (){ var $this = $(this), zoom = 8, lat = -34, lng = 150, scrollwheel = false, draggable = true, mapType = google.maps.MapTypeId.ROADMAP, title = '', contentString = ''; if ($this.data('zoom')){ zoom = parseFloat($this.data('zoom')); } if ($this.data('lat')){ lat = parseFloat($this.data('lat')); } if ($this.data('lng')){ lng = parseFloat($this.data('lng')); } if ($this.data('scrollwheel')){ scrollwheel = $this.data('scrollwheel'); } if ($this.data('type')){ if ($this.data('type') == 'satellite'){ mapType = google.maps.MapTypeId.SATELLITE; } else if ($this.data('type') == 'hybrid'){ mapType = google.maps.MapTypeId.HYBRID; } else if ($this.data('type') == 'terrain'){ mapType = google.maps.MapTypeId.TERRAIN; } } if ($this.data('title')){ title = $this.data('title'); } if( navigator.userAgent.match(/iPad|iPhone|Android/i) ){ draggable = false; } var mapOptions = { zoom : zoom, scrollwheel : scrollwheel, draggable : draggable, center : new google.maps.LatLng(lat, lng), mapTypeId : mapType, streetViewControl : false }; var map = new google.maps.Map($this[0], mapOptions); var is_internetExplorer11= navigator.userAgent.toLowerCase().indexOf('trident') > -1; var image = ( is_internetExplorer11 ) ? 'img/map-marker.png' : 'img/svg/map-marker.svg'; if ($this.data('content')){ contentString = '
' + '

' + title + '

' + $this.data('content') + '
'; } var infowindow = new google.maps.InfoWindow({ content: contentString }); var marker = new google.maps.Marker({ position : new google.maps.LatLng(lat, lng), map : map, icon : image, title : title }); if ($this.data('content')){ google.maps.event.addListener(marker, 'click', function(){ infowindow.open(map,marker); }); } }); } // Load google maps script function loadScript(){ var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' + 'callback=initialize'; document.body.appendChild(script); } window.onload = loadScript; //Map function mapBox(){ $('.map-show').on('click', function(e){ var id = $(this).attr('href'); e.preventDefault(); $(id).addClass('active animated zoomIn'); }); $('.map-box .close').on('click', function(e){ var mapBox = $(this).closest('.map-box'); e.preventDefault(); mapBox.removeClass('zoomIn').addClass('zoomOut'); setTimeout(function() { mapBox.removeClass('active').removeClass('zoomOut'); }, 500); }); } //HTML5 Video Background function videoBg(){ var $this = $('.background-video'); if ($this.find('video').length){ var video = $this.find('video'); if (video.width() == $this.width()){ video.css({ marginLeft : 0, marginTop : -((video.height() - $this.height()) / 2) }); } else { video.css({ marginTop : 0, marginLeft : -((video.width() - $this.width()) / 2) }); } } } //YouTube Video Background function youtubeVideoBg(){ var $this = $('.background-video'); if (($this.data('video')) && ($.fn.tubular)){ if ($this.find('video').length){ $this.find('video').remove(); } if (!$this.find('.tubular-container').length) { var videoId = ''; if ($this.data('video')) { videoId = $this.data('video'); } $this.tubular({ videoId : videoId, container : $this }); } } } //Slider Background function backgroundSlider() { var slider = $('.background-slider'); if (slider.length) { var autoplayTimeout = 2000, animateIn = 'fadeIn', animateOut = 'fadeOut'; if (slider.data('animateIn')) { animateIn = slider.data('animateIn'); } if (slider.data('animateOut')) { animateOut = slider.data('animateOut'); } if (slider.data('timeout')) { autoplayTimeout = slider.data('timeout'); } slider.owlCarousel({ animateIn : animateIn, animateOut : animateOut, items : 1, loop : true, autoplay : true, autoplayTimeout : autoplayTimeout }); } } //Send Email function sendEmail(){ $('.send-email').on('click', function(e){ var $this = $(this); e.preventDefault(); $.ajax({ url : 'php/u-c.php', type : 'POST', data : $this.closest('.under-construction').serialize(), success : function(data){ if ($(data).is('.send-true')){ $this.addClass('loading').delay(650).queue(function(){ $this.addClass('success').addClass('loaded').dequeue(); }); } else { $this.addClass('error'); } $this.delay(500).queue(function(){ $this.removeClass('loaded').removeClass('loading').dequeue(); }); $this.delay(400).queue(function(){ if ($(data).is('.send-true')){ $this.removeClass('success').closest('.under-construction').trigger('reset'); } else { $this.removeClass('error'); } $this.dequeue(); }); } }); return false; }); } //Contact Form function contactForm(){ $('.btn-submit').on('click',function(e){ var $this = $(this); e.preventDefault(); $.ajax({ url : 'php/contact.php', type : 'POST', data : $this.closest('.contact-form').serialize(), success : function(data){ if ($(data).is('.send-true')){ $this.addClass('loading').delay(650).queue(function(){ $this.addClass('success').addClass('loaded').dequeue(); }); } else { $this.addClass('error'); } $this.delay(500).queue(function(){ $this.removeClass('loaded').removeClass('loading').dequeue(); }); $this.delay(400).queue(function(){ if ($(data).is('.send-true')){ $this.removeClass('success').closest('.contact-form').trigger('reset'); } else { $this.removeClass('error'); } $this.dequeue(); }); } }); }); } //Content Scroll function contentScroll(){ var section = $('.section.active'); if (section.length && $.fn.mCustomScrollbar) { section.each(function (){ var $this = $(this); if (($this.height() - 40) < $this.find('.container').height()) { $this.addClass('scroll-content'); if(!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|Windows Phone)/)){ $this.find('.section-content').mCustomScrollbar({ scrollInertia : 100 }); } } else { $this.removeClass('scroll-content'); } }); } } //Notify My function notifyMy(){ var margin = 70; if (($('body').height() < 600) || ($('body').width() < 768)) { margin = 0; } $('.notify-my .modal-dialog').css('margin-top', (($('body').height() - $('.notify-my .modal-dialog').height()) / 2) - margin); } $(document).ready(function(){ 'use strict'; var isTouchDevice = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|Windows Phone)/); //Touch device if(isTouchDevice){ $('body').addClass('touch-device'); $('.background-video').remove(); } //Bootstrap Elements $('[data-toggle="tooltip"], .tooltip-link').tooltip(); $('a[data-toggle=popover]') .popover() .on('click', function(e){ e.preventDefault(); }); $('.disabled, fieldset[disabled] .selectBox').on('click', function (){ return false; }); //Functions formStylization(); mainMenu(); mapBox(); youtubeVideoBg(); sendEmail(); contactForm(); backgroundSlider(); //Functions(load) $(window).on('load', function(){ animateStart(); carousels(); videoBg(); contentScroll(); //Preloader $('body').delay(500).addClass('loaded').find('.preloader').fadeOut(400); }); //Notify me (MailChimp) if (($('.mailchimp').length) && ($.fn.ajaxChimp)) { $('.mailchimp').ajaxChimp({ url: 'http://us10.list-manage.com/subscribe/post?u=69007f000c70b89e124b9308d&id=1225ba8aee' }); } //Retina if('devicePixelRatio' in window && window.devicePixelRatio >= 2){ var imgToReplace = $('img.replace-2x').get(); for (var i=0,l=imgToReplace.length; i