Commit 5c1465da authored by Sindre Sorhus's avatar Sindre Sorhus

Use a constant for Enter instead of magic number

parent 3fb908aa
...@@ -18,6 +18,7 @@ jQuery(function($) { ...@@ -18,6 +18,7 @@ jQuery(function($) {
var App = { var App = {
init: function() { init: function() {
this.ENTER_KEY = 13;
this.todos = this.store(); this.todos = this.store();
this.cacheElements(); this.cacheElements();
this.bindEvents(); this.bindEvents();
...@@ -108,7 +109,7 @@ jQuery(function($) { ...@@ -108,7 +109,7 @@ jQuery(function($) {
}); });
}, },
create: function(e) { create: function(e) {
if ( e.which !== 13 ) { if ( e.which !== App.ENTER_KEY ) {
return; return;
} }
var $input = $(this), var $input = $(this),
...@@ -134,7 +135,7 @@ jQuery(function($) { ...@@ -134,7 +135,7 @@ jQuery(function($) {
$(this).closest('li').addClass('editing').find('.edit').focus(); $(this).closest('li').addClass('editing').find('.edit').focus();
}, },
blurOnEnter: function(e) { blurOnEnter: function(e) {
if ( e.keyCode === 13 ) { if ( e.keyCode === App.ENTER_KEY ) {
e.target.blur(); e.target.blur();
} }
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment