[build style menu in javascript Mark Lentczner **20100814034446 Ignore-this: 4e9df51c79d4720bbc82961ae6e3c2f2 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 ] { hunk ./html/haddock-util.js 167 -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); - } - } -} - hunk ./html/haddock-util.js 173 +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"); + } +} + hunk ./html/haddock-util.js 201 +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); + } +} + hunk ./html/haddock-util.js 250 + +function pageLoad() { + addStyleMenu(); + addFramesButton(); + resetStyle(); +} + hunk ./src/Haddock/Backends/Xhtml.hs 118 - "// Maybe Interface -> Themes +bodyHtml :: String -> Maybe Interface hunk ./src/Haddock/Backends/Xhtml.hs 164 -bodyHtml doctitle iface themes +bodyHtml doctitle iface hunk ./src/Haddock/Backends/Xhtml.hs 174 - indexButton maybe_index_url, - styleMenu themes]) + indexButton maybe_index_url]) hunk ./src/Haddock/Backends/Xhtml.hs 229 - bodyHtml doctitle Nothing themes + bodyHtml doctitle Nothing hunk ./src/Haddock/Backends/Xhtml.hs 347 - bodyHtml doctitle Nothing themes + bodyHtml doctitle Nothing hunk ./src/Haddock/Backends/Xhtml.hs 453 - bodyHtml doctitle (Just iface) themes + bodyHtml doctitle (Just iface) hunk ./src/Haddock/Backends/Xhtml/Themes.hs 15 - cssFiles, styleSheet, stylePickers, styleMenu + cssFiles, styleSheet hunk ./src/Haddock/Backends/Xhtml/Themes.hs 19 -import Haddock.Backends.Xhtml.Utils (onclick) hunk ./src/Haddock/Backends/Xhtml/Themes.hs 189 - -stylePickers :: Themes -> [Html] -stylePickers ts = map mkPicker ts - where - mkPicker t = - let js = "setActiveStyleSheet('" ++ themeHref t ++ "'); return false;" in - anchor ! [href "#", onclick js] << themeName t - - -styleMenu :: Themes -> Maybe Html -styleMenu [] = Nothing -styleMenu [_] = Nothing -styleMenu ts = Just $ thediv ! [identifier "style-menu-holder"] << [ - anchor ! [ href "#", onclick js ] << "Style \9662", - unordList (stylePickers ts) ! [ identifier "style-menu", theclass "hide" ] - ] - where - js = "styleMenu(); return false;" - - hunk ./src/Haddock/Backends/Xhtml/Utils.hs 27 - onclick, hunk ./src/Haddock/Backends/Xhtml/Utils.hs 155 -onclick :: String -> HtmlAttr -onclick = strAttr "onclick" - - hunk ./src/Haddock/Backends/Xhtml/Utils.hs 184 -collapser id_ classes = [ theclass cs, onclick js ] +collapser id_ classes = [ theclass cs, strAttr "onclick" js ] }