use super::prelude::*;
use crate::tree::{Alignment, AttributeMap, FloatAlignment};
pub fn render_table_of_contents(
ctx: &mut HtmlContext,
align: Option<Alignment>,
attributes: &AttributeMap,
) {
debug!("Creating table of contents");
let use_true_ids = ctx.settings().use_true_ids;
let class_value = match align {
None => "",
Some(align) => {
FloatAlignment { align, float: true }.wj_html_class()
}
};
ctx.html()
.div()
.attr(attr!(
"id" => "wj-toc"; if use_true_ids,
"class" => class_value; if align.is_some();;
attributes
))
.inner(|ctx| {
ctx.html()
.div()
.attr(attr!("id" => "wj-toc-action-bar"; if use_true_ids))
.inner(|ctx| {
ctx.html().a().attr(attr!(
"href" => "javascript:;",
"onclick" => "WIKIJUMP.page.listeners.foldToc(event)",
));
});
let table_of_contents_title = ctx
.handle()
.get_message(ctx.language(), "table-of-contents");
ctx.html()
.div()
.attr(attr!("class" => "title"))
.contents(table_of_contents_title);
let table_of_contents = ctx.table_of_contents();
ctx.html()
.div()
.attr(attr!("id" => "wj-toc-list"; if use_true_ids))
.contents(table_of_contents);
});
}