From be99350655ca33aaa14b99d7b44b529aba0c8773 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Tue, 9 May 2017 22:11:57 +0800 Subject: Fix to implement toggle of TOC in HTML template --- public/views/html.hbs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/public/views/html.hbs b/public/views/html.hbs index 5ef51920..a300ddd5 100644 --- a/public/views/html.hbs +++ b/public/views/html.hbs @@ -160,6 +160,29 @@ removeHash(); }); + var toggle = $('.expand-toggle'); + var tocExpand = false; + + checkExpandToggle(); + toggle.click(function (e) { + e.preventDefault(); + e.stopPropagation(); + tocExpand = !tocExpand; + checkExpandToggle(); + }) + + function checkExpandToggle () { + var toc = $('.ui-toc-dropdown .toc'); + var toggle = $('.expand-toggle'); + if (!tocExpand) { + toc.removeClass('expand'); + toggle.text('Expand all'); + } else { + toc.addClass('expand'); + toggle.text('Collapse all'); + } + } + function scrollToTop() { $('body, html').stop(true, true).animate({ scrollTop: 0 -- cgit v1.2.3