mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #2064 from TimKam/feature-1970-navigate-with-keys
HTML doc: navigate with left/right arrow keys
This commit is contained in:
commit
0b28ee775f
2
AUTHORS
2
AUTHORS
@ -29,7 +29,7 @@ Other contributors, listed alphabetically, are:
|
|||||||
* Horst Gutmann -- internationalization support
|
* Horst Gutmann -- internationalization support
|
||||||
* Martin Hans -- autodoc improvements
|
* Martin Hans -- autodoc improvements
|
||||||
* Doug Hellmann -- graphviz improvements
|
* Doug Hellmann -- graphviz improvements
|
||||||
* Timotheus Kampik - stop words language fix
|
* Timotheus Kampik - JS enhancements, stop words language fix
|
||||||
* Takeshi Komiya -- numref feature
|
* Takeshi Komiya -- numref feature
|
||||||
* Dave Kuhlman -- original LaTeX writer
|
* Dave Kuhlman -- original LaTeX writer
|
||||||
* Blaise Laflamme -- pyramid theme
|
* Blaise Laflamme -- pyramid theme
|
||||||
|
1
CHANGES
1
CHANGES
@ -30,6 +30,7 @@ Features added
|
|||||||
* C++ type alias support (e.g., ``.. type:: T = int``).
|
* C++ type alias support (e.g., ``.. type:: T = int``).
|
||||||
* C++ template support for classes, functions, type aliases, and variables (#1729, #1314).
|
* C++ template support for classes, functions, type aliases, and variables (#1729, #1314).
|
||||||
* C++, added new scope management directives ``namespace-push`` and ``namespace-pop``.
|
* C++, added new scope management directives ``namespace-push`` and ``namespace-pop``.
|
||||||
|
* #1970: Keyboard shortcuts to navigate Next and Previous topics
|
||||||
* Intersphinx: Added support for fetching Intersphinx inventories with URLs
|
* Intersphinx: Added support for fetching Intersphinx inventories with URLs
|
||||||
using HTTP basic auth.
|
using HTTP basic auth.
|
||||||
* C++, added support for template parameter in function info field lists.
|
* C++, added support for template parameter in function info field lists.
|
||||||
|
@ -124,6 +124,9 @@ var Documentation = {
|
|||||||
this.fixFirefoxAnchorBug();
|
this.fixFirefoxAnchorBug();
|
||||||
this.highlightSearchWords();
|
this.highlightSearchWords();
|
||||||
this.initIndexTable();
|
this.initIndexTable();
|
||||||
|
{% if theme_navigation_with_keys|tobool %}
|
||||||
|
this.initOnKeyListeners();
|
||||||
|
{% endif %}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,6 +255,29 @@ var Documentation = {
|
|||||||
});
|
});
|
||||||
var url = parts.join('/');
|
var url = parts.join('/');
|
||||||
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
|
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
|
||||||
|
},
|
||||||
|
|
||||||
|
initOnKeyListeners: function() {
|
||||||
|
$(document).keyup(function(event) {
|
||||||
|
var activeElementType = document.activeElement.tagName;
|
||||||
|
// don't navigate when in search box or textarea
|
||||||
|
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') {
|
||||||
|
switch (event.keyCode) {
|
||||||
|
case 37: // left
|
||||||
|
var prevHref = $('link[rel="prev"]').prop('href');
|
||||||
|
if (prevHref) {
|
||||||
|
window.location.href = prevHref;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case 39: // right
|
||||||
|
var nextHref = $('link[rel="next"]').prop('href');
|
||||||
|
if (nextHref) {
|
||||||
|
window.location.href = nextHref;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -5,4 +5,5 @@ pygments_style = none
|
|||||||
|
|
||||||
[options]
|
[options]
|
||||||
nosidebar = false
|
nosidebar = false
|
||||||
sidebarwidth = 230
|
sidebarwidth = 230
|
||||||
|
navigation_with_keys = False
|
Loading…
Reference in New Issue
Block a user