debian-mirror-gitlab/app/assets/javascripts/avatar_picker.js

17 lines
536 B
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2019-05-18 00:54:41 +05:30
export default function initAvatarPicker() {
$('.js-choose-avatar-button').on('click', function onClickAvatar() {
2018-03-17 18:26:18 +05:30
const form = $(this).closest('form');
2019-05-18 00:54:41 +05:30
return form.find('.js-avatar-input').click();
2018-03-17 18:26:18 +05:30
});
2019-05-18 00:54:41 +05:30
$('.js-avatar-input').on('change', function onChangeAvatarInput() {
2018-03-17 18:26:18 +05:30
const form = $(this).closest('form');
2018-12-13 13:39:08 +05:30
const filename = $(this)
.val()
.replace(/^.*[\\\/]/, ''); // eslint-disable-line no-useless-escape
2018-03-17 18:26:18 +05:30
return form.find('.js-avatar-filename').text(filename);
});
}