-
Notifications
You must be signed in to change notification settings - Fork 7
/
profile.handlebars
378 lines (346 loc) · 17.7 KB
/
profile.handlebars
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<style type="text/css">
.cropit-preview {
/* You can specify preview size in CSS */
width: 200px;
height: 200px;
}
</style>
{{> orgheader}}
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ><a href="/organizations/{{organization.entry.name}}" role="tab" ><i class="fas fa-list"></i> Summary</a></li>
<li role="presentation" ><a href="/organizations/{{organization.entry.name}}/people" role="tab"><i class="fas fa-users"></i> People</a></li>
{{#if orgowner}}
<li role="presentation" class="active"><a href="/organizations/{{organization.entry.name}}/settings/profile" role="tab"><i class="fas fa-cog"></i> Settings</a></li>
{{else}}
{{/if}}
</ul>
<div class="row" style="padding-top: 25px">
<div class="col-md-3" id="navMenuPanel">
<div class="panel panel-default">
<div class="panel-heading">
Organization settings
</div>
<ul class="list-group">
<a href="/organizations/{{organization.entry.name}}/settings/profile" class="list-group-item active">Profile</a>
<a href="/organizations/{{organization.entry.name}}/settings/member_privileges" class="list-group-item">Member privileges</a>
<a href="/organizations/{{organization.entry.name}}/settings/billing" class="list-group-item ">Billing - Braintree</a>
<a href="/organizations/{{organization.entry.name}}/settings/billing-paypal" class="list-group-item ">Billing - PayPal</a>
</ul>
</div>
</div>
<div class="col-md-9" id="browserArea">
{{#if messages.success}}
<div role="alert" class="alert alert-success">
{{#each messages.success}}
<div>{{msg}}</div>
{{/each}}
</div>
{{/if}}
{{#if messages.error}}
<div role="alert" class="alert alert-danger">
{{#each messages.error}}
<div>{{msg}}</div>
{{/each}}
</div>
{{/if}}
<form method="POST" action="/organizations/{{organization.entry.name}}/?_method=PUT" class="auto-approve" >
<h2>Organizational Profile</h2>
<hr>
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label for="displayname" class="col-sm-12">Organization username</label>
<div class="col-sm-11 form-group">
<input type="displayname" name="name" id="name"
class="form-control" value="{{organization.entry.name}}">
<p class="help-block">Organization name changes can have unforeseen consequences. <a class="btn btn-default btn-xs" href="/contact" >Request new name</a></p>
</div>
</div>
<div class="form-group">
<label for="displayname" class="col-sm-12">Display name</label>
<div class="col-sm-11 form-group">
<input type="displayname" name="displayname" id="displayname" class="form-control" value="{{organization.entry.displayname}}" >
</div>
</div>
{{#if organization.entry.business_billing_name.length}}
<div class="form-group">
<div class="col-sm-11 form-group">
<div class="col-md-12">
<div class="form-group">
<label for="displayname" class="col-sm-12">Billing Name</label>
<input type="text" name="business_billing_name" id="business_billing_name" class="form-control" value="{{organization.entry.business_billing_name}}">
<p class="help-block">What is the name of the business that owns this account? e.g, Acme, Inc.</p>
</div>
</div>
</div>
</div>
{{else}}
<div class="form-group">
<div class="col-sm-11 form-group">
<input type="checkbox" name="chkBox1" id="chkBox1" class="showHideCheck" /> This account is owned by a business (see the <a href="/terms" target="_blank">terms of service</a> for details).
<p></p>
<div class="hiddenInput">
<div class="col-md-12">
<div class="form-group">
<label for="displayname" class="col-sm-12">Billing Name</label>
<input type="text" name="business_billing_name" id="business_billing_name" class="form-control" value="{{organization.entry.business_billing_name}}">
<p class="help-block">What is the name of the business that owns this account? e.g, Acme, Inc.</p>
</div>
</div>
</div>
</div>
</div>
{{/if}}
<div class="form-group">
<label for="displayemail" class="col-sm-12">Email (will be public)</label>
<div class="col-sm-11 form-group">
<input type="email" name="displayemail" id="displayemail" data-validate='{
"title":"Email",
"required": true,
"email": true
}' class="form-control" value="{{organization.entry.displayemail}}">
</div>
</div>
<div class="form-group">
<label for="displayname" class="col-sm-12">Description</label>
<div class="col-sm-11 form-group">
<textarea type="description" rows="3" name="description" id="description" class="form-control" >{{organization.entry.description}}</textarea>
</div>
</div>
<div class="form-group">
<label for="displayname" class="col-sm-12">Url</label>
<div class="col-sm-11 form-group">
<input type="url" name="url" id="url" class="form-control" data-validate='{
"title":"website",
"url": true
}' value="{{organization.entry.url}}" >
</div>
</div>
<div class="form-group">
<label for="location" class="col-md-12">Location</label>
<div class="col-md-11">
<select type="text" name="location" id="location" class="form-control" value="{{organization.entry.location}}"></select>
<p class="help-block">We store your organizational data in South Africa. See our <a href="/privacy">privacy policy</a> for more information. </p>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-12">Billing email (Private)</label>
<div class="col-sm-11 form-group">
<input type="email" name="email" data-validate='{
"title":"Email",
"email": true
}' id="email" class="form-control" value="{{organization.entry.email}}">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<button type="submit" id="export" class="btn btn-default">Update Profile</button>
</div>
</div>
</div>
<div class="col-md-4">
<style type="text/css">
/* Limit image width to avoid overflow the container */
img {
max-width: 100%; /* This rule is very important, please do not ignore this! */
}
</style>
<div class="form-group">
<div class="col-sm-12">
<h4>Profile Picture</h4>
<!-- This wraps the whole cropper -->
<div id="image-cropper" >
<!-- This is where the preview image is displayed -->
<div class="cropit-preview" style="border: 1px solid #eee;position: relative;text-align: center;"><img id="image" style="padding-top: 15px"></div>
<!-- This is where user selects new image -->
<p></p>
<input type="file" class="cropit-image-input" />
<input style="display:none" name="croppedImg" id="croppedImg"/>
<!-- The cropit- classes above are needed
so cropit can identify these elements -->
</div>
<p></p>
</div>
</div>
</div>
</div>
</form>
<div class="form-group">
<h3 style="color:#d9534f">Delete Organization</h3>
<hr style="color:#d9534f">
<form method="POST" action="" class="form-horizontal">
<div class="form-group">
<p class=" col-sm-9" style="color:#d9534f">You can delete this organization, but keep in mind this action is irreversible.</p>
<div class=" col-sm-9">
<!-- Button trigger modal -->
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal" id="{{organization._id}}" onclick="deleteOrgnaization(this.id)">
Delete {{organization.entry.name}}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content" id="modalTextArea">
</div>
</div>
</div>
<style type="text/css">
form.auto-approve {
.form-group {
.error-text {
opacity: 0;
color: #d9534f;
transition: opacity 0.5s linear;
}
&.has-error .error-text {
opacity: 1;
}
}
}
</style>
<script type="text/javascript">
function activate(){
$('#name').prop('disabled', false);
}
{{#if organization.entry.image}}
var imageSrc = '{{{organization.entry.image}}}'
{{else}}
var imageSrc = '{{{organization.gravatar}}}'
{{/if}}
////////////////////////
///// INITIALIZE //////
//////////////////////
$(document).ready( function() {
$("#image").attr("src", imageSrc);
$('#export').click(function(){
var imageData = $("#image").cropper('getCroppedCanvas', {
width: 350,
height: 350,
imageSmoothingEnabled: false,
imageSmoothingQuality: 'high',
guides :false,
autoCropArea:1,
}).toDataURL('image/jpeg')
$('#croppedImg').val(imageData);
})
$('#image').cropper({
aspectRatio: 1 / 1,
guides :false,
autoCropArea:1,
crop: function(e) {
}
});
$(function () {
$(":file").change(function () {
if (this.files && this.files[0]) {
var reader = new FileReader();
reader.onload = imageIsLoaded;
reader.readAsDataURL(this.files[0]);
}
});
});
function imageIsLoaded(e) {
$('#image').cropper('destroy')
$('#image').attr('src', e.target.result);
$('#image').cropper({
aspectRatio: 1 / 1,
guides :false,
autoCropArea:1,
crop: function(e) {
}
});
};
});
/////////////////////////////////////
//// KICK MEMBER ////
///////////////////////////////////
function deleteOrgnaization(ids){
var html = '<div style="color:#d9534f" class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel"><i class="fa fa-trash-o" aria-hidden="true"></i> Delete this Organization.</h4> </div> <div class="modal-body" style="color:#d9534f"> <p>Are you sure you wish to delete <strong>{{organization.entry.name}}</strong>? This action cannot be undone.</p> <div style="text-align: center"> <div id="modelHtml"></div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div>'
$('#modalTextArea').html(html)
$('#modelHtml').html('<a href="/deleteorganiztion/'+ids+'" class="btn btn-danger">Delete {{organization.entry.name}}</a>')
}
///////////////////////////////////////////////////
//// BILLING ADDRESS SHOW/HIDE ////
/////////////////////////////////////////////////
$(".hiddenInput").hide();
$(".showHideCheck").on("change", function() {
$this = $(this);
$input = $this.parent().find(".hiddenInput");
if($this.is(":checked")) {
$input.slideDown();
} else {
$input.slideUp();
}
});
/////////////////////////////////////////////////////
//// POPULATE THE COUNTRY SELECT ////
///////////////////////////////////////////////////
var country_arr = new Array("Afghanistan", "Albania", "Algeria", "American Samoa", "Angola", "Anguilla", "Antartica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Ashmore and Cartier Island", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Clipperton Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo, Democratic Republic of the", "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czeck Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Europa Island", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern and Antarctic Lands", "Gabon", "Gambia, The", "Gaza Strip", "Georgia", "Germany", "Ghana", "Gibraltar", "Glorioso Islands", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (Vatican City)", "Honduras", "Hong Kong", "Howland Island", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Ireland, Northern", "Israel", "Italy", "Jamaica", "Jan Mayen", "Japan", "Jarvis Island", "Jersey", "Johnston Atoll", "Jordan", "Juan de Nova Island", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia, Former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Man, Isle of", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Midway Islands", "Moldova", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcaim Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romainia", "Russia", "Rwanda", "Saint Helena", "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Scotland", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and South Sandwich Islands", "Spain", "Spratly Islands", "Sri Lanka", "Sudan", "Suriname", "Svalbard", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Tobago", "Toga", "Tokelau", "Tonga", "Trinidad", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "Uruguay", "USA", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "Wales", "Wallis and Futuna", "West Bank", "Western Sahara", "Yemen", "Yugoslavia", "Zambia", "Zimbabwe","None");
populateCountries("location");
function populateCountries(countryElementId, stateElementId) {
// given the id of the <select> tag as function argument, it inserts <option> tags
var countryElement = document.getElementById(countryElementId);
countryElement.length = 0;
if ('{{organization.entry.location}}' == -1) {
countryElement.options[0] = new Option('None', '-1');
} else {
countryElement.options[0] = new Option('{{organization.entry.location}}', '-1');
}
countryElement.selectedIndex = 0;
for (var i = 0; i < country_arr.length; i++) {
countryElement.options[countryElement.length] = new Option(country_arr[i], country_arr[i]);
}
}
</script>
<script type="text/javascript">
$('form.auto-approve [data-validate]').blur(function () {
validate(this);
});
$('form.auto-approve').submit(function (event) {
validate(this);
var errorItems = $('.has-error', this);
if (errorItems.length > 0) {
$('html, body').animate({
scrollTop: $(errorItems[0]).offset().top
}, 500);
event.preventDefault();
}
});
function validate(item) {
if ($(item).is('form')) {
$.each($('form.auto-approve [data-validate]'), function () {validate(this)});
return;
}
var result = approve.value(getValue(item), $(item).data('validate'));
if (!result.approved) {
var errors = "";
for (var error in result.errors) {
errors = result.errors[error] + "<br/>";
}
var errorDiv = $("<div class='control-label error-text'></div>").html(errors);
$(item).closest('.form-group').find('.error-text').remove();
$(item).closest('.form-group').append(errorDiv).addClass('has-error');
} else {
$(item).closest('.form-group').removeClass('has-error').find('.error-text').remove();
}
}
function getValue(item) {
// input types button, reset, submit, hidden, and image don't really make sense to validate, so I didn't test them
// radio buttons
if ($(item).is('[type=radio]')) {
var name = $(item).attr('name');
return $('input[name=' + name + ']:checked').val();
}
// checkboxes
if ($(item).is('[type=checkbox]')) {
return $(item).is(':checked');
}
// textarea, select, input(text, checkbox, color, date, datetime-local, email, file, month, number, password, range, search, tel, time, url, week)
return $(item).val();
};
</script>