events.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. Template.memberMenuPopup.events({
  2. 'click .js-language': Popup.open('setLanguage'),
  3. 'click .js-logout': function(evt) {
  4. evt.preventDefault();
  5. Meteor.logout(function() {
  6. Router.go('Home');
  7. });
  8. }
  9. });
  10. Template.setLanguagePopup.events({
  11. 'click .js-set-language': function(evt) {
  12. Users.update(Meteor.userId(), {
  13. $set: {
  14. 'profile.language': this.tag
  15. }
  16. });
  17. evt.preventDefault();
  18. }
  19. });
  20. Template.profileEditForm.events({
  21. 'click .js-edit-profile': function() {
  22. Session.set('ProfileEditForm', true);
  23. },
  24. 'click .js-cancel-edit-profile': function() {
  25. Session.set('ProfileEditForm', false);
  26. },
  27. 'submit #ProfileEditForm': function(evt, t) {
  28. var name = t.find('#name').value;
  29. var bio = t.find('#bio').value;
  30. // trim and update
  31. if ($.trim(name)) {
  32. Users.update(this.profile()._id, {
  33. $set: {
  34. 'profile.name': name,
  35. 'profile.bio': bio
  36. }
  37. }, function() {
  38. // update complete close profileEditForm
  39. Session.set('ProfileEditForm', false);
  40. });
  41. }
  42. evt.preventDefault();
  43. }
  44. });
  45. Template.memberName.events({
  46. 'click .js-show-mem-menu': Popup.open('user')
  47. });