File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
2
+ const contributorsList = document . querySelector ( "#contributorsList" ) ;
3
+ const toggleContributorsLink = document . getElementById ( "toggleContributors" ) ;
4
+ const maxVisibleContributors = 5 ;
5
+
6
+ const contributors = Array . from ( contributorsList . getElementsByClassName ( "contributor-item" ) ) ;
7
+ const totalContributors = contributors . length ;
8
+
9
+ // Function to toggle between showing more or fewer contributors
10
+ function toggleContributors ( ) {
11
+ const isShowingAll = toggleContributorsLink . textContent === "View Less" ;
12
+
13
+ contributors . forEach ( ( contributor , index ) => {
14
+ if ( isShowingAll || index < maxVisibleContributors ) {
15
+ contributor . classList . remove ( "d-none" ) ;
16
+ } else {
17
+ contributor . classList . add ( "d-none" ) ;
18
+ }
19
+ } ) ;
20
+
21
+ if ( isShowingAll ) {
22
+ toggleContributorsLink . textContent = `+${ totalContributors - maxVisibleContributors } more Contributors` ;
23
+ } else {
24
+ toggleContributorsLink . textContent = "View Less" ;
25
+ }
26
+ }
27
+
28
+ if ( toggleContributorsLink ) {
29
+ toggleContributorsLink . addEventListener ( "click" , function ( e ) {
30
+ e . preventDefault ( ) ;
31
+ toggleContributors ( ) ;
32
+ } ) ;
33
+ }
34
+ } ) ;
You can’t perform that action at this time.
0 commit comments