Add table of contents on wiki pages

This commit is contained in:
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> </div>
{/if} {/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> <p class="desc">{$page.summary}</p>
{if !$oldrev} {if !$oldrev}
@ -29,6 +32,7 @@ by {$submitter}.{/blocktrans}</p>
{/if} {/if}
{/if} {/if}
</div>
{/block} {/block}
{block context} {block context}
{ashowuser 'submitter', $page.get_submitter(), $request} {ashowuser 'submitter', $page.get_submitter(), $request}

View File

@ -746,6 +746,32 @@ ol > li {
margin: 0px; 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 * 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');
});
});