Fossil SCM
Tree-view expand/collapse enhancements. Press "Reload" after upgraded in order to reload CSS.
Commit
0647dd38b853e3c097d548a58314068fb271e172
Parent
7b30a7c7ef8977a…
2 files changed
+8
-9
+4
+8
-9
| --- 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,19 +660,19 @@ | ||
| 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 | - @ if( expandMap['*'] ) toggleAll(outer_ul, true); | |
| 673 | + @ if( '*' in expandMap ) toggleAll(outer_ul, true); | |
| 676 | 674 | @ for( var id in expandMap ){ |
| 677 | 675 | @ if( id!=='*' ) toggleDir(gebi(id), true); |
| 678 | 676 | @ } |
| 679 | 677 | @ } |
| 680 | 678 | @ |
| @@ -691,11 +689,12 @@ | ||
| 691 | 689 | @ var outer_ul = document.querySelector('.filetree > ul'); |
| 692 | 690 | @ var subdir = outer_ul.querySelector('.subdir'); |
| 693 | 691 | @ var expandMap = {}; |
| 694 | 692 | @ checkState(); |
| 695 | 693 | @ outer_ul.onclick = function(e){ |
| 696 | - @ var a = e.target; | |
| 694 | + @ e = e || window.event; | |
| 695 | + @ var a = e.target || e.srcElement; | |
| 697 | 696 | @ if( a.nodeName!='A' ) return true; |
| 698 | 697 | @ if( a.parentNode==subdir ){ |
| 699 | 698 | @ toggleAll(outer_ul); |
| 700 | 699 | @ return false; |
| 701 | 700 | @ } |
| 702 | 701 |
| --- 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,19 +660,19 @@ | |
| 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 | @ if( expandMap['*'] ) toggleAll(outer_ul, true); |
| 676 | @ for( var id in expandMap ){ |
| 677 | @ if( id!=='*' ) toggleDir(gebi(id), true); |
| 678 | @ } |
| 679 | @ } |
| 680 | @ |
| @@ -691,11 +689,12 @@ | |
| 691 | @ var outer_ul = document.querySelector('.filetree > ul'); |
| 692 | @ var subdir = outer_ul.querySelector('.subdir'); |
| 693 | @ var expandMap = {}; |
| 694 | @ checkState(); |
| 695 | @ outer_ul.onclick = function(e){ |
| 696 | @ var a = e.target; |
| 697 | @ if( a.nodeName!='A' ) return true; |
| 698 | @ if( a.parentNode==subdir ){ |
| 699 | @ toggleAll(outer_ul); |
| 700 | @ return false; |
| 701 | @ } |
| 702 |
| --- 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,19 +660,19 @@ | |
| 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 | @ if( '*' in expandMap ) toggleAll(outer_ul, true); |
| 674 | @ for( var id in expandMap ){ |
| 675 | @ if( id!=='*' ) toggleDir(gebi(id), true); |
| 676 | @ } |
| 677 | @ } |
| 678 | @ |
| @@ -691,11 +689,12 @@ | |
| 689 | @ var outer_ul = document.querySelector('.filetree > ul'); |
| 690 | @ var subdir = outer_ul.querySelector('.subdir'); |
| 691 | @ var expandMap = {}; |
| 692 | @ checkState(); |
| 693 | @ outer_ul.onclick = function(e){ |
| 694 | @ e = e || window.event; |
| 695 | @ var a = e.target || e.srcElement; |
| 696 | @ if( a.nodeName!='A' ) return true; |
| 697 | @ if( a.parentNode==subdir ){ |
| 698 | @ toggleAll(outer_ul); |
| 699 | @ return false; |
| 700 | @ } |
| 701 |
+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 |