2011-05-11 21:25:29 +02:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-differential-comment-jump
|
|
|
|
* @requires javelin-behavior
|
2013-05-19 02:04:22 +02:00
|
|
|
* javelin-stratcom
|
2011-05-11 21:25:29 +02:00
|
|
|
* javelin-dom
|
|
|
|
*/
|
|
|
|
|
2014-06-23 19:27:47 +02:00
|
|
|
JX.behavior('differential-comment-jump', function() {
|
2011-05-11 21:25:29 +02:00
|
|
|
function handle_jump(offset) {
|
2014-06-30 22:00:12 +02:00
|
|
|
return function(e) {
|
2011-05-11 21:25:29 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2012-06-12 00:59:26 +02:00
|
|
|
JX.Stratcom.invoke('differential-toggle-file-request', null, {
|
2013-05-19 02:04:22 +02:00
|
|
|
element: jumpto
|
2012-06-12 00:59:26 +02:00
|
|
|
});
|
2011-05-11 21:25:29 +02:00
|
|
|
JX.DOM.scrollTo(jumpto);
|
|
|
|
e.kill();
|
2014-06-30 22:00:12 +02:00
|
|
|
};
|
2011-05-11 21:25:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
JX.Stratcom.listen('click', 'differential-inline-prev', handle_jump(-1));
|
|
|
|
JX.Stratcom.listen('click', 'differential-inline-next', handle_jump(+1));
|
|
|
|
});
|