summaryrefslogtreecommitdiff
path: root/lib/tpl/nowawes/script.js
blob: d80a978505586cc54df041a140dc5d2236cab615 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
 * javascript functionality for the arctic template
 * copies the mothod for dokuwikis TOC functionality
 * in order to keep the template XHTML valid
 */

/**
 * Adds the toggle switch to the TOC
 */
function addSbLeftTocToggle() {
    if(!document.getElementById) return;
    var header = jQuery('#sb__left__toc__header');
    if(!header.length) return;

    var obj          = document.createElement('span');
    obj.id           = 'sb__left__toc__toggle';
    obj.innerHTML    = '<span>&minus;</span>';
    obj.className    = 'toc_close';
    obj.style.cursor = 'pointer';

    //prependChild(header,obj);
    jQuery( header ).prepend( obj );
    //obj.parentNode.onclick = toggleSbLeftToc;
    jQuery( obj.parentNode ).bind( 'click', toggleSbLeftToc );
    try {
       obj.parentNode.style.cursor = 'pointer';
       obj.parentNode.style.cursor = 'hand';
    }catch(e){}
}

/**
 * This toggles the visibility of the Table of Contents
 */
function toggleSbLeftToc() {
  var toc = jQuery('#sb__left__toc__inside');
  var obj = jQuery('#sb__left__toc__toggle');
  if( toc.css( 'display' ) == 'none' ) {
    toc.css( 'display', 'block' );
    obj.innerHTML       = '<span>&minus;</span>';
    obj.className       = 'toc_close';
  } else {
    toc.css( 'display', 'none' );
    toc.style.display   = 'none';
    obj.innerHTML       = '<span>+</span>';
    obj.className       = 'toc_open';
  }
}

/**
 * Adds the toggle switch to the TOC
 */
function addSbRightTocToggle() {
    if(!document.getElementById) return;
    var header = jQuery('#sb__right__toc__header');
    if(!header.length) return;

    var obj          = document.createElement('span');
    obj.id           = 'sb__right__toc__toggle';
    obj.innerHTML    = '<span>&minus;</span>';
    obj.className    = 'toc_close';
    obj.style.cursor = 'pointer';

    //prependChild(header,obj);
    jQuery( header ).prepend( obj );

    //obj.parentNode.onclick = toggleSbRightToc;
    jQuery( obj.parentNode ).bind( 'click', toggleSbRightToc );
    try {
       obj.parentNode.style.cursor = 'pointer';
       obj.parentNode.style.cursor = 'hand';
    }catch(e){}
}

/**
 * This toggles the visibility of the Table of Contents
 */
function toggleSbRightToc() {
  var toc = jQuery('#sb__right__toc__inside');
  var obj = jQuery('#sb__right__toc__toggle');

  if( toc.css( 'display' ) == 'none' ) {
    toc.css( 'display', 'block' );
    obj.innerHTML       = '<span>&minus;</span>';
    obj.className       = 'toc_close';
  } else {
    toc.css( 'display', 'none' );
    obj.innerHTML       = '<span>+</span>';
    obj.className       = 'toc_open';
  }
}

var left_dw_index = jQuery('#left__index__tree').dw_tree({deferInit: true,
    load_data: function  (show_sublist, $clicky) {
        jQuery.post(
            DOKU_BASE + 'lib/exe/ajax.php',
            $clicky[0].search.substr(1) + '&call=index',
            show_sublist, 'html'
        );
    }
});  
var right_dw_index = jQuery('#right__index__tree').dw_tree({deferInit: true,
    load_data: function  (show_sublist, $clicky) {
        jQuery.post(
            DOKU_BASE + 'lib/exe/ajax.php',
            $clicky[0].search.substr(1) + '&call=index',
            show_sublist, 'html'
        );
    }
});  

jQuery(function(){
// from lib/scripts/index.js 
    var $tree = jQuery('#left__index__tree');
    left_dw_index.$obj = $tree;
    left_dw_index.init();

    var $tree = jQuery('#right__index__tree');
    right_dw_index.$obj = $tree;
    right_dw_index.init();

// add TOC events
    jQuery(addSbLeftTocToggle);
    jQuery(addSbRightTocToggle);

});

// vim:ts=4:sw=4:et:enc=utf-8: