Skip to content

Commit

Permalink
enter returns focus to log entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Boudreaux committed Mar 2, 2012
1 parent 16e3c70 commit 11f52d5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Web/Scripts/usablog/logEntry.js
Expand Up @@ -90,6 +90,11 @@ $.Controller('Usablog.EntryInputController', {
controller.inputEl = $(controller.element).find("input[name=logEntry]");
controller.inputEl.focus();
});


this.bodyKeypressBinding = $("body").bind("keypress", function (event) {
controller.keyPressed(event);
});
},

"input[name=logEntry] keyup": function (el, ev) {
Expand All @@ -107,6 +112,17 @@ $.Controller('Usablog.EntryInputController', {
}
},

keyPressed: function (event) {
if (!event.which)
return true;

if (event.which == 13 || event.which == 47) {
this.ensureFocusAndCaptureTimeStamp(event.target);
}

return true;
},

ensureFocusAndCaptureTimeStamp: function (eventTarget) {
var input = this.inputEl;
if (input != $(eventTarget)) {
Expand Down

0 comments on commit 11f52d5

Please sign in to comment.