Fossil

Check-in [75b96a2912]
Login

Check-in [75b96a2912]

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

Overview
Comment:Set/unset new "collapsed" class on tree-view lists instead of setting display property. This breaks collapse/expand on Chrome.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tree-view-work
Files: files | file ages | folders
SHA1: 75b96a2912f6f34b212876e58c481aabf887241d
User & Date: joel 2014-01-16 23:43:18.595
Original Comment: Set/unset new "collapsed" class on tree-view lists instead of setting display property.
Context
2014-01-17
00:07
Recognize old IE event object to make tree-view expand/collapse work in IE8. This breaks expand/collapse on FF. ... (check-in: 21426d01b4 user: joel tags: tree-view-work)
2014-01-16
23:43
Set/unset new "collapsed" class on tree-view lists instead of setting display property. This breaks collapse/expand on Chrome. ... (check-in: 75b96a2912 user: joel tags: tree-view-work)
22:15
Avoid superfluous variable assignment. ... (check-in: cdab54ed78 user: mistachkin tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/browse.c.
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
    if( p->isDir ){
      const char *zSubdirClass = p->nFullName==nD-1 ? " subdir" : "";
      @ <li class="dir%s(zSubdirClass)%s(zLastClass)">
      @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a>
      if( startExpanded || p->nFullName<=nD ){
        @ <ul id="dir%d(nDir)">
      }else{
        @ <ul id="dir%d(nDir)" style='display:none;'>
      }
      nDir++;
    }else if( !showDirOnly ){
      const char *zFileClass = fileext_class(p->zName);
      char *zLink;
      if( zCI ){
        zLink = href("%R/artifact/%S",p->zUuid);







|







610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
    if( p->isDir ){
      const char *zSubdirClass = p->nFullName==nD-1 ? " subdir" : "";
      @ <li class="dir%s(zSubdirClass)%s(zLastClass)">
      @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a>
      if( startExpanded || p->nFullName<=nD ){
        @ <ul id="dir%d(nDir)">
      }else{
        @ <ul id="dir%d(nDir)" class="collapsed">
      }
      nDir++;
    }else if( !showDirOnly ){
      const char *zFileClass = fileext_class(p->zName);
      char *zLink;
      if( zCI ){
        zLink = href("%R/artifact/%S",p->zUuid);
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
      }
    }
  }
  @ </ul>
  @ </ul></div>
  @ <script>(function(){
  @ function isExpanded(ul){
  @   var ulStyle = window.getComputedStyle && window.getComputedStyle(ul,null);
  @   var display = (ulStyle && ulStyle.getPropertyValue('display')) || 'none';
  @   return display!='none';
  @ }
  @
  @ function toggleDir(ul, useInitValue){
  @   if( !useInitValue ){
  @     expandMap[ul.id] = !isExpanded(ul);
  @     history.replaceState(expandMap, '');
  @   }
  @   ul.style.display = expandMap[ul.id] ? 'block' : 'none';
  @ }
  @
  @ function toggleAll(tree, useInitValue){
  @   var lists = tree.querySelectorAll('.subdir > ul > li ul');
  @   if( !useInitValue ){
  @     var 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};
  @     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 ){







<
<
|







|















|

|







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
      }
    }
  }
  @ </ul>
  @ </ul></div>
  @ <script>(function(){
  @ function isExpanded(ul){


  @   return ul.className=='';
  @ }
  @
  @ function toggleDir(ul, useInitValue){
  @   if( !useInitValue ){
  @     expandMap[ul.id] = !isExpanded(ul);
  @     history.replaceState(expandMap, '');
  @   }
  @   ul.className = expandMap[ul.id] ? '' : 'collapsed';
  @ }
  @
  @ function toggleAll(tree, useInitValue){
  @   var lists = tree.querySelectorAll('.subdir > ul > li ul');
  @   if( !useInitValue ){
  @     var 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};
  @     history.replaceState(expandMap, '');
  @   }
  @   var className = expandMap['*'] ? '' : 'collapsed';
  @   for( var i=0; lists[i]; i++ ){
  @     lists[i].className = className;
  @   }
  @ }
  @
  @ function checkState(){
  @   expandMap = history.state || {};
  @   if( expandMap['*'] ) toggleAll(outer_ul, true);
  @   for( var id in expandMap ){
Changes to src/style.c.
779
780
781
782
783
784
785




786
787
788
789
790
791
792
    @   line-height: 1.5;
  },
  { ".filetree ul",
    "tree-view lists",
    @   margin: 0;
    @   padding: 0;
    @   list-style: none;




  },
  { ".filetree ul ul",
    "tree-view lists below the root",
    @   position: relative;
    @   margin: 0 0 0 21px;
  },
  { ".filetree li",







>
>
>
>







779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
    @   line-height: 1.5;
  },
  { ".filetree ul",
    "tree-view lists",
    @   margin: 0;
    @   padding: 0;
    @   list-style: none;
  },
  { ".filetree ul.collapsed",
    "tree-view collapsed list",
    @   display: none;
  },
  { ".filetree ul ul",
    "tree-view lists below the root",
    @   position: relative;
    @   margin: 0 0 0 21px;
  },
  { ".filetree li",