Add table of contents on wiki pages

feature.better-home
William MARTIN 2011-01-07 22:33:18 +01:00
parent 146e956432
commit 93af6a68bd
3 changed files with 37 additions and 0 deletions

View File

@ -18,6 +18,9 @@ by {$submitter}.{/blocktrans}</p>
</div>
{/if}
<div id="wiki-content">
<div id="wiki-toc"><span id="contentheader">{trans 'Table of Content'}</span><div id="wiki-toc-content"></div></div>
<script type="text/javascript" src="{media '/idf/js/wiki-toc.js'}"></script>
<p class="desc">{$page.summary}</p>
{if !$oldrev}
@ -29,6 +32,7 @@ by {$submitter}.{/blocktrans}</p>
{/if}
{/if}
</div>
{/block}
{block context}
{ashowuser 'submitter', $page.get_submitter(), $request}

View File

@ -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
*/

View File

@ -0,0 +1,7 @@
$(document).ready(function() {
$(":header", "#wiki-content").map(function (index) {
this.id = "wikititle_" + index;
$("<a href='#" + this.id + "'>" + this.innerText + "</a>").addClass("wiki-" + this.tagName.toLowerCase()).appendTo('#wiki-toc-content');
});
});