1/* FastWiki Plugin Support */
2function tpl_fastwiki_support() { }
3
4jQuery(window).on('fastwiki:afterSwitch', function (evt, viewMode, isSectionEdit, prevViewMode) {
5    if (viewMode === 'show') {
6        // Check if the source element 'article.mikio-article div.mikio-article-content.content_initial #dw__toc' exists
7        var sourceToc = jQuery('article.mikio-article div.mikio-article-content.content_initial #dw__toc');
8
9        if (sourceToc.length > 0) {
10            // Check if the target location 'article.mikio-article .mikio-toc #dw__toc' already has a 'dw__toc' element
11            var targetToc = jQuery('article.mikio-article .mikio-toc #dw__toc');
12
13            if (targetToc.length > 0) {
14                // If the target already has a 'dw__toc', remove it
15                targetToc.remove();
16            }
17
18            // Move the 'dw__toc' from the source to the target location
19            sourceToc.appendTo('article.mikio-article .mikio-toc');
20
21            // Bookcreator is shown - so we do this hack
22            jQuery('.bookcreator__bookbar').hide();
23        }
24    }
25});
26