diff options
author | Timotheus Kampik <timotheus.kampik@signavio.com> | 2015-10-04 19:44:17 +0200 |
---|---|---|
committer | Timotheus Kampik <timotheus.kampik@signavio.com> | 2015-10-04 19:44:17 +0200 |
commit | 1b80100dffc2e3bcab2ac7825d2ec7fcfbd941fb (patch) | |
tree | eed1c6f9a58b87c3ba07f2b94b8115f0ee24d552 /sphinx/themes/basic/static/doctools.js | |
parent | 470bac3d1c17f2728573f96c2864ab07918692d2 (diff) | |
download | sphinx-git-1b80100dffc2e3bcab2ac7825d2ec7fcfbd941fb.tar.gz |
HTML doc: navigate with left/right arrow keys
Adjusted basic theme's JS accordingly
Diffstat (limited to 'sphinx/themes/basic/static/doctools.js')
-rw-r--r-- | sphinx/themes/basic/static/doctools.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sphinx/themes/basic/static/doctools.js b/sphinx/themes/basic/static/doctools.js index c7bfe760a..07a6355af 100644 --- a/sphinx/themes/basic/static/doctools.js +++ b/sphinx/themes/basic/static/doctools.js @@ -124,6 +124,7 @@ var Documentation = { this.fixFirefoxAnchorBug(); this.highlightSearchWords(); this.initIndexTable(); + this.initOnKeyListeners(); }, /** @@ -252,6 +253,30 @@ var Documentation = { }); var url = parts.join('/'); return path.substring(url.lastIndexOf('/') + 1, path.length - 1); + }, + + /** + * init onKeyListernes (for navigation) + */ + initOnKeyListeners: function() { + $(document).keyup(function(event) { + if (!$(document.activeElement).is('input')) { //don't navigate when in search box + switch (event.keyCode) { + case 37: //left + var prevElement = $('link[rel="prev"]')[0]; + if (prevElement) { + window.location.href = prevElement.href; + } + break; + case 39: //right + var nextElement = $('link[rel="next"]')[0]; + if (nextElement) { + window.location.href = nextElement.href; + } + break; + } + } + }); } }; |