From 1f02ba813da79cc17c22ca6ca53d62ee3f72b420 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 31 May 2011 11:23:48 -0400 Subject: [PATCH] CC-2290:Clicking on another tab whilst uploading track kills - note that change in queue will trigger the alert(on unload), not the actual upload process --- .../public/js/airtime/library/plupload.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/airtime_mvc/public/js/airtime/library/plupload.js b/airtime_mvc/public/js/airtime/library/plupload.js index 930bb60f1..74d59798f 100644 --- a/airtime_mvc/public/js/airtime/library/plupload.js +++ b/airtime_mvc/public/js/airtime/library/plupload.js @@ -25,5 +25,24 @@ $(document).ready(function() { $("#plupload_error").find("table").append(row); } }); + + var uploadProgress = false; + + uploader.bind('QueueChanged', function(){ + uploadProgress = true; + }); + + uploader.bind('UploadComplete', function(){ + uploadProgress = false; + }); + + + $(window).bind('beforeunload', function(){ + if(uploadProgress){ + if(!confirm("Are you sure you want to navigate away from the page?\nNavigating away from the page will cancel all the upload process.")){ + return false; + } + } + }); });