From b195ecb345132895e0564e4e849196d137e24cdd Mon Sep 17 00:00:00 2001 From: Mark Lentczner Date: Mon, 26 Jul 2010 02:39:15 +0000 Subject: make module list use new collapsers --- html/themes/Ocean/ocean.css | 14 ++++++++++++-- html/themes/Snappy/snappy.css | 21 ++++++++++++++++++--- html/themes/Tibbe/tibbe.css | 15 +++++++++++++-- src/Haddock/Backends/Xhtml.hs | 12 ++++++------ src/Haddock/Backends/Xhtml/Layout.hs | 4 +--- src/Haddock/Backends/Xhtml/Utils.hs | 10 ++++++---- 6 files changed, 56 insertions(+), 20 deletions(-) diff --git a/html/themes/Ocean/ocean.css b/html/themes/Ocean/ocean.css index f671a170..53af455f 100644 --- a/html/themes/Ocean/ocean.css +++ b/html/themes/Ocean/ocean.css @@ -75,10 +75,20 @@ ul.links li a { padding: 5px 10px; } .clear { clear: both; } .collapser { - background: url(minus.gif) no-repeat 0 0.4em; + background-image: url(minus.gif); + background-repeat: no-repeat; } .expander { - background: url(plus.gif) no-repeat 0 0.4em; + background-image: url(plus.gif); + background-repeat: no-repeat; +} +span.module.collapser, +span.module.expander { + background-position: 0 0.3em; +} +p.caption.collapser, +p.caption.expander { + background-position: 0 0.4em; } .collapser, .expander { padding-left: 14px; diff --git a/html/themes/Snappy/snappy.css b/html/themes/Snappy/snappy.css index 52215f93..d3d5bf84 100644 --- a/html/themes/Snappy/snappy.css +++ b/html/themes/Snappy/snappy.css @@ -142,13 +142,28 @@ ul.links li { .hide { display: none; } .show { } + .collapser { - background: url(minus.gif) no-repeat 0 17px; + background-image: url(minus.gif); + background-repeat: no-repeat; } .expander { - background: url(plus.gif) no-repeat 0 17px; + background-image: url(plus.gif); + background-repeat: no-repeat; +} + +span.module.collapser, +span.module.expander { + background-position: 0 6px; +} +p.caption.collapser, +p.caption.expander { + background-position: 0 17px; } -.subs .collapser, .subs .expander { +#module-list .collapser, +#module-list .expander, +.subs p.caption.collapser, +.subs p.caption.expander { padding-left: 14px; margin-left: -14px; cursor: pointer; diff --git a/html/themes/Tibbe/tibbe.css b/html/themes/Tibbe/tibbe.css index d92c269b..886e3253 100644 --- a/html/themes/Tibbe/tibbe.css +++ b/html/themes/Tibbe/tibbe.css @@ -227,11 +227,22 @@ dd { .hide { display: none; } .show { } + .collapser { - background: url(minus.gif) no-repeat 0 1.3em; + background-image: url(minus.gif); + background-repeat: no-repeat; } .expander { - background: url(plus.gif) no-repeat 0 1.3em; + background-image: url(plus.gif); + background-repeat: no-repeat; +} +span.module.collapser, +span.module.expander { + background-position: 0 0.3em; +} +p.caption.collapser, +p.caption.expander { + background-position: 0 1.3em; } .collapser, .expander { padding-left: 14px; diff --git a/src/Haddock/Backends/Xhtml.hs b/src/Haddock/Backends/Xhtml.hs index 94ee6347..7eb3180d 100644 --- a/src/Haddock/Backends/Xhtml.hs +++ b/src/Haddock/Backends/Xhtml.hs @@ -279,13 +279,13 @@ mkNodeList ss p ts = case ts of mkNode :: [String] -> String -> ModuleTree -> Html mkNode ss p (Node s leaf pkg short ts) = - collBtn +++ htmlModule +++ shortDescr +++ htmlPkg +++ subtree + htmlModule +++ shortDescr +++ htmlPkg +++ subtree where - collBtn = case ts of - [] -> noHtml - _ -> collapsebutton p + modAttrs = case ts of + [] -> [theclass "module"] + _ -> collapser p "module" - htmlModule = thespan ! [theclass "module" ] << + htmlModule = thespan ! modAttrs << (if leaf then ppModule (mkModule (stringToPackageId (fromMaybe "" pkg)) (mkModuleName mdl)) @@ -297,7 +297,7 @@ mkNode ss p (Node s leaf pkg short ts) = shortDescr = maybe noHtml origDocToHtml short htmlPkg = maybe noHtml (thespan ! [theclass "package"] <<) pkg - subtree = mkNodeList (s:ss) p ts ! [identifier p] + subtree = mkNodeList (s:ss) p ts ! [identifier p, theclass "show"] -- | Turn a module tree into a flat list of full module names. E.g., diff --git a/src/Haddock/Backends/Xhtml/Layout.hs b/src/Haddock/Backends/Xhtml/Layout.hs index 3535ba0e..9e45b812 100644 --- a/src/Haddock/Backends/Xhtml/Layout.hs +++ b/src/Haddock/Backends/Xhtml/Layout.hs @@ -163,9 +163,7 @@ subInstances id_ = maybe noHtml wrap . instTable wrap = (subSection <<) . (subCaption +++) instTable = fmap (thediv ! [identifier id_, theclass "show"] <<) . subTable subSection = thediv ! [theclass $ "subs instances"] - subCaption = paragraph ! [theclass cs, onclick js] << "Instances" - cs = "caption collapser" - js = "toggleSection(this,'" ++ id_ ++ "')" + subCaption = paragraph ! collapser id_ "caption" << "Instances" subMethods :: [Html] -> Html diff --git a/src/Haddock/Backends/Xhtml/Utils.hs b/src/Haddock/Backends/Xhtml/Utils.hs index 61f0894d..30abfdcd 100644 --- a/src/Haddock/Backends/Xhtml/Utils.hs +++ b/src/Haddock/Backends/Xhtml/Utils.hs @@ -25,7 +25,7 @@ module Haddock.Backends.Xhtml.Utils ( hsep, onclick, - collapsebutton, collapseId, + collapser, collapseId, ) where @@ -182,9 +182,11 @@ linkedAnchor n = anchor ! [href ('#':n)] -- below to a 'plusFile' and the 'display:block;' to a 'display:none;' when we -- use cookies from JavaScript to have a more persistent state. -collapsebutton :: String -> Html -collapsebutton id_ = - image ! [ src "minus.gif", theclass "coll", onclick ("toggle(this,'" ++ id_ ++ "')"), alt "show/hide" ] +collapser :: String -> String -> [HtmlAttr] +collapser id_ classes = [ theclass cs, onclick js ] + where + cs = unwords (words classes ++ ["collapser"]) + js = "toggleSection(this,'" ++ id_ ++ "')" -- A quote is a valid part of a Haskell identifier, but it would interfere with -- cgit v1.2.3