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.highlightSearchWords();
this.initIndexTable();
{% if not theme_nonavigationwithkeys|tobool %}
this.initOnKeyListeners();
{% endif %}
},
/**
@ -255,28 +257,26 @@ 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;
}
case 39: // right
var nextHref = $('link[rel="next"]').prop('href');
if (nextHref) {
window.location.href = nextHref;
}
return false;
}
}
}
});
}
};

View File

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