Fossil SCM
Set/unset new "collapsed" class on tree-view lists instead of setting display property.
Commit
75b96a2912f6f34b212876e58c481aabf887241d
Parent
cdab54ed7804117…
2 files changed
+5
-7
+4
+5
-7
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -612,11 +612,11 @@ | ||
| 612 | 612 | @ <li class="dir%s(zSubdirClass)%s(zLastClass)"> |
| 613 | 613 | @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a> |
| 614 | 614 | if( startExpanded || p->nFullName<=nD ){ |
| 615 | 615 | @ <ul id="dir%d(nDir)"> |
| 616 | 616 | }else{ |
| 617 | - @ <ul id="dir%d(nDir)" style='display:none;'> | |
| 617 | + @ <ul id="dir%d(nDir)" class="collapsed"> | |
| 618 | 618 | } |
| 619 | 619 | nDir++; |
| 620 | 620 | }else if( !showDirOnly ){ |
| 621 | 621 | const char *zFileClass = fileext_class(p->zName); |
| 622 | 622 | char *zLink; |
| @@ -636,21 +636,19 @@ | ||
| 636 | 636 | } |
| 637 | 637 | @ </ul> |
| 638 | 638 | @ </ul></div> |
| 639 | 639 | @ <script>(function(){ |
| 640 | 640 | @ function isExpanded(ul){ |
| 641 | - @ var ulStyle = window.getComputedStyle && window.getComputedStyle(ul,null); | |
| 642 | - @ var display = (ulStyle && ulStyle.getPropertyValue('display')) || 'none'; | |
| 643 | - @ return display!='none'; | |
| 641 | + @ return ul.className==''; | |
| 644 | 642 | @ } |
| 645 | 643 | @ |
| 646 | 644 | @ function toggleDir(ul, useInitValue){ |
| 647 | 645 | @ if( !useInitValue ){ |
| 648 | 646 | @ expandMap[ul.id] = !isExpanded(ul); |
| 649 | 647 | @ history.replaceState(expandMap, ''); |
| 650 | 648 | @ } |
| 651 | - @ ul.style.display = expandMap[ul.id] ? 'block' : 'none'; | |
| 649 | + @ ul.className = expandMap[ul.id] ? '' : 'collapsed'; | |
| 652 | 650 | @ } |
| 653 | 651 | @ |
| 654 | 652 | @ function toggleAll(tree, useInitValue){ |
| 655 | 653 | @ var lists = tree.querySelectorAll('.subdir > ul > li ul'); |
| 656 | 654 | @ if( !useInitValue ){ |
| @@ -662,13 +660,13 @@ | ||
| 662 | 660 | @ } |
| 663 | 661 | @ } |
| 664 | 662 | @ expandMap = {'*': expand}; |
| 665 | 663 | @ history.replaceState(expandMap, ''); |
| 666 | 664 | @ } |
| 667 | - @ var display = expandMap['*'] ? 'block' : 'none'; | |
| 665 | + @ var className = expandMap['*'] ? '' : 'collapsed'; | |
| 668 | 666 | @ for( var i=0; lists[i]; i++ ){ |
| 669 | - @ lists[i].style.display = display; | |
| 667 | + @ lists[i].className = className; | |
| 670 | 668 | @ } |
| 671 | 669 | @ } |
| 672 | 670 | @ |
| 673 | 671 | @ function checkState(){ |
| 674 | 672 | @ expandMap = history.state || {}; |
| 675 | 673 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -612,11 +612,11 @@ | |
| 612 | @ <li class="dir%s(zSubdirClass)%s(zLastClass)"> |
| 613 | @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a> |
| 614 | if( startExpanded || p->nFullName<=nD ){ |
| 615 | @ <ul id="dir%d(nDir)"> |
| 616 | }else{ |
| 617 | @ <ul id="dir%d(nDir)" style='display:none;'> |
| 618 | } |
| 619 | nDir++; |
| 620 | }else if( !showDirOnly ){ |
| 621 | const char *zFileClass = fileext_class(p->zName); |
| 622 | char *zLink; |
| @@ -636,21 +636,19 @@ | |
| 636 | } |
| 637 | @ </ul> |
| 638 | @ </ul></div> |
| 639 | @ <script>(function(){ |
| 640 | @ function isExpanded(ul){ |
| 641 | @ var ulStyle = window.getComputedStyle && window.getComputedStyle(ul,null); |
| 642 | @ var display = (ulStyle && ulStyle.getPropertyValue('display')) || 'none'; |
| 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 ){ |
| @@ -662,13 +660,13 @@ | |
| 662 | @ } |
| 663 | @ } |
| 664 | @ expandMap = {'*': expand}; |
| 665 | @ history.replaceState(expandMap, ''); |
| 666 | @ } |
| 667 | @ var display = expandMap['*'] ? 'block' : 'none'; |
| 668 | @ for( var i=0; lists[i]; i++ ){ |
| 669 | @ lists[i].style.display = display; |
| 670 | @ } |
| 671 | @ } |
| 672 | @ |
| 673 | @ function checkState(){ |
| 674 | @ expandMap = history.state || {}; |
| 675 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -612,11 +612,11 @@ | |
| 612 | @ <li class="dir%s(zSubdirClass)%s(zLastClass)"> |
| 613 | @ %z(href("%s",url_render(&sURI,"name",p->zFullName,0,0)))%h(p->zName)</a> |
| 614 | if( startExpanded || p->nFullName<=nD ){ |
| 615 | @ <ul id="dir%d(nDir)"> |
| 616 | }else{ |
| 617 | @ <ul id="dir%d(nDir)" class="collapsed"> |
| 618 | } |
| 619 | nDir++; |
| 620 | }else if( !showDirOnly ){ |
| 621 | const char *zFileClass = fileext_class(p->zName); |
| 622 | char *zLink; |
| @@ -636,21 +636,19 @@ | |
| 636 | } |
| 637 | @ </ul> |
| 638 | @ </ul></div> |
| 639 | @ <script>(function(){ |
| 640 | @ function isExpanded(ul){ |
| 641 | @ return ul.className==''; |
| 642 | @ } |
| 643 | @ |
| 644 | @ function toggleDir(ul, useInitValue){ |
| 645 | @ if( !useInitValue ){ |
| 646 | @ expandMap[ul.id] = !isExpanded(ul); |
| 647 | @ history.replaceState(expandMap, ''); |
| 648 | @ } |
| 649 | @ ul.className = expandMap[ul.id] ? '' : 'collapsed'; |
| 650 | @ } |
| 651 | @ |
| 652 | @ function toggleAll(tree, useInitValue){ |
| 653 | @ var lists = tree.querySelectorAll('.subdir > ul > li ul'); |
| 654 | @ if( !useInitValue ){ |
| @@ -662,13 +660,13 @@ | |
| 660 | @ } |
| 661 | @ } |
| 662 | @ expandMap = {'*': expand}; |
| 663 | @ history.replaceState(expandMap, ''); |
| 664 | @ } |
| 665 | @ var className = expandMap['*'] ? '' : 'collapsed'; |
| 666 | @ for( var i=0; lists[i]; i++ ){ |
| 667 | @ lists[i].className = className; |
| 668 | @ } |
| 669 | @ } |
| 670 | @ |
| 671 | @ function checkState(){ |
| 672 | @ expandMap = history.state || {}; |
| 673 |
+4
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -781,10 +781,14 @@ | ||
| 781 | 781 | { ".filetree ul", |
| 782 | 782 | "tree-view lists", |
| 783 | 783 | @ margin: 0; |
| 784 | 784 | @ padding: 0; |
| 785 | 785 | @ list-style: none; |
| 786 | + }, | |
| 787 | + { ".filetree ul.collapsed", | |
| 788 | + "tree-view collapsed list", | |
| 789 | + @ display: none; | |
| 786 | 790 | }, |
| 787 | 791 | { ".filetree ul ul", |
| 788 | 792 | "tree-view lists below the root", |
| 789 | 793 | @ position: relative; |
| 790 | 794 | @ margin: 0 0 0 21px; |
| 791 | 795 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -781,10 +781,14 @@ | |
| 781 | { ".filetree ul", |
| 782 | "tree-view lists", |
| 783 | @ margin: 0; |
| 784 | @ padding: 0; |
| 785 | @ list-style: none; |
| 786 | }, |
| 787 | { ".filetree ul ul", |
| 788 | "tree-view lists below the root", |
| 789 | @ position: relative; |
| 790 | @ margin: 0 0 0 21px; |
| 791 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -781,10 +781,14 @@ | |
| 781 | { ".filetree ul", |
| 782 | "tree-view lists", |
| 783 | @ margin: 0; |
| 784 | @ padding: 0; |
| 785 | @ list-style: none; |
| 786 | }, |
| 787 | { ".filetree ul.collapsed", |
| 788 | "tree-view collapsed list", |
| 789 | @ display: none; |
| 790 | }, |
| 791 | { ".filetree ul ul", |
| 792 | "tree-view lists below the root", |
| 793 | @ position: relative; |
| 794 | @ margin: 0 0 0 21px; |
| 795 |