| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @provides javelin-behavior-differential-keyboard-navigation | 
					
						
							|  |  |  |  * @requires javelin-behavior | 
					
						
							|  |  |  |  *           javelin-dom | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |  *           javelin-stratcom | 
					
						
							| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  |  *           phabricator-keyboard-shortcut | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | JX.behavior('differential-keyboard-navigation', function(config) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |   var cursor = -1; | 
					
						
							| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  |   var changesets; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-02 07:49:00 -07:00
										 |  |  |   var selection_begin = null; | 
					
						
							|  |  |  |   var selection_end = null; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-11 15:59:26 -07:00
										 |  |  |   var refreshFocus = function() {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  |   function init() { | 
					
						
							|  |  |  |     if (changesets) { | 
					
						
							|  |  |  |       return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     changesets = JX.DOM.scry(document.body, 'div', 'differential-changeset'); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |   function getBlocks(cursor) { | 
					
						
							|  |  |  |     // TODO: This might not be terribly fast; we can't currently memoize it
 | 
					
						
							|  |  |  |     // because it can change as ajax requests come in (e.g., content loads).
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     var rows = JX.DOM.scry(changesets[cursor], 'tr'); | 
					
						
							|  |  |  |     var blocks = [[changesets[cursor], changesets[cursor]]]; | 
					
						
							|  |  |  |     var start = null; | 
					
						
							|  |  |  |     var type; | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |     var ii; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-11 15:59:26 -07:00
										 |  |  |     // Don't show code blocks inside a collapsed file.
 | 
					
						
							|  |  |  |     var diff = JX.DOM.scry(changesets[cursor], 'table', 'differential-diff'); | 
					
						
							|  |  |  |     if (diff.length == 1 && JX.Stratcom.getData(diff[0]).hidden) { | 
					
						
							|  |  |  |       return blocks; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |     function push() { | 
					
						
							|  |  |  |       if (start) { | 
					
						
							|  |  |  |         blocks.push([start, rows[ii - 1]]); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       start = null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (ii = 0; ii < rows.length; ii++) { | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |       type = getRowType(rows[ii]); | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |       if (type == 'comment') { | 
					
						
							|  |  |  |         // If we see these types of rows, make a block for each one.
 | 
					
						
							|  |  |  |         push(); | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |       } | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |       if (!type) { | 
					
						
							|  |  |  |         push(); | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |       } else if (type && !start) { | 
					
						
							|  |  |  |         start = rows[ii]; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |     push(); | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return blocks; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   function getRowType(row) { | 
					
						
							|  |  |  |     // NOTE: Being somewhat over-general here to allow other types of objects
 | 
					
						
							|  |  |  |     // to be easily focused in the future (inline comments, 'show more..').
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (row.className.indexOf('inline') !== -1) { | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |       return 'comment'; | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-02 07:49:00 -07:00
										 |  |  |     if (row.className.indexOf('differential-changeset') !== -1) { | 
					
						
							|  |  |  |       return 'file'; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |     var cells = JX.DOM.scry(row, 'td'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (var ii = 0; ii < cells.length; ii++) { | 
					
						
							|  |  |  |       // NOTE: The semantic use of classnames here is for performance; don't
 | 
					
						
							|  |  |  |       // emulate this elsewhere since it's super terrible.
 | 
					
						
							|  |  |  |       if (cells[ii].className.indexOf('old') !== -1 || | 
					
						
							|  |  |  |           cells[ii].className.indexOf('new') !== -1) { | 
					
						
							|  |  |  |         return 'change'; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return null; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |   function jump(manager, delta, jump_to_type) { | 
					
						
							| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  |     init(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |     if (cursor < 0) { | 
					
						
							|  |  |  |       if (delta < 0) { | 
					
						
							|  |  |  |         // If the user goes "back" without a selection, just reject the action.
 | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         cursor = 0; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |     while (true) { | 
					
						
							|  |  |  |       var blocks = getBlocks(cursor); | 
					
						
							|  |  |  |       var focus; | 
					
						
							|  |  |  |       if (delta < 0) { | 
					
						
							|  |  |  |         focus = blocks.length; | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         focus = -1; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       for (var ii = 0; ii < blocks.length; ii++) { | 
					
						
							| 
									
										
										
										
											2011-08-02 07:49:00 -07:00
										 |  |  |         if (blocks[ii][0] == selection_begin) { | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |           focus = ii; | 
					
						
							|  |  |  |           break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-02 07:49:00 -07:00
										 |  |  |       while (true) { | 
					
						
							|  |  |  |         focus += delta; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (blocks[focus]) { | 
					
						
							|  |  |  |           var row_type = getRowType(blocks[focus][0]); | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |           if (jump_to_type && row_type != jump_to_type) { | 
					
						
							| 
									
										
										
										
											2011-08-02 07:49:00 -07:00
										 |  |  |             continue; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           selection_begin = blocks[focus][0]; | 
					
						
							|  |  |  |           selection_end = blocks[focus][1]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           manager.scrollTo(selection_begin); | 
					
						
							| 
									
										
										
										
											2012-06-11 15:59:26 -07:00
										 |  |  |           (refreshFocus = function() { | 
					
						
							|  |  |  |             manager.focusOn(selection_begin, selection_end); | 
					
						
							|  |  |  |           })(); | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |           return; | 
					
						
							| 
									
										
										
										
											2011-08-02 07:49:00 -07:00
										 |  |  |         } else { | 
					
						
							|  |  |  |           var adjusted = (cursor + delta); | 
					
						
							|  |  |  |           if (adjusted < 0 || adjusted >= changesets.length) { | 
					
						
							|  |  |  |             // Stop cursor movement when the user reaches either end.
 | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |           cursor = adjusted; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           // Break the inner loop and go to the next file.
 | 
					
						
							|  |  |  |           break; | 
					
						
							| 
									
										
										
										
											2011-06-10 08:34:17 -07:00
										 |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |   // When inline comments are updated, wipe out our cache of blocks since
 | 
					
						
							|  |  |  |   // comments may have been added or deleted.
 | 
					
						
							|  |  |  |   JX.Stratcom.listen( | 
					
						
							|  |  |  |     null, | 
					
						
							|  |  |  |     'differential-inline-comment-update', | 
					
						
							|  |  |  |     function() { | 
					
						
							|  |  |  |       changesets = null; | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2012-06-11 15:59:26 -07:00
										 |  |  |   // Same thing when a file is hidden or shown; don't want to highlight
 | 
					
						
							|  |  |  |   // invisible code.
 | 
					
						
							|  |  |  |   JX.Stratcom.listen( | 
					
						
							|  |  |  |     'differential-toggle-file-toggled', | 
					
						
							|  |  |  |     null, | 
					
						
							|  |  |  |     function() { | 
					
						
							|  |  |  |       changesets = null; | 
					
						
							|  |  |  |       init(); | 
					
						
							|  |  |  |       refreshFocus(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-28 10:11:41 -07:00
										 |  |  |   var haunt_mode = 0; | 
					
						
							| 
									
										
										
										
											2011-07-08 13:00:30 -07:00
										 |  |  |   function haunt() { | 
					
						
							| 
									
										
										
										
											2012-03-28 10:11:41 -07:00
										 |  |  |     haunt_mode = (haunt_mode + 1) % 3; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     var el = JX.$(config.haunt); | 
					
						
							|  |  |  |     for (var ii = 1; ii <= 2; ii++) { | 
					
						
							|  |  |  |       JX.DOM.alterClass(el, 'differential-haunt-mode-'+ii, (haunt_mode == ii)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-07-08 13:00:30 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  |   new JX.KeyboardShortcut('j', 'Jump to next change.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							|  |  |  |       jump(manager, 1); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   new JX.KeyboardShortcut('k', 'Jump to previous change.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							|  |  |  |       jump(manager, -1); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-02 07:49:00 -07:00
										 |  |  |   new JX.KeyboardShortcut('J', 'Jump to next file.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |       jump(manager, 1, 'file'); | 
					
						
							| 
									
										
										
										
											2011-08-02 07:49:00 -07:00
										 |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   new JX.KeyboardShortcut('K', 'Jump to previous file.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |       jump(manager, -1, 'file'); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   new JX.KeyboardShortcut('n', 'Jump to next inline comment.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							|  |  |  |       jump(manager, 1, 'comment'); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   new JX.KeyboardShortcut('p', 'Jump to previous inline comment.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							|  |  |  |       jump(manager, -1, 'comment'); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-28 13:49:46 -07:00
										 |  |  |   new JX.KeyboardShortcut('t', 'Jump to the table of contents.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							| 
									
										
										
										
											2012-08-21 15:01:20 -07:00
										 |  |  |       var toc = JX.$('toc'); | 
					
						
							| 
									
										
										
										
											2012-04-28 13:49:46 -07:00
										 |  |  |       manager.scrollTo(toc); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-30 17:22:20 -07:00
										 |  |  |   new JX.KeyboardShortcut('f', 'Toggle file tree.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							|  |  |  |       JX.Stratcom.invoke('differential-filetree-toggle'); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							| 
									
										
										
										
											2012-04-28 13:49:46 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-11 15:59:26 -07:00
										 |  |  |   new JX.KeyboardShortcut('h', 'Collapse or expand the file display.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							|  |  |  |       if (!changesets || !changesets[cursor]) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       JX.Stratcom.invoke('differential-toggle-file', null, { | 
					
						
							| 
									
										
										
										
											2012-08-21 15:01:20 -07:00
										 |  |  |         diff: JX.DOM.scry(changesets[cursor], 'table', 'differential-diff') | 
					
						
							| 
									
										
										
										
											2012-06-11 15:59:26 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Add more keyboard navigation options for inline comments
Summary:
  - Use n/p to jump between comments.
  - Use r to reply to the selected comment.
  - Use e to edit the selected comment.
Test Plan: Verified n, p, r, e, j, k, J, K, "click edit" and "click reply"
behavior in as many weird cases as I could come up with.
Reviewers: btrahan, jungejason, nh, cpiro, jl
Reviewed By: btrahan
CC: aran, btrahan, epriestley
Maniphest Tasks: T583
Differential Revision: https://secure.phabricator.com/D1308
											
										 
											2012-01-04 08:21:22 -08:00
										 |  |  |   function inline_op(node, op) { | 
					
						
							|  |  |  |     if (!JX.DOM.scry(node, 'a', 'differential-inline-' + op)) { | 
					
						
							|  |  |  |       // No link for this operation, e.g. editing a comment you can't edit.
 | 
					
						
							|  |  |  |       return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     var data = { | 
					
						
							|  |  |  |       node: JX.DOM.find(node, 'div', 'differential-inline-comment'), | 
					
						
							|  |  |  |       op: op | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     JX.Stratcom.invoke('differential-inline-action', null, data); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   new JX.KeyboardShortcut('r', 'Reply to selected inline comment.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							|  |  |  |       inline_op(selection_begin, 'reply'); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   new JX.KeyboardShortcut('e', 'Edit selected inline comment.') | 
					
						
							|  |  |  |     .setHandler(function(manager) { | 
					
						
							|  |  |  |       inline_op(selection_begin, 'edit'); | 
					
						
							| 
									
										
										
										
											2011-08-02 07:49:00 -07:00
										 |  |  |     }) | 
					
						
							|  |  |  |     .register(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-18 19:44:28 -07:00
										 |  |  |   if (config.haunt) { | 
					
						
							| 
									
										
										
										
											2012-03-28 10:11:41 -07:00
										 |  |  |     new JX.KeyboardShortcut('z', 'Cycle comment panel haunting modes.') | 
					
						
							| 
									
										
										
										
											2012-03-18 19:44:28 -07:00
										 |  |  |       .setHandler(haunt) | 
					
						
							|  |  |  |       .register(); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-07-08 13:00:30 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-08 11:53:10 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 |