_signup_form.rhtml
7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<% if @block_bot %>
<div class="atention" style="font-size: 150%;">
<strong><%=_('Are you a robot?')%></strong> <br />
<%=_('Please, prove that you are human by filling the captcha.')%>
</div>
<% end %>
<% @profile_data = @person %>
<%= error_messages_for :user, :person, :header_message => _('The account could not be created') %>
<% labelled_form_for :user, @user, :html => { :multipart => true, :id => 'signup-form', :honeypot => true } do |f| %>
<input type="hidden" id="signup_time_key" name="signup_time_key" />
<script type="text/javascript">
jQuery.ajax({
type: "POST",
url: "<%= url_for :controller=>'account', :action=>'signup_time' %>",
dataType: 'json',
success: function(data) {
if (data.ok) jQuery('#signup_time_key').val(data.key);
}
});
</script>
<%= hidden_field_tag :invitation_code, @invitation_code %>
<div id='signup-form-header'>
<div id='signup-formfield-group'>
<%= label(:user, :login, _('Username'), {:class => 'formlabel'}) %>
<span id="signup-domain"><%= environment.default_hostname %>/</span>
<div id='signup-login'>
<div id='signup-login-field' class='formfield'>
<%= required text_field(:user, :login, :id => 'user_login',
:onchange => 'this.value = convToValidUsername(this.value);') %>
<div id='url-check'><p> </p></div>
</div>
<%= content_tag(:small, _('Choose your login name carefully! It will be your network access and you will not be able to change it later.'), :id => 'signup-balloon') %>
<br style="clear: both;" />
</div>
</div>
<%= observe_field 'user_login',
:url => { :action => 'check_url' },
:with => 'identifier',
:update => 'url-check',
:loading => "jQuery('#user_login').removeClass('#{validation_classes}').addClass('checking');
jQuery('#url-check').html('<p><span class=\"checking\">#{checking_message(:url)}</span></p>');",
:complete => "jQuery('#user_login').removeClass('checking')"
%>
<div id='signup-password'>
<%= required f.password_field(:password, :id => 'user_pw') %>
<%= content_tag(:small,_('Choose a password that you can remember easily. It must have at least 4 characters.'), :id => 'password-balloon') %>
<div id='fake-check'><p> </p></div>
</div>
<div id='signup-password-confirmation'>
<%= required f.password_field(:password_confirmation) %>
<%= content_tag(:small,_('We need to be sure that you filled in your password correctly. Confirm you password.'), :id => 'password-confirmation-balloon') %>
<div id='password-check'><p> </p></div>
</div>
<div id='signup-email'>
<%= required f.text_field(:email) %>
<%= content_tag(:small,_('This e-mail address will be used to contact you.'), :id => 'email-balloon') %>
<div id='email-check'><p> </p></div>
</div>
<%= observe_field "user_email",
:url => { :action => "check_email" },
:with => "address",
:update => "email-check",
:loading => "jQuery('#user_email').removeClass('#{validation_classes}').addClass('checking');
jQuery('#email-check').html('<p><span class=\"checking\">#{checking_message(:email)}</span></p>');",
:complete => "jQuery('#user_email').removeClass('checking')",
:before => "var field = jQuery('#user_email');
if (field.val()=='') {
field.removeClass('#{validation_classes}');
jQuery('#email-check').html('<p> </p>');
return false;
}
if (!( field.valid() )) {
field.removeClass('#{validation_classes}').addClass('invalid');
jQuery('#email-check').html('<p><span class=\"invalid\">#{_('This e-mail address is not valid')}</span></p>');
return false;
}"
%>
<div id='signup-name'>
<%= labelled_form_field(_('Full name'), text_field(:profile_data, :name)) %>
<%= content_tag(:small,_('Tell us your name, it will be used to identify yourself.'), :id => 'name-balloon') %>
</div>
</div>
<div id="signup-form-profile">
<% labelled_fields_for :profile_data, @person do |f| %>
<%= render :partial => 'profile_editor/person_form', :locals => {:f => f} %>
<% end %>
<%= @plugins.dispatch(:signup_extra_contents).collect { |content| instance_eval(&content) }.join("") %>
<%= template_options(:people, 'profile_data') %>
<% unless @terms_of_use.blank? %>
<div id='terms-of-use-box' class='formfieldline'>
<%= labelled_check_box(_('I accept the %s') % link_to(_('terms of use'), {:controller => 'home', :action => 'terms'}, :target => '_blank'), 'user[terms_accepted]') %>
</div>
<% end %>
<% if params[:enterprise_code] %>
<%= hidden_field_tag :enterprise_code, params[:enterprise_code] %>
<%= hidden_field_tag :answer, params[:answer] %>
<%= hidden_field_tag :terms_accepted, params[:terms_accepted] %>
<%= hidden_field_tag :new_user, true %>
<% end %>
</div>
<%= recaptcha_tags :ajax => true, :display => {:theme => 'clean'} if @block_bot %>
<p style="text-align: center">
<%= submit_button('save', _('Create my account')) %>
</p>
<% end -%>
<script type="text/javascript">
jQuery(function($) {
$('#signup-form #user_login').css('width', 335 - $('#signup-domain').outerWidth());
$('#signup-form input[type=text], #signup-form textarea').each(function() {
$(this).bind('blur', function() {
if ($(this).val() == '') {
$(this).removeClass('filled-in');
}
else $(this).addClass('filled-in');
});
});
$('#user_pw').focus(function() {
$('#password-balloon').fadeIn('slow');
});
$('#user_password_confirmation').focus(function() {
$('#password-confirmation-balloon').fadeIn('slow');
});
$('#user_password_confirmation, #user_pw').blur(function() {
if ($('#user_password_confirmation').val() != '') {
if ($('#user_password_confirmation').val() == $('#user_pw').val()) {
$('#user_password_confirmation').addClass('validated').removeClass('invalid');
$('#user_pw').removeClass('invalid_input').addClass('valid_input');
$('#password-check').html("<p> </p>");
} else if ($('#user_password_confirmation').val() != $('#user_pw').val()) {
$('#user_password_confirmation').removeClass('validated').addClass('invalid');
$('#user_pw').addClass('invalid_input').removeClass('valid_input');
$('#password-check').html("<p><span class='invalid'><%= _('Passwords don\'t match') %></span></p>");
}
}
$('#password-balloon').fadeOut('slow');
$('#password-confirmation-balloon').fadeOut('slow');
});
$('#user_login').focus(function() {
$('#signup-balloon').fadeIn('slow');
});
$('#user_login').blur(function() { $('#signup-balloon').fadeOut('slow'); });
$('#signup-form').validate({ rules: { 'user[email]': { email: true } }, messages: { 'user[email]' : '' } });
$('#user_email').focus(function() {
$('#email-balloon').fadeIn('slow');
});
$('#user_email').blur(function() {
$('#email-balloon').fadeOut('slow');
});
$('#profile_data_name').focus(function() {
$('#name-balloon').fadeIn('slow');
});
$('#profile_data_name').blur(function() {
$('#name-balloon').fadeOut('slow');
if ($(this).val() == '') {
$(this).removeClass('validated');
}
else $(this).addClass('validated');
});
});
</script>