summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js
diff options
context:
space:
mode:
authorHeather Miller <heather.miller@epfl.ch>2012-05-19 14:53:21 +0200
committerHeather Miller <heather.miller@epfl.ch>2012-05-19 14:53:21 +0200
commit234390f654c82769f677479221ba9a2c8bbba265 (patch)
treed3e1202f433c10cf540cef8cd08d632937ae5508 /src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js
parent86da9aaa05549d18524d9fe5b00a37ffe1d99c68 (diff)
downloadscala-234390f654c82769f677479221ba9a2c8bbba265.tar.gz
scala-234390f654c82769f677479221ba9a2c8bbba265.tar.bz2
scala-234390f654c82769f677479221ba9a2c8bbba265.zip
Adds ability to navigate Scaladoc with arrow keys
Diffstat (limited to 'src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js')
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js80
1 files changed, 76 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js
index 982a6d0210..eb7f752440 100644
--- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js
+++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js
@@ -15,10 +15,10 @@ var lastHash = "";
$(document).ready(function() {
$('body').layout({ west__size: '20%' });
- $('#browser').layout({
- center__paneSelector: ".ui-west-center"
+ $('#browser').layout({
+ center__paneSelector: ".ui-west-center"
//,center__initClosed:true
- ,north__paneSelector: ".ui-west-north"
+ ,north__paneSelector: ".ui-west-north"
});
$('iframe').bind("load", function(){
var subtitle = $(this).contents().find('title').text();
@@ -260,6 +260,73 @@ function prepareEntityList() {
.prepend("<a class='packfocus'>focus</a>");
}
+/* Handles all key presses while scrolling around with keyboard shortcuts in left panel */
+function keyboardScrolldownLeftPane() {
+ scheduler.add("init", function() {
+ $("#textfilter input").blur();
+ var $items = $("#tpl li");
+ $items.first().addClass('selected');
+
+ $(window).bind("keydown", function(e) {
+ var $old = $items.filter('.selected'),
+ $new;
+
+ switch ( e.keyCode ) {
+
+ case 9: // tab
+ $old.removeClass('selected');
+ break;
+
+ case 13: // enter
+ $old.removeClass('selected');
+ var $url = $old.children().filter('a:last').attr('href');
+ $("#template").attr("src",$url);
+ break;
+
+ case 27: // escape
+ $old.removeClass('selected');
+ $(window).unbind(e);
+ $("#textfilter input").focus();
+
+ break;
+
+ case 38: // up
+ $new = $old.prev();
+
+ if (!$new.length) {
+ $new = $old.parent().prev();
+ }
+
+ if ($new.is('ol') && $new.children(':last').is('ol')) {
+ $new = $new.children().children(':last');
+ } else if ($new.is('ol')) {
+ $new = $new.children(':last');
+ }
+
+ break;
+
+ case 40: // down
+ $new = $old.next();
+ if (!$new.length) {
+ $new = $old.parent().parent().next();
+ }
+ if ($new.is('ol')) {
+ $new = $new.children(':first');
+ }
+ break;
+ }
+
+ if ($new.is('li')) {
+ $old.removeClass('selected');
+ $new.addClass('selected');
+ } else if (e.keyCode == 38) {
+ $(window).unbind(e);
+ $("#textfilter input").focus();
+ }
+ });
+ });
+}
+
/* Configures the text filter */
function configureTextFilter() {
scheduler.add("init", function() {
@@ -276,7 +343,12 @@ function configureTextFilter() {
input.attr("value", "");
return false;
}
- textFilter();
+ if (event.keyCode == 40) { // down arrow
+ $(window).unbind("keydown");
+ keyboardScrolldownLeftPane();
+ return false;
+ }
+ textFilter();
});
input.focus(function(event) { input.select(); });
});