View Issue Details

IDProjectCategoryView StatusLast Update
0024402mantisbtuipublic2022-09-23 06:54
Reporterkae_verens Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Summary0024402: tree-based project navigation
Description

instead of having to read through or search through a long list of projects, why not have them automatically hidden/shown by hierarchy?

I wrote a small script which, when attached to the layout, will transform the HTML of the projects menu and add some jQuery toggle events.

screenshots show before, after (with sub-menus collapsed), and after (with a sub-menu expanded)

The code is in the Additional Information section below.

I put that in a file (/js/project-navigation.js), and then in core/layout_api.js, I put the following line after line 632 (where the "projects-list" div is echoed)
<pre> echo '<script src="/js/project-navigation.js"></script>';</pre>

Additional Information

my code:
<pre>
$(function() {
var $menu=$('#projects-list>ul');
$menu.find('>li').each(function() { // transform the menu into something that can be opened/closed
var $this=$(this), id_postfix=$this.find('a').attr('href').replace(/.=/, '').replace(/;/g, '-');
$this.attr('id', 'projects-list-'+id_postfix);
if (/-/.test(id_postfix)) {
var id_parent=id_postfix.replace(/-[0-9]
$/, '');
var $item_wrapper=$('#projects-list-wrapper-'+id_parent);
if (!$item_wrapper.length) {
var $parent_item=$('#projects-list-'+id_parent);
var $item_wrapper=$('<ul class="list dropdown-yellow no-margin" id="projects-list-wrapper-'+id_parent+'" style="display:none"/>').insertAfter($parent_item);
$('<button style="float:right;padding:0 5px;margin:0;">☰</button>').prependTo($parent_item).click(function() {
$(this).closest('li').next().toggle();
return false;
});
}
$this.appendTo($item_wrapper);
}
});
$menu.find('.active').parents('.list').each(function() { // expand the parents of the active item
$(this).css('display', 'block');
});
});
</pre>

TagsNo tags attached.
Attached Files
screen1.png (24,179 bytes)   
screen1.png (24,179 bytes)   
screen2.png (20,947 bytes)   
screen2.png (20,947 bytes)   
screen3.png (23,384 bytes)   
screen3.png (23,384 bytes)   

Activities

tedritheni

tedritheni

2019-07-22 19:31

reporter   ~0062415

Nice - is this likely to make it to the core product?

weldbug

weldbug

2022-09-23 06:54

reporter   ~0067010

Is there any news here or a plugin for this function? I couldn't find anything about such a feature, but it would be great to have it.
It seems that it doesn't work with 2.25.2.

Thanks for any help!