72 lines
1.8 KiB
Plaintext
72 lines
1.8 KiB
Plaintext
<%
|
|
|
|
function layoutTocBody() {
|
|
if (toc(page.content).length > 0) {
|
|
return toc(page.content, {
|
|
list_number: item.list_number,
|
|
min_depth: item.min_depth,
|
|
max_depth: item.max_depth
|
|
})
|
|
}
|
|
return ''
|
|
}
|
|
|
|
function layoutTocHeader(title) {
|
|
var el = ''
|
|
el += `<div class="widget-header dis-select">`
|
|
el += `<span class="name">${title || __("meta.toc")}</span>`
|
|
el += `<a class="cap-action" onclick="sidebar.toggleTOC()" >${icon('default:rightbar')}</a>`
|
|
el += `</div>`
|
|
return el
|
|
}
|
|
|
|
function layoutToc(fallback) {
|
|
const tocBody = layoutTocBody()
|
|
if (tocBody.length == 0) {
|
|
return ''
|
|
}
|
|
var el = ''
|
|
el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">`
|
|
el += layoutTocHeader()
|
|
el += `<div class="widget-body">`
|
|
el += tocBody
|
|
el += `</div>`
|
|
el += `</widget>`
|
|
return el
|
|
}
|
|
|
|
function layoutDiv(fallback) {
|
|
const editBtn = partial('components/edit', {map: item.edit_this_page})
|
|
const tocBody = layoutTocBody()
|
|
if (tocBody.trim().length == 0 && editBtn.trim().length == 0) {
|
|
return ''
|
|
}
|
|
var el = ''
|
|
el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">`
|
|
if (tocBody.length > 0) {
|
|
el += layoutTocHeader()
|
|
el += `<div class="widget-body">`
|
|
el += tocBody
|
|
el += `</div>`
|
|
}
|
|
el += `<div class="widget-footer">`
|
|
el += editBtn
|
|
el += `<a class="top" onclick="util.scrollTop()">`
|
|
el += icon('default:upup')
|
|
el += `<span>${__('btn.top')}</span>`
|
|
el += `</a>`
|
|
if (page.comments) {
|
|
el += `<a class="buttom" onclick="util.scrollComment()">`
|
|
el += icon('default:tocomment')
|
|
el += `<span>${__('btn.comments')}</span>`
|
|
el += `</a>`
|
|
}
|
|
el += `</div>`
|
|
el += `</widget>`
|
|
return el
|
|
}
|
|
|
|
%>
|
|
|
|
<%- layoutDiv() %>
|