(function($){
'use strict';
if(typeof wpcf7==='undefined'||wpcf7===null){
return;
}
wpcf7=$.extend({
cached: 0,
inputs: []
}, wpcf7);
$(function(){
wpcf7.supportHtml5=(function(){
var features={};
var input=document.createElement('input');
features.placeholder='placeholder' in input;
var inputTypes=[ 'email', 'url', 'tel', 'number', 'range', 'date' ];
$.each(inputTypes, function(index, value){
input.setAttribute('type', value);
features[ value ]=input.type!=='text';
});
return features;
})();
$('div.wpcf7 > form').each(function(){
var $form=$(this);
wpcf7.initForm($form);
if(wpcf7.cached){
wpcf7.refill($form);
}});
});
wpcf7.getId=function(form){
return parseInt($('input[name="_wpcf7"]', form).val(), 10);
};
wpcf7.initForm=function(form){
var $form=$(form);
$form.submit(function(event){
if(! wpcf7.supportHtml5.placeholder){
$('[placeholder].placeheld', $form).each(function(i, n){
$(n).val('').removeClass('placeheld');
});
}
if(typeof window.FormData==='function'){
wpcf7.submit($form);
event.preventDefault();
}});
$('.wpcf7-submit', $form).after('<span class="ajax-loader"></span>');
wpcf7.toggleSubmit($form);
$form.on('click', '.wpcf7-acceptance', function(){
wpcf7.toggleSubmit($form);
});
$('.wpcf7-exclusive-checkbox', $form).on('click', 'input:checkbox', function(){
var name=$(this).attr('name');
$form.find('input:checkbox[name="' + name + '"]').not(this).prop('checked', false);
});
$('.wpcf7-list-item.has-free-text', $form).each(function(){
var $freetext=$(':input.wpcf7-free-text', this);
var $wrap=$(this).closest('.wpcf7-form-control');
if($(':checkbox, :radio', this).is(':checked')){
$freetext.prop('disabled', false);
}else{
$freetext.prop('disabled', true);
}
$wrap.on('change', ':checkbox, :radio', function(){
var $cb=$('.has-free-text', $wrap).find(':checkbox, :radio');
if($cb.is(':checked')){
$freetext.prop('disabled', false).focus();
}else{
$freetext.prop('disabled', true);
}});
});
if(! wpcf7.supportHtml5.placeholder){
$('[placeholder]', $form).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');
}});
});
}
if(wpcf7.jqueryUi&&! wpcf7.supportHtml5.date){
$form.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){
$form.find('input.wpcf7-number[type="number"]').each(function(){
$(this).spinner({
min: $(this).attr('min'),
max: $(this).attr('max'),
step: $(this).attr('step')
});
});
}
$('.wpcf7-character-count', $form).each(function(){
var $count=$(this);
var name=$count.attr('data-target-name');
var down=$count.hasClass('down');
var starting=parseInt($count.attr('data-starting-value'), 10);
var maximum=parseInt($count.attr('data-maximum-value'), 10);
var minimum=parseInt($count.attr('data-minimum-value'), 10);
var updateCount=function(target){
var $target=$(target);
var length=$target.val().length;
var count=down ? starting - length:length;
$count.attr('data-current-value', count);
$count.text(count);
if(maximum&&maximum < length){
$count.addClass('too-long');
}else{
$count.removeClass('too-long');
}
if(minimum&&length < minimum){
$count.addClass('too-short');
}else{
$count.removeClass('too-short');
}};
$(':input[name="' + name + '"]', $form).each(function(){
updateCount(this);
$(this).keyup(function(){
updateCount(this);
});
});
});
$form.on('change', '.wpcf7-validates-as-url', function(){
var val=$.trim($(this).val());
if(val
&& ! val.match(/^[a-z][a-z0-9.+-]*:/i)
&& -1!==val.indexOf('.')){
val=val.replace(/^\/+/, '');
val='http://' + val;
}
$(this).val(val);
});
};
wpcf7.submit=function(form){
if(typeof window.FormData!=='function'){
return;
}
var $form=$(form);
$('.ajax-loader', $form).addClass('is-active');
wpcf7.clearResponse($form);
var formData=new FormData($form.get(0));
var detail={
id: $form.closest('div.wpcf7').attr('id'),
status: 'init',
inputs: [],
formData: formData
};
$.each($form.serializeArray(), function(i, field){
if('_wpcf7'==field.name){
detail.contactFormId=field.value;
}else if('_wpcf7_version'==field.name){
detail.pluginVersion=field.value;
}else if('_wpcf7_locale'==field.name){
detail.contactFormLocale=field.value;
}else if('_wpcf7_unit_tag'==field.name){
detail.unitTag=field.value;
}else if('_wpcf7_container_post'==field.name){
detail.containerPostId=field.value;
}else if(field.name.match(/^_wpcf7_\w+_free_text_/)){
var owner=field.name.replace(/^_wpcf7_\w+_free_text_/, '');
detail.inputs.push({
name: owner + '-free-text',
value: field.value
});
}else if(field.name.match(/^_/)){
}else{
detail.inputs.push(field);
}});
wpcf7.triggerEvent($form.closest('div.wpcf7'), 'beforesubmit', detail);
var ajaxSuccess=function(data, status, xhr, $form){
detail.id=$(data.into).attr('id');
detail.status=data.status;
detail.apiResponse=data;
var $message=$('.wpcf7-response-output', $form);
switch(data.status){
case 'validation_failed':
$.each(data.invalidFields, function(i, n){
$(n.into, $form).each(function(){
wpcf7.notValidTip(this, n.message);
$('.wpcf7-form-control', this).addClass('wpcf7-not-valid');
$('[aria-invalid]', this).attr('aria-invalid', 'true');
});
});
$message.addClass('wpcf7-validation-errors');
$form.addClass('invalid');
wpcf7.triggerEvent(data.into, 'invalid', detail);
break;
case 'acceptance_missing':
$message.addClass('wpcf7-acceptance-missing');
$form.addClass('unaccepted');
wpcf7.triggerEvent(data.into, 'unaccepted', detail);
break;
case 'spam':
$message.addClass('wpcf7-spam-blocked');
$form.addClass('spam');
wpcf7.triggerEvent(data.into, 'spam', detail);
break;
case 'aborted':
$message.addClass('wpcf7-aborted');
$form.addClass('aborted');
wpcf7.triggerEvent(data.into, 'aborted', detail);
break;
case 'mail_sent':
$message.addClass('wpcf7-mail-sent-ok');
$form.addClass('sent');
wpcf7.triggerEvent(data.into, 'mailsent', detail);
break;
case 'mail_failed':
$message.addClass('wpcf7-mail-sent-ng');
$form.addClass('failed');
wpcf7.triggerEvent(data.into, 'mailfailed', detail);
break;
default:
var customStatusClass='custom-'
+ data.status.replace(/[^0-9a-z]+/i, '-');
$message.addClass('wpcf7-' + customStatusClass);
$form.addClass(customStatusClass);
}
wpcf7.refill($form, data);
wpcf7.triggerEvent(data.into, 'submit', detail);
if('mail_sent'==data.status){
$form.each(function(){
this.reset();
});
wpcf7.toggleSubmit($form);
}
if(! wpcf7.supportHtml5.placeholder){
$form.find('[placeholder].placeheld').each(function(i, n){
$(n).val($(n).attr('placeholder'));
});
}
$message.html('').append(data.message).slideDown('fast');
$message.attr('role', 'alert');
$('.screen-reader-response', $form.closest('.wpcf7')).each(function(){
var $response=$(this);
$response.html('').attr('role', '').append(data.message);
if(data.invalidFields){
var $invalids=$('<ul></ul>');
$.each(data.invalidFields, function(i, n){
if(n.idref){
var $li=$('<li></li>').append($('<a></a>').attr('href', '#' + n.idref).append(n.message));
}else{
var $li=$('<li></li>').append(n.message);
}
$invalids.append($li);
});
$response.append($invalids);
}
$response.attr('role', 'alert').focus();
});
};
$.ajax({
type: 'POST',
url: wpcf7.apiSettings.getRoute('/contact-forms/' + wpcf7.getId($form) + '/feedback'),
data: formData,
dataType: 'json',
processData: false,
contentType: false
}).done(function(data, status, xhr){
ajaxSuccess(data, status, xhr, $form);
$('.ajax-loader', $form).removeClass('is-active');
}).fail(function(xhr, status, error){
var $e=$('<div class="ajax-error"></div>').text(error.message);
$form.after($e);
});
};
wpcf7.triggerEvent=function(target, name, detail){
var $target=$(target);
var event=new CustomEvent('wpcf7' + name, {
bubbles: true,
detail: detail
});
$target.get(0).dispatchEvent(event);
$target.trigger('wpcf7:' + name, detail);
$target.trigger(name + '.wpcf7', detail);
};
wpcf7.toggleSubmit=function(form, state){
var $form=$(form);
var $submit=$('input:submit', $form);
if(typeof state!=='undefined'){
$submit.prop('disabled', ! state);
return;
}
if($form.hasClass('wpcf7-acceptance-as-validation')){
return;
}
$submit.prop('disabled', false);
$('.wpcf7-acceptance', $form).each(function(){
var $span=$(this);
var $input=$('input:checkbox', $span);
if(! $span.hasClass('optional')){
if($span.hasClass('invert')&&$input.is(':checked')
|| ! $span.hasClass('invert')&&! $input.is(':checked')){
$submit.prop('disabled', true);
return false;
}}
});
};
wpcf7.notValidTip=function(target, message){
var $target=$(target);
$('.wpcf7-not-valid-tip', $target).remove();
$('<span role="alert" class="wpcf7-not-valid-tip"></span>')
.text(message).appendTo($target);
if($target.is('.use-floating-validation-tip *')){
var fadeOut=function(target){
$(target).not(':hidden').animate({
opacity: 0
}, 'fast', function(){
$(this).css({ 'z-index': -100 });
});
};
$target.on('mouseover', '.wpcf7-not-valid-tip', function(){
fadeOut(this);
});
$target.on('focus', ':input', function(){
fadeOut($('.wpcf7-not-valid-tip', $target));
});
}};
wpcf7.refill=function(form, data){
var $form=$(form);
var refillCaptcha=function($form, items){
$.each(items, function(i, n){
$form.find(':input[name="' + i + '"]').val('');
$form.find('img.wpcf7-captcha-' + i).attr('src', n);
var match=/([0-9]+)\.(png|gif|jpeg)$/.exec(n);
$form.find('input:hidden[name="_wpcf7_captcha_challenge_' + i + '"]').attr('value', match[ 1 ]);
});
};
var refillQuiz=function($form, items){
$.each(items, function(i, n){
$form.find(':input[name="' + i + '"]').val('');
$form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[ 0 ]);
$form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[ 1 ]);
});
};
if(typeof data==='undefined'){
$.ajax({
type: 'GET',
url: wpcf7.apiSettings.getRoute('/contact-forms/' + wpcf7.getId($form) + '/refill'),
beforeSend: function(xhr){
var nonce=$form.find(':input[name="_wpnonce"]').val();
if(nonce){
xhr.setRequestHeader('X-WP-Nonce', nonce);
}},
dataType: 'json'
}).done(function(data, status, xhr){
if(data.captcha){
refillCaptcha($form, data.captcha);
}
if(data.quiz){
refillQuiz($form, data.quiz);
}});
}else{
if(data.captcha){
refillCaptcha($form, data.captcha);
}
if(data.quiz){
refillQuiz($form, data.quiz);
}}
};
wpcf7.clearResponse=function(form){
var $form=$(form);
$form.removeClass('invalid spam sent failed');
$form.siblings('.screen-reader-response').html('').attr('role', '');
$('.wpcf7-not-valid-tip', $form).remove();
$('[aria-invalid]', $form).attr('aria-invalid', 'false');
$('.wpcf7-form-control', $form).removeClass('wpcf7-not-valid');
$('.wpcf7-response-output', $form)
.hide().empty().removeAttr('role')
.removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked');
};
wpcf7.apiSettings.getRoute=function(path){
var url=wpcf7.apiSettings.root;
url=url.replace(wpcf7.apiSettings.namespace,
wpcf7.apiSettings.namespace + path);
return url;
};})(jQuery);
(function (){
if(typeof window.CustomEvent==="function") return false;
function CustomEvent(event, params){
params=params||{ bubbles: false, cancelable: false, detail: undefined };
var evt=document.createEvent('CustomEvent');
evt.initCustomEvent(event,
params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype=window.Event.prototype;
window.CustomEvent=CustomEvent;
})();
!function(factory){
"function"==typeof define&&define.amd ? define([ "jquery" ], factory):factory("object"==typeof exports ? require("jquery"):jQuery);
}(function($){
var caretTimeoutId, ua=navigator.userAgent, iPhone=/iphone/i.test(ua), chrome=/chrome/i.test(ua), android=/android/i.test(ua);
$.mask={
definitions: {
"_": "[0-9]",
},
autoclear: !0,
dataName: "mask",
placeholder: "_"
}, $.fn.extend({
caret: function(begin, end){
var range;
if(0!==this.length&&!this.is(":hidden")) return "number"==typeof begin ? (end="number"==typeof end ? end:begin,
this.each(function(){
this.setSelectionRange ? this.setSelectionRange(begin, end):this.createTextRange&&(range=this.createTextRange(),
range.collapse(!0), range.moveEnd("character", end), range.moveStart("character", begin),
range.select());
})):(this[0].setSelectionRange ? (begin=this[0].selectionStart, end=this[0].selectionEnd):document.selection&&document.selection.createRange&&(range=document.selection.createRange(),
begin=0 - range.duplicate().moveStart("character", -1e5), end=begin + range.text.length),
{
begin: begin,
end: end
});
},
unmask: function(){
return this.trigger("unmask");
},
mask: function(mask, settings){
var input, defs, tests, partialPosition, firstNonMaskPos, lastRequiredNonMaskPos, len, oldVal;
if(!mask&&this.length > 0){
input=$(this[0]);
var fn=input.data($.mask.dataName);
return fn ? fn():void 0;
}
return settings=$.extend({
autoclear: $.mask.autoclear,
placeholder: $.mask.placeholder,
completed: null
}, settings), defs=$.mask.definitions, tests=[], partialPosition=len=mask.length,
firstNonMaskPos=null, $.each(mask.split(""), function(i, c){
"?"==c ? (len--, partialPosition=i):defs[c] ? (tests.push(new RegExp(defs[c])),
null===firstNonMaskPos&&(firstNonMaskPos=tests.length - 1), partialPosition > i&&(lastRequiredNonMaskPos=tests.length - 1)):tests.push(null);
}), this.trigger("unmask").each(function(){
function tryFireCompleted(){
if(settings.completed){
for (var i=firstNonMaskPos; lastRequiredNonMaskPos >=i; i++) if(tests[i]&&buffer[i]===getPlaceholder(i)) return;
settings.completed.call(input);
}}
function getPlaceholder(i){
return settings.placeholder.charAt(i < settings.placeholder.length ? i:0);
}
function seekNext(pos){
for (;++pos < len&&!tests[pos];) ;
return pos;
}
function seekPrev(pos){
for (;--pos >=0&&!tests[pos];) ;
return pos;
}
function shiftL(begin, end){
var i, j;
if(!(0 > begin)){
for (i=begin, j=seekNext(end); len > i; i++) if(tests[i]){
if(!(len > j&&tests[i].test(buffer[j]))) break;
buffer[i]=buffer[j], buffer[j]=getPlaceholder(j), j=seekNext(j);
}
writeBuffer(), input.caret(Math.max(firstNonMaskPos, begin));
}}
function shiftR(pos){
var i, c, j, t;
for (i=pos, c=getPlaceholder(pos); len > i; i++) if(tests[i]){
if(j=seekNext(i), t=buffer[i], buffer[i]=c, !(len > j&&tests[j].test(t))) break;
c=t;
}}
function androidInputEvent(){
var curVal=input.val(), pos=input.caret();
if(oldVal&&oldVal.length&&oldVal.length > curVal.length){
for (checkVal(!0); pos.begin > 0&&!tests[pos.begin - 1];) pos.begin--;
if(0===pos.begin) for (;pos.begin < firstNonMaskPos&&!tests[pos.begin];) pos.begin++;
input.caret(pos.begin, pos.begin);
}else{
for (checkVal(!0); pos.begin < len&&!tests[pos.begin];) pos.begin++;
input.caret(pos.begin, pos.begin);
}
tryFireCompleted();
}
function blurEvent(){
checkVal(), input.val()!=focusText&&input.change();
}
function keydownEvent(e){
if(!input.prop("readonly")){
var pos, begin, end, k=e.which||e.keyCode;
oldVal=input.val(), 8===k||46===k||iPhone&&127===k ? (pos=input.caret(),
begin=pos.begin, end=pos.end, end - begin===0&&(begin=46!==k ? seekPrev(begin):end=seekNext(begin - 1),
end=46===k ? seekNext(end):end), clearBuffer(begin, end), shiftL(begin, end - 1),
e.preventDefault()):13===k ? blurEvent.call(this, e):27===k&&(input.val(focusText),
input.caret(0, checkVal()), e.preventDefault());
}}
function keypressEvent(e){
if(!input.prop("readonly")){
var p, c, next, k=e.which||e.keyCode, pos=input.caret();
if(!(e.ctrlKey||e.altKey||e.metaKey||32 > k)&&k && 13!==k){
if(pos.end - pos.begin!==0&&(clearBuffer(pos.begin, pos.end), shiftL(pos.begin, pos.end - 1)),
p=seekNext(pos.begin - 1), len > p&&(c=String.fromCharCode(k), tests[p].test(c))){
if(shiftR(p), buffer[p]=c, writeBuffer(), next=seekNext(p), android){
var proxy=function(){
$.proxy($.fn.caret, input, next)();
};
setTimeout(proxy, 0);
} else input.caret(next);
pos.begin <=lastRequiredNonMaskPos&&tryFireCompleted();
}
e.preventDefault();
}}
}
function clearBuffer(start, end){
var i;
for (i=start; end > i&&len > i; i++) tests[i]&&(buffer[i]=getPlaceholder(i));
}
function writeBuffer(){
input.val(buffer.join(""));
}
function checkVal(allow){
var i, c, pos, test=input.val(), lastMatch=-1;
for (i=0, pos=0; len > i; i++) if(tests[i]){
for (buffer[i]=getPlaceholder(i); pos++ < test.length;) if(c=test.charAt(pos - 1),
tests[i].test(c)){
buffer[i]=c, lastMatch=i;
break;
}
if(pos > test.length){
clearBuffer(i + 1, len);
break;
}} else buffer[i]===test.charAt(pos)&&pos++, partialPosition > i&&(lastMatch=i);
return allow ? writeBuffer():partialPosition > lastMatch + 1 ? settings.autoclear||buffer.join("")===defaultBuffer ? (input.val()&&input.val(""),
clearBuffer(0, len)):writeBuffer():(writeBuffer(), input.val(input.val().substring(0, lastMatch + 1))),
partialPosition ? i:firstNonMaskPos;
}
var input=$(this), buffer=$.map(mask.split(""), function(c, i){
return "?"!=c ? defs[c] ? getPlaceholder(i):c : void 0;
}), defaultBuffer=buffer.join(""), focusText=input.val();
input.data($.mask.dataName, function(){
return $.map(buffer, function(c, i){
return tests[i]&&c!=getPlaceholder(i) ? c:null;
}).join("");
}), input.one("unmask", function(){
input.off(".mask").removeData($.mask.dataName);
}).on("focus.mask", function(){
if(!input.prop("readonly")){
clearTimeout(caretTimeoutId);
var pos;
focusText=input.val(), pos=checkVal(), caretTimeoutId=setTimeout(function(){
input.get(0)===document.activeElement&&(writeBuffer(), pos==mask.replace("?", "").length ? input.caret(0, pos):input.caret(pos));
}, 10);
}}).on("blur.mask", blurEvent).on("keydown.mask", keydownEvent).on("keypress.mask", keypressEvent).on("input.mask paste.mask", function(){
input.prop("readonly")||setTimeout(function(){
var pos=checkVal(!0);
input.caret(pos), tryFireCompleted();
}, 0);
}), chrome&&android&&input.off("input.mask").on("input.mask", androidInputEvent),
checkVal();
});
}});
$(document).ready(function(){
var $fields=$('.wpcf7-mask');
if(! $fields.length){
return false;
}
$fields.each(function(){
var $this=$(this),
mask=$this.data('mask');
if(!mask){
return;
}
$this.mask(mask, {
'autoclear': getOption($this.data('autoclear')),
});
if('tel'!=$this.attr('type')&&-1==mask.indexOf('.')){
$this.attr({
'inputmode': 'numeric',
});
}});
});
function getOption(valule){
if(typeof valule=='undefined'){
return 0;
}
return valule;
}});