billy_signup 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,78 +1,81 @@
1
1
  $(document).ready(function() {
2
2
 
3
- // auto load
4
- if($('form input[name=email]').val().length > 0) {
5
- processSignupAuthCheck();
6
- }
7
-
8
- var formAuthCheckTimer;
9
- $('form fieldset.creds input').keyup(function(e) {
10
- if(e.which != 9 && e.which != 16 && e.which != 91 && e.which != 91) {
11
- clearTimeout(formAuthCheckTimer);
12
- formAuthCheckTimer = setTimeout(processSignupAuthCheck, 500);
3
+ signupForm = $('form.signup');
4
+ if(signupForm.length){
5
+
6
+ var formAuthCheckTimer;
7
+
8
+ // auto load
9
+ if(signupForm.find('input[name=email]').val().length > 0) {
10
+ processSignupAuthCheck();
13
11
  }
14
- });
15
-
16
- $('form fieldset.creds input').change(function() {
17
- clearTimeout(formAuthCheckTimer);
18
- processSignupAuthCheck();
19
- });
20
-
21
- $('form p.exists a').on('click', function() {
22
- $.ajax({
23
- url: '/signup/reset_password',
24
- type: 'post',
25
- data: $('form').serialize(),
26
- dataType:'json',
27
- success: function(data) {
28
- if(data.status == 'sent') {
29
- $('p.exists').html('An email has been sent to <b>' + $('form input[name=email]').attr('value') + '</b> which contains a new password. You can copy this password into the password field above to continue your signup.');
30
- } else {
31
- alert('The address you entered could not be found. Please contact support if need further assistance.')
32
- }
12
+
13
+ signupForm.on('keyup', 'fieldset.creds input', function(e){
14
+ if(e.which != 9 && e.which != 16 && e.which != 91 && e.which != 91) {
15
+ clearTimeout(formAuthCheckTimer);
16
+ formAuthCheckTimer = setTimeout(processSignupAuthCheck, 500);
33
17
  }
34
18
  });
35
- return false;
36
- })
37
-
38
- });
39
-
40
19
 
41
- function processSignupAuthCheck() {
42
- console.log("Processing auth check");
43
- var form = $('form.signup');
44
- $.ajax({
45
- url: '/signup/validate_user',
46
- type: 'post',
47
- data: form.serialize(),
48
- dataType:'json',
49
- success: function(data) {
50
- if(data.email_check.status == 'available') {
51
- form.find('li.password p.label label').text('Choose a password');
52
- form.find('p.exists').hide();
53
- form.find('input[name=password]').removeClass('ok').removeClass('error');
54
- form.find('input[name=first_name]').attr('disabled', false);
55
- form.find('input[name=last_name]').attr('disabled', false);
56
- } else {
57
- form.find('li.password p.label label').text('Enter your password');
58
- form.find('p.exists b').text(data.email_check.email);
59
-
60
- if(data.authentication) {
61
- if(data.authentication.status == 'valid') {
62
- form.find('input[name=first_name]').attr('value', data.authentication.first_name).attr('disabled', true);
63
- form.find('input[name=last_name]').attr('value', data.authentication.last_name).attr('disabled', true);
64
- form.find('input[name=password]').addClass('ok').removeClass('error');
65
- form.find('p.exists').hide('fast');
20
+ signupForm.on('change', 'fieldset.creds input', function() {
21
+ clearTimeout(formAuthCheckTimer);
22
+ processSignupAuthCheck();
23
+ });
24
+
25
+ signupForm.on('click', 'p.exists a', function(){
26
+ $.ajax({
27
+ url: '/signup/reset_password',
28
+ type: 'post',
29
+ data: $('form').serialize(),
30
+ dataType:'json',
31
+ success: function(data) {
32
+ if(data.status == 'sent') {
33
+ signupForm.find('p.exists').html('An email has been sent to <b>' + signupForm.find('input[name=email]').val() + '</b> which contains a new password. You can copy this password into the password field above to continue your signup.');
66
34
  } else {
67
- form.find('input[name=password]').removeClass('ok').addClass('error');
68
- form.find('input[name=first_name]').attr('disabled', false);
69
- form.find('input[name=last_name]').attr('disabled', false);
70
- form.find('p.exists').show('fast');
35
+ alert('The address you entered could not be found. Please contact support if need further assistance.');
71
36
  }
72
- } else {
73
- form.find('p.exists').show('fast');
74
37
  }
75
- }
76
- }
77
- });
78
- }
38
+ });
39
+ return false;
40
+ });
41
+
42
+ processSignupAuthCheck = function(){
43
+ $.ajax({
44
+ url: '/signup/validate_user',
45
+ type: 'post',
46
+ data: signupForm.serialize(),
47
+ dataType:'json',
48
+ success: function(data) {
49
+ if(data.email_check.status == 'available') {
50
+ signupForm.find('li.password p.label label').text('Choose a password');
51
+ signupForm.find('p.exists').hide();
52
+ signupForm.find('input[name=password]').removeClass('ok').removeClass('error');
53
+ signupForm.find('input[name=first_name]').attr('disabled', false);
54
+ signupForm.find('input[name=last_name]').attr('disabled', false);
55
+ } else {
56
+ signupForm.find('li.password p.label label').text('Enter your password');
57
+ signupForm.find('p.exists b').text(data.email_check.email);
58
+
59
+ if(data.authentication) {
60
+ if(data.authentication.status == 'valid') {
61
+ signupForm.find('input[name=first_name]').attr('value', data.authentication.first_name).attr('disabled', true);
62
+ signupForm.find('input[name=last_name]').attr('value', data.authentication.last_name).attr('disabled', true);
63
+ signupForm.find('input[name=password]').addClass('ok').removeClass('error');
64
+ signupForm.find('input[name=account_name]').focus();
65
+ signupForm.find('p.exists').hide('fast');
66
+ } else {
67
+ signupForm.find('input[name=password]').removeClass('ok').addClass('error');
68
+ signupForm.find('input[name=first_name]').attr('disabled', false);
69
+ signupForm.find('input[name=last_name]').attr('disabled', false);
70
+ signupForm.find('p.exists').show('fast');
71
+ }
72
+ } else {
73
+ signupForm.find('p.exists').show('fast');
74
+ }
75
+ }
76
+ }
77
+ });
78
+ };
79
+
80
+ }
81
+ });
@@ -1,3 +1,3 @@
1
1
  module BillySignup
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: billy_signup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: