xref: /plugin/qc/script.js (revision 5ae683c7a46f396115e5dc73c00635f98e9a5e43)
1/**
2 * Add the QC info to the sitemap
3 */
4function plugin_qc_enhance($data){
5    $data.find('div.li a.wikilink1').each(function(){
6        var $link = jQuery(this);
7        var img = document.createElement('img');
8        img.src = DOKU_BASE + 'lib/plugins/qc/icon.php?id=' + $link.attr('title') + '&type=small';
9        img.alt = '';
10        img.className = 'qc_smallicon';
11        $link.parent().append(img);
12    });
13}
14
15
16/**
17 * Override the sitemap initialization
18 *
19 * ugly, but currently not differently doable
20 */
21dw_index = jQuery('#index__tree').dw_tree({deferInit: true,
22    load_data: function (show_sublist, $clicky) {
23        jQuery.post(
24            DOKU_BASE + 'lib/exe/ajax.php',
25            $clicky[0].search.substr(1) + '&call=index',
26            function (data) {
27                $data = jQuery(data);
28                plugin_qc_enhance($data);
29                show_sublist($data);
30            },
31            'html'
32        );
33    }
34});
35
36jQuery(function () {
37    // add stuff to the sitemap tree
38    plugin_qc_enhance(jQuery('#index__tree'));
39
40    /**
41     * Open/Close the QC panel
42     */
43    jQuery('#plugin__qc__icon')
44        .css('cursor', 'pointer')
45        .click(function () {
46            var $out = jQuery('#plugin__qc__out');
47            var on = $out.is(':visible');
48            $out.html('');
49            $out.dw_toggle(!on, function () {
50                if (!on) {
51                    var url = DOKU_BASE+'/lib/plugins/qc/pageinfo.php?' +
52                              jQuery('#plugin__qc__icon').attr('src').split('?')[1];
53                    $out.html('loading...').load(
54                        url.replace(/^\/+/, '/')
55                    );
56                }
57            });
58        });
59});
60