Generate valid html for the apidoc navigation

Only `<li>` can be a direct descendant of `<ul>` tags.
This commit is contained in:
Maximilian Krög
2020-02-09 18:12:24 +01:00
parent 5d922fc53b
commit 300cc282e4
3 changed files with 14 additions and 12 deletions

View File

@@ -33,7 +33,7 @@ $(function () {
if (value && value.length > 1) { if (value && value.length > 1) {
var regexp = new RegExp(value, 'i'); var regexp = new RegExp(value, 'i');
$el.find('li, .itemMembers').hide(); $el.find('li, .member-list').hide();
$el.find('li').each(function (i, v) { $el.find('li').each(function (i, v) {
const $item = $(v); const $item = $(v);
@@ -41,7 +41,7 @@ $(function () {
if (name && regexp.test(name)) { if (name && regexp.test(name)) {
const $classEntry = $item.closest('.item'); const $classEntry = $item.closest('.item');
const $members = $item.closest('.itemMembers'); const $members = $item.closest('.member-list');
// Do the weight thing // Do the weight thing
$classEntry.removeData('weight'); $classEntry.removeData('weight');
@@ -60,7 +60,7 @@ $(function () {
.appendTo(".navigation ul.list"); // append again to the list .appendTo(".navigation ul.list"); // append again to the list
} else { } else {
$el.find('.item, .itemMembers').show(); $el.find('.item, .member-list').show();
} }
$el.find('.list').scrollTop(0); $el.find('.list').scrollTop(0);
@@ -68,7 +68,7 @@ $(function () {
// Toggle when click an item element // Toggle when click an item element
$('.navigation').on('click', '.toggle', function (e) { $('.navigation').on('click', '.toggle', function (e) {
$(this).parent().parent().find('.itemMembers').toggle(); $(this).parent().parent().find('.member-list').toggle();
}); });
// Show an item related a current documentation automatically // Show an item related a current documentation automatically
@@ -84,7 +84,7 @@ $(function () {
.remove() .remove()
.prependTo('.navigation .list') .prependTo('.navigation .list')
.show() .show()
.find('.itemMembers') .find('.member-list')
.show(); .show();
} }

View File

@@ -183,7 +183,7 @@ li {
padding-left: 8px; padding-left: 8px;
margin-top: 2px; margin-top: 2px;
} }
.navigation li.item .itemMembers { .navigation li.item .member-list {
display: none; display: none;
padding-left: 8px; padding-left: 8px;
} }

View File

@@ -15,22 +15,24 @@ function getItemCssClass(type) {
} }
const printList = v => { ?> const printList = v => { ?>
<li data-name="<?js= v.longname ?>"><?js <li data-name="<?js= v.longname ?>"><?js
} }
const printListWithStability = v => { const printListWithStability = v => {
const cls = v.stability && v.stability !== 'stable' ? ' class="unstable"' : ''; ?> const cls = v.stability && v.stability !== 'stable' ? ' class="unstable"' : ''; ?>
<li data-name="<?js= v.longname ?>"<?js= cls ?>><?js <li data-name="<?js= v.longname ?>"<?js= cls ?>><?js
} }
function listContent(item, title, listItemPrinter) { function listContent(item, title, listItemPrinter) {
const type = title.toLowerCase(); const type = title.toLowerCase();
if (item[type] && item[type].length) { ?> if (item[type] && item[type].length) { ?>
<ul class="<?js= type ?> itemMembers"> <div class="member-list">
<span class="subtitle"><?js= title ?></span><?js <span class="subtitle"><?js= title ?></span>
<ul><?js
item[type].forEach(function (v) { item[type].forEach(function (v) {
listItemPrinter(v); ?><?js= self.linkto(v.longname, toShortName(v.name)) ?><?js listItemPrinter(v); ?><?js= self.linkto(v.longname, toShortName(v.name)) ?><?js
}); ?> }); ?>
</ul><?js </ul>
</div><?js
} }
} }
?> ?>