4848 role ="button "
4949 aria-expanded ="false "
5050 aria-controls ="collapse{{directory.id}} "
51- onclick ="window.location.href = '{% url 'file_manager' directory.path|urlencode %}'; "
51+ onclick ="window.location.href = '{% url 'file_manager' directory.path|encoded_path %}'; "
5252 >
5353 {{ directory.name }}
5454 </ a >
5757 {% else %}
5858 < li >
5959 < i class ="fa-solid fa-folder "> </ i >
60- < a href ="{% url 'file_manager' directory.path|urlencode %} "> {{ directory.name }}</ a >
60+ < a href ="{% url 'file_manager' directory.path|encoded_path %} "> {{ directory.name }}</ a >
6161 </ li >
6262 {% endif %}
6363 {% endfor %}
7575 </ form >
7676 </ div >
7777 {% if files %}
78+ {{files|length|json_script:"files-count"}}
7879 < div class ="table-responsive ">
7980 < table class ="table ">
8081 < tr >
9293 < i title ="View " class ="fa-solid fa-eye text-primary "> </ i >
9394 </ span >
9495 < div class ="dot-separator mx-2 "> </ div >
95- < span >
96- < a href ="{% url 'download_file' file.file|encoded_file_path %} ">
97- < i title ="Download " class ="fa-solid fa-download text-success "> </ i >
98- </ a >
99- </ span >
100- < div class ="dot-separator mx-2 "> </ div >
10196 < span data-bs-toggle ="modal " data-bs-target ="#delete-{{forloop.counter}} ">
10297 < i title ="Delete " class ="fa-solid fa-trash text-danger "> </ i >
10398 </ span >
111106 < div class ="modal-content ">
112107 < div class ="modal-header ">
113108 < h1 class ="modal-title fs-5 " id ="staticBackdropLabel "> {{ file.filename }}</ h1 >
114- < div class ="" data-bs-dismiss ="modal " aria-label ="Close ">
109+ < span >
110+ < a href ="{% url 'download_file' file.file|encoded_file_path %} ">
111+ < i title ="Download " class ="fa-solid fa-download text-success fs-4 "> </ i >
112+ </ a >
113+ </ span >
114+ < div class ="" id ="modal-close-btn-{{forloop.counter}} " data-bs-dismiss ="modal " aria-label ="Close ">
115115 < i class ="fa-solid fa-circle-xmark fs-5 "> </ i >
116116 </ div >
117117 </ div >
@@ -164,6 +164,16 @@ <h1 class="modal-title fs-5" id="exampleModalLabel">Delete File</h1>
164164 function submitForm ( ) {
165165 document . getElementById ( "upload-file" ) . submit ( ) ;
166166 }
167+
168+ document . addEventListener ( 'keydown' , ( event ) => {
169+ if ( event . key === 'Escape' || event . key === 'Esc' || event . key === 27 ) {
170+ let files = document . getElementById ( 'files-count' ) . textContent ;
171+ for ( let i = 1 ; i <= files ; i ++ ) {
172+ let closeButtonElements = document . getElementById ( `modal-close-btn-${ i } ` ) ;
173+ closeButtonElements . click ( ) ;
174+ }
175+ }
176+ } )
167177</ script >
168178
169179{% endblock extrascripts %}
0 commit comments