(function($) { $(function() { try { if (typeof _wpcf7 == 'undefined' || _wpcf7 === null) _wpcf7 = {}; _wpcf7 = $.extend({ cached: 0 }, _wpcf7); _wpcf7.supportHtml5 = $.wpcf7SupportHtml5(); $('div.wpcf7 > form').ajaxForm({ beforeSubmit: function(formData, jqForm, options) { jqForm.wpcf7ClearResponseOutput(); jqForm.find('img.ajax-loader').css({ visibility: 'visible' }); return true; }, beforeSerialize: function(jqForm, options) { jqForm.find('[placeholder].placeheld').each(function(i, n) { $(n).val(''); }); return true; }, data: { '_wpcf7_is_ajax_call': 1 }, dataType: 'json', success: function(data) { if (! $.isPlainObject(data) || $.isEmptyObject(data)) return; var ro = $(data.into).find('div.wpcf7-response-output'); $(data.into).wpcf7ClearResponseOutput(); $(data.into).find('.wpcf7-form-control').removeClass('wpcf7-not-valid'); $(data.into).find('form.wpcf7-form').removeClass('invalid spam sent failed'); if (data.captcha) $(data.into).wpcf7RefillCaptcha(data.captcha); if (data.quiz) $(data.into).wpcf7RefillQuiz(data.quiz); if (data.invalids) { $.each(data.invalids, function(i, n) { $(data.into).find(n.into).wpcf7NotValidTip(n.message); $(data.into).find(n.into).find('.wpcf7-form-control').addClass('wpcf7-not-valid'); }); ro.addClass('wpcf7-validation-errors'); $(data.into).find('form.wpcf7-form').addClass('invalid'); $(data.into).trigger('invalid.wpcf7'); } else if (1 == data.spam) { ro.addClass('wpcf7-spam-blocked'); $(data.into).find('form.wpcf7-form').addClass('spam'); $(data.into).trigger('spam.wpcf7'); } else if (1 == data.mailSent) { ro.addClass('wpcf7-mail-sent-ok'); $(data.into).find('form.wpcf7-form').addClass('sent'); if (data.onSentOk) $.each(data.onSentOk, function(i, n) { eval(n) }); $(data.into).trigger('mailsent.wpcf7'); } else { ro.addClass('wpcf7-mail-sent-ng'); $(data.into).find('form.wpcf7-form').addClass('failed'); $(data.into).trigger('mailfailed.wpcf7'); } if (data.onSubmit) $.each(data.onSubmit, function(i, n) { eval(n) }); $(data.into).trigger('submit.wpcf7'); if (1 == data.mailSent) $(data.into).find('form').resetForm().clearForm(); $(data.into).find('[placeholder].placeheld').each(function(i, n) { $(n).val($(n).attr('placeholder')); }); $(data.into).wpcf7FillResponseOutput(data.message); }, error: function(xhr, status, error, $form) { var e = $('
').text(error.message); $form.after(e); } }); $('div.wpcf7 > form').wpcf7InitForm(); } catch (e) { } }); $.fn.wpcf7InitForm = function() { return this.each(function(i, n) { var $f = $(n); if (_wpcf7.cached) $f.wpcf7OnloadRefill(); $f.wpcf7ToggleSubmit(); $f.find('.wpcf7-submit').wpcf7AjaxLoader(); $f.find('.wpcf7-acceptance').click(function() { $f.wpcf7ToggleSubmit(); }); $f.find('.wpcf7-exclusive-checkbox').wpcf7ExclusiveCheckbox(); $f.find('[placeholder]').wpcf7Placeholder(); if (_wpcf7.jqueryUi && ! _wpcf7.supportHtml5.date) { $f.find('input.wpcf7-date[type="date"]').each(function() { $(this).datepicker({ dateFormat: 'yy-mm-dd', minDate: new Date($(this).attr('min')), maxDate: new Date($(this).attr('max')) }); }); } if (_wpcf7.jqueryUi && ! _wpcf7.supportHtml5.number) { $f.find('input.wpcf7-number[type="number"]').each(function() { $(this).spinner({ min: $(this).attr('min'), max: $(this).attr('max'), step: $(this).attr('step') }); }); } }); }; $.fn.wpcf7ExclusiveCheckbox = function() { return this.find('input:checkbox').click(function() { $(this).closest('.wpcf7-checkbox').find('input:checkbox').not(this).removeAttr('checked'); }); }; $.fn.wpcf7Placeholder = function() { if (_wpcf7.supportHtml5.placeholder) return this; return this.each(function() { $(this).val($(this).attr('placeholder')); $(this).addClass('placeheld'); $(this).focus(function() { if ($(this).hasClass('placeheld')) $(this).val('').removeClass('placeheld'); }); $(this).blur(function() { if ('' == $(this).val()) { $(this).val($(this).attr('placeholder')); $(this).addClass('placeheld'); } }); }); }; $.fn.wpcf7AjaxLoader = function() { return this.each(function() { var loader = $('