1/**
2 * javascript functionality for the arctic template
3 * copies the mothod for dokuwikis TOC functionality
4 * in order to keep the template XHTML valid
5 */
6
7/**
8 * Adds the toggle switch to the TOC
9 */
10function addSbLeftTocToggle() {
11    if(!document.getElementById) return;
12    var header = jQuery('sb__left__toc__header');
13    var header = "";
14    if(!header) return;
15
16    var obj          = document.createElement('span');
17    obj.id           = 'sb__left__toc__toggle';
18    obj.innerHTML    = '<span>&minus;</span>';
19    obj.className    = 'toc_close';
20    obj.style.cursor = 'pointer';
21
22    jQuery.prepend(header,obj);
23    obj.parentNode.onclick = toggleSbLeftToc;
24    try {
25       obj.parentNode.style.cursor = 'pointer';
26       obj.parentNode.style.cursor = 'hand';
27    }catch(e){}
28}
29
30/**
31 * This toggles the visibility of the Table of Contents
32 */
33function toggleSbLeftToc() {
34  var toc = jQuery('sb__left__toc__inside');
35  var obj = jQuery('sb__left__toc__toggle');
36  if(toc.style.display == 'none') {
37    toc.style.display   = '';
38    obj.innerHTML       = '<span>&minus;</span>';
39    obj.className       = 'toc_close';
40  } else {
41    toc.style.display   = 'none';
42    obj.innerHTML       = '<span>+</span>';
43    obj.className       = 'toc_open';
44  }
45}
46
47/**
48 * Adds the toggle switch to the TOC
49 */
50function addSbRightTocToggle() {
51    if(!document.getElementById) return;
52    var header = jQuery('sb__right__toc__header');
53    if(!header) return;
54
55    var obj          = document.createElement('span');
56    obj.id           = 'sb__right__toc__toggle';
57    obj.innerHTML    = '<span>&minus;</span>';
58    obj.className    = 'toc_close';
59    obj.style.cursor = 'pointer';
60
61    jQuery.prepend(header,obj);
62    obj.parentNode.onclick = toggleSbRightToc;
63    try {
64       obj.parentNode.style.cursor = 'pointer';
65       obj.parentNode.style.cursor = 'hand';
66    }catch(e){}
67}
68
69/**
70 * This toggles the visibility of the Table of Contents
71 */
72function toggleSbRightToc() {
73  var toc = jQuery('sb__right__toc__inside');
74  var obj = jQuery('sb__right__toc__toggle');
75  if(toc.style.display == 'none') {
76    toc.style.display   = '';
77    obj.innerHTML       = '<span>&minus;</span>';
78    obj.className       = 'toc_close';
79  } else {
80    toc.style.display   = 'none';
81    obj.innerHTML       = '<span>+</span>';
82    obj.className       = 'toc_open';
83  }
84}
85
86// add TOC events
87jQuery(addSbLeftTocToggle);
88jQuery(addSbRightTocToggle);
89
90// add AJAX index events
91jQuery(function(){
92    index.treeattach($('left__index__tree'));
93    index.treeattach($('right__index__tree'));
94});
95
96// vim:ts=4:sw=4:et:enc=utf-8:
97