Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15511233
D11977.id28828.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D11977.id28828.diff
View Options
diff --git a/src/applications/differential/controller/DifferentialChangesetViewController.php b/src/applications/differential/controller/DifferentialChangesetViewController.php
--- a/src/applications/differential/controller/DifferentialChangesetViewController.php
+++ b/src/applications/differential/controller/DifferentialChangesetViewController.php
@@ -229,10 +229,7 @@
->setCoverage($coverage);
}
- Javelin::initBehavior('differential-show-more', array(
- 'uri' => '/differential/changeset/',
- 'whitespace' => $request->getStr('whitespace'),
- ));
+ Javelin::initBehavior('differential-show-more');
Javelin::initBehavior('differential-comment-jump', array());
diff --git a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
--- a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
+++ b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
@@ -519,7 +519,6 @@
'sigil' => 'show-more',
'meta' => array(
'type' => ($is_all ? 'all' : null),
- 'ref' => $reference,
'range' => $range,
),
),
diff --git a/src/applications/differential/view/DifferentialChangesetListView.php b/src/applications/differential/view/DifferentialChangesetListView.php
--- a/src/applications/differential/view/DifferentialChangesetListView.php
+++ b/src/applications/differential/view/DifferentialChangesetListView.php
@@ -205,11 +205,7 @@
'changesetViewIDs' => $ids,
));
- $this->initBehavior('differential-show-more', array(
- 'uri' => $this->renderURI,
- 'whitespace' => $this->whitespace,
- ));
-
+ $this->initBehavior('differential-show-more');
$this->initBehavior('differential-comment-jump', array());
if ($this->inlineURI) {
diff --git a/src/applications/phriction/controller/PhrictionDiffController.php b/src/applications/phriction/controller/PhrictionDiffController.php
--- a/src/applications/phriction/controller/PhrictionDiffController.php
+++ b/src/applications/phriction/controller/PhrictionDiffController.php
@@ -95,10 +95,7 @@
require_celerity_resource('syntax-highlighting-css');
require_celerity_resource('phriction-document-css');
- Javelin::initBehavior('differential-show-more', array(
- 'uri' => '/phriction/diff/'.$document->getID().'/',
- 'whitespace' => $whitespace_mode,
- ));
+ Javelin::initBehavior('differential-show-more');
$slug = $document->getSlug();
diff --git a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
--- a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
+++ b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
@@ -948,8 +948,8 @@
),
"\xE2\x96\xB2 Show %d Line(s)" => array(
- "\xE2\x96\xB2 Show %d Line(s)",
- "\xE2\x96\xB2 Show %d Line(s)",
+ "\xE2\x96\xB2 Show Line",
+ "\xE2\x96\xB2 Show %d Lines",
),
'Show All %d Line(s)' => array(
diff --git a/webroot/rsrc/js/application/differential/ChangesetViewManager.js b/webroot/rsrc/js/application/differential/ChangesetViewManager.js
--- a/webroot/rsrc/js/application/differential/ChangesetViewManager.js
+++ b/webroot/rsrc/js/application/differential/ChangesetViewManager.js
@@ -118,17 +118,61 @@
this._loaded = true;
this._sequence++;
- var params = {
- ref: this._ref,
- whitespace: this._whitespace || '',
- renderer: this.getRenderer() || '',
- highlight: this._highlight || '',
- encoding: this._encoding || ''
- };
+ var params = this._getViewParameters();
var workflow = new JX.Workflow(this._renderURI, params)
.setHandler(JX.bind(this, this._onresponse, this._sequence));
+ this._startContentWorkflow(workflow);
+
+ JX.DOM.setContent(
+ this._getContentFrame(),
+ JX.$N(
+ 'div',
+ {className: 'differential-loading'},
+ 'Loading...'));
+
+ return this;
+ },
+
+ /**
+ * Load missing context in a changeset.
+ *
+ * We do this when the user clicks "Show X Lines". We also expand all of
+ * the missing context when they "Show Entire File".
+ *
+ * @param string Line range specification, like "0-40/0-20".
+ * @param node Row where the context should be rendered after loading.
+ * @param bool True if this is a bulk load of multiple context blocks.
+ * @return this
+ */
+ loadContext: function(range, target, bulk) {
+ var params = this._getViewParameters();
+ params.range = range;
+
+ var container = JX.DOM.scry(target, 'td')[0];
+ // TODO: pht()
+ JX.DOM.setContent(container, 'Loading...');
+ JX.DOM.alterClass(target, 'differential-show-more-loading', true);
+
+ var workflow = new JX.Workflow(this._renderURI, params)
+ .setHandler(JX.bind(this, this._oncontext, target));
+
+ if (bulk) {
+ // If we're loading a bunch of these because the viewer clicked
+ // "Show Entire File Content" or similar, use lower-priority requests
+ // and draw a progress bar.
+ this._startContentWorkflow(workflow);
+ } else {
+ // If this is a single click on a context link, use a higher priority
+ // load without a chrome change.
+ workflow.start();
+ }
+
+ return this;
+ },
+
+ _startContentWorkflow: function(workflow) {
var routable = workflow.getRoutable();
routable
@@ -137,17 +181,49 @@
.setKey(this._getRoutableKey());
JX.Router.getInstance().queue(routable);
+ },
- JX.DOM.setContent(
- this._getContentFrame(),
- JX.$N(
- 'div',
- {className: 'differential-loading'},
- 'Loading...'));
- return this;
+ /**
+ * Receive a response to a context request.
+ */
+ _oncontext: function(target, response) {
+ var table = JX.$H(response.changeset).getNode();
+ var root = target.parentNode;
+ this._moveRows(table, root, target);
+ root.removeChild(target);
+ },
+
+ _moveRows: function(src, dst, before) {
+ var rows = JX.DOM.scry(src, 'tr');
+ for (var ii = 0; ii < rows.length; ii++) {
+
+ // Find the table this <tr /> belongs to. If it's a sub-table, like a
+ // table in an inline comment, don't copy it.
+ if (JX.DOM.findAbove(rows[ii], 'table') !== src) {
+ continue;
+ }
+
+ if (before) {
+ dst.insertBefore(rows[ii], before);
+ } else {
+ dst.appendChild(rows[ii]);
+ }
+ }
},
+ /**
+ * Get parameters which define the current rendering options.
+ */
+ _getViewParameters: function() {
+ return {
+ ref: this._ref,
+ whitespace: this._whitespace || '',
+ renderer: this.getRenderer() || '',
+ highlight: this._highlight || '',
+ encoding: this._encoding || ''
+ };
+ },
/**
* Get the active @{class:JX.Routable} for this changeset.
diff --git a/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js b/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js
--- a/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js
+++ b/webroot/rsrc/js/application/differential/DifferentialInlineCommentEditor.js
@@ -43,6 +43,25 @@
var table = this.getTable();
var target = exact_row ? row : this._skipOverInlineCommentRows(row);
+ function copyRows(dst, src, before) {
+ var rows = JX.DOM.scry(src, 'tr');
+ for (var ii = 0; ii < rows.length; ii++) {
+
+ // Find the table this <tr /> belongs to. If it's a sub-table, like a
+ // table in an inline comment, don't copy it.
+ if (JX.DOM.findAbove(rows[ii], 'table') !== src) {
+ continue;
+ }
+
+ if (before) {
+ dst.insertBefore(rows[ii], before);
+ } else {
+ dst.appendChild(rows[ii]);
+ }
+ }
+ return rows;
+ }
+
return copyRows(table, content, target);
},
_removeUndoLink : function() {
diff --git a/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js b/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js
--- a/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js
+++ b/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js
@@ -16,18 +16,17 @@
var pht = JX.phtize(config.pht);
function show_more(container) {
+ var view = JX.ChangesetViewManager.getForNode(container);
+
var nodes = JX.DOM.scry(container, 'tr', 'context-target');
for (var ii = 0; ii < nodes.length; ii++) {
var show = JX.DOM.scry(nodes[ii], 'a', 'show-more');
for (var jj = 0; jj < show.length; jj++) {
- if (JX.Stratcom.getData(show[jj]).type != 'all') {
+ var data = JX.Stratcom.getData(show[jj]);
+ if (data.type != 'all') {
continue;
}
- var event_data = {
- context : nodes[ii],
- show : show[jj]
- };
- JX.Stratcom.invoke('differential-reveal-context', null, event_data);
+ view.loadContext(data.range, nodes[ii], true);
}
}
}
diff --git a/webroot/rsrc/js/application/differential/behavior-show-more.js b/webroot/rsrc/js/application/differential/behavior-show-more.js
--- a/webroot/rsrc/js/application/differential/behavior-show-more.js
+++ b/webroot/rsrc/js/application/differential/behavior-show-more.js
@@ -5,67 +5,23 @@
* javelin-workflow
* javelin-util
* javelin-stratcom
+ * changeset-view-manager
*/
-JX.behavior('differential-show-more', function(config) {
-
- function onresponse(context, response) {
- var table = JX.$H(response.changeset).getNode();
- var root = context.parentNode;
- copyRows(root, table, context);
- root.removeChild(context);
- }
+JX.behavior('differential-show-more', function() {
JX.Stratcom.listen(
'click',
'show-more',
function(e) {
- var event_data = {
- context : e.getNodes()['context-target'],
- show : e.getNodes()['show-more']
- };
-
- JX.Stratcom.invoke('differential-reveal-context', null, event_data);
e.kill();
- });
-
- JX.Stratcom.listen(
- 'differential-reveal-context',
- null,
- function(e) {
- var context = e.getData().context;
- var data = JX.Stratcom.getData(e.getData().show);
-
- var container = JX.DOM.scry(context, 'td')[0];
- JX.DOM.setContent(container, 'Loading...');
- JX.DOM.alterClass(context, 'differential-show-more-loading', true);
- if (!data.whitespace) {
- data.whitespace = config.whitespace;
- }
+ var changeset = e.getNode('differential-changeset');
+ var view = JX.ChangesetViewManager.getForNode(changeset);
+ var data = e.getNodeData('show-more');
+ var target = e.getNode('context-target');
- new JX.Workflow(config.uri, data)
- .setHandler(JX.bind(null, onresponse, context))
- .start();
+ view.loadContext(data.range, target);
});
});
-
-function copyRows(dst, src, before) {
- var rows = JX.DOM.scry(src, 'tr');
- for (var ii = 0; ii < rows.length; ii++) {
-
- // Find the table this <tr /> belongs to. If it's a sub-table, like a
- // table in an inline comment, don't copy it.
- if (JX.DOM.findAbove(rows[ii], 'table') !== src) {
- continue;
- }
-
- if (before) {
- dst.insertBefore(rows[ii], before);
- } else {
- dst.appendChild(rows[ii]);
- }
- }
- return rows;
-}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 18, 12:39 AM (1 w, 19 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7735419
Default Alt Text
D11977.id28828.diff (11 KB)
Attached To
Mode
D11977: Make "Show Context" persist rendering, whitespace, encoding, etc
Attached
Detach File
Event Timeline
Log In to Comment