diff options
author | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-07-21 19:47:16 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-07-21 12:47:16 +0200 |
commit | f2390e2803248ba8e37ee5bd50c36051552773e3 (patch) | |
tree | 94fb055f8bdcf30b9258aed402900317670bc3ed /app/javascript/packs | |
parent | dbaa6a0e13b66ebd7cb0a622db55471f63da3d2f (diff) |
Dynamicaly change avatar and header bg from account setting (#4289)
Diffstat (limited to 'app/javascript/packs')
-rw-r--r-- | app/javascript/packs/public.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index a2ed086f1..da1f550fc 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -88,6 +88,20 @@ function main() { noteCounter.textContent = 160 - length(target.value); } }); + + delegate(document, '#account_avatar', 'change', ({ target }) => { + const avatar = document.querySelector('.card.compact .avatar img'); + const [file] = target.files || []; + const url = URL.createObjectURL(file); + avatar.src = url; + }); + + delegate(document, '#account_header', 'change', ({ target }) => { + const header = document.querySelector('.card.compact'); + const [file] = target.files || []; + const url = URL.createObjectURL(file); + header.style.backgroundImage = `url(${url})`; + }); } loadPolyfills().then(main).catch(error => { |