From 9931362030c9536caf5c1d04a34d428b59bf3b04 Mon Sep 17 00:00:00 2001 From: Mark Lentczner Date: Sat, 14 Aug 2010 03:44:46 +0000 Subject: build style menu in javascript moved to javascript, so as to not polute the content with the style menu removed menu building code in Themes.hs removed onclick in Utils.hs changed text of button in header from "Source code" to "Source" more consistent with links in rest of page --- html/haddock-util.js | 53 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'html') diff --git a/html/haddock-util.js b/html/haddock-util.js index 1a57b24b..c5bc6a8d 100644 --- a/html/haddock-util.js +++ b/html/haddock-util.js @@ -164,23 +164,27 @@ function perform_search(full) } } -function addFramesButton() { - if (parent.location.href == window.location.href) { - var menu = document.getElementById("page-menu"); - if (menu) { - var btn = menu.lastChild.cloneNode(false); - btn.innerHTML = "Frames"; - menu.appendChild(btn); - } - } -} - function setSynopsis(filename) { if (parent.window.synopsis) { parent.window.synopsis.location = filename; } } +function addMenuItem(html) { + var menu = document.getElementById("page-menu"); + if (menu) { + var btn = menu.firstChild.cloneNode(false); + btn.innerHTML = html; + menu.appendChild(btn); + } +} + +function addFramesButton() { + if (parent.location.href == window.location.href) { + addMenuItem("Frames"); + } +} + function reframe() { setCookie("haddock-reframe", document.URL); window.location = "frames.html"; @@ -194,6 +198,26 @@ function postReframe() { } } +function addStyleMenu() { + var i, a, c = 0, btns = ""; + for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { + if(a.getAttribute("rel").indexOf("style") != -1 + && a.getAttribute("title")) { + btns += "
  • " + + a.getAttribute("title") + "
  • " + c += 1; + } + } + if (c > 1) { + var h = "
    " + + "Style ▾" + + "" + + "
    "; + addMenuItem(h); + } +} + function setActiveStyleSheet(href) { var i, a, found = false; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { @@ -223,3 +247,10 @@ function styleMenu(show) { toggleClassShow(m, show); } + +function pageLoad() { + addStyleMenu(); + addFramesButton(); + resetStyle(); +} + -- cgit v1.2.3