3112: report issue works for no user and inactive user cases.
[arvados.git] / apps / workbench / app / views / users / setup_popup.js.erb
1 $("#user-setup-modal-window").html("<%= escape_javascript(render partial: 'setup_popup') %>");
2
3 // disable the submit button on load
4 var $input = $('input:text'),
5 $register = $('#register');
6
7 var email_disabled = document.forms["setup_form"]["email"].disabled;
8 var email_value = document.forms["setup_form"]["email"].value;
9 var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
10 if ((email_disabled == false) && (email_value == null || email_value == "" ||
11         prefix_value == null || prefix_value == "")) {
12   $register.attr('disabled', true);
13 }
14
15 // capture events to enable submit button when applicable
16 $input.on('keyup paste mouseleave', function() {
17   var trigger = false;
18
19   var email_disabled = document.forms["setup_form"]["email"].disabled;
20   var email_value = document.forms["setup_form"]["email"].value;
21   var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
22
23   var emailRegExp = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
24   var validEmail = false;
25  
26   if (emailRegExp.test(email_value )) {
27     validEmail = true;
28   }
29
30   if ((email_disabled == false) && (!validEmail || email_value == null ||
31             email_value == "" || prefix_value == null || prefix_value == "")){
32     trigger = true;
33   }
34
35   trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
36 });
37
38 // reset form input fields, for the next time around
39 function reset_form() {
40   $('#email').val("");
41   $('#openid_prefix').val("");
42   $('#repo_name').val("");
43   $('select').val('')
44 }