1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 17:28:51 +02:00
phorge-phorge/webroot/rsrc/js/application/differential/behavior-comment-jump.js
Alan Huang d5e61f5250 Let the viewer collapse/expand individual files in a diff.
Summary:
Added a dropdown menu button and the keyboard shortcut 'h' to the
web diff view. These hide or show the annotated code display.

Test Plan:
Viewed an example diff that changed a large number of source files
and played around with keyboard shortcuts. Everything seemed to
work as expected.

Reviewers: nh, epriestley

Reviewed By: epriestley

CC: aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D2714
2012-06-13 16:52:42 -07:00

32 lines
1,008 B
JavaScript

/**
* @provides javelin-behavior-differential-comment-jump
* @requires javelin-behavior
* javelin-util
* javelin-dom
*/
JX.behavior('differential-comment-jump', function(config) {
function handle_jump(offset) {
return (function(e) {
var parent = JX.$('differential-review-stage');
var clicked = e.getNode('differential-inline-comment');
var inlines = JX.DOM.scry(parent, 'div', 'differential-inline-comment');
var jumpto = null;
for (var ii = 0; ii < inlines.length; ii++) {
if (inlines[ii] == clicked) {
jumpto = inlines[(ii + offset + inlines.length) % inlines.length];
break;
}
}
JX.Stratcom.invoke('differential-toggle-file-request', null, {
element: jumpto,
});
JX.DOM.scrollTo(jumpto);
e.kill();
});
}
JX.Stratcom.listen('click', 'differential-inline-prev', handle_jump(-1));
JX.Stratcom.listen('click', 'differential-inline-next', handle_jump(+1));
});