From 93af6a68bd07fd2377d8b09db3d989fbe1bf8d23 Mon Sep 17 00:00:00 2001 From: William MARTIN Date: Fri, 7 Jan 2011 22:33:18 +0100 Subject: [PATCH] Add table of contents on wiki pages --- src/IDF/templates/idf/wiki/view.html | 4 ++++ www/media/idf/css/style.css | 26 ++++++++++++++++++++++++++ www/media/idf/js/wiki-toc.js | 7 +++++++ 3 files changed, 37 insertions(+) create mode 100644 www/media/idf/js/wiki-toc.js diff --git a/src/IDF/templates/idf/wiki/view.html b/src/IDF/templates/idf/wiki/view.html index 21594cd..42fba21 100644 --- a/src/IDF/templates/idf/wiki/view.html +++ b/src/IDF/templates/idf/wiki/view.html @@ -18,6 +18,9 @@ by {$submitter}.{/blocktrans}

{/if} +
+
{trans 'Table of Content'}
+

{$page.summary}

{if !$oldrev} @@ -29,6 +32,7 @@ by {$submitter}.{/blocktrans}

{/if} {/if} +
{/block} {block context} {ashowuser 'submitter', $page.get_submitter(), $request} diff --git a/www/media/idf/css/style.css b/www/media/idf/css/style.css index 9188e1d..942a1b7 100644 --- a/www/media/idf/css/style.css +++ b/www/media/idf/css/style.css @@ -746,6 +746,32 @@ ol > li { margin: 0px; } +#wiki-toc { + float: right; + margin-left: 10px; +} + +#wiki-toc-content { + border: 1px solid #999999; + border-width: 1px 0; + padding: 10px 0; + padding-bottom: 25px; + background-color: #ffffff; + display: block; +} + +#wiki-toc-content a { + display: block; +} + +#wiki-toc-content a.wiki-h2 { + margin-left: 1em; +} + +#wiki-toc-content a.wiki-h3 { + margin-left: 2em; +} + /** * main menu */ diff --git a/www/media/idf/js/wiki-toc.js b/www/media/idf/js/wiki-toc.js new file mode 100644 index 0000000..e7e8e3d --- /dev/null +++ b/www/media/idf/js/wiki-toc.js @@ -0,0 +1,7 @@ +$(document).ready(function() { + $(":header", "#wiki-content").map(function (index) { + this.id = "wikititle_" + index; + $("" + this.innerText + "").addClass("wiki-" + this.tagName.toLowerCase()).appendTo('#wiki-toc-content'); + }); +}); +