aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Lentczner <markl@glyphic.com>2010-08-13 21:43:41 +0000
committerMark Lentczner <markl@glyphic.com>2010-08-13 21:43:41 +0000
commite56b9cce24ac4895705576e282223f8811ed8eab (patch)
tree82b1337aeded36bef84984a5a3d494274da2352b
parentb67e3a4102fd607f7d9133f74467b76deb0a652a (diff)
add Frames button and clean up frames.html
-rw-r--r--html/frames.html55
-rw-r--r--html/haddock-util.js48
-rw-r--r--src/Haddock/Backends/Xhtml.hs4
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 @@
-<html>
-<head>
-<script type="text/javascript"><!--
-/*
-
- The synopsis frame needs to be updated using javascript, so we hide
- it by default and only show it if javascript is enabled.
-
- TODO: provide some means to disable it.
-*/
-function load() {
- var d = document.getElementById("inner-fs");
- d.rows = "50%,50%";
-}
---></script>
-<frameset id="outer-fs" cols="25%,75%" onload="load()">
- <frameset id="inner-fs" rows="100%,0%">
-
- <frame src="index-frames.html" name="modules">
- <frame src="" name="synopsis">
-
- </frameset>
- <frame src="index.html" name="main">
-
-</frameset>
-
-</html>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script src="haddock-util.js" type="text/javascript"></script>
+<script type="text/javascript"><!--
+/*
+
+ The synopsis frame needs to be updated using javascript, so we hide
+ it by default and only show it if javascript is enabled.
+
+ TODO: provide some means to disable it.
+*/
+function load() {
+ var d = document.getElementById("inner-fs");
+ d.rows = "50%,50%";
+ postReframe();
+}
+--></script>
+<frameset id="outer-fs" cols="25%,75%" onload="load()">
+ <frameset id="inner-fs" rows="100%,0%">
+ <frame src="index-frames.html" name="modules">
+ <frame src="" name="synopsis">
+ </frameset>
+ <frame src="index.html" name="main">
+</frameset>
+</html>
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,