summaryrefslogtreecommitdiff
path: root/src/scaladoc
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@epfl.ch>2016-03-25 15:48:03 +0100
committerVlad Ureche <vlad.ureche@epfl.ch>2016-03-25 15:48:03 +0100
commit0e4c39aee4196573e8fb94a01fd92e0be4e4dd05 (patch)
tree1a9ad304e86c0ef1e18c9b5c225f472ff0a47e6c /src/scaladoc
parent6173274e2731a69a92b2371662959eaf89dd6836 (diff)
parent1087539f49d461bb12d70381e01ee6af8bf73d64 (diff)
downloadscala-0e4c39aee4196573e8fb94a01fd92e0be4e4dd05.tar.gz
scala-0e4c39aee4196573e8fb94a01fd92e0be4e4dd05.tar.bz2
scala-0e4c39aee4196573e8fb94a01fd92e0be4e4dd05.zip
Merge pull request #5050 from code-star/topic/2.12.x-scaladoc-Auto-expand
Fix scaladoc scroll and auto-expand on permalinks
Diffstat (limited to 'src/scaladoc')
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/resource/lib/scheduler.js2
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js55
2 files changed, 31 insertions, 26 deletions
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 750c9099fd..52fb1770ee 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
@@ -5,7 +5,7 @@ function Scheduler() {
var scheduler = this;
var resolution = 0;
this.timeout = undefined;
- this.queues = new Array(0); // an array of work pacakges indexed by index in the labels table.
+ this.queues = new Array(0); // an array of work packages indexed by index in the labels table.
this.labels = new Array(0); // an indexed array of labels indexed by priority. This should be short.
this.label = function(name, priority) {
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js
index 5f42dfa114..e6fc01325a 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js
+++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js
@@ -16,18 +16,6 @@ $(document).ready(function() {
$zoomOut: $('#diagram-zoom-out'),
});
- $("#template > div > div > ol > li > span.permalink").click(function(e) {
- e.preventDefault();
- var href = $("a", this).attr("href");
- if (href.indexOf("#") != -1) {
- location.hash = href.split("#").pop();
- $("#template > div > div > ol > li").removeClass("selected");
- var parent = $(this).parent().addClass("selected");
- $("#content-container").animate({scrollTop: $("#content-container").scrollTop() + $(this).offset().top - $("#search").height() - 23}, 500);
- }
- return false;
- });
-
var oldWidth = $("div#subpackage-spacer").width() + 1 + "px";
$("div#packages > ul > li.current").click(function() {
$("div#subpackage-spacer").css({ "width": oldWidth });
@@ -65,21 +53,22 @@ $(document).ready(function() {
function exposeMember(jqElem) {
var jqElemParent = jqElem.parent(),
parentName = jqElemParent.attr("name"),
- linearizationName = /^([^#]*)(#.*)?$/gi.exec(parentName)[1];
+ ancestorName = /^([^#]*)(#.*)?$/gi.exec(parentName)[1];
// switch visibility filter if necessary
if (jqElemParent.attr("visbl") == "prt") {
toggleVisibilityFilter(controls.visibility.all, controls.visibility.publicOnly);
}
- // toggle appropriate linearization buttons
- if (linearizationName) {
- $("#linearization li.out[name='" + linearizationName + "']").removeClass("out").addClass("in");
+ // toggle appropriate ancestor filter buttons
+ if (ancestorName) {
+ $("#filterby li.out[name='" + ancestorName + "']").removeClass("out").addClass("in");
}
filter();
jqElemParent.addClass("selected");
- $("#content-container").animate({scrollTop: jqElemParent.offset().top - $("#search").height() - 5 }, 1000);
+ commentToggleFct(jqElemParent);
+ $("#content-scroll-container").animate({scrollTop: $("#content-scroll-container").scrollTop() + jqElemParent.offset().top - $("#search").height() - 23 }, 1000);
}
var isHiddenClass = function (name) {
@@ -241,10 +230,12 @@ $(document).ready(function() {
/* Add toggle arrows */
$("#template li[fullComment=yes] .modifier_kind").addClass("closed");
- function commentToggleFct(signature){
- var parent = signature.parent();
- var shortComment = $(".shortcomment", parent);
- var fullComment = $(".fullcomment", parent);
+ function commentToggleFct(element){
+ $("#template li.selected").removeClass("selected");
+ element.toggleClass("open");
+ var signature = element.find(".modifier_kind")
+ var shortComment = element.find(".shortcomment");
+ var fullComment = element.find(".fullcomment");
var vis = $(":visible", fullComment);
signature.toggleClass("closed").toggleClass("opened");
if (vis.length > 0) {
@@ -268,9 +259,7 @@ $(document).ready(function() {
};
$("#template li[fullComment=yes]").click(function() {
- $("#template li.selected").removeClass("selected");
- commentToggleFct($(".modifier_kind", this));
- $(this).toggleClass("open");
+ commentToggleFct($(this));
});
/* Linear super types and known subclasses */
@@ -298,13 +287,29 @@ $(document).ready(function() {
return $(memberSelector);
}
- // highlight and jump to selected member
+ // highlight and jump to selected member if an anchor is provided
if (window.location.hash) {
var jqElem = findElementByHash(window.location.hash);
if (jqElem.length > 0)
exposeMember(jqElem);
}
+ $("#template span.permalink").click(function(e) {
+ e.preventDefault();
+ var href = $("a", this).attr("href");
+ if (href.indexOf("#") != -1) {
+ var hash = href.split("#").pop()
+ try {
+ window.history.pushState({}, "", "#" + hash)
+ } catch (e) {
+ // fallback for file:// URLs, has worse scrolling behavior
+ location.hash = hash;
+ }
+ exposeMember(findElementByHash(hash))
+ }
+ return false;
+ });
+
$("#mbrsel-input").on("input", function() {
if ($(this).val().length > 0)
$("#memberfilter > .clear").show();