From 4a9c30bf333e14d9fe080163fe2f3dd57ca05ccb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9gis=20Hanol?= <regis@hanol.fr>
Date: Mon, 11 Mar 2013 00:46:28 +0100
Subject: [PATCH] allows the submission of the create account form by pressing
 enter

---
 .../discourse/views/modal/create_account_view.js  | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/app/assets/javascripts/discourse/views/modal/create_account_view.js b/app/assets/javascripts/discourse/views/modal/create_account_view.js
index 00bc3ea0c..910ee9993 100644
--- a/app/assets/javascripts/discourse/views/modal/create_account_view.js
+++ b/app/assets/javascripts/discourse/views/modal/create_account_view.js
@@ -276,8 +276,19 @@ Discourse.CreateAccountView = Discourse.ModalBodyView.extend({
       _this.set('formSubmitted', false);
       return _this.flash(Em.String.i18n('create_account.failed'), 'error');
     });
+  },
+
+  didInsertElement: function(e) {
+    // allows the submission the form when pressing 'ENTER' on *any* text input field
+    // but only when the submit button is enabled
+    var _this = this;
+    return Em.run.next(function() {
+      return $("input[type='text']").keydown(function(e) {
+        if (_this.get('submitDisabled') === false && e.keyCode === 13) {
+          return _this.createAccount();
+        }
+      });
+    });
   }
 
 });
-
-