events.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // XXX This should be handled by default (and in a better way) by useraccounts.
  2. // See https://github.com/meteor-useraccounts/core/issues/384
  3. Template.atForm.onRendered(function() {
  4. this.find('input').focus();
  5. });
  6. Template.memberMenuPopup.events({
  7. 'click .js-language': Popup.open('setLanguage'),
  8. 'click .js-logout': function(evt) {
  9. evt.preventDefault();
  10. Meteor.logout(function() {
  11. Router.go('Home');
  12. });
  13. }
  14. });
  15. Template.setLanguagePopup.events({
  16. 'click .js-set-language': function(evt) {
  17. Users.update(Meteor.userId(), {
  18. $set: {
  19. 'profile.language': this.tag
  20. }
  21. });
  22. evt.preventDefault();
  23. }
  24. });
  25. Template.profileEditForm.events({
  26. 'click .js-edit-profile': function() {
  27. Session.set('ProfileEditForm', true);
  28. },
  29. 'click .js-cancel-edit-profile': function() {
  30. Session.set('ProfileEditForm', false);
  31. },
  32. 'submit #ProfileEditForm': function(evt, t) {
  33. var name = t.find('#name').value;
  34. var bio = t.find('#bio').value;
  35. // trim and update
  36. if ($.trim(name)) {
  37. Users.update(this.profile()._id, {
  38. $set: {
  39. 'profile.name': name,
  40. 'profile.bio': bio
  41. }
  42. }, function() {
  43. // update complete close profileEditForm
  44. Session.set('ProfileEditForm', false);
  45. });
  46. }
  47. evt.preventDefault();
  48. }
  49. });
  50. Template.memberName.events({
  51. 'click .js-show-mem-menu': Popup.open('user')
  52. });