1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

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:
tuomaspelkonen 2011-05-11 12:25:29 -07:00
parent f36c852542
commit 43f6cc75f6
5 changed files with 75 additions and 11 deletions

View file

@ -61,6 +61,15 @@ celerity_register_resource_map(array(
), ),
'disk' => '/rsrc/css/aphront/headsup-action-list-view.css', 'disk' => '/rsrc/css/aphront/headsup-action-list-view.css',
), ),
'aphront-list-filter-view-css' =>
array(
'uri' => '/res/e6cff171/rsrc/css/aphront/list-filter-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/list-filter-view.css',
),
0 => 0 =>
array( array(
'uri' => '/res/39de799e/rsrc/js/javelin/docs/Base.js', 'uri' => '/res/39de799e/rsrc/js/javelin/docs/Base.js',
@ -71,15 +80,6 @@ celerity_register_resource_map(array(
), ),
'disk' => '/rsrc/js/javelin/docs/Base.js', 'disk' => '/rsrc/js/javelin/docs/Base.js',
), ),
'aphront-list-filter-view-css' =>
array(
'uri' => '/res/e6cff171/rsrc/css/aphront/list-filter-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/aphront/list-filter-view.css',
),
'aphront-pager-view-css' => 'aphront-pager-view-css' =>
array( array(
'uri' => '/res/43fb79f0/rsrc/css/aphront/pager-view.css', 'uri' => '/res/43fb79f0/rsrc/css/aphront/pager-view.css',
@ -322,6 +322,18 @@ celerity_register_resource_map(array(
), ),
'disk' => '/rsrc/js/application/differential/behavior-add-reviewers.js', 'disk' => '/rsrc/js/application/differential/behavior-add-reviewers.js',
), ),
'javelin-behavior-differential-comment-jump' =>
array(
'uri' => '/res/a84186de/rsrc/js/application/differential/behavior-comment-jump.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-util',
2 => 'javelin-dom',
),
'disk' => '/rsrc/js/application/differential/behavior-comment-jump.js',
),
'javelin-behavior-differential-diff-radios' => 'javelin-behavior-differential-diff-radios' =>
array( array(
'uri' => '/res/004cb66f/rsrc/js/application/differential/behavior-diff-radios.js', 'uri' => '/res/004cb66f/rsrc/js/application/differential/behavior-diff-radios.js',

View file

@ -192,6 +192,8 @@ class DifferentialChangesetViewController extends DifferentialController {
'whitespace' => $request->getStr('whitespace'), 'whitespace' => $request->getStr('whitespace'),
)); ));
Javelin::initBehavior('differential-comment-jump', array());
$detail = new DifferentialChangesetDetailView(); $detail = new DifferentialChangesetDetailView();
$detail->setChangeset($changeset); $detail->setChangeset($changeset);
$detail->appendChild($output); $detail->appendChild($output);
@ -219,7 +221,8 @@ class DifferentialChangesetViewController extends DifferentialController {
$output = $output =
'<div class="differential-primary-pane">'. '<div class="differential-primary-pane">'.
'<div class="differential-review-stage">'. '<div class="differential-review-stage" '.
'id="differential-review-stage">'.
$detail->render(). $detail->render().
'</div>'. '</div>'.
'</div>'; '</div>';

View file

@ -133,6 +133,8 @@ class DifferentialChangesetListView extends AphrontView {
'uri' => $this->renderURI, 'uri' => $this->renderURI,
)); ));
Javelin::initBehavior('differential-comment-jump', array());
if ($this->editable) { if ($this->editable) {
$revision = $this->revision; $revision = $this->revision;
Javelin::initBehavior('differential-edit-inline-comments', array( Javelin::initBehavior('differential-edit-inline-comments', array(
@ -141,7 +143,7 @@ class DifferentialChangesetListView extends AphrontView {
} }
return return
'<div class="differential-review-stage">'. '<div class="differential-review-stage" id="differential-review-stage">'.
implode("\n", $output). implode("\n", $output).
'</div>'; '</div>';
} }

View file

@ -82,6 +82,24 @@ final class DifferentialInlineCommentView extends AphrontView {
$links = array(); $links = array();
$links[] = javelin_render_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
'sigil' => 'differential-inline-prev',
),
'Previous');
$links[] = javelin_render_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
'sigil' => 'differential-inline-next',
),
'Next');
$links[] = javelin_render_tag( $links[] = javelin_render_tag(
'a', 'a',
array( array(

View file

@ -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));
});