function Login() { var $ = jQuery.noConflict(); var TAG = 'Login.js | ', my = { $loginForm: null, $loginWrapper: null, $registrationForm: null, $submitLoginInput: null, $manualProgramCheckbox: null, $customProgramWrapper: null, $customProgramInput: null, $programSelect: null, $programSelectWrapper: null, } my.C = { FIELD_NAME: { EMAIL: 'ypsc-email', NAME: 'ypsc-name' } }; my.init = function() { console.debug(TAG + 'init'); // Selectors my.$loginWrapper = $('.ypsc-login-wrapper'); my.$registrationForm = my.$loginWrapper.find('form.registration-form'); my.$loginForm = my.$loginWrapper.find('form.login-form'); my.$submitLoginInput = my.$loginForm.find('input[type=submit]'); my.$submitRegistrationInput = my.$registrationForm.find('input[type=submit]'); my.$manualProgramCheckbox = $('#manual-program-checkbox'); my.$customProgramWrapper = my.$registrationForm.find('.ypsc-program-custom-wrapper'); my.$customProgramInput = $('#sign-up-ypsc-program-custom'); my.$programSelect = $('#sign-up-ypsc-program-select'); my.$programSelectWrapper = my.$registrationForm.find('.input-wrapper.ypsc-program-select'); // Bindings my.$submitLoginInput.on('click', my.onLoginSubmit); my.$submitRegistrationInput.on('click', my.onRegistrationSubmit); my.$manualProgramCheckbox.on('change', my.onCustomProgramCheckboxChange); // Existing validation message? my.highlightFormErrorsOnStartup(my.$loginForm); my.highlightFormErrorsOnStartup(my.$registrationForm); }; /* Methods ********************************************************************************************************/ my.formClearValidationMessages = function($form) { var $messageList = $form.find('.validation-messages'); $messageList.hide(); }; /** * * @param $form * @param messages {String[]} */ my.formDisplayValidationMessages = function($form, messages) { var $messageList = $form.find('.validation-messages'); var messagesHTML = ""; for (var i = 0; i < messages.length; i++) { messagesHTML += '