Page MenuHomePhabricator

D17131.id41200.diff
No OneTemporary

D17131.id41200.diff

diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentPreviewListView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentPreviewListView.php
--- a/src/infrastructure/diff/view/PHUIDiffInlineCommentPreviewListView.php
+++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentPreviewListView.php
@@ -28,6 +28,14 @@
public function render() {
$viewer = $this->getViewer();
+ $config = array(
+ 'pht' => array(
+ 'view' => pht('View'),
+ ),
+ );
+
+ Javelin::initBehavior('diff-preview-link', $config);
+
$inlines = $this->getInlineComments();
foreach ($inlines as $key => $inline) {
$inlines[$key] = DifferentialInlineComment::newFromModernComment(
diff --git a/webroot/rsrc/js/application/diff/behavior-preview-link.js b/webroot/rsrc/js/application/diff/behavior-preview-link.js
new file mode 100644
--- /dev/null
+++ b/webroot/rsrc/js/application/diff/behavior-preview-link.js
@@ -0,0 +1,36 @@
+/**
+ * @provides javelin-behavior-diff-preview-link
+ * @requires javelin-behavior
+ * javelin-stratcom
+ * javelin-dom
+ */
+
+JX.behavior('diff-preview-link', function(config, statics) {
+ if (statics.initialized) {
+ return;
+ }
+ statics.initialized = true;
+
+ var pht = JX.phtize(config.pht);
+
+ // After inline comment previews are rendered, hook up the links to the
+ // comments that are visible on the current page.
+ function link_inline_preview(e) {
+ var root = e.getData().rootNode;
+ var links = JX.DOM.scry(root, 'a', 'differential-inline-preview-jump');
+
+ for (var ii = 0; ii < links.length; ii++) {
+ var data = JX.Stratcom.getData(links[ii]);
+ try {
+ JX.$(data.anchor);
+ links[ii].href = '#' + data.anchor;
+ JX.DOM.setContent(links[ii], pht('view'));
+ } catch (ignored) {
+ // This inline comment isn't visible, e.g. on some other diff.
+ }
+ }
+
+ }
+
+ JX.Stratcom.listen('EditEngine.didCommentPreview', null, link_inline_preview);
+});
diff --git a/webroot/rsrc/js/application/transactions/behavior-comment-actions.js b/webroot/rsrc/js/application/transactions/behavior-comment-actions.js
--- a/webroot/rsrc/js/application/transactions/behavior-comment-actions.js
+++ b/webroot/rsrc/js/application/transactions/behavior-comment-actions.js
@@ -147,13 +147,27 @@
if (!response.xactions.length) {
JX.DOM.hide(panel);
} else {
+ var preview_root = JX.$(config.timelineID);
JX.DOM.setContent(
- JX.$(config.timelineID),
+ preview_root,
[
JX.$H(response.xactions.join('')),
JX.$H(response.previewContent)
]);
JX.DOM.show(panel);
+
+ // NOTE: Resonses are currently processed before associated behaviors are
+ // registered. We need to defer invoking this event so that any behaviors
+ // accompanying the response are registered.
+ var invoke_preview = function() {
+ JX.Stratcom.invoke(
+ 'EditEngine.didCommentPreview',
+ null,
+ {
+ rootNode: preview_root
+ });
+ };
+ setTimeout(invoke_preview, 0);
}
}

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 20, 6:49 PM (1 h, 2 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7714300
Default Alt Text
D17131.id41200.diff (3 KB)

Event Timeline