mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor navigation basic template
enable configuration via theme.conf
This commit is contained in:
parent
06ac2a0059
commit
a6a55898a0
@ -124,7 +124,9 @@ var Documentation = {
|
||||
this.fixFirefoxAnchorBug();
|
||||
this.highlightSearchWords();
|
||||
this.initIndexTable();
|
||||
{% if not theme_nonavigationwithkeys|tobool %}
|
||||
this.initOnKeyListeners();
|
||||
{% endif %}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -255,26 +257,24 @@ var Documentation = {
|
||||
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* init onKeyListernes (for navigation)
|
||||
*/
|
||||
initOnKeyListeners: function() {
|
||||
$(document).keyup(function(event) {
|
||||
var activeElementType = $(document.activeElement).prop('tagName');
|
||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT') { // don't navigate when in search box or textarea
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
case 39: // right
|
||||
var nextHref = $('link[rel="next"]').prop('href');
|
||||
if (nextHref) {
|
||||
window.location.href = nextHref;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
@ -5,4 +5,5 @@ pygments_style = none
|
||||
|
||||
[options]
|
||||
nosidebar = false
|
||||
sidebarwidth = 230
|
||||
sidebarwidth = 230
|
||||
nonavigationwithkeys = false
|
Loading…
Reference in New Issue
Block a user