From f293a16b9c1ea8b393c72a061ef3b893b8dae4dd Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 14 Feb 2017 11:59:08 +0100 Subject: [PATCH] use jQuery slector to define the elements This makes it possible to use multiple. For now I just use all headlines --- js/sidebar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/sidebar.js b/js/sidebar.js index 9279c1e..15e14f6 100644 --- a/js/sidebar.js +++ b/js/sidebar.js @@ -5,7 +5,7 @@ jQuery(function () { const $nav = jQuery('#dokuwiki__aside').find('nav.nav-main'); if (!$nav.length) return; - const ELEMENT = 'h2'; // FIXME move to config + const ELEMENT = 'h1,h2,h3,h4,h5'; // FIXME move to config const $elements = $nav.find(ELEMENT); $elements.each(function () { const $me = jQuery(this); @@ -31,8 +31,8 @@ jQuery(function () { const $wrap = jQuery('
').addClass('navi-pane'); const $sibs = $me.nextAll(); for (let i = 0; i < $sibs.length; i++) { - if ($sibs[i].tagName.toLowerCase() === ELEMENT) break; const $sib = jQuery($sibs[i]); + if($sib.is(ELEMENT)) break; $sib.detach().appendTo($wrap); } $wrap.hide();