Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"file_save_confirm": "Do you want to save the following file:",
"file_save_error": "Could not save file.",
"file_save_success": "File saved.",
"file_overwrite_confirm": "File already exists. Overwrite?",
"file_upload_error": "Could not upload file.",
"file_upload_success": "File uploaded.",
"filename": "Filename",
Expand Down
26 changes: 23 additions & 3 deletions src/ifm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Shows the download dialogue
window.confirmDownload = function(event, el) {
event.preventDefault();
var filename = el.getAttribute('data-filename') || '';
var msg = filename ? 'Are you sure to download "' + filename + '"?' : 'Start download?';
if (window.confirm(msg)) {
window.location.href = el.getAttribute('href');
}
return false;
}
/**
* IFM constructor
*
Expand Down Expand Up @@ -511,9 +521,19 @@ function IFM(params) {
form.addEventListener( 'click', function( e ) {
if( e.target.id == "buttonSave" ) {
e.preventDefault();
self.saveFile( document.querySelector( '#formFile input[name=filename]' ).value, self.editor.getValue() );
self.isModalClosedByButton = true;
self.hideModal();
let filename = document.querySelector( '#formFile input[name=filename]' ).value;
let exists = self.fileCache.map(x => x.name).indexOf(filename) !== -1;
if (exists) {
if (window.confirm(self.i18n.file_overwrite_confirm || 'Die Datei existiert bereits. Überschreiben?')) {
self.saveFile(filename, self.editor.getValue());
self.isModalClosedByButton = true;
self.hideModal();
}
} else {
self.saveFile(filename, self.editor.getValue());
self.isModalClosedByButton = true;
self.hideModal();
}
} else if( e.target.id == "buttonSaveNotClose" ) {
e.preventDefault();
self.saveFile( document.querySelector( '#formFile input[name=filename]' ).value, self.editor.getValue() );
Expand Down
9 changes: 8 additions & 1 deletion src/templates/filetable.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
</td>
{{#config.download}}
<td>
<a href="{{download.link}}"><span class="{{download.icon}}"></span></a>
{{#type}}
{{#isDir}}
<a href="{{download.link}}" class="download-link" data-filename="{{download.name}}" onclick="return confirmDownload(event, this)"><span class="{{download.icon}}"></span></a>
{{/isDir}}
{{^isDir}}
<a href="{{download.link}}" class="download-link" data-filename="{{download.name}}"><span class="{{download.icon}}"></span></a>
{{/isDir}}
{{/type}}
</td>
{{/config.download}}
{{#config.showlastmodified}}
Expand Down
Loading