summaryrefslogtreecommitdiff
path: root/src/scaladoc/scala/tools/nsc/doc/html
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-02-18 16:00:16 +0100
committerFelix Mulder <felix.mulder@gmail.com>2016-02-18 16:01:15 +0100
commit4545b1684f2023cf83f9d2200027fc9c6df2ea33 (patch)
tree505b51a641a296eda476e052e17be662ed549934 /src/scaladoc/scala/tools/nsc/doc/html
parent908c2e7af8bda3b4ca50c25fb1a0f1aa51eb86e2 (diff)
downloadscala-4545b1684f2023cf83f9d2200027fc9c6df2ea33.tar.gz
scala-4545b1684f2023cf83f9d2200027fc9c6df2ea33.tar.bz2
scala-4545b1684f2023cf83f9d2200027fc9c6df2ea33.zip
Add progress bar for search
Diffstat (limited to 'src/scaladoc/scala/tools/nsc/doc/html')
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala3
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.css14
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js75
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/resource/lib/scheduler.js7
4 files changed, 57 insertions, 42 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala
index 37ce28a838..969e19c770 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala
@@ -63,6 +63,9 @@ trait EntityPage extends HtmlPage {
<body>
{ search }
<div id="search-results">
+ <div id="search-progress">
+ <div id="progress-fill"></div>
+ </div>
<div id="results-content">
<div id="entity-results"></div>
<div id="member-results"></div>
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.css b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.css
index b4c4af9dd2..ea1c358149 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.css
+++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.css
@@ -316,6 +316,20 @@ textarea, input { outline: none; }
z-index: 1;
}
+div#search-progress {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 0.25em;
+}
+
+div#search-progress > div#progress-fill {
+ width: 0%;
+ background-color: #f16665;
+ transition: 0.1s;
+}
+
#focusfilter .focuscoll {
font-weight: bold;
}
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js
index c23ece144a..caa6406bc5 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js
+++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/index.js
@@ -7,6 +7,20 @@ var title = $(document).attr('title');
var lastFragment = "";
+var Index = {};
+(function (ns) {
+ ns.keyLength = 0;
+ ns.keys = function (obj) {
+ var result = [];
+ var key;
+ for (key in obj) {
+ result.push(key);
+ ns.keyLength++;
+ }
+ return result;
+ }
+})(Index);
+
$(document).ready(function() {
// Clicking #doc-title returns the user to the root package
$("#doc-title").click(function() { document.location = toRoot + "index.html" });
@@ -30,48 +44,6 @@ $(document).ready(function() {
});
});
-// Set the url fragment according to the src of the iframe "template".
-// iframe url = "scala/Either.html" => url fragment = "#scala.Either"
-// iframe url = "scala/Either.html#isRight:Boolean" => url fragment = "#scala.Either@isRight:Boolean"
-// iframe url = "scalaz/iteratee/package.html#>@>[E,A]=scalaz.iteratee.package.Iteratee[E,A]" => fragment = "#scalaz.iteratee.package@>@>[E,A]=scalaz.iteratee.package.Iteratee[E,A]"
-function setUrlFragmentFromFrameSrc() {
- try {
- var commonLength = location.pathname.lastIndexOf("/");
- var frameLocation = frames["template"].location;
- var relativePath = frameLocation.pathname.slice(commonLength + 1);
-
- if(!relativePath || frameLocation.pathname.indexOf("/") < 0)
- return;
-
- // Add #, remove ".html" and replace "/" with "."
- fragment = "#" + relativePath.replace(/\.html$/, "").replace(/\//g, ".");
-
- // Add the frame's hash after an @
- if(frameLocation.hash) fragment += ("@" + frameLocation.hash.slice(1));
-
- // Use replace to not add history items
- lastFragment = fragment;
- location.replace(fragment);
- }
- catch(e) {
- // Chrome doesn't allow reading the iframe's location when
- // used on the local file system.
- }
-}
-
-var Index = {};
-
-(function (ns) {
- ns.keys = function (obj) {
- var result = [];
- var key;
- for (key in obj) {
- result.push(key);
- }
- return result;
- }
-})(Index);
-
/* Handles all key presses while scrolling around with keyboard shortcuts in search results */
function handleKeyNavigation() {
/** Iterates both back and forth among selected elements */
@@ -308,6 +280,7 @@ function searchPackage(pack, regExp) {
scheduler.add("search", function() {
handleSearchedPackage(results, regExp);
+ setProgress();
});
});
}
@@ -527,6 +500,7 @@ function listItem(entity, regExp) {
*/
function searchAll() {
scheduler.clear("search"); // clear previous search
+ maxJobs = 1; // clear previous max
var searchStr = $("#textfilter input").attr("value").trim() || '';
if (searchStr === '') {
@@ -582,3 +556,20 @@ function urlFriendlyEntity(entity) {
return entity;
}
+
+var maxJobs = 1;
+function setProgress() {
+ var running = scheduler.numberOfJobs("search");
+ maxJobs = Math.max(maxJobs, running);
+
+ var percent = 100 - (running / maxJobs * 100);
+ var bar = document.getElementById("progress-fill");
+ bar.style.height = "100%";
+ bar.style.width = percent + "%";
+
+ if (percent == 100) {
+ setTimeout(function() {
+ bar.style.height = 0;
+ }, 500);
+ }
+}
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/scheduler.js b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/scheduler.js
index 39ce2a5d29..750c9099fd 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/scheduler.js
+++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/scheduler.js
@@ -98,4 +98,11 @@ function Scheduler() {
});
}
}
+
+ this.numberOfJobs = function(label) {
+ var index = scheduler.indexOf(label);
+ if (index == -1) throw("queue for label '" + label + "' non-existent");
+
+ return scheduler.queues[index].length;
+ }
};