Added 'Next' and 'Previous' links to differential
Summary: Browsing comments was a bit difficult without the possibllity to jump between comments. These links will make the browsing easier. Test Plan: Tested on multiple diffs that the links were working correctly. Reviewed By: epriestley Reviewers: epriestley CC: jungejason, aran, tuomaspelkonen, epriestley Differential Revision: 266
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @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.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));
|
||||
});
|
||||
Reference in New Issue
Block a user