Fossil SCM

Add ID attribute to subdirectory lists.

joel 2014-01-15 01:26 tree-view-enhancements
Commit 24fa1e680288cfaa07b9950e0db792ab23a54927
1 file changed +13 -11
+13 -11
--- src/browse.c
+++ src/browse.c
@@ -418,10 +418,11 @@
418418
FileTreeNode *p; /* One line of the tree */
419419
FileTree sTree; /* The complete tree of files */
420420
HQuery sURI; /* Hyperlink */
421421
int startExpanded; /* True to start out with the tree expanded */
422422
int showDirOnly; /* Show directories only. Omit files */
423
+ int nDir = 0; /* Number of directories. Used for ID attributes */
423424
char *zProjectName = db_get("project-name", 0);
424425
425426
if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; }
426427
memset(&sTree, 0, sizeof(sTree));
427428
login_check_credentials();
@@ -602,23 +603,24 @@
602603
}else{
603604
@ <li class="dir subdir">
604605
}
605606
@ %z(href("%s",url_render(&sURI,"name",0,0,0)))%h(zProjectName)</a>
606607
@ <ul>
607
- for(p=sTree.pFirst; p; p=p->pNext){
608
+ for(p=sTree.pFirst, nDir=0; p; p=p->pNext){
608609
if( p->isDir ){
609610
if( p->nFullName==nD-1 ){
610611
@ <li class="dir subdir">
611612
}else{
612613
@ <li class="dir">
613614
}
614615
@ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a>
615616
if( startExpanded || p->nFullName<=nD ){
616
- @ <ul>
617
+ @ <ul id="dir%d(nDir)">
617618
}else{
618
- @ <ul style='display:none;'>
619
+ @ <ul id="dir%d(nDir)" style='display:none;'>
619620
}
621
+ nDir++;
620622
}else if( !showDirOnly ){
621623
char *zLink;
622624
if( zCI ){
623625
zLink = href("%R/artifact/%S",p->zUuid);
624626
}else{
@@ -639,20 +641,16 @@
639641
@ function isExpanded(ul){
640642
@ var display = window.getComputedStyle(ul).getPropertyValue('display');
641643
@ return display!='none';
642644
@ }
643645
@
644
- @ function toggleDir(a, useInitValue){
645
- @ var ul = a.nextSibling;
646
- @ while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling;
647
- @ if( !ul ) return false; /* This is a file link, not a directory */
646
+ @ function toggleDir(ul, useInitValue){
648647
@ if( !useInitValue ){
649
- @ expandMap[a.id] = !isExpanded(ul);
648
+ @ expandMap[ul.id] = !isExpanded(ul);
650649
@ history.replaceState(expandMap, '');
651650
@ }
652
- @ ul.style.display = expandMap[a.id] ? 'block' : 'none';
653
- @ return true;
651
+ @ ul.style.display = expandMap[ul.id] ? 'block' : 'none';
654652
@ }
655653
@
656654
@ function toggleAll(tree, useInitValue){
657655
@ var lists = tree.querySelectorAll('.subdir > ul > li ul');
658656
@ if( !useInitValue ){
@@ -692,11 +690,15 @@
692690
@ if( a.parentNode==subdir ){
693691
@ toggleAll(outer_ul);
694692
@ return false;
695693
@ }
696694
@ if( !subdir.contains(a) ) return true;
697
- @ return !toggleDir(a);
695
+ @ var ul = a.nextSibling;
696
+ @ while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling;
697
+ @ if( !ul ) return true; /* This is a file link, not a directory */
698
+ @ toggleDir(ul);
699
+ @ return false;
698700
@ }
699701
@ }())</script>
700702
style_footer();
701703
702704
/* We could free memory used by sTree here if we needed to. But
703705
--- src/browse.c
+++ src/browse.c
@@ -418,10 +418,11 @@
418 FileTreeNode *p; /* One line of the tree */
419 FileTree sTree; /* The complete tree of files */
420 HQuery sURI; /* Hyperlink */
421 int startExpanded; /* True to start out with the tree expanded */
422 int showDirOnly; /* Show directories only. Omit files */
 
423 char *zProjectName = db_get("project-name", 0);
424
425 if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; }
426 memset(&sTree, 0, sizeof(sTree));
427 login_check_credentials();
@@ -602,23 +603,24 @@
602 }else{
603 @ <li class="dir subdir">
604 }
605 @ %z(href("%s",url_render(&sURI,"name",0,0,0)))%h(zProjectName)</a>
606 @ <ul>
607 for(p=sTree.pFirst; p; p=p->pNext){
608 if( p->isDir ){
609 if( p->nFullName==nD-1 ){
610 @ <li class="dir subdir">
611 }else{
612 @ <li class="dir">
613 }
614 @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a>
615 if( startExpanded || p->nFullName<=nD ){
616 @ <ul>
617 }else{
618 @ <ul style='display:none;'>
619 }
 
620 }else if( !showDirOnly ){
621 char *zLink;
622 if( zCI ){
623 zLink = href("%R/artifact/%S",p->zUuid);
624 }else{
@@ -639,20 +641,16 @@
639 @ function isExpanded(ul){
640 @ var display = window.getComputedStyle(ul).getPropertyValue('display');
641 @ return display!='none';
642 @ }
643 @
644 @ function toggleDir(a, useInitValue){
645 @ var ul = a.nextSibling;
646 @ while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling;
647 @ if( !ul ) return false; /* This is a file link, not a directory */
648 @ if( !useInitValue ){
649 @ expandMap[a.id] = !isExpanded(ul);
650 @ history.replaceState(expandMap, '');
651 @ }
652 @ ul.style.display = expandMap[a.id] ? 'block' : 'none';
653 @ return true;
654 @ }
655 @
656 @ function toggleAll(tree, useInitValue){
657 @ var lists = tree.querySelectorAll('.subdir > ul > li ul');
658 @ if( !useInitValue ){
@@ -692,11 +690,15 @@
692 @ if( a.parentNode==subdir ){
693 @ toggleAll(outer_ul);
694 @ return false;
695 @ }
696 @ if( !subdir.contains(a) ) return true;
697 @ return !toggleDir(a);
 
 
 
 
698 @ }
699 @ }())</script>
700 style_footer();
701
702 /* We could free memory used by sTree here if we needed to. But
703
--- src/browse.c
+++ src/browse.c
@@ -418,10 +418,11 @@
418 FileTreeNode *p; /* One line of the tree */
419 FileTree sTree; /* The complete tree of files */
420 HQuery sURI; /* Hyperlink */
421 int startExpanded; /* True to start out with the tree expanded */
422 int showDirOnly; /* Show directories only. Omit files */
423 int nDir = 0; /* Number of directories. Used for ID attributes */
424 char *zProjectName = db_get("project-name", 0);
425
426 if( strcmp(PD("type",""),"flat")==0 ){ page_dir(); return; }
427 memset(&sTree, 0, sizeof(sTree));
428 login_check_credentials();
@@ -602,23 +603,24 @@
603 }else{
604 @ <li class="dir subdir">
605 }
606 @ %z(href("%s",url_render(&sURI,"name",0,0,0)))%h(zProjectName)</a>
607 @ <ul>
608 for(p=sTree.pFirst, nDir=0; p; p=p->pNext){
609 if( p->isDir ){
610 if( p->nFullName==nD-1 ){
611 @ <li class="dir subdir">
612 }else{
613 @ <li class="dir">
614 }
615 @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a>
616 if( startExpanded || p->nFullName<=nD ){
617 @ <ul id="dir%d(nDir)">
618 }else{
619 @ <ul id="dir%d(nDir)" style='display:none;'>
620 }
621 nDir++;
622 }else if( !showDirOnly ){
623 char *zLink;
624 if( zCI ){
625 zLink = href("%R/artifact/%S",p->zUuid);
626 }else{
@@ -639,20 +641,16 @@
641 @ function isExpanded(ul){
642 @ var display = window.getComputedStyle(ul).getPropertyValue('display');
643 @ return display!='none';
644 @ }
645 @
646 @ function toggleDir(ul, useInitValue){
 
 
 
647 @ if( !useInitValue ){
648 @ expandMap[ul.id] = !isExpanded(ul);
649 @ history.replaceState(expandMap, '');
650 @ }
651 @ ul.style.display = expandMap[ul.id] ? 'block' : 'none';
 
652 @ }
653 @
654 @ function toggleAll(tree, useInitValue){
655 @ var lists = tree.querySelectorAll('.subdir > ul > li ul');
656 @ if( !useInitValue ){
@@ -692,11 +690,15 @@
690 @ if( a.parentNode==subdir ){
691 @ toggleAll(outer_ul);
692 @ return false;
693 @ }
694 @ if( !subdir.contains(a) ) return true;
695 @ var ul = a.nextSibling;
696 @ while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling;
697 @ if( !ul ) return true; /* This is a file link, not a directory */
698 @ toggleDir(ul);
699 @ return false;
700 @ }
701 @ }())</script>
702 style_footer();
703
704 /* We could free memory used by sTree here if we needed to. But
705

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button