From 6187118166b485adb64d43dfbbff5d694b09f60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sun, 16 Feb 2020 14:47:01 +0100 Subject: [PATCH] Hide member-lists, show current item when clearing input --- .../jsdoc/api/template/static/scripts/main.js | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/config/jsdoc/api/template/static/scripts/main.js b/config/jsdoc/api/template/static/scripts/main.js index 6e609f9d01..a3a623c934 100644 --- a/config/jsdoc/api/template/static/scripts/main.js +++ b/config/jsdoc/api/template/static/scripts/main.js @@ -26,6 +26,22 @@ $(function () { return bW - aW; }; + // Show an item related a current documentation automatically + const longname = $('.page-title').data('filename') + .replace(/\.[a-z]+$/, '') + .replace('module-', 'module:') + .replace(/_/g, '/') + .replace(/-/g, '~'); + var $currentItem = $('.navigation .item[data-name*="' + longname + '"]:eq(0)'); + + if ($currentItem.length) { + $currentItem + .prependTo('.navigation .list') + .show() + .find('.member-list') + .show(); + } + // Search Items $('#search').on('keyup', function (e) { var value = $(this).val(); @@ -60,7 +76,9 @@ $(function () { .appendTo(".navigation ul.list"); // append again to the list } else { - $el.find('.item, .member-list').show(); + $currentItem.prependTo('.navigation .list'); + $currentItem.find('.member-list, li').show(); + $el.find('.item').show(); } $el.find('.list').scrollTop(0); @@ -71,23 +89,6 @@ $(function () { $(this).parent().parent().find('.member-list').toggle(); }); - // Show an item related a current documentation automatically - var filename = $('.page-title').data('filename') - .replace(/\.[a-z]+$/, '') - .replace('module-', 'module:') - .replace(/_/g, '/') - .replace(/-/g, '~'); - var $currentItem = $('.navigation .item[data-name*="' + filename + '"]:eq(0)'); - - if ($currentItem.length) { - $currentItem - .remove() - .prependTo('.navigation .list') - .show() - .find('.member-list') - .show(); - } - // Auto resizing on navigation var _onResize = function () { var height = $(window).height();