Fossil

Check-in [434e4538]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use history API instead of sessionStorage.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tree-view-enhancements
Files: files | file ages | folders
SHA1: 434e4538bc95f423804c4e6af1bfeb8a40644b07
User & Date: joel 2014-01-15 00:15:51
Context
2014-01-15
01:26
Add ID attribute to subdirectory lists. check-in: 24fa1e68 user: joel tags: tree-view-enhancements
00:15
Use history API instead of sessionStorage. check-in: 434e4538 user: joel tags: tree-view-enhancements
2014-01-14
19:46
Initialize expandMap variable check-in: 3bdbc040 user: joel tags: tree-view-enhancements
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/browse.c.

641
642
643
644
645
646
647

648


649
650
651
652
653
654
655
...
657
658
659
660
661
662
663

664
665
666
667
668
669
670

671








672
673


674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
  @   return display!='none';
  @ }
  @
  @ function toggleDir(a, useInitValue){
  @   var ul = a.nextSibling;
  @   while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling;
  @   if( !ul ) return false; /* This is a file link, not a directory */

  @   if( !useInitValue ) expandMap[a.id] = !isExpanded(ul);


  @   ul.style.display = expandMap[a.id] ? 'block' : 'none';
  @   return true;
  @ }
  @
  @ function toggleAll(tree, useInitValue){
  @   var lists = tree.querySelectorAll('.subdir > ul > li ul');
  @   if( !useInitValue ){
................................................................................
  @     for( var i=0; lists[i]; i++ ){
  @       if( isExpanded(lists[i]) ){
  @         expand = false; /* Any already visible - make them all hidden */
  @         break;
  @       }
  @     }
  @     expandMap = {'*': expand};

  @   }
  @   var display = expandMap['*'] ? 'block' : 'none';
  @   for( var i=0; lists[i]; i++ ){
  @     lists[i].style.display = display;
  @   }
  @ }
  @

  @ var expandMap = {};








  @ var outer_ul = document.querySelector('.filetree > ul');
  @ var subdir = outer_ul.querySelector('.subdir');


  @ outer_ul.onclick = function(e){
  @   var a = e.target;
  @   if( a.nodeName!='A' ) return true;
  @   if( a.parentNode==subdir ){
  @     toggleAll(outer_ul);
  @     return false;
  @   }
  @   if( !subdir.contains(a) ) return true;
  @   return !toggleDir(a);
  @ }
  @ addEventListener('pagehide', function(){
  @   sessionStorage.setItem('tree-expandMap', JSON.stringify(expandMap));
  @ });
  @ addEventListener('pageshow', function(){
  @   expandMap = JSON.parse(sessionStorage.getItem('tree-expandMap')) || {};
  @   if( expandMap['*'] ) toggleAll(outer_ul, true);
  @   for( var id in expandMap ){
  @     if( id!=='*' ) toggleDir(gebi(id), true);
  @   }
  @ });
  @ }())</script>
  style_footer();

  /* We could free memory used by sTree here if we needed to.  But
  ** the process is about to exit, so doing so would not really accomplish
  ** anything useful. */
}







>
|
>
>







 







>







>
|
>
>
>
>
>
>
>
>


>
>










<
<
<
<
<
<
<
<
<
<







641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
...
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698










699
700
701
702
703
704
705
  @   return display!='none';
  @ }
  @
  @ function toggleDir(a, useInitValue){
  @   var ul = a.nextSibling;
  @   while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling;
  @   if( !ul ) return false; /* This is a file link, not a directory */
  @   if( !useInitValue ){
  @     expandMap[a.id] = !isExpanded(ul);
  @     history.replaceState(expandMap, '');
  @   }
  @   ul.style.display = expandMap[a.id] ? 'block' : 'none';
  @   return true;
  @ }
  @
  @ function toggleAll(tree, useInitValue){
  @   var lists = tree.querySelectorAll('.subdir > ul > li ul');
  @   if( !useInitValue ){
................................................................................
  @     for( var i=0; lists[i]; i++ ){
  @       if( isExpanded(lists[i]) ){
  @         expand = false; /* Any already visible - make them all hidden */
  @         break;
  @       }
  @     }
  @     expandMap = {'*': expand};
  @     history.replaceState(expandMap, '');
  @   }
  @   var display = expandMap['*'] ? 'block' : 'none';
  @   for( var i=0; lists[i]; i++ ){
  @     lists[i].style.display = display;
  @   }
  @ }
  @
  @ function checkState(){
  @   expandMap = history.state || {};
  @   if( expandMap['*'] ) toggleAll(outer_ul, true);
  @   for( var id in expandMap ){
  @     if( id!=='*' ) toggleDir(gebi(id), true);
  @   }
  @ }
  @
  @ /* No-op shim for IE9 */
  @ if( !history.replaceState ) history.replaceState = function(){};
  @ var outer_ul = document.querySelector('.filetree > ul');
  @ var subdir = outer_ul.querySelector('.subdir');
  @ var expandMap = {};
  @ checkState();
  @ outer_ul.onclick = function(e){
  @   var a = e.target;
  @   if( a.nodeName!='A' ) return true;
  @   if( a.parentNode==subdir ){
  @     toggleAll(outer_ul);
  @     return false;
  @   }
  @   if( !subdir.contains(a) ) return true;
  @   return !toggleDir(a);
  @ }










  @ }())</script>
  style_footer();

  /* We could free memory used by sTree here if we needed to.  But
  ** the process is about to exit, so doing so would not really accomplish
  ** anything useful. */
}