-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcomponent.html
206 lines (181 loc) · 7.32 KB
/
component.html
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!--Add this in Customize - Themes - Components - <head> -->
<!-- don't forget to change 'sitekey' to actual sitekey -->
<script src="https://www.google.com/recaptcha/api.js?render=explicit&hl=en" async defer ></script>
<script type="text/x-handlebars" data-template-name="modal/create-account">
{{#create-account email=accountEmail disabled=submitDisabled }}
{{#unless complete}}
{{plugin-outlet name="create-account-before-modal-body"}}
{{#d-modal-body title="create_account.title" class=(concat (if hasAtLeastOneLoginButton "has-alt-auth") " " (if userFields "has-user-fields"))}}
{{#unless hasAuthOptions}}
{{login-buttons externalLogin=(action "externalLogin")}}
{{/unless}}
{{#if showCreateForm}}
<div class="login-form">
<form id="no-enter-form" {{action "" on="submit" }}>
<table>
<tr class="input create-account-email">
<td class="label"><label for='new-account-email'>{{i18n 'user.email.title'}}</label></td>
<td>
{{input type="email" value=accountEmail id="new-account-email" disabled=emailValidated name="email" autofocus="autofocus"}}
</td>
</tr>
<tr class="instructions create-account-email">
<td></td>
{{input-tip validation=emailValidation id="account-email-validation"}}
<td><label>{{i18n 'user.email.instructions'}}</label></td>
</tr>
{{#if usernameRequired}}
<tr class="input">
<td class="label"><label for='new-account-username'>{{i18n 'user.username.title'}}</label></td>
<td>
{{input value=accountUsername id="new-account-username" name="username" maxlength=maxUsernameLength autocomplete="discourse"}}
</td>
</tr>
<tr class="instructions">
<td></td>
{{input-tip validation=usernameValidation id="username-validation"}}
<td><label>{{i18n 'user.username.instructions'}}</label></td>
</tr>
{{/if}}
{{#if fullnameRequired}}
<tr class="input">
<td class="label">
<label for='new-account-name'>{{i18n 'user.name.title'}}</label>
</td>
<td>
{{text-field value=accountName id="new-account-name"}}
</td>
</tr>
<tr class="instructions">
<td></td>
{{input-tip validation=nameValidation}}
<td><label>{{nameInstructions}}</label></td>
</tr>
{{/if}}
{{plugin-outlet name="create-account-before-password"
noTags=true
args=(hash accountName=accountName
accountUsername=accountUsername
accountPassword=accountPassword
userFields=userFields)}}
{{#if passwordRequired}}
<tr class="input">
<td class="label"><label for='new-account-password'>{{i18n 'user.password.title'}}</label></td>
<td>
{{password-field value=accountPassword type="password" id="new-account-password" capsLockOn=capsLockOn}}
</td>
</tr>
<tr class="instructions">
<td></td>
{{input-tip validation=passwordValidation}}
<td>
<label>{{passwordInstructions}}</label>
<div class="caps-lock-warning {{unless capsLockOn 'hidden'}}">
{{d-icon "exclamation-triangle"}} {{i18n 'login.caps_lock_warning'}}</div>
</td>
</tr>
{{/if}}
{{plugin-outlet name="create-account-after-password"
noTags=true
args=(hash accountName=accountName
accountUsername=accountUsername
accountPassword=accountPassword
userFields=userFields)}}
<tr>
<td>
<div class="g-recaptcha" id="recaptcha" data-sitekey="sitekey"></div>
<input type="hidden" value="" id="gr-ver" />
</td>
</tr>
</table>
{{#if userFields}}
<div class='user-fields'>
{{#each userFields as |f|}}
{{user-field field=f.field value=f.value}}
{{/each}}
</div>
{{/if}}
</form>
</div>
{{/if}}
{{/d-modal-body}}
{{#if showCreateForm}}
<div class="modal-footer">
<button class='btn btn-large btn-primary' id="btn-sign-up" disabled={{submitDisabled}} {{action "createAccount"}}>{{i18n 'create_account.title'}}</button>
{{#conditional-loading-spinner condition=formSubmitted size="small"}}
{{#d-button class="btn btn-large" id="login-link" action=(route-action "showLogin")}}
{{i18n "log_in"}}
{{/d-button}}
{{/conditional-loading-spinner}}
<div class='disclaimer'>{{{disclaimerHtml}}}</div>
</div>
{{/if}}
{{/unless}}
{{/create-account}}
</script>
<script type="text/javascript">
$(document).ready(function() {
$('.sign-up-button').click(function() {
_captchaTries = 0;
recaptchaOnLoad();
});
});
function signUpClick() {
var grecaptchaResponse = grecaptcha.getResponse();
var btn = $('#btn-sign-up');
btn.prop('disabled', true);
$.ajax({
url: '/grverify',
type: 'POST',
dataType: 'json',
data: {
recaptcha_response: grecaptchaResponse
},
success: function (res) {
console.log(res);
var enabled = btn.prop('disabled');
var verified = res.verify;
if (enabled && verified) {
btn.prop('disabled', false);
$('#gr-ver').val('yes');
}
},
error: function (jqXHR, exception) {
console.log('failure'); console.log(jqXHR); console.log(exception);
btn.prop('disabled', true);
}
});
//});
}
function recaptchaOnLoad() {
_captchaTries++;
if(_captchaTries > 9)
return;
if ($('.ember-text-field').length > 1) {
$('#no-enter-form').on('keyup keypress', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode === 13) {
e.preventDefault();
return false;
}
});
$('.ember-text-field').change(function(){
$('#btn-sign-up').prop('disabled', true);
if ( $('.tip.good').length == 4 && $('#gr-ver').val == 'yes') {
$('#btn-sign-up').prop('disabled', false);
}
});
}
if ( $('.g-recaptcha').length > 0 ) {
grecaptcha.render("recaptcha", {
sitekey: "sitekey",
callback: function() {
console.log('rec callback');
signUpClick();
}
});
return;
}
window.setTimeout(recaptchaOnLoad, 1000);
}
</script>