~ubuntu-branches/ubuntu/precise/trac-xmlrpc/precise

« back to all changes in this revision

Viewing changes to trunk/tracrpc/htdocs/rpc.js

  • Committer: Package Import Robot
  • Author(s): W. Martin Borgert, Jakub Wilk
  • Date: 2011-12-31 18:27:57 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20111231182757-oe70jynzu0lk5hny
Tags: 1.1.2+r10706-1
* New upstream version (Closes: #653726). Works with Trac 0.12.
* Fixed lintians.
  [Jakub Wilk <jwilk@debian.org>]
* Replace deprecated > operator with >=.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(function($) {
 
2
    $(document).ready(function () {
 
3
        // Create a Table of Contents (TOC)
 
4
        $('#content .wikipage')
 
5
            .prepend('<div id="rpc-toc" class="wiki-toc"><h4>Contents</h4><ul /></div>');
 
6
        function toc_entry(_this, item) {
 
7
            return $('<li><a href="#' + _this.id + '" title="'
 
8
                     + $(item).text().replace(/^\s+|\s+$/g, '')
 
9
                     + '">' + _this.id.replace(/^rpc\./, '') + '</a></li>');
 
10
        }
 
11
        var ul = $('#rpc-toc ul');
 
12
        $("#content").find("*[id]").each(function(index, item) {
 
13
            var elem = undefined;
 
14
            if (this.tagName == 'H2') {
 
15
                elem = toc_entry(this, item);
 
16
                elem.css('padding-top', '0.5em');
 
17
            }
 
18
            if (this.tagName == 'H3') {
 
19
                elem = toc_entry(this, item);
 
20
                elem.css('padding-left', '1.2em');
 
21
            }
 
22
            ul.append(elem);
 
23
        });
 
24
        $('#rpc-toc').toggle();
 
25
        // Add anchors to headings
 
26
        $("#content").find("h2,h3").addAnchor("Link here");
 
27
    });
 
28
})(jQuery);