From e56b9cce24ac4895705576e282223f8811ed8eab Mon Sep 17 00:00:00 2001 From: Mark Lentczner Date: Fri, 13 Aug 2010 21:43:41 +0000 Subject: add Frames button and clean up frames.html --- html/frames.html | 55 ++++++++++++++++++++++--------------------- html/haddock-util.js | 48 ++++++++++++++++++++++++++++++------- src/Haddock/Backends/Xhtml.hs | 4 +++- 3 files changed, 70 insertions(+), 37 deletions(-) diff --git a/html/frames.html b/html/frames.html index 9e904fc1..30ce1fa5 100644 --- a/html/frames.html +++ b/html/frames.html @@ -1,27 +1,28 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/html/haddock-util.js b/html/haddock-util.js index 155ee08f..d9b0b3e4 100644 --- a/html/haddock-util.js +++ b/html/haddock-util.js @@ -24,6 +24,29 @@ function toggleSection(toggler,id) } +function setCookie(name, value) { + document.cookie = name + "=" + escape(value) + ";path=/;"; +} + +function clearCookie(name) { + document.cookie = name + "=;path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT;"; +} + +function getCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) { + return unescape(c.substring(nameEQ.length,c.length)); + } + } + return null; +} + + + var max_results = 75; // 50 is not enough to search for map in the base libraries var shown_range = null; var last_search = null; @@ -147,6 +170,20 @@ function setSynopsis(filename) { } } +function reframe() { + if (parent.location.href == window.location.href) { + setCookie("haddock-reframe", document.URL); + window.location = "frames.html"; + } +} + +function postReframe() { + var s = getCookie("haddock-reframe"); + if (s) { + parent.window.main.location = s; + clearCookie("haddock-reframe"); + } +} function setActiveStyleSheet(href) { var i, a, found = false; @@ -162,19 +199,12 @@ function setActiveStyleSheet(href) { } } if (!found) href = ""; - document.cookie = "style=" + href + ";path=/"; + setCookie("haddock-style", href); styleMenu(false); } function resetStyle() { - var nameEQ = "style="; - var s; - var ca = document.cookie.split(';'); - for(var i=0;i < ca.length;i++) { - var c = ca[i]; - while (c.charAt(0)==' ') c = c.substring(1,c.length); - if (c.indexOf(nameEQ) == 0) s = c.substring(nameEQ.length,c.length); - } + var s = getCookie("haddock-style"); if (s) setActiveStyleSheet(s); } diff --git a/src/Haddock/Backends/Xhtml.hs b/src/Haddock/Backends/Xhtml.hs index 4bd355ae..8618d16f 100644 --- a/src/Haddock/Backends/Xhtml.hs +++ b/src/Haddock/Backends/Xhtml.hs @@ -172,7 +172,9 @@ bodyHtml doctitle iface themes wikiButton maybe_wiki_url (ifaceMod `fmap` iface), contentsButton maybe_contents_url, indexButton maybe_index_url, - styleMenu themes]) ! [theclass "links"], + styleMenu themes, + Just (anchor ! [ href "#", onclick "reframe();"] << "Frames")]) + ! [theclass "links"], nonEmpty sectionName << doctitle ], divContent << pageContent, -- cgit v1.2.3