1 // Sidebar table of contents
4 var click_func = function (e) {
6 if ($('#toc').data('opened')) {
7 $('#toc > *').animate({
8 left: '-=' + $('#toc > ul').width() + 'px'
10 $('#toc').removeData('opened');
12 $('#toc > *').animate({
13 left: '+=' + $('#toc > ul').width() + 'px'
15 $('#toc').data('opened', 1);
19 $('body').click(function () {
20 if( $('#toc').data('opened') ) $('#toc > img').mousedown();
23 var type = document.location.pathname.match(/\/doc\/html\/spec_html\/filter/) ? 'filter' : 'spec';
25 // Get the relevant table of contents
26 $.get(type === 'spec' ? 'index_toc.xml' : 'filter_toc.xml', function (xml) {
28 // Remove the main list from the DOM for performance
29 var $ul = $('#toc > ul').remove();
33 $(xml).find('c').each(function () {
35 var chapter_title = $(this).children('t').text();
36 var chapter_url = $(this).children('u').text();
38 var chapter_li = $('<li/>').append(
42 }).text(chapter_id + '. ' + chapter_title), $('<ul/>').hide()).appendTo($ul);
45 $('#toc img').fadeIn('slow', function () {
46 // Add the main list back to the DOM
47 $ul.removeClass('hidden').css('visibility', 'hidden').appendTo('#toc').css('left', '-' + $ul.width() + 'px').css('visibility', 'visible');
48 $('#toc > img').mousedown(click_func);
49 $('#toc > ul').click(click_func);
50 $('#toc, #toc a').click(function (e) {