From 5dd793cdaadc0456892673ee70a04df774bae522 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 26 Feb 2016 15:11:13 +0100 Subject: Improve forms --- js/codeq/login.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'js/codeq') diff --git a/js/codeq/login.js b/js/codeq/login.js index 5f6aa4c..ff217c5 100644 --- a/js/codeq/login.js +++ b/js/codeq/login.js @@ -25,8 +25,8 @@ along with this program. If not, see . */ jqNavBarRight = $('.nav.navbar-nav.navbar-right'), jqNavigationHomeBtn = $('#navigation-home'), jqAAILoginBtn = $('#aai_login_button'), + jqLoginForm = $('#login-form'), jqSignupBtn = $('#signup_button'), - jqSubmitLoginBtn = $("#submit"), jqLangSelect = jqScreen.find('.lang-select'), jqDisabledOverlay = $('#disabled'), jqLoginFailed = jqScreen.find('.login-failed'); @@ -61,7 +61,7 @@ along with this program. If not, see . */ codeq.globalStateMachine.transition('language'); }; - var loginFun = function(){ + var loginFun = function() { jqLoginFailed.hide(); codeq.comms.connect() .then(function () { @@ -72,8 +72,7 @@ along with this program. If not, see . */ jqLoginFailed.show(); }) .done(); - }, - formInputs = $('#username, #password'); + }; codeq.globalStateMachine.register('login',{ 'jqScreen': jqScreen, @@ -87,23 +86,21 @@ along with this program. If not, see . */ codeq.samlLogin = false;//remove saml login flag $('.saml-login-hide').css('display','');//if we login the normal way we want to show the change password buttons. if we enter the saml login they will be hidden - //setup the signup button - jqSignupBtn.on('click', function(e){ - codeq.globalStateMachine.transition('signup'); + // setup login form + jqLoginForm.on('submit', function (e) { e.preventDefault(); + loginFun(); }); - //setup the AAI login btn + // setup the AAI login btn jqAAILoginBtn.on('click',function(e){ codeq.globalStateMachine.transition('aailogin'); e.preventDefault(); }); - jqSubmitLoginBtn.on('click', loginFun); - formInputs.on('keyup', function (ev) { - if ((ev.keyCode || ev.which) == 13) { - jqSubmitLoginBtn.trigger('click'); - } + // setup the signup button + jqSignupBtn.on('click', function(e){ + codeq.globalStateMachine.transition('signup'); + e.preventDefault(); }); - // setup language selection links jqLangSelect.on('click', function (e) { codeq.setLang($(this).data('lang')); @@ -115,8 +112,7 @@ along with this program. If not, see . */ }, 'exit' : function(){ //remove the listener from the buttons specific to this page - jqSubmitLoginBtn.off('click', loginFun); - formInputs.off('keyup'); + jqLoginForm.off('submit'); jqSignupBtn.off('click'); jqAAILoginBtn.off('click'); jqLangSelect.off('click'); -- cgit v1.2.1