Created
September 10, 2015 01:30
-
-
Save jaxbot/95c7720cbea4c91cb04b to your computer and use it in GitHub Desktop.
This file contains 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
if (!window.Bastide) window.Bastide = {}; | |
window.Bastide.Registration = { | |
signup: function() { | |
var nameInput = document.querySelector('#signUpModal .name'), | |
emailInput = document.querySelector('#signUpModal .email'), | |
schoolInput = document.querySelector('#signUpModal .school'); | |
var params = { | |
name: nameInput.value, | |
email: emailInput.value, | |
school: schoolInput.value, | |
}; | |
var error = false; | |
if (!params.name) { | |
error = true; | |
nameInput.className += " invalid"; | |
} | |
if (!params.email || !Bastide.Helpers.validateEmail(params.email)) { | |
error = true; | |
emailInput.className += " invalid"; | |
} | |
if (!params.school) { | |
error = true; | |
schoolInput.className += " invalid"; | |
} | |
var errorMessage = document.querySelector('#signUpModal .errors'); | |
if (error) { | |
errorMessage.className += ' visible'; | |
return false; | |
} else { | |
errorMessage.className = errorMessage.className.replace(/ visible/g, ''); | |
} | |
if (window.DEV) | |
_handleSignupCompleted(); | |
else | |
Bastide.ajax("/api/registration/signup", params, _handleSignupCompleted); | |
} | |
}; | |
function _handleSignupCompleted(data) { | |
$('#signUpModal').foundation('reveal', 'close'); | |
$('#signUpCompletedModal').foundation('reveal', 'open'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment