jq = jQuery.noConflict(); jq(document).ready(function (jq) { jq('form#recaptcha').on('submit', function (event) { event.stopImmediatePropagation(); event.stopPropagation(); jq.post(jq(this).attr('action'), jq(this).serialize(), function (response) { data = JSON.parse(response); if (false === data.valid) { data.message.every(function (d) { UIkit.notify(' ' + d, { pos: 'bottom-center', status: 'danger' }); }); } else if (true === data.valid) { var divRoot = jq('
'), h1 = jq('

'), href = jq(''), phone = jq('.hidden-phone'); href .attr('href', 'tel:' + data.message.phone) .text(data.message.phone); h1.append(href); phone.attr('href', 'tel:' + data.message.phone); phone.text(data.message.phone); divRoot.append(h1); jq('#recaptcha-wrapper').replaceWith(divRoot); } }); }); // Phone form jq('form[name=contact]').on('submit', function(event) { jq.post(jq(this).attr('action'), jq(this).serialize(), function(response) { if(response.status !== 'success') { jq('#' + response.id).addClass('uk-form-danger'); UIkit.notify('' + response.message + ' ('+response.code+')

', { pos: 'top-center', status: 'danger' }); console.log(response); } else { console.log(response); UIkit.notify(' ' + response.message, { pos: 'top-center', status: 'success' }); var $wrapper = jq('#contact-form'), $button = jq(''), $thankYouText = jq('

Thank you for your message.

I will get back to you as soon as possible.

'); $wrapper.empty().append($thankYouText).append($button); jq('a[href="#contact-form-wrapper"]').replaceWith('eric@ericwheeler.net'); } }); }); jq('form[name=contact] input, form[name=contact] textarea').on('focus', function() { if(jq(this).hasClass('uk-form-danger')) { jq(this).removeClass('uk-form-danger'); } }); });