Merge pull request #16984 from nextcloud/bugfix/noid/warn-during-upload-drop

Warn user before closing when uploading a file on a upload only link
This commit is contained in:
Roeland Jago Douma 2019-09-06 12:18:08 +02:00 committed by GitHub
commit 803c8ddf7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 11 deletions

View File

@ -14,6 +14,9 @@
/** @type {Function} **/
_template: undefined,
/** @type {bool} */
_uploading: false,
addFileToUpload: function(e, data) {
var errors = [];
var output = this.template();
@ -79,10 +82,17 @@
e.preventDefault();
});
var output = this.template();
var self = this;
$('#public-upload').fileupload({
type: 'PUT',
dropZone: $('#public-upload'),
sequentialUploads: true,
start: function(e) {
self._uploading = true;
},
stop: function(e) {
self._uploading = false;
},
add: function(e, data) {
Drop.addFileToUpload(e, data);
//we return true to keep trying to upload next file even
@ -120,6 +130,9 @@
e.preventDefault();
$('#public-upload #emptycontent input').focus().trigger('click');
});
window.onbeforeunload = function() {
return self.confirmBeforeUnload();
}
},
/**
@ -128,7 +141,13 @@
*/
template: function () {
return OCA.Sharing.Templates['files_drop'];
},
confirmBeforeUnload: function() {
if (this._uploading) {
return t('files', 'This will stop your current uploads.')
}
},
};
OCA.FilesSharingDrop = Drop;