/* ZeroFour by HTML5 UP html5up.net | @ajlkn Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) */ (function ($) { skel .breakpoints({ desktop: '(min-width: 737px)', tablet: '(min-width: 737px) and (max-width: 1200px)', mobile: '(max-width: 736px)' }) .viewport({ breakpoints: { tablet: { width: 1080 } } }); $(function () { var $window = $(window), $body = $('body'); // Disable animations/transitions until the page has loaded. $body.addClass('is-loading'); $window.on('load', function () { $body.removeClass('is-loading'); }); // Fix: Placeholder polyfill. $('form').placeholder(); // Dropdowns. $('#nav > ul').dropotron({ offsetY: -22, mode: 'fade', noOpenerFade: true, speed: 300, detach: false }); // Prioritize "important" elements on mobile. skel.on('+mobile -mobile', function () { $.prioritize( '.important\\28 mobile\\29', skel.breakpoint('mobile').active ); }); // Off-Canvas Navigation. // Title Bar. $( '
' ) .appendTo($body); // Navigation Panel. $( ' ' ) .appendTo($body) .panel({ delay: 500, hideOnClick: true, hideOnSwipe: true, resetScroll: true, resetForms: true, side: 'left', target: $body, visibleClass: 'navPanel-visible' }); // Fix: Remove navPanel transitions on WP<10 (poor/buggy performance). if (skel.vars.os == 'wp' && skel.vars.osVersion < 10) $('#titleBar, #navPanel, #page-wrapper') .css('transition', 'none'); $('.social-icon-whatsapp').mouseover(function(){ $(this).find('.social-icon-label').css('opacity', 1).css('display', 'block'); }); $('.social-icon-whatsapp').mouseout(function(){ $(this).find('.social-icon-label').css('opacity', 0).css('display', 'none'); }); }); /* -------------------------------------------------------- Footer Contact Form -------------------------------------------------------- */ $('#send').click(function () { // when the button is clicked the code executes $('.error').fadeOut('slow'); // reset the error messages (hides them) var error = false; // we will set this true if the form isn't valid var name = $('input#name').val(); // get the value of the input field if (name == "" || name == " " || name == "Nombre") { $('#err-name').fadeIn('slow'); // show the error message error = true; // change the error state to true } var email_compare = /^([a-z0-9_.-]+)@([da-z.-]+).([a-z.]{2,6})$/; // Syntax to compare against input var email = $('input#email').val(); // get the value of the input field if (email == "" || email == " " || email == "E-mail") { // check if the field is empty $('#err-email').fadeIn('slow'); // error - empty error = true; } else if (!email_compare.test(email)) { // if it's not empty check the format against our email_compare variable $('#err-emailvld').fadeIn('slow'); // error - not right format error = true; } var phone_compare = /^\d{10}$/; // Syntax to compare against input var phone = $('input#phone').val(); // get the value of the input field if (phone == "" || phone == " " || phone == "Teléfono") { // check if the field is empty $('#err-phone').fadeIn('slow'); // error - empty error = true; } else if (!phone_compare.test(phone)) { // if it's not empty check the format against our email_compare variable $('#err-phonevld').fadeIn('slow'); // error - not right format error = true; } var message = $('textarea#message').val(); // get the value of the input field if (message == "" || message == " " || message == "Mensaje") { $('#err-message').fadeIn('slow'); // show the error message error = true; // change the error state to true } if (error == true) { $('#err-form').slideDown('slow'); return false; } var data_string = $('#ajax-form').serialize(); // Collect data from form //alert(data_string); $.ajax({ type: "POST", url: $('#ajax-form').attr('action'), data: data_string, timeout: 6000, success: function () { //$('#ajax-form').slideUp('slow'); $('#ajaxsuccess').slideDown('slow'); $('#ajaxsuccess').delay(4000); $('#ajaxsuccess').fadeOut(1000); $("#name").val('Nombre'); $("#email").val('E-mail'); $("#phone").val('Teléfono'); $("#message").val('Mensaje'); }, error: function (request, error) { if (error == "timeout") { $('#err-timedout').slideDown('slow'); } else { $('#err-state').slideDown('slow'); $("#err-state").html('Error: ' + error + ''); } } }); return false; // stops user browser being directed to the php file }); // end click function })(jQuery);