@@ -19,65 +19,6 @@ <h5 class="p-muted-heading">Last updated</h5>
1919 < hr >
2020{% endif %}
2121
22- {%- if aliases -%}
23- {%- set show_more = "Show more" -%}
24- {%- set show_less = "Show less" -%}
25-
26- {#-
27- # The list starts displaying maximum 3 elements with the rest hidden.
28- # With the script provided and the link element rendered the user can toggle
29- # displaying and hiding all the aliases.
30- -#}
31- < h5 class ="p-muted-heading "> Command › Alias</ h5 >
32- < ul class ="p-list js-expandable-list ">
33- {%- set aliases_len = aliases|length -%}
34- {%- set default_visible_aliases = 3 -%}
35- {%- for alias in aliases -%}
36- {%- set invisible_class = "" -%}
37- {%- if loop.index > default_visible_aliases -%}
38- {%- set invisible_class = "js-hidable u-hide" -%}
39- {%- endif -%}
40- < li class ="p-list__item {{ invisible_class }} ">
41- {{ alias[0]|safe }} › {{ alias[1]|safe }}
42- </ li >
43- {%- endfor -%}
44- {%- if aliases_len > default_visible_aliases -%}
45- < li class ="p-list__item ">
46- < a class ="js-toggle-full-list " href ="# " title ="Display more/less aliases ">
47- {{ show_more }}
48- </ a >
49- </ li >
50- {%- endif -%}
51- </ ul >
52- < hr >
53-
54- < script >
55- // Handle aliases "show more" button
56- const list = document . querySelector ( ".js-expandable-list" ) ;
57- const showMoreButton = document . querySelector ( ".js-toggle-full-list" ) ;
58- let hasAllElementsDisplayed = false ;
59-
60- const updateAliasesListUI = ( displayAllElements , elements ) => {
61- // change button
62- showMoreButton . innerHTML = displayAllElements ? "{{ show_less }}" : "{{ show_more }}" ;
63- // toggle hide classes
64- for ( const element of elements ) {
65- element . classList . toggle ( 'u-hide' , ! displayAllElements ) ;
66- }
67- }
68-
69- if ( list && showMoreButton ) {
70- const listElements = list . querySelectorAll ( ".js-hidable" ) ;
71- showMoreButton . addEventListener ( "click" , ( e ) => {
72- e . preventDefault ( ) ;
73- // switch toggle
74- hasAllElementsDisplayed = ! hasAllElementsDisplayed ;
75- updateAliasesListUI ( hasAllElementsDisplayed , listElements ) ;
76- } ) ;
77- }
78- </ script >
79- {%- endif -%}
80-
8122{% if links %}
8223 {% if links["website"] %}
8324 < h5 class ="p-muted-heading "> Websites</ h5 >
@@ -135,6 +76,65 @@ <h5 class="p-muted-heading">Source code</h5>
13576 < hr >
13677 {% endif %}
13778
79+ {%- if aliases -%}
80+ {%- set show_more = "Show more" -%}
81+ {%- set show_less = "Show less" -%}
82+
83+ {#-
84+ # The list starts displaying maximum 3 elements with the rest hidden.
85+ # With the script provided and the link element rendered the user can toggle
86+ # displaying and hiding all the aliases.
87+ -#}
88+ < h5 class ="p-muted-heading "> Command › Alias</ h5 >
89+ < ul class ="p-list js-expandable-list ">
90+ {%- set aliases_len = aliases|length -%}
91+ {%- set default_visible_aliases = 3 -%}
92+ {%- for alias in aliases -%}
93+ {%- set invisible_class = "" -%}
94+ {%- if loop.index > default_visible_aliases -%}
95+ {%- set invisible_class = "js-hidable u-hide" -%}
96+ {%- endif -%}
97+ < li class ="p-list__item {{ invisible_class }} ">
98+ {{ alias[0]|safe }} › {{ alias[1]|safe }}
99+ </ li >
100+ {%- endfor -%}
101+ {%- if aliases_len > default_visible_aliases -%}
102+ < li class ="p-list__item ">
103+ < a class ="js-toggle-full-list " href ="# " title ="Display more/less aliases ">
104+ {{ show_more }}
105+ </ a >
106+ </ li >
107+ {%- endif -%}
108+ </ ul >
109+ < hr >
110+
111+ < script >
112+ // Handle aliases "show more" button
113+ const list = document . querySelector ( ".js-expandable-list" ) ;
114+ const showMoreButton = document . querySelector ( ".js-toggle-full-list" ) ;
115+ let hasAllElementsDisplayed = false ;
116+
117+ const updateAliasesListUI = ( displayAllElements , elements ) => {
118+ // change button
119+ showMoreButton . innerHTML = displayAllElements ? "{{ show_less }}" : "{{ show_more }}" ;
120+ // toggle hide classes
121+ for ( const element of elements ) {
122+ element . classList . toggle ( 'u-hide' , ! displayAllElements ) ;
123+ }
124+ }
125+
126+ if ( list && showMoreButton ) {
127+ const listElements = list . querySelectorAll ( ".js-hidable" ) ;
128+ showMoreButton . addEventListener ( "click" , ( e ) => {
129+ e . preventDefault ( ) ;
130+ // switch toggle
131+ hasAllElementsDisplayed = ! hasAllElementsDisplayed ;
132+ updateAliasesListUI ( hasAllElementsDisplayed , listElements ) ;
133+ } ) ;
134+ }
135+ </ script >
136+ {%- endif -%}
137+
138138 {% if links["issues"] %}
139139 < h5 class ="p-muted-heading "> Report a bug</ h5 >
140140 < ul class ="p-list ">
0 commit comments