MozReview: Trigger an event on commit message file related action (
Bug 1248008) r?smacleod
Two events are triggered on `RB::page`: mr:fileDiffRendered and mr:revisionSelected
To modify the looks of commit message filediff DOM element front-end needs
to react as soon as it's loaded from API and rendered to DOM. mr:fileDiffRendered
is responsible for that. It also delivers filediff's ID to the listener so
it can be compared with commit message one.
Current commit message filediff ID is needed to compare it with the loaded one.
There is a need to create an event when user switches revisions as different
fildiff might be loaded. mr:selectedRevision is triggered. It provides
two revisions (base and tip) as any of these might be used.
MozReview-Commit-ID: 5TGxbZV54zS
--- a/reviewboard/reviewboard/static/rb/js/pages/views/diffViewerPageView_mozreview.js
+++ b/reviewboard/reviewboard/static/rb/js/pages/views/diffViewerPageView_mozreview.js
@@ -408,16 +408,18 @@ RB.DiffViewerPageView = RB.ReviewablePag
}
if ($anchor.length !== 0) {
this.selectAnchor($anchor);
this._startAtAnchorName = null;
}
}
+ // Emit a fileDiffRenderedEvent
+ this.trigger('mr:fileDiffRendered', diffReviewable.get('fileDiffID'));
$.funcQueue('diff_files').next();
},
/*
* Selects the anchor at a specified location.
*
* By default, this will scroll the page to position the anchor near
* the top of the view.
@@ -672,16 +674,17 @@ RB.DiffViewerPageView = RB.ReviewablePag
var base = revisions[0],
tip = revisions[1];
if (base === 0) {
this.router.navigate(tip + '/', {trigger: true});
} else {
this.router.navigate(base + '-' + tip + '/', {trigger: true});
}
+ this.trigger('mr:revisionSelected', revisions);
},
/*
* Get the current URL.
*
* This will compute and return the current page's URL (relative to the
* router root), not including query parameters or hash locations.
*/