Merge pull request #2064 from TimKam/feature-1970-navigate-with-keys

HTML doc: navigate with left/right arrow keys
This commit is contained in:
Takeshi KOMIYA 2016-02-08 11:25:49 +09:00
commit 0b28ee775f
4 changed files with 30 additions and 2 deletions

View File

@ -29,7 +29,7 @@ Other contributors, listed alphabetically, are:
* Horst Gutmann -- internationalization support * Horst Gutmann -- internationalization support
* Martin Hans -- autodoc improvements * Martin Hans -- autodoc improvements
* Doug Hellmann -- graphviz improvements * Doug Hellmann -- graphviz improvements
* Timotheus Kampik - stop words language fix * Timotheus Kampik - JS enhancements, stop words language fix
* Takeshi Komiya -- numref feature * Takeshi Komiya -- numref feature
* Dave Kuhlman -- original LaTeX writer * Dave Kuhlman -- original LaTeX writer
* Blaise Laflamme -- pyramid theme * Blaise Laflamme -- pyramid theme

View File

@ -30,6 +30,7 @@ Features added
* C++ type alias support (e.g., ``.. type:: T = int``). * C++ type alias support (e.g., ``.. type:: T = int``).
* C++ template support for classes, functions, type aliases, and variables (#1729, #1314). * C++ template support for classes, functions, type aliases, and variables (#1729, #1314).
* C++, added new scope management directives ``namespace-push`` and ``namespace-pop``. * C++, added new scope management directives ``namespace-push`` and ``namespace-pop``.
* #1970: Keyboard shortcuts to navigate Next and Previous topics
* Intersphinx: Added support for fetching Intersphinx inventories with URLs * Intersphinx: Added support for fetching Intersphinx inventories with URLs
using HTTP basic auth. using HTTP basic auth.
* C++, added support for template parameter in function info field lists. * C++, added support for template parameter in function info field lists.

View File

@ -124,6 +124,9 @@ var Documentation = {
this.fixFirefoxAnchorBug(); this.fixFirefoxAnchorBug();
this.highlightSearchWords(); this.highlightSearchWords();
this.initIndexTable(); this.initIndexTable();
{% if theme_navigation_with_keys|tobool %}
this.initOnKeyListeners();
{% endif %}
}, },
/** /**
@ -252,6 +255,29 @@ var Documentation = {
}); });
var url = parts.join('/'); var url = parts.join('/');
return path.substring(url.lastIndexOf('/') + 1, path.length - 1); return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
},
initOnKeyListeners: function() {
$(document).keyup(function(event) {
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

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