You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Profile.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* global $ */
  2. import UIUtil from "../../util/UIUtil";
  3. import UIEvents from "../../../../service/UI/UIEvents";
  4. import Settings from '../../../settings/Settings';
  5. export default {
  6. init (emitter) {
  7. // DISPLAY NAME
  8. function updateDisplayName () {
  9. emitter.emit(UIEvents.NICKNAME_CHANGED, $('#setDisplayName').val());
  10. }
  11. $('#setDisplayName')
  12. .val(Settings.getDisplayName())
  13. .keyup(function (event) {
  14. if (event.keyCode === 13) { // enter
  15. updateDisplayName();
  16. }
  17. })
  18. .focusout(updateDisplayName);
  19. // EMAIL
  20. function updateEmail () {
  21. emitter.emit(UIEvents.EMAIL_CHANGED, $('#setEmail').val());
  22. }
  23. $('#setEmail')
  24. .val(Settings.getEmail())
  25. .keyup(function (event) {
  26. if (event.keyCode === 13) { // enter
  27. updateEmail();
  28. }
  29. }).focusout(updateEmail);
  30. },
  31. /**
  32. * Check if settings menu is visible or not.
  33. * @returns {boolean}
  34. */
  35. isVisible () {
  36. return UIUtil.isVisible(document.getElementById("profile_container"));
  37. },
  38. /**
  39. * Change user display name in the settings menu.
  40. * @param {string} newDisplayName
  41. */
  42. changeDisplayName (newDisplayName) {
  43. $('#setDisplayName').val(newDisplayName);
  44. },
  45. /**
  46. * Change user avatar in the settings menu.
  47. * @param {string} avatarUrl url of the new avatar
  48. */
  49. changeAvatar (avatarUrl) {
  50. $('#avatar').attr('src', avatarUrl);
  51. }
  52. };