Revamp this a little and make it jQuery 1.7 compatible (fixes issue 803)

This commit is contained in:
Thomas Keller 2012-04-29 00:24:09 +02:00
parent e8882292b5
commit 8db3c45763
2 changed files with 8 additions and 4 deletions

View File

@ -3,6 +3,7 @@
## Bugfixes ## Bugfixes
- Compatiblity fixes for PostgreSQL (fixes issue 800) - Compatiblity fixes for PostgreSQL (fixes issue 800)
- Fix TOC generation in wiki (issue 803)
## Language and Translations ## Language and Translations

View File

@ -1,9 +1,12 @@
$(document).ready(function() { $(document).ready(function() {
$(":header", "#wiki-content").map(function(index) { $(":header", "#wiki-content").map(function(index) {
this.id = "wikititle_" + index; var $header = $(this);
$("<a href='#" + this.id + "'>" + jQuery.fn.text([this]) + "</a>") var $toc = $('#wiki-toc-content');
.addClass("wiki-" + this.tagName.toLowerCase()) $header.attr('id', 'wikititle_' + index);
.appendTo('#wiki-toc-content'); $('<a />').attr('href', '#' + $header.attr('id'))
.text($header.text())
.addClass("wiki-" + $header[0].tagName.toLowerCase())
.appendTo($toc);
}); });
if ($('#wiki-toc-content *').size() < 2) if ($('#wiki-toc-content *').size() < 2)
$('#wiki-toc').hide(); $('#wiki-toc').hide();