From efd68171b564ae4ee46149f9ca4329858c1c231e Mon Sep 17 00:00:00 2001 From: Gilles Dubochet Date: Tue, 19 Jan 2010 10:52:43 +0000 Subject: [scaladoc] Search tool will ignore case for low... [scaladoc] Search tool will ignore case for lowercase-only queries. Type return when search tool is active to immediately search and display the first result. Contributed by Johannes Rudolph. Also: removed useless `DocProvider` class. No review, checked by dubochet. --- src/compiler/scala/tools/nsc/doc/DocProvider.scala | 3 -- .../scala/tools/nsc/doc/html/resource/lib/index.js | 32 ++++++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) delete mode 100644 src/compiler/scala/tools/nsc/doc/DocProvider.scala (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/doc/DocProvider.scala b/src/compiler/scala/tools/nsc/doc/DocProvider.scala deleted file mode 100644 index bcf227ebb9..0000000000 --- a/src/compiler/scala/tools/nsc/doc/DocProvider.scala +++ /dev/null @@ -1,3 +0,0 @@ -package scala.tools.nsc.doc - -class DocProvider \ No newline at end of file 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 ad8a53529b..b9a1408016 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 @@ -1,4 +1,4 @@ -// © 2009 EPFL/LAMP +// © 2009 EPFL/LAMP // written by Gilles Dubochet with contributions by Johannes Rudolph and "spiros" $(document).ready(function(){ @@ -16,9 +16,15 @@ $(document).ready(function(){ }); function search() { var query = $("#quickflt").attr("value"); - // Regexp that matches CamelCase subbits: "BiSe" is - // "[a-z]*Bi[a-z]*Se" and matches "BitSet", "ABitSet", ... - var queryRegExp = new RegExp(query.replace(/([A-Z])/g,"[a-z]*$1")); + var queryRegExp; + if (query.toLowerCase() != query) + // Regexp that matches CamelCase subbits: "BiSe" is + // "[a-z]*Bi[a-z]*Se" and matches "BitSet", "ABitSet", ... + queryRegExp = new RegExp(query.replace(/([A-Z])/g,"[a-z]*$1")); + else + // if query is all lower case make a normal case insensitive search + queryRegExp = new RegExp(query, "i"); + $("#tpl ol.templates > li").each(function(){ var item = $(this).attr("title"); if (item == "" || queryRegExp.test(item)) { @@ -34,14 +40,22 @@ $(document).ready(function(){ pendingTimeout = undefined; }; var pendingTimeout = undefined; - $("#quickflt").bind("keyup", function(event) { - if (event.keyCode == 27) { // escape - $("#quickflt").attr("value", ""); - } + $("#quickflt").bind("keyup", function(event) { if (pendingTimeout != undefined) { clearTimeout(pendingTimeout); } - pendingTimeout = setTimeout(search, 200); //delay 0.2 sec + if (event.keyCode == 27) { // escape + $("#quickflt").attr("value", ""); + search(); + } + else if (event.keyCode == 13) { // return key: + // search immediately and go into first entry + search(); + $("#tpl ol.templates > li:not(.hide) a:first").click(); + } + else { + pendingTimeout = setTimeout(search, 200); //delay 0.2 sec + } }); $("#tpl .packages > li").prepend("hide"); $("#tpl .packages > li > a.packhide").click(function(event){ -- cgit v1.2.3