| 1 |
/* Form submission functions for the MailChimp Widget */ |
| 2 |
;(function($){ |
| 3 |
$(function($) { |
| 4 |
// Change our submit type from HTML (default) to JS |
| 5 |
$('#mc_submit_type').val('js'); |
| 6 |
|
| 7 |
// Attach our form submitter action |
| 8 |
$('#mc_signup_form').ajaxForm({ |
| 9 |
url: mailchimpSF.ajax_url, |
| 10 |
type: 'POST', |
| 11 |
dataType: 'text', |
| 12 |
beforeSubmit: mc_beforeForm, |
| 13 |
success: mc_success |
| 14 |
}); |
| 15 |
}); |
| 16 |
|
| 17 |
function mc_beforeForm(){ |
| 18 |
// Disable the submit button |
| 19 |
$('#mc_signup_submit').attr("disabled","disabled"); |
| 20 |
} |
| 21 |
function mc_success(data){ |
| 22 |
// Re-enable the submit button |
| 23 |
$('#mc_signup_submit').removeAttr("disabled"); |
| 24 |
|
| 25 |
// Put the response in the message div |
| 26 |
$('#mc_message').html(data); |
| 27 |
|
| 28 |
// See if we're successful, if so, wipe the fields |
| 29 |
var reg = new RegExp("class='mc_success_msg'", 'i'); |
| 30 |
if (reg.test(data)){ |
| 31 |
$('#mc_signup_form').each(function(){ |
| 32 |
this.reset(); |
| 33 |
}); |
| 34 |
$('#mc_submit_type').val('js'); |
| 35 |
} |
| 36 |
$.scrollTo('#mc_signup', {offset: {top: -28}}); |
| 37 |
} |
| 38 |
})(jQuery); |
| 39 |
|