From dec2f98d9b3c7ed518a6de881abb2590f75216af Mon Sep 17 00:00:00 2001 From: Tamotsu Takahashi Date: Thu, 3 Sep 2020 09:46:13 +0900 Subject: [PATCH] Make "Expand all" translatable Move HTML from JS to EJS I don't know how to register i18n helper to handlebars, so "export to raw HTML" has not been touched. You can do the same for html.hbs if you want. Signed-off-by: Tamotsu Takahashi --- public/js/extra.js | 20 +++++++++++--------- public/views/codimd/body.ejs | 7 +++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/public/js/extra.js b/public/js/extra.js index d1f605c3..bc2c6b98 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -840,13 +840,16 @@ let tocExpand = false function checkExpandToggle () { const toc = $('.ui-toc-dropdown .toc') - const toggle = $('.expand-toggle') + const expand = $('.expand-toggle.expand-all') + const collapse = $('.expand-toggle.collapse-all') if (!tocExpand) { toc.removeClass('expand') - toggle.text('Expand all') + expand.show() + collapse.hide() } else { toc.addClass('expand') - toggle.text('Collapse all') + expand.hide() + collapse.show() } } @@ -865,11 +868,12 @@ export function generateToc (id) { }) /* eslint-enable no-unused-vars */ if (target.text() === 'undefined') { target.html('') } - const tocMenu = $('
Expand all') - const backtotop = $('Back to top') - const gotobottom = $('Go to bottom') checkExpandToggle() + const tocMenu = $('body').children('.toc-menu') + target.append(tocMenu.clone().show()) + const toggle = $('.expand-toggle', target) + const backtotop = $('.back-to-top', target) + const gotobottom = $('.go-to-bottom', target) toggle.click(e => { e.preventDefault() e.stopPropagation() @@ -888,8 +892,6 @@ export function generateToc (id) { if (window.scrollToBottom) { window.scrollToBottom() } removeHash() }) - tocMenu.append(toggle).append(backtotop).append(gotobottom) - target.append(tocMenu) } // smooth all hash trigger scrolling diff --git a/public/views/codimd/body.ejs b/public/views/codimd/body.ejs index 0a2f17ee..ff3e1eea 100644 --- a/public/views/codimd/body.ejs +++ b/public/views/codimd/body.ejs @@ -49,6 +49,13 @@
+ +