mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactored code according to discussion in #2064
This commit is contained in:
parent
1b80100dff
commit
06ac2a0059
@ -260,20 +260,21 @@ var Documentation = {
|
||||
*/
|
||||
initOnKeyListeners: function() {
|
||||
$(document).keyup(function(event) {
|
||||
if (!$(document.activeElement).is('input')) { //don't navigate when in search box
|
||||
var activeElementType = $(document.activeElement).prop('tagName');
|
||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT') { // don't navigate when in search box or textarea
|
||||
switch (event.keyCode) {
|
||||
case 37: //left
|
||||
var prevElement = $('link[rel="prev"]')[0];
|
||||
if (prevElement) {
|
||||
window.location.href = prevElement.href;
|
||||
case 37: // left
|
||||
var prevHref = $('link[rel="prev"]').prop('href');
|
||||
if (prevHref) {
|
||||
window.location.href = prevHref;
|
||||
}
|
||||
break;
|
||||
case 39: //right
|
||||
var nextElement = $('link[rel="next"]')[0];
|
||||
if (nextElement) {
|
||||
window.location.href = nextElement.href;
|
||||
return false;
|
||||
case 39: // right
|
||||
var nextHref = $('link[rel="next"]').prop('href');
|
||||
if (nextHref) {
|
||||
window.location.href = nextHref;
|
||||
}
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user