Fossil

Check-in [cd554eb6]
Login

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

Overview
Comment:Persist expand/collapse state of tree-view directories in all modern browsers.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tree-view-enhancements
Files: files | file ages | folders
SHA1:cd554eb63cb2e0b17c3f57fa4882fa4cbccdd5df
User & Date: joel 2014-01-14 15:33:36
Context
2014-01-14
19:46
Initialize expandMap variable check-in: 3bdbc040 user: joel tags: tree-view-enhancements
15:33
Persist expand/collapse state of tree-view directories in all modern browsers. check-in: cd554eb6 user: joel tags: tree-view-enhancements
13:41
Make a change to the test/utf16le.txt file as a test case to verify that the diff logic displays utf16 changes correctly. check-in: 6228efbb user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/browse.c.

632
633
634
635
636
637
638
639
640

641
642









643
644

645
646
647

648

649
650

651

652
653
654
655
656

657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672






673
674
675
676
677
678
679
        @ </ul>
      }
    }
  }
  @ </ul>
  @ </ul></div>
  @ <script>(function(){
  @ function style(elem, prop){
  @   return window.getComputedStyle(elem).getPropertyValue(prop);

  @ }
  @









  @ function toggleAll(tree){
  @   var lists = tree.querySelectorAll('.subdir > ul > li ul');

  @   var display = 'block';  /* Default action: make all sublists visible */
  @   for( var i=0; lists[i]; i++ ){
  @     if( style(lists[i], 'display')!='none'){

  @       display = 'none'; /* Any already visible - make them all hidden */

  @       break;
  @     }

  @   }

  @   for( var i=0; lists[i]; i++ ){
  @     lists[i].style.display = display;
  @   }
  @ }
  @ 

  @ 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;
  @   var ul = a.nextSibling;
  @   while( ul && ul.nodeName!='UL' ) ul = ul.nextSibling;
  @   if( !ul ) return true; /* This is a file link, not a directory */
  @   ul.style.display = style(ul, 'display')=='none' ? 'block' : 'none';
  @   return false;
  @ }






  @ }())</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. */
}







|
|
>


>
>
>
>
>
>
>
>
>
|

>
|
|
<
>
|
>
|

>

>




|
>


|







|
|
|
|
|
|
>
>
>
>
>
>







632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
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
        @ </ul>
      }
    }
  }
  @ </ul>
  @ </ul></div>
  @ <script>(function(){
  @ function isExpanded(ul){
  @   var display = window.getComputedStyle(ul).getPropertyValue('display');
  @   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 ){
  @     expand = true;  /* Default action: make all sublists visible */
  @     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. */
}