Post by Admin on Sept 23, 2021 15:43:27 GMT
Testing Chris's code, below.
<script>
$(function buildCreateThreadDialog() {
if ("function" === typeof String.raw) {
let choose_boards = $('<div />', {
id: 'create_thread_boards'
}).appendTo('body').attr('style', 'display: none;background-color: #f5f5f5; padding: 10px; border: solid #000000; border-width: 0px 1px 1px 1px;')
.append('<div style="font-weight: bold;margin: 5px; padding: 5px;">Click the board you wish to post a thread in</div>');
let structure = pb.data('pop_menu_structure').menuStructure;
$.each(structure._root.items, buildMenu.bind(structure, ))
function processLiteral(k) {
return $(k);
}
function buildMenu(menu, i, e) {
if (!e) {
e = i;
i = menu;
menu = null
}
let {
submenu,
href,
text
} = e;
let depth = menu ? +menu.split('-')[0] : 0;
let id = (href && href.match(/\/board\/(\d+)/i)) ? +RegExp.$1 : 0
let templates = [
`<div style="background: var(--create-thread-category-background,#105469); border: var(--create-thread-category-border,1px solid #000000); margin: var(--create-thread-category-margin,5px); padding: var(--create-thread-category-padding,5px); font-weight: var(--create-thread-category-font-weight,bold); color: var(--create-thread-category-color,#FFFFFF);">${text}</div>`
,
`<div class="create_thread_board_link" data-boardid="${id}" style="border: var(--create-thread-board-border,1px solid #000000); margin: var(--create-thread-board-margin,5px);margin-left: ${5+15*depth}px; padding: var(--create-thread-board-padding,5px);background: var(--create-thread-category-background,#fff);cursor: pointer;">${text}</div>`
]
if (submenu || id) {
choose_boards.append(processLiteral(templates[id == 0 ? 0 : 1]));
submenu && $.each(structure[submenu].items, buildMenu.bind(structure, submenu))
}
}
choose_boards.dialog({
title: 'choose Board',
width:'40%',
autoOpen:!1
})
.on('click', '.create_thread_board_link', function (ev) { //debugger;
location = "/thread/new/" + ev.currentTarget.dataset.boardid;
})
.find('> div').wrapAll('<div style="max-height:var(--create-thread-dialog-height,20rem);overflow-y:auto"></div>')
//create breadcrumb button
$('<a class="recent-threads-button create-topic-button">Create New Topic</a>')
.insertBefore($("#navigation-tree"))
.click(function(){$('#create_thread_boards').dialog('open')})
}
});
</script>