summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/avatar_picker.js
blob: d38e0b4abaa4931385fd1f113ce96430e7494753 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import $ from 'jquery';

export default function initAvatarPicker() {
  $('.js-choose-avatar-button').on('click', function onClickAvatar() {
    const form = $(this).closest('form');
    return form.find('.js-avatar-input').click();
  });

  $('.js-avatar-input').on('change', function onChangeAvatarInput() {
    const form = $(this).closest('form');
    const filename = $(this)
      .val()
      .replace(/^.*[\\\/]/, ''); // eslint-disable-line no-useless-escape
    return form.find('.js-avatar-filename').text(filename);
  });
}