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 ( ) {
2
2
const contributorsList = document . querySelector ( "#contributorsList" ) ;
3
3
const toggleContributorsLink = document . getElementById ( "toggleContributors" ) ;
4
4
const maxVisibleContributors = 5 ;
@@ -10,6 +10,7 @@ document.addEventListener("DOMContentLoaded", function () {
10
10
function toggleContributors ( ) {
11
11
const isShowingAll = toggleContributorsLink . textContent === "View Less" ;
12
12
13
+ // Show or hide contributors based on the toggle state
13
14
contributors . forEach ( ( contributor , index ) => {
14
15
if ( isShowingAll || index < maxVisibleContributors ) {
15
16
contributor . classList . remove ( "d-none" ) ;
@@ -18,17 +19,19 @@ document.addEventListener("DOMContentLoaded", function () {
18
19
}
19
20
} ) ;
20
21
22
+ // Toggle the link text based on the current state
21
23
if ( isShowingAll ) {
22
24
toggleContributorsLink . textContent = `+${ totalContributors - maxVisibleContributors } more Contributors` ;
23
25
} else {
24
26
toggleContributorsLink . textContent = "View Less" ;
25
27
}
26
28
}
27
29
30
+ // Click event for the "View More / View Less" link
28
31
if ( toggleContributorsLink ) {
29
32
toggleContributorsLink . addEventListener ( "click" , function ( e ) {
30
33
e . preventDefault ( ) ;
31
- toggleContributors ( ) ;
34
+ toggleContributors ( ) ; // Toggle the contributors and text
32
35
} ) ;
33
36
}
34
37
} ) ;
You can’t perform that action at this time.
0 commit comments