mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 21:40:55 +01:00
17306b7a92
Summary: ReviewBoard has a fancier version of this feature that's more granular -- the keyboard can focus on individual changes. I think that's good and intend to implement something similar, but this gets us a step closer and gets rid of some of the bookkeeping stuff like making shortcuts discoverable. (I have another brnach with Maniphest merging which also uses fatcow icons, which is why the README seems a little out of context.) Test Plan: Used "j" and "k" to jump between changesets. Pressed "?" and got a list of available shortcuts. Reviewed By: tuomaspelkonen Reviewers: aran, jungejason, tuomaspelkonen CC: moskov, aran, epriestley, tuomaspelkonen Differential Revision: 412
48 lines
993 B
JavaScript
48 lines
993 B
JavaScript
/**
|
|
* @provides javelin-behavior-differential-keyboard-navigation
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* phabricator-keyboard-shortcut
|
|
*/
|
|
|
|
JX.behavior('differential-keyboard-navigation', function(config) {
|
|
|
|
var cursor = null;
|
|
var changesets;
|
|
|
|
function init() {
|
|
if (changesets) {
|
|
return;
|
|
}
|
|
changesets = JX.DOM.scry(document.body, 'div', 'differential-changeset');
|
|
}
|
|
|
|
function jump(manager, delta) {
|
|
init();
|
|
|
|
if (cursor === null) {
|
|
cursor = -1;
|
|
}
|
|
|
|
cursor = (cursor + changesets.length + delta) % changesets.length;
|
|
|
|
var selected = changesets[cursor];
|
|
|
|
manager.scrollTo(selected);
|
|
manager.focusOn(selected);
|
|
}
|
|
|
|
new JX.KeyboardShortcut('j', 'Jump to next change.')
|
|
.setHandler(function(manager) {
|
|
jump(manager, 1);
|
|
})
|
|
.register();
|
|
|
|
new JX.KeyboardShortcut('k', 'Jump to previous change.')
|
|
.setHandler(function(manager) {
|
|
jump(manager, -1);
|
|
})
|
|
.register();
|
|
|
|
});
|
|
|