diff options
-rw-r--r-- | html/haddock-util.js | 45 | ||||
-rw-r--r-- | html/shaddock.css | 47 | ||||
-rw-r--r-- | html/thaddock.css | 44 | ||||
-rw-r--r-- | html/xhaddock.css | 60 | ||||
-rw-r--r-- | src/Haddock/Backends/Xhtml.hs | 4 | ||||
-rw-r--r-- | src/Haddock/Backends/Xhtml/Util.hs | 12 |
6 files changed, 185 insertions, 27 deletions
diff --git a/html/haddock-util.js b/html/haddock-util.js index 227ac4f8..326a64b9 100644 --- a/html/haddock-util.js +++ b/html/haddock-util.js @@ -136,17 +136,44 @@ function setSynopsis(filename) { if (parent.window.synopsis) { parent.window.synopsis.location = filename; } + resetStyle(); // ugly: we are using setSynopsis as a hook! } function setActiveStyleSheet(href) { - var i, a, main; - for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { - if(a.getAttribute("rel").indexOf("style") != -1 - && a.getAttribute("title")) { - a.disabled = true; - if(a.getAttribute("href") == href) a.disabled = false; - //a.disabled = a.getAttribute("title") != title; - } - } + var i, a, found = false; + for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { + if(a.getAttribute("rel").indexOf("style") != -1 + && a.getAttribute("title")) { + a.disabled = true; + // need to do this always, some browsers are edge triggered + if(a.getAttribute("href") == href) { + a.disabled = false; + found = true; + } + } + } + if (!found) href = ""; + document.cookie = "style=" + href + ";path=/"; + 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); + } + if (s) setActiveStyleSheet(s); } + + +function styleMenu(show) { + var m = document.getElementById('style-menu'); + if (show == null) { show = m.className == "hide"; } + m.className = show ? "show" : "hide"; +} + diff --git a/html/shaddock.css b/html/shaddock.css index 3df31926..7be02966 100644 --- a/html/shaddock.css +++ b/html/shaddock.css @@ -133,7 +133,8 @@ ul.links li { white-space: nowrap; } - +.hide { display: none; } +.show { } /* Captions and Headers */ @@ -145,6 +146,14 @@ p.caption, h1, h2, h3, h4 { line-height: inherit; } +#package-header .caption { + font-size: 80%; + font-weight: bold; + padding-left: 26px; + padding-top: 2px; + padding-bottom: 3px; +} + #module-header .caption { font-weight: bold; letter-spacing: -0.02em; font-size: 201%; @@ -222,6 +231,42 @@ h4, #package-header a:hover { background-color: #C9D3DE; } #package-header li:hover { background-color: #C9D3DE; } +div#style-menu-holder { + position: relative; + z-index: 2; + display: inline; + margin: 0; + padding: 0; +} + +#style-menu { + position: absolute; + z-index: 1; + overflow: visible; + background-color: #3465a4; + margin: 0; + width: 6em; + text-align: center; + right: 0; + padding: 0 2px 1px; + border-left: 1px solid #fffffff; + border-right: 1px solid #fffffff; + border-bottom: 1px solid #fffffff; +} + +#style-menu li { + display: list-item; + border-style: none; + margin: 0; + padding: 3px; + color: #000; + list-style-type: none; +} + +#style-menu li + li { + border-top: 1px solid #ffffff; +} + #module-header { font-family: "Gill Sans", "Helvetica Neue","Arial",sans-serif; color: #141B24; diff --git a/html/thaddock.css b/html/thaddock.css index c7ae7d8c..fc7cac09 100644 --- a/html/thaddock.css +++ b/html/thaddock.css @@ -22,6 +22,47 @@ body { position: relative; } +#package-header .caption { + margin-left: 30px; + padding-top: 6px; +} + + + +div#style-menu-holder { + position: relative; + z-index: 2; + display: inline; +} + +#style-menu { + position: absolute; + z-index: 1; + overflow: visible; + background-color: #eaeaea; + margin: 0; + width: 6em; + text-align: center; + right: 0; + padding: 0 2px 1px; + border-left: 1px solid #919191; + border-right: 1px solid #919191; + border-bottom: 1px solid #919191; +} + +#style-menu li { + display: list-item; + border-style: none; + margin: 0; + padding: 3px; + color: #000; + list-style-type: none; +} + +#style-menu li + li { + border-top: 1px solid #919191; +} + #module-header .caption { background:transparent none repeat scroll 0 0; border:medium none; @@ -185,6 +226,9 @@ dd { padding:0; } +.hide { display: none; } +.show { } + .top, .subs { margin:0.4em 0 0 2em; padding:0; diff --git a/html/xhaddock.css b/html/xhaddock.css index 768e16a6..9901c26c 100644 --- a/html/xhaddock.css +++ b/html/xhaddock.css @@ -76,6 +76,26 @@ pre { margin-top: 0; } +ul.links { + list-style: none; + text-align: left; + position: absolute; + right: 5px; + top: 5px; + display: inline-table; +} + +ul.links li { + display: inline; + border-left-width: 1px; + border-left-color: #ffffff; + border-left-style: solid; + white-space: nowrap; + padding: 1px 5px; +} + +.hide { display: none; } +.show { } #package-header { color: #ffffff; @@ -85,27 +105,41 @@ pre { position: relative; } +#package-header .caption { + font-weight: normal; + font-style: normal; +} #package-header a:link { color: #ffffff } #package-header a:visited { color: #ffff00 } #package-header a:hover { background-color: #6060ff; } #package-header ul.links li:hover { background-color: #6060ff; } -ul.links { - list-style: none; - text-align: left; +div#style-menu-holder { + position: relative; + z-index: 2; + display: inline; +} + +#style-menu { position: absolute; - right: 5px; - top: 5px; - display: inline-table; + z-index: 1; + overflow: visible; + background-color: #000099; + margin: 0; + width: 6em; + text-align: center; + right: 0; + padding: 2px 2px 1px; } -ul.links li { - display: inline; - border-left-width: 1px; - border-left-color: #ffffff; - border-left-style: solid; - white-space: nowrap; - padding: 1px 5px; +#style-menu li { + display: list-item; + border-style: none; + margin: 0; + padding: 3px; + color: #000; + list-style-type: none; + border-top: 1px solid #ffffff; } #module-header { diff --git a/src/Haddock/Backends/Xhtml.hs b/src/Haddock/Backends/Xhtml.hs index c24dec6a..e204a9da 100644 --- a/src/Haddock/Backends/Xhtml.hs +++ b/src/Haddock/Backends/Xhtml.hs @@ -204,7 +204,7 @@ simpleHeader doctitle maybe_contents_url maybe_index_url wikiButton maybe_wiki_url Nothing, contentsButton maybe_contents_url, indexButton maybe_index_url - ] ++ stylePickers) ! [theclass "links"] + ] ++ [styleMenu]) ! [theclass "links"] ) pageHeader :: String -> Interface -> String @@ -220,7 +220,7 @@ pageHeader mdl iface doctitle wikiButton maybe_wiki_url (Just $ ifaceMod iface), contentsButton maybe_contents_url, indexButton maybe_index_url - ] ++ stylePickers) ! [theclass "links"] + ] ++ [styleMenu]) ! [theclass "links"] ) +++ divModuleHeader << ( sectionName << mdl +++ diff --git a/src/Haddock/Backends/Xhtml/Util.hs b/src/Haddock/Backends/Xhtml/Util.hs index de5f8180..13215bb7 100644 --- a/src/Haddock/Backends/Xhtml/Util.hs +++ b/src/Haddock/Backends/Xhtml/Util.hs @@ -28,7 +28,7 @@ module Haddock.Backends.Xhtml.Util ( collapsebutton, collapseId, collapsed, documentCharacterEncoding, - cssFiles, styleSheet, stylePickers + cssFiles, styleSheet, stylePickers, styleMenu ) where import Haddock.GhcUtils @@ -243,4 +243,12 @@ stylePickers = map mkPicker cssThemes mkPicker (aTitle, aFile) = let js = "setActiveStyleSheet('" ++ aFile ++ "'); return false;" in anchor ! [href "#", onclick js] << aTitle -
\ No newline at end of file + +styleMenu :: Html +styleMenu = thediv ! [identifier "style-menu-holder"] << [ + anchor ! [ href "#", onclick js ] << "Style\9662", + unordList stylePickers ! [ identifier "style-menu", theclass "hide" ] + ] + where + js = "styleMenu(); return false;" +
\ No newline at end of file |