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    if(!header.length) return;
14
15    var obj          = document.createElement('span');
16    obj.id           = 'sb__left__toc__toggle';
17    obj.innerHTML    = '<span>&minus;</span>';
18    obj.className    = 'toc_close';
19    obj.style.cursor = 'pointer';
20
21    //prependChild(header,obj);
22    jQuery( header ).prepend( obj );
23    //obj.parentNode.onclick = toggleSbLeftToc;
24    jQuery( obj.parentNode ).bind( 'click', toggleSbLeftToc );
25    try {
26       obj.parentNode.style.cursor = 'pointer';
27       obj.parentNode.style.cursor = 'hand';
28    }catch(e){}
29}
30
31/**
32 * This toggles the visibility of the Table of Contents
33 */
34function toggleSbLeftToc() {
35  var toc = jQuery('#sb__left__toc__inside');
36  var obj = jQuery('#sb__left__toc__toggle');
37  if( toc.css( 'display' ) == 'none' ) {
38    toc.css( 'display', 'block' );
39    obj.innerHTML       = '<span>&minus;</span>';
40    obj.className       = 'toc_close';
41  } else {
42    toc.css( 'display', 'none' );
43    toc.style.display   = 'none';
44    obj.innerHTML       = '<span>+</span>';
45    obj.className       = 'toc_open';
46  }
47}
48
49/**
50 * Adds the toggle switch to the TOC
51 */
52function addSbRightTocToggle() {
53    if(!document.getElementById) return;
54    var header = jQuery('#sb__right__toc__header');
55    if(!header.length) return;
56
57    var obj          = document.createElement('span');
58    obj.id           = 'sb__right__toc__toggle';
59    obj.innerHTML    = '<span>&minus;</span>';
60    obj.className    = 'toc_close';
61    obj.style.cursor = 'pointer';
62
63    //prependChild(header,obj);
64    jQuery( header ).prepend( obj );
65
66    //obj.parentNode.onclick = toggleSbRightToc;
67    jQuery( obj.parentNode ).bind( 'click', toggleSbRightToc );
68    try {
69       obj.parentNode.style.cursor = 'pointer';
70       obj.parentNode.style.cursor = 'hand';
71    }catch(e){}
72}
73
74/**
75 * This toggles the visibility of the Table of Contents
76 */
77function toggleSbRightToc() {
78  var toc = jQuery('#sb__right__toc__inside');
79  var obj = jQuery('#sb__right__toc__toggle');
80
81  if( toc.css( 'display' ) == 'none' ) {
82    toc.css( 'display', 'block' );
83    obj.innerHTML       = '<span>&minus;</span>';
84    obj.className       = 'toc_close';
85  } else {
86    toc.css( 'display', 'none' );
87    obj.innerHTML       = '<span>+</span>';
88    obj.className       = 'toc_open';
89  }
90}
91
92var left_dw_index = jQuery('#left__index__tree').dw_tree({deferInit: true,
93    load_data: function  (show_sublist, $clicky) {
94        jQuery.post(
95            DOKU_BASE + 'lib/exe/ajax.php',
96            $clicky[0].search.substr(1) + '&call=index',
97            show_sublist, 'html'
98        );
99    }
100});
101var right_dw_index = jQuery('#right__index__tree').dw_tree({deferInit: true,
102    load_data: function  (show_sublist, $clicky) {
103        jQuery.post(
104            DOKU_BASE + 'lib/exe/ajax.php',
105            $clicky[0].search.substr(1) + '&call=index',
106            show_sublist, 'html'
107        );
108    }
109});
110
111jQuery(function(){
112// from lib/scripts/index.js
113    var $tree = jQuery('#left__index__tree');
114    left_dw_index.$obj = $tree;
115    left_dw_index.init();
116
117    var $tree = jQuery('#right__index__tree');
118    right_dw_index.$obj = $tree;
119    right_dw_index.init();
120
121// add TOC events
122    jQuery(addSbLeftTocToggle);
123    jQuery(addSbRightTocToggle);
124
125});
126
127// vim:ts=4:sw=4:et:enc=utf-8:
128