refactor navigation basic template

enable configuration via theme.conf
This commit is contained in:
Timotheus Kampik 2015-11-27 00:54:10 +01:00
parent 06ac2a0059
commit a6a55898a0
2 changed files with 9 additions and 8 deletions

View File

@ -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;
} }
} }
}); });

View File

@ -5,4 +5,5 @@ pygments_style = none
[options] [options]
nosidebar = false nosidebar = false
sidebarwidth = 230 sidebarwidth = 230
nonavigationwithkeys = false