summaryrefslogtreecommitdiff
path: root/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js')
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.js112
1 files changed, 54 insertions, 58 deletions
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 b0719b1ed5..64177a7723 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
@@ -4,10 +4,10 @@
var $panzoom = undefined;
$(document).ready(function() {
// Add zoom functionality to type inheritance diagram
- $panzoom = $("#inheritance-diagram").panzoom({
+ $panzoom = $(".diagram-container > .diagram").panzoom({
increment: 0.1,
minScale: 1,
- maxScale: 3,
+ maxScale: 7,
transition: true,
duration: 200,
contain: 'invert',
@@ -16,15 +16,10 @@ $(document).ready(function() {
$zoomOut: $('#diagram-zoom-out'),
});
- $("#template > div > div > ol > li > span > a").click(function(e) {
- var href = $(this).attr("href");
- if (href.indexOf("#") != -1) {
- e.preventDefault();
- location.hash = href.split("#").pop();
- $("#template > div > div > ol > li").removeClass("selected");
- var parent = $(this).parent().parent().addClass("selected");
- $("#content-container").animate({scrollTop: $("#content-container").scrollTop() + $(this).offset().top - $("#search").height() - 22}, 500);
- }
+ var oldWidth = $("div#subpackage-spacer").width() + 1 + "px";
+ $("div#packages > ul > li.current").click(function() {
+ $("div#subpackage-spacer").css({ "width": oldWidth });
+ $("li.current-entities").toggle();
});
var controls = {
@@ -58,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) {
@@ -140,10 +136,10 @@ $(document).ready(function() {
});
$("#memberfilter > .clear").click(function() {
$("#memberfilter input").attr("value", "");
+ $(this).hide();
filter();
});
$(document).keydown(function(event) {
-
if (event.keyCode == 9) { // tab
$("#index-input", window.parent.document).focus();
input.attr("value", "");
@@ -155,8 +151,7 @@ $(document).ready(function() {
if ($(this).hasClass("in")) {
$(this).removeClass("in");
$(this).addClass("out");
- }
- else if ($(this).hasClass("out")) {
+ } else if ($(this).hasClass("out")) {
$(this).removeClass("out");
$(this).addClass("in");
}
@@ -167,8 +162,7 @@ $(document).ready(function() {
if ($(this).hasClass("in")) {
$(this).removeClass("in");
$(this).addClass("out");
- }
- else if ($(this).hasClass("out")) {
+ } else if ($(this).hasClass("out")) {
$(this).removeClass("out");
$(this).addClass("in");
}
@@ -208,19 +202,16 @@ $(document).ready(function() {
filter();
});
$("#order > ol > li.alpha").click(function() {
- if ($(this).hasClass("out")) {
+ if ($(this).hasClass("out"))
orderAlpha();
- }
})
$("#order > ol > li.inherit").click(function() {
- if ($(this).hasClass("out")) {
+ if ($(this).hasClass("out"))
orderInherit();
- }
});
$("#order > ol > li.group").click(function() {
- if ($(this).hasClass("out")) {
+ if ($(this).hasClass("out"))
orderGroup();
- }
});
$("#groupedMembers").hide();
@@ -237,14 +228,14 @@ $(document).ready(function() {
});
/* Add toggle arrows */
- //var docAllSigs = $("#template li").has(".fullcomment").find(".signature");
- // trying to speed things up a little bit
- var docAllSigs = $("#template li[fullComment=yes] .modifier_kind");
-
- function commentToggleFct(signature){
- var parent = signature.parent();
- var shortComment = $(".shortcomment", parent);
- var fullComment = $(".fullcomment", parent);
+ $("#template li[fullComment=yes] .modifier_kind").addClass("closed");
+
+ 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) {
@@ -266,15 +257,15 @@ $(document).ready(function() {
}
}
};
- docAllSigs.addClass("closed");
- docAllSigs.click(function() {
+
+ $("#template li[fullComment=yes]").click(function() {
commentToggleFct($(this));
});
/* Linear super types and known subclasses */
function toggleShowContentFct(e){
e.toggleClass("open");
- var content = $(".hiddenContent", e.parent().get(0));
+ var content = $(".hiddenContent", e);
if(content.is(':visible')) {
if (!isMobile()) content.slideUp(100);
else content.hide();
@@ -284,12 +275,14 @@ $(document).ready(function() {
}
};
- $(".toggle:not(.diagram-link)").click(function() {
+ $(".toggleContainer:not(.diagram-container):not(.full-signature-block)").click(function() {
toggleShowContentFct($(this));
});
- // Set parent window title
- windowTitle();
+ $(".toggleContainer.full-signature-block").click(function() {
+ toggleShowContentFct($(this));
+ return false;
+ });
if ($("#order > ol > li.group").length == 1) { orderGroup(); };
@@ -299,22 +292,34 @@ $(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) {
+ if (jqElem.length > 0)
exposeMember(jqElem);
- }
}
- $("#mbrsel-input").on("focus", function() {
- $("#memberfilter > .clear").show();
+ $("#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("blur", function() {
- setTimeout(function() {
+ $("#mbrsel-input").on("input", function() {
+ if ($(this).val().length > 0)
+ $("#memberfilter > .clear").show();
+ else
$("#memberfilter > .clear").hide();
- }, 10);
});
});
@@ -537,15 +542,6 @@ function filter() {
return false;
};
-function windowTitle() {
- try {
- parent.document.title=document.title;
- } catch(e) {
- // Chrome doesn't allow settings the parent's title when
- // used on the local file system.
- }
-};
-
/** Check if user agent is associated with a known mobile browser */
function isMobile() {
return /Android|webOS|Mobi|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);