$( document ).ready(function() { google.maps.event.addDomListener(window, 'load', init); var map, markersArray = []; function init() { var mapOptions = { center: new google.maps.LatLng(51.9674883,4.5834841), zoom: 10, minZoom: 1, gestureHandling: 'auto', fullscreenControl: false, zoomControl: false, disableDoubleClickZoom: false, disableDefaultUI: true, mapTypeControl: false, scaleControl: true, scrollwheel: false, streetViewControl: false, draggable : true, clickableIcons: false, mapTypeId: google.maps.MapTypeId.ROADMAP, styles: [{"featureType":"water","elementType":"geometry","stylers":[{"color":"#e9e9e9"},{"lightness":17}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#ffffff"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#ffffff"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":16}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":21}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#dedede"},{"lightness":21}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#ffffff"},{"lightness":16}]},{"elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#333333"},{"lightness":40}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#f2f2f2"},{"lightness":19}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#fefefe"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#fefefe"},{"lightness":17},{"weight":1.2}]}] } var mapElement = document.getElementById('map'); var map = new google.maps.Map(mapElement, mapOptions); var locations = [ {"lat":51.9674883,"lng":4.5834841,"marker":"/assets/img/marker.png","iw":{"address":false,"desc":true,"email":true,"enable":false,"int_tel":false,"open":true,"open_hours":true,"photo":true,"tel":false,"title":false,"web":false}} ]; for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ icon: 'assets/img/marker.png', position: new google.maps.LatLng(51.9674883, 4.5834841), map: map, }); markersArray.push(marker); } } grecaptcha.ready(function () { grecaptcha.execute('6LfqCeQUAAAAAIJhsWOjtRxIED1GlHzf1n9iaDa9', { action: 'contact' }).then(function (token) { var recaptchaResponse = document.getElementById('recaptchaResponse'); recaptchaResponse.value = token; }); }); $('.field.select .customSelect').on('select2:open', function (e) { $(this).parent('.field').addClass('focus'); $(this).parent('.field').removeClass('invalid'); checkForm(); }); $('.field.select .customSelect').on('select2:select', function (e) { checkForm(); }); $('.field.select .customSelect').on('select2:close', function (e) { if(!$(this).val()){ checkForm(); $(this).parent('.field').removeClass('focus'); $(this).parent('.field').addClass('invalid'); } }); $(".field").on("click", function() { $(this).find(".input").focus(); }); $('.field input, .field textarea').bind('focus', function() { $(this).parent('.field').addClass('focus'); }); $('.field input, .field textarea').bind('keyup blur input', function() { checkForm(); if ($(this).parent('.field').hasClass("invalid")) { $(this).parent('.field').removeClass("invalid"); } }); $('.field input, .field textarea').bind('blur', function() { if ($(this).is(':invalid')){ $(this).parent('.field').addClass('invalid'); } else { $(this).parent('.field').removeClass('invalid'); } var value=$.trim($(this).val()); if (!value.length>0) { $(this).parent('.field').removeClass('focus'); } }); $(".field.submit .button").on("click", function(){ if(!$(this).parent(".field").hasClass("disabled")){ var formData = $(contactForm).serialize(); console.log(formData); $.ajax({ type: "POST", url: "parts/contactsender.php", data: formData, cache: false, success: function(result){ } }); $(".form").hide(); $(".success").show(); return false; } else { return false; } }); }); function checkForm() { var valid = true; var firstInvalidObject; $('.field.text input').each(function(i, obj) { if (!obj.checkValidity()) { valid = false; if (!firstInvalidObject) { firstInvalidObject = $(obj); } } }); $('.field textarea').each(function(i, obj) { if (!obj.checkValidity()) { valid = false; if (!firstInvalidObject) { firstInvalidObject = $(obj); } } }); $('.field select').each(function(i, obj) { if (!obj.checkValidity()) { valid = false; if (!firstInvalidObject) { firstInvalidObject = $(obj); } } }); if (valid) { $('.field.submit').removeClass("disabled"); } else { $('.field.submit').addClass("disabled"); } }