diff --git a/core/client/tpl/settings/user-profile.hbs b/core/client/tpl/settings/user-profile.hbs
index 12255a8f27..23d4bb78f5 100644
--- a/core/client/tpl/settings/user-profile.hbs
+++ b/core/client/tpl/settings/user-profile.hbs
@@ -19,7 +19,7 @@
@@ -78,7 +78,7 @@
-
+
diff --git a/core/client/views/settings.js b/core/client/views/settings.js
index 3cbbd9fbfc..4c38afbf86 100644
--- a/core/client/views/settings.js
+++ b/core/client/views/settings.js
@@ -234,6 +234,8 @@
// ### User profile
Settings.user = Settings.Pane.extend({
+ templateName: 'settings/user-profile',
+
id: 'user',
options: {
@@ -244,7 +246,8 @@
'click .button-save': 'saveUser',
'click .button-change-password': 'changePassword',
'click .js-modal-cover': 'showCover',
- 'click .js-modal-image': 'showImage'
+ 'click .js-modal-image': 'showImage',
+ 'keyup .user-profile': 'handleEnterKeyOnForm'
},
showCover: function (e) {
e.preventDefault();
@@ -281,6 +284,31 @@
}));
},
+ handleEnterKeyOnForm: function (ev) {
+ // Don't worry about it unless it's an enter key
+ if (ev.which !== 13) {
+ return;
+ }
+
+ var $target = $(ev.target);
+
+ if ($target.is("textarea")) {
+ // Allow enter key on user bio text area.
+ return;
+ }
+
+ if ($target.is('input[type=password]')) {
+ // Change password if on a password input
+ return this.changePassword(ev);
+ }
+
+ // Simulate clicking save otherwise
+ ev.preventDefault();
+
+ this.saveUser(ev);
+
+ return false;
+ },
saveUser: function () {
var userName = this.$('#user-name').val(),
@@ -369,8 +397,6 @@
}
},
- templateName: 'settings/user-profile',
-
afterRender: function () {
var self = this;
Countable.live(document.getElementById('user-bio'), function (counter) {