File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 1- document . addEventListener ( "DOMContentLoaded" , function ( ) {
1+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
22 const contributorsList = document . querySelector ( "#contributorsList" ) ;
33 const toggleContributorsLink = document . getElementById ( "toggleContributors" ) ;
44 const maxVisibleContributors = 5 ;
@@ -10,6 +10,7 @@ document.addEventListener("DOMContentLoaded", function () {
1010 function toggleContributors ( ) {
1111 const isShowingAll = toggleContributorsLink . textContent === "View Less" ;
1212
13+ // Show or hide contributors based on the toggle state
1314 contributors . forEach ( ( contributor , index ) => {
1415 if ( isShowingAll || index < maxVisibleContributors ) {
1516 contributor . classList . remove ( "d-none" ) ;
@@ -18,17 +19,19 @@ document.addEventListener("DOMContentLoaded", function () {
1819 }
1920 } ) ;
2021
22+ // Toggle the link text based on the current state
2123 if ( isShowingAll ) {
2224 toggleContributorsLink . textContent = `+${ totalContributors - maxVisibleContributors } more Contributors` ;
2325 } else {
2426 toggleContributorsLink . textContent = "View Less" ;
2527 }
2628 }
2729
30+ // Click event for the "View More / View Less" link
2831 if ( toggleContributorsLink ) {
2932 toggleContributorsLink . addEventListener ( "click" , function ( e ) {
3033 e . preventDefault ( ) ;
31- toggleContributors ( ) ;
34+ toggleContributors ( ) ; // Toggle the contributors and text
3235 } ) ;
3336 }
3437 } ) ;
You can’t perform that action at this time.
0 commit comments