-九游官网入口
(function($) {
$(function() {
try {
if (typeof _wpcf7 == 'undefined' || _wpcf7 === null)
_wpcf7 = {};
_wpcf7 = $.extend({ cached: 0 }, _wpcf7);
$('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('.wpcf7-use-title-as-watermark.watermark').each(function(i, n) {
$(n).val('');
});
return true;
},
data: { '_wpcf7_is_ajax_call': 1 },
datatype: 'json',
success: function(data) {
var ro = $(data.into).find('div.wpcf7-response-output');
$(data.into).wpcf7clearresponseoutput();
if (data.invalids) {
$.each(data.invalids, function(i, n) {
$(data.into).find(n.into).wpcf7notvalidtip(n.message);
});
ro.addclass('wpcf7-validation-errors');
}
if (data.captcha)
$(data.into).wpcf7refillcaptcha(data.captcha);
if (data.quiz)
$(data.into).wpcf7refillquiz(data.quiz);
if (1 == data.spam)
ro.addclass('wpcf7-spam-blocked');
if (1 == data.mailsent) {
$(data.into).find('form').resetform().clearform();
ro.addclass('wpcf7-mail-sent-ok');
if (data.onsentok)
$.each(data.onsentok, function(i, n) { eval(n) });
} else {
ro.addclass('wpcf7-mail-sent-ng');
}
if (data.onsubmit)
$.each(data.onsubmit, function(i, n) { eval(n) });
$(data.into).find('.wpcf7-use-title-as-watermark.watermark').each(function(i, n) {
$(n).val($(n).attr('title'));
});
ro.append(data.message).slidedown('fast');
}
});
$('div.wpcf7 > form').each(function(i, n) {
if (_wpcf7.cached)
$(n).wpcf7onloadrefill();
$(n).wpcf7togglesubmit();
$(n).find('.wpcf7-acceptance').click(function() {
$(n).wpcf7togglesubmit();
});
$(n).find('.wpcf7-exclusive-checkbox').each(function(i, n) {
$(n).find('input:checkbox').click(function() {
$(n).find('input:checkbox').not(this).removeattr('checked');
});
});
$(n).find('.wpcf7-use-title-as-watermark').each(function(i, n) {
var input = $(n);
input.val(input.attr('title'));
input.addclass('watermark');
input.focus(function() {
if ($(this).hasclass('watermark'))
$(this).val('').removeclass('watermark');
});
input.blur(function() {
if ('' == $(this).val())
$(this).val($(this).attr('title')).addclass('watermark');
});
});
});
} catch (e) {
}
});
$.fn.wpcf7togglesubmit = function() {
return this.each(function() {
var form = $(this);
if (this.tagname.tolowercase() != 'form')
form = $(this).find('form').first();
if (form.hasclass('wpcf7-acceptance-as-validation'))
return;
var submit = form.find('input:submit');
if (! submit.length) return;
var acceptances = form.find('input:checkbox.wpcf7-acceptance');
if (! acceptances.length) return;
submit.removeattr('disabled');
acceptances.each(function(i, n) {
n = $(n);
if (n.hasclass('wpcf7-invert') && n.is(':checked')
|| ! n.hasclass('wpcf7-invert') && ! n.is(':checked'))
submit.attr('disabled', 'disabled');
});
});
};
$.fn.wpcf7notvalidtip = function(message) {
return this.each(function() {
var into = $(this);
into.append('' message '');
$('span.wpcf7-not-valid-tip').mouseover(function() {
$(this).fadeout('fast');
});
into.find(':input').mouseover(function() {
into.find('.wpcf7-not-valid-tip').not(':hidden').fadeout('fast');
});
into.find(':input').focus(function() {
into.find('.wpcf7-not-valid-tip').not(':hidden').fadeout('fast');
});
});
};
$.fn.wpcf7onloadrefill = function() {
return this.each(function() {
var url = $(this).attr('action');
if (0 < url.indexof('#'))
url = url.substr(0, url.indexof('#'));
var id = $(this).find('input[name="_wpcf7"]').val();
var unittag = $(this).find('input[name="_wpcf7_unit_tag"]').val();
$.getjson(url,
{ _wpcf7_is_ajax_call: 1, _wpcf7: id },
function(data) {
if (data && data.captcha)
$('#' unittag).wpcf7refillcaptcha(data.captcha);
if (data && data.quiz)
$('#' unittag).wpcf7refillquiz(data.quiz);
}
);
});
};
$.fn.wpcf7refillcaptcha = function(captcha) {
return this.each(function() {
var form = $(this);
$.each(captcha, function(i, n) {
form.find(':input[name="' i '"]').clearfields();
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]);
});
});
};
$.fn.wpcf7refillquiz = function(quiz) {
return this.each(function() {
var form = $(this);
$.each(quiz, function(i, n) {
form.find(':input[name="' i '"]').clearfields();
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]);
});
});
};
$.fn.wpcf7clearresponseoutput = function() {
return this.each(function() {
$(this).find('div.wpcf7-response-output').hide().empty().removeclass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked');
$(this).find('span.wpcf7-not-valid-tip').remove();
$(this).find('img.ajax-loader').css({ visibility: 'hidden' });
});
};
})(jquery);