This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.js
40 lines (37 loc) · 1.57 KB
/
profile.js
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
$(document).ready(function () {
$imgSrc = $('#imgProfile').attr('src');
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imgProfile').attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
$('#btnChangePicture').on('click', function () {
// document.getElementById('profilePicture').click();
if (!$('#btnChangePicture').hasClass('changing')) {
$('#profilePicture').click();
}
else {
// change
}
});
$('#profilePicture').on('change', function () {
readURL(this);
$('#btnChangePicture').addClass('changing');
$('#btnChangePicture').attr('value', 'Confirm');
$('#btnDiscard').removeClass('d-none');
// $('#imgProfile').attr('src', '');
});
$('#btnDiscard').on('click', function () {
// if ($('#btnDiscard').hasClass('d-none')) {
$('#btnChangePicture').removeClass('changing');
$('#btnChangePicture').attr('value', 'Change');
$('#btnDiscard').addClass('d-none');
$('#imgProfile').attr('src', $imgSrc);
$('#profilePicture').val('');
// }
});
});