2018-03-09 15:18:59 -05:00
|
|
|
import $ from 'jquery';
|
|
|
|
|
2019-03-14 16:52:01 -04:00
|
|
|
export default function initAvatarPicker() {
|
|
|
|
$('.js-choose-avatar-button').on('click', function onClickAvatar() {
|
2017-10-23 09:05:53 -04:00
|
|
|
const form = $(this).closest('form');
|
2019-03-14 16:52:01 -04:00
|
|
|
return form.find('.js-avatar-input').click();
|
2017-10-23 09:05:53 -04:00
|
|
|
});
|
2019-03-14 16:52:01 -04:00
|
|
|
|
|
|
|
$('.js-avatar-input').on('change', function onChangeAvatarInput() {
|
2017-10-23 09:05:53 -04:00
|
|
|
const form = $(this).closest('form');
|
2018-10-24 15:17:03 -04:00
|
|
|
const filename = $(this)
|
|
|
|
.val()
|
|
|
|
.replace(/^.*[\\\/]/, ''); // eslint-disable-line no-useless-escape
|
2017-10-23 09:05:53 -04:00
|
|
|
return form.find('.js-avatar-filename').text(filename);
|
|
|
|
});
|
|
|
|
}
|