@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Let the viewer collapse/expand individual files in a diff.

Summary:
Added a dropdown menu button and the keyboard shortcut 'h' to the
web diff view. These hide or show the annotated code display.

Test Plan:
Viewed an example diff that changed a large number of source files
and played around with keyboard shortcuts. Everything seemed to
work as expected.

Reviewers: nh, epriestley

Reviewed By: epriestley

CC: aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D2714

+115 -1
+2
src/applications/differential/view/DifferentialChangesetListView.php
··· 112 112 113 113 Javelin::initBehavior('buoyant', array()); 114 114 115 + Javelin::initBehavior('differential-toggle-files', array()); 116 + 115 117 $output = array(); 116 118 $mapping = array(); 117 119 foreach ($changesets as $key => $changeset) {
+3
webroot/rsrc/js/application/differential/behavior-comment-jump.js
··· 19 19 break; 20 20 } 21 21 } 22 + JX.Stratcom.invoke('differential-toggle-file-request', null, { 23 + element: jumpto, 24 + }); 22 25 JX.DOM.scrollTo(jumpto); 23 26 e.kill(); 24 27 });
+15
webroot/rsrc/js/application/differential/behavior-dropdown-menus.js
··· 52 52 var menu = new JX.PhabricatorDropdownMenu(buttons[ii]) 53 53 .addItem(reveal_item); 54 54 55 + var visible_item = new JX.PhabricatorMenuItem('', function () { 56 + JX.Stratcom.invoke('differential-toggle-file', null, { 57 + diff: JX.DOM.scry(JX.$(data.containerID), 'table', 'differential-diff'), 58 + }); 59 + }); 60 + menu.addItem(visible_item); 61 + 55 62 if (diffusion_item) { 56 63 menu.addItem(diffusion_item); 57 64 } ··· 92 99 } else { 93 100 reveal_item.setDisabled(true); 94 101 reveal_item.setName('Entire File Shown'); 102 + } 103 + 104 + var diff = JX.DOM.find(JX.$(data.containerID), 105 + 'table', 'differential-diff'); 106 + if (JX.Stratcom.getData(diff).hidden) { 107 + visible_item.setName('Expand File'); 108 + } else { 109 + visible_item.setName('Collapse File'); 95 110 } 96 111 }); 97 112 }
+33 -1
webroot/rsrc/js/application/differential/behavior-keyboard-nav.js
··· 14 14 var selection_begin = null; 15 15 var selection_end = null; 16 16 17 + var refreshFocus = function() {}; 18 + 17 19 function init() { 18 20 if (changesets) { 19 21 return; ··· 30 32 var start = null; 31 33 var type; 32 34 var ii; 35 + 36 + // Don't show code blocks inside a collapsed file. 37 + var diff = JX.DOM.scry(changesets[cursor], 'table', 'differential-diff'); 38 + if (diff.length == 1 && JX.Stratcom.getData(diff[0]).hidden) { 39 + return blocks; 40 + } 33 41 34 42 function push() { 35 43 if (start) { ··· 122 130 selection_end = blocks[focus][1]; 123 131 124 132 manager.scrollTo(selection_begin); 125 - manager.focusOn(selection_begin, selection_end); 133 + (refreshFocus = function() { 134 + manager.focusOn(selection_begin, selection_end); 135 + })(); 126 136 127 137 return; 128 138 } else { ··· 149 159 function() { 150 160 changesets = null; 151 161 }); 162 + // Same thing when a file is hidden or shown; don't want to highlight 163 + // invisible code. 164 + JX.Stratcom.listen( 165 + 'differential-toggle-file-toggled', 166 + null, 167 + function() { 168 + changesets = null; 169 + init(); 170 + refreshFocus(); 171 + }); 152 172 153 173 var haunt_mode = 0; 154 174 function haunt() { ··· 201 221 .setHandler(function(manager) { 202 222 var toc = JX.$('differential-review-toc'); 203 223 manager.scrollTo(toc); 224 + }) 225 + .register(); 226 + 227 + 228 + new JX.KeyboardShortcut('h', 'Collapse or expand the file display.') 229 + .setHandler(function(manager) { 230 + if (!changesets || !changesets[cursor]) { 231 + return; 232 + } 233 + JX.Stratcom.invoke('differential-toggle-file', null, { 234 + diff: JX.DOM.scry(changesets[cursor], 'table', 'differential-diff'), 235 + }); 204 236 }) 205 237 .register(); 206 238
+62
webroot/rsrc/js/application/differential/behavior-toggle-files.js
··· 1 + /** 2 + * @provides javelin-behavior-differential-toggle-files 3 + * @requires javelin-behavior 4 + * javelin-dom 5 + * javelin-stratcom 6 + * phabricator-keyboard-shortcut 7 + */ 8 + 9 + JX.behavior('differential-toggle-files', function(config) { 10 + 11 + JX.Stratcom.listen( 12 + 'differential-toggle-file', 13 + null, 14 + function(e) { 15 + if (e.getData().diff.length != 1) { 16 + return; 17 + } 18 + var diff = e.getData().diff[0], 19 + data = JX.Stratcom.getData(diff); 20 + if(data.hidden) { 21 + data.hidden = false; 22 + JX.DOM.show(diff); 23 + } else { 24 + data.hidden = true; 25 + JX.DOM.hide(diff); 26 + } 27 + JX.Stratcom.invoke('differential-toggle-file-toggled'); 28 + }); 29 + 30 + JX.Stratcom.listen( 31 + 'differential-toggle-file-request', 32 + null, 33 + function(e) { 34 + var elt = e.getData().element; 35 + while (elt !== document.body) { 36 + if (JX.Stratcom.hasSigil(elt, 'differential-diff') && 37 + JX.Stratcom.getData(elt).hidden) { 38 + JX.Stratcom.invoke('differential-toggle-file', null, { 39 + diff: [ elt ], 40 + }); 41 + return; 42 + } 43 + elt = elt.parentNode; 44 + } 45 + }); 46 + 47 + JX.Stratcom.listen( 48 + 'hashchange', 49 + null, 50 + function(e) { 51 + var id = window.location.hash; 52 + if (!id.match(/^#/)) { 53 + return; 54 + } 55 + JX.Stratcom.invoke('differential-toggle-file-request', null, { 56 + element: JX.$(id.substr(1)), 57 + }); 58 + // This event is processed after the hash has changed, so it doesn't 59 + // automatically jump there like we want. 60 + JX.DOM.scrollTo(JX.$(id.substr(1))); 61 + }); 62 + });