Last active
December 15, 2015 22:29
-
-
Save MikeMcChillin/5333820 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################### | |
# Email subscribe | |
####################### | |
form = $("#subscribe") | |
form.submit (e) -> | |
e.preventDefault() | |
form.removeClass('shake') | |
$.getJSON @action + "?callback=?", $(this).serialize(), (data) -> | |
messageNode = $('.message') | |
# if there's an error... | |
if data.Status is 400 | |
invalidSubmit = $("#{form} input[type=email]").val() | |
form.addClass('shake') | |
messageNode.html("Sorry, something went wrong with the email address #{invalidSubmit}.") | |
else | |
justSubmitted = $("#{form} input[type=email]").val() | |
successEntry = "Thank You!" | |
messageNode.html("Welcome to the mailing list!") | |
if $('.email-added').length > 0 | |
$('.email-added').replaceWith(successEntry) | |
else | |
$('form input[type=submit]').val(successEntry) | |
setTimeout ( -> | |
$('form input[type=submit]').val('Submit') | |
), 1500 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="subscribe"> | |
<input type="email" /> | |
<input type="submit" /> | |
</form> | |
<p class="message"></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
form | |
::-webkit-input-placeholder | |
::-moz-placeholder | |
:-ms-input-placeholder | |
input[type="email"] | |
&:focus | |
input[type="submit"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment