Jump to content

Topic on Extension talk:RevisionSlider/Flow

Suggestion: Add keyboard shortcuts to move between revisions

6
Summary by 197.218.83.36

Tracked here.

197.218.90.49 (talkcontribs)

Problem

As a user, I can't easily move to the previous (or next) set of revisions easily without using the mouse.

Background

Currently, if a user wants to move both pointers at the same time they need to click and drag the pointers twice, once to move the first pointer, and a second time to move the second one. While this makes perfect sense when the revisions are far apart, it is quite cumbersome when one wants to move to the previous (or next) two revisions.

Proposed solution

Keyboard shortcuts to move in each direction:

  • Shortcut to move both pointers ( ctrl + alt + ) - simultaneous move the pointers to the two previous revisions.
  • Shortcut to move one pointer (ctrl + ) - move the left or right pointer to previous or next revision
197.218.90.49 (talkcontribs)

For the second shortcut since there are cases where one would want to use either the left or the right pointer, maybe these would be better:

  • Move right pointer- META+ Shift+ 
  • Move left pointer - META+ 
Christoph Jauera (WMDE) (talkcontribs)

Hej,

thanks for the feedback. I created a ticket for your proposal on Phabricator so we can keep track off the idea and consider it for a future version or volunteers that might want to work on it. https://phabricator.wikimedia.org/T162119

Best,

Christoph

197.218.80.245 (talkcontribs)

This seems like such an easy hack, that it would probably also be useful for mediawiki core, and it is also easy to write a simple userscript (something I'll probably do for myself).

Thanks for the prompt feedback...

197.218.83.36 (talkcontribs)

I created this small userscript that does this. It doesn't yet move the pointers individually because that's a bit more complex. This even works on older mediawiki versions (> mediawiki 1.19).

// This software is entirely free to re-use, adapt, or sell  (hope it makes someone rich!), without any warranty of any kind or need to attribute "the IP". Use it at your own risk.
// Use ctrl + alt + arrow (left or right) to move to previous revisions or next.
var pressedKeys = {
	ctrl: false,
	shift : false,
	left: false,
	right : false
};
var urlQry = {};
location.search.substr(1).split("&").forEach(function(token) {
	urlQry[token.split("=")[0]] = token.split("=")[1];
});
document.onkeydown = function (event) {
	if (urlQry.type === "revision" || urlQry.diff) {
		if (event.ctrlKey) {
			pressedKeys.ctrl = true;
		}
		if (event.keyCode == 37) {
			pressedKeys.left = true;
		} else if (event.keyCode == 39) {
			pressedKeys.right = true;
		}
		if (pressedKeys.ctrl && pressedKeys.left) {
			document.getElementById("differences-prevlink").click();
		} else if (pressedKeys.ctrl && pressedKeys.right) {
			document.getElementById("differences-nextlink").click();
		}
	}
};
document.onkeyup = (function(event) {
	// reset status of the button 'released' == 'false'
	if (urlQry.type === "revision" || urlQry.diff) {
		if (event.ctrlKey) {
			pressedKeys.ctrl = false;
		}
		if (event.keyCode == 37) {
			pressedKeys.left = false;
		}
		if (event.keyCode == 39) {
			pressedKeys.right = false;
		}
	}
});
197.218.83.36 (talkcontribs)

It is also works independently from revision slider, so maybe it will help future "searchers".