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.fixFirefoxAnchorBug();
|
||||||
this.highlightSearchWords();
|
this.highlightSearchWords();
|
||||||
this.initIndexTable();
|
this.initIndexTable();
|
||||||
|
{% if not theme_nonavigationwithkeys|tobool %}
|
||||||
this.initOnKeyListeners();
|
this.initOnKeyListeners();
|
||||||
|
{% endif %}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,26 +257,24 @@ var Documentation = {
|
|||||||
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
|
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* init onKeyListernes (for navigation)
|
|
||||||
*/
|
|
||||||
initOnKeyListeners: function() {
|
initOnKeyListeners: function() {
|
||||||
$(document).keyup(function(event) {
|
$(document).keyup(function(event) {
|
||||||
var activeElementType = $(document.activeElement).prop('tagName');
|
var activeElementType = document.activeElement.tagName;
|
||||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT') { // don't navigate when in search box or textarea
|
// don't navigate when in search box or textarea
|
||||||
|
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') {
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
case 37: // left
|
case 37: // left
|
||||||
var prevHref = $('link[rel="prev"]').prop('href');
|
var prevHref = $('link[rel="prev"]').prop('href');
|
||||||
if (prevHref) {
|
if (prevHref) {
|
||||||
window.location.href = prevHref;
|
window.location.href = prevHref;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
case 39: // right
|
case 39: // right
|
||||||
var nextHref = $('link[rel="next"]').prop('href');
|
var nextHref = $('link[rel="next"]').prop('href');
|
||||||
if (nextHref) {
|
if (nextHref) {
|
||||||
window.location.href = nextHref;
|
window.location.href = nextHref;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -5,4 +5,5 @@ pygments_style = none
|
|||||||
|
|
||||||
[options]
|
[options]
|
||||||
nosidebar = false
|
nosidebar = false
|
||||||
sidebarwidth = 230
|
sidebarwidth = 230
|
||||||
|
nonavigationwithkeys = false
|
Loading…
Reference in New Issue
Block a user