1/**
2 * javascript functionality for the arctic template.
3 * Copies the method for dokuwiki's 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    jQuery( header ).prepend( obj );
22    jQuery( obj.parentNode ).bind( 'click', toggleSbLeftToc );
23    try {
24       obj.parentNode.style.cursor = 'pointer';
25       obj.parentNode.style.cursor = 'hand';
26    }catch(e){}
27}
28
29/**
30 * This toggles the visibility of the Table of Contents.
31 */
32function toggleSbLeftToc() {
33  var toc = jQuery('#sb__left__toc__inside');
34  var obj = jQuery('#sb__left__toc__toggle');
35  if( toc.css( 'display' ) == 'none' ) {
36    toc.css( 'display', 'block' );
37    obj.innerHTML       = '<span>&minus;</span>';
38    obj.className       = 'toc_close';
39  } else {
40    toc.css( 'display', 'none' );
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.length) 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( header ).prepend( obj );
62
63    jQuery( obj.parentNode ).bind( 'click', toggleSbRightToc );
64    try {
65       obj.parentNode.style.cursor = 'pointer';
66       obj.parentNode.style.cursor = 'hand';
67    }catch(e){}
68}
69
70/**
71 * This toggles the visibility of the Table of Contents.
72 */
73function toggleSbRightToc() {
74  var toc = jQuery('#sb__right__toc__inside');
75  var obj = jQuery('#sb__right__toc__toggle');
76
77  if( toc.css( 'display' ) == 'none' ) {
78    toc.css( 'display', 'block' );
79    obj.innerHTML       = '<span>&minus;</span>';
80    obj.className       = 'toc_close';
81  } else {
82    toc.css( 'display', 'none' );
83    obj.innerHTML       = '<span>+</span>';
84    obj.className       = 'toc_open';
85  }
86}
87
88var left_dw_index = jQuery('#left__index__tree').dw_tree({deferInit: true,
89    load_data: function  (show_sublist, $clicky) {
90        jQuery.post(
91            DOKU_BASE + 'lib/exe/ajax.php',
92            $clicky[0].search.substr(1) + '&call=index',
93            show_sublist, 'html'
94        );
95    }
96});
97var right_dw_index = jQuery('#right__index__tree').dw_tree({deferInit: true,
98    load_data: function  (show_sublist, $clicky) {
99        jQuery.post(
100            DOKU_BASE + 'lib/exe/ajax.php',
101            $clicky[0].search.substr(1) + '&call=index',
102            show_sublist, 'html'
103        );
104    }
105});
106
107jQuery(function(){
108// from lib/scripts/index.js
109    var $tree = jQuery('#left__index__tree');
110    left_dw_index.$obj = $tree;
111    left_dw_index.init();
112
113    var $tree = jQuery('#right__index__tree');
114    right_dw_index.$obj = $tree;
115    right_dw_index.init();
116
117// add TOC events
118    jQuery(addSbLeftTocToggle);
119    jQuery(addSbRightTocToggle);
120
121});
122
123// vim:ts=4:sw=4:et:enc=utf-8:
124