diff options
Diffstat (limited to 'client/components/users/events.js')
-rw-r--r-- | client/components/users/events.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/client/components/users/events.js b/client/components/users/events.js new file mode 100644 index 00000000..14df9717 --- /dev/null +++ b/client/components/users/events.js @@ -0,0 +1,59 @@ +// XXX This should be handled by default (and in a better way) by useraccounts. +// See https://github.com/meteor-useraccounts/core/issues/384 +Template.atForm.onRendered(function() { + this.find('input').focus(); +}); + +Template.memberMenuPopup.events({ + 'click .js-language': Popup.open('setLanguage'), + 'click .js-logout': function(evt) { + evt.preventDefault(); + + Meteor.logout(function() { + Router.go('Home'); + }); + } +}); + +Template.setLanguagePopup.events({ + 'click .js-set-language': function(evt) { + Users.update(Meteor.userId(), { + $set: { + 'profile.language': this.tag + } + }); + evt.preventDefault(); + } +}); + +Template.profileEditForm.events({ + 'click .js-edit-profile': function() { + Session.set('ProfileEditForm', true); + }, + 'click .js-cancel-edit-profile': function() { + Session.set('ProfileEditForm', false); + }, + 'submit #ProfileEditForm': function(evt, t) { + var name = t.find('#name').value; + var bio = t.find('#bio').value; + + // trim and update + if ($.trim(name)) { + Users.update(this.profile()._id, { + $set: { + 'profile.name': name, + 'profile.bio': bio + } + }, function() { + + // update complete close profileEditForm + Session.set('ProfileEditForm', false); + }); + } + evt.preventDefault(); + } +}); + +Template.memberName.events({ + 'click .js-show-mem-menu': Popup.open('user') +}); |