aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2012-08-31 00:45:03 +0200
committerThomas Mueller <thomas.mueller@tmit.eu>2012-08-31 00:45:03 +0200
commit077e98813606c07e35f73533f349a4f66f3c1e99 (patch)
tree387536adb492a918f033dc8c1d43ff2919228a8b /apps
parentbd809574dc06a68d5e1060fb8b9f0484e6a4f1f5 (diff)
downloadnextcloud-server-077e98813606c07e35f73533f349a4f66f3c1e99.tar.gz
nextcloud-server-077e98813606c07e35f73533f349a4f66f3c1e99.zip
oc-1548: prevent user from leaving the page while a file upload is in progress
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/files.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 5ecc5bc22cb..6165da22830 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -389,6 +389,21 @@ $(document).ready(function() {
})
});
+ $.assocArraySize = function(obj) {
+ // http://stackoverflow.com/a/6700/11236
+ var size = 0, key;
+ for (key in obj) {
+ if (obj.hasOwnProperty(key)) size++;
+ }
+ return size;
+ };
+
+ // warn user not to leave the page while upload is in progress
+ $(window).bind('beforeunload', function(e) {
+ if ($.assocArraySize(uploadingFiles) > 0)
+ return t('files','File upload is in progress. Leaving the page now will cancel the upload.');
+ });
+
//add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)
if(navigator.userAgent.search(/konqueror/i)==-1){
$('.file_upload_start').attr('multiple','multiple')