Skip to content

Commit

Permalink
Add a shortcut for focusing the commit comment box (shift+c).
Browse files Browse the repository at this point in the history
This makes performing the typical code review even quicker!

Fixes #106.
  • Loading branch information
cespare committed Oct 7, 2011
1 parent 9a0b5d2 commit 5d1be41
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 7 additions & 0 deletions public/commit.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ window.Commit =
$(".edit").live "click", (e) => @onCommentEdit e
$("#sideBySideButton").live "click", => @toggleSideBySide true

commitComment = $("#commitComments .commentText")
KeyboardShortcuts.createShortcutContext commitComment
KeyboardShortcuts.registerShortcut commitComment, "esc", => commitComment.blur()

shortcuts =
"a": => @approveOrDisapprove()
"j": => @selectNextLine true
Expand All @@ -26,6 +30,9 @@ window.Commit =
"n": => @scrollChunk true
"p": => @scrollChunk false
"b": => @toggleSideBySide true
"shift+c": =>
commitComment.focus()
false
"return": => $(".diffLine.selected").first().dblclick() unless $(".commentCancel").length > 0
# TODO(kle): cancel comment forms
"esc": => @clearSelectedLine()
Expand Down
14 changes: 8 additions & 6 deletions views/commit.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@
<% end %>
</div>
<% if current_user %>
<%= erb :_comment_form, :locals => {
:repo_name => commit.git_repo.name,
:sha => commit.sha,
:filename => nil,
:line_number => nil
} %>
<div id="commitComments">
<%= erb :_comment_form, :locals => {
:repo_name => commit.git_repo.name,
:sha => commit.sha,
:filename => nil,
:line_number => nil
} %>
</div>
<% end %>
</div>
</div>

0 comments on commit 5d1be41

Please sign in to comment.