From d0b80697c20907523417c631bab0dca7f9a30a26 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 23 Jun 2014 21:58:27 +0000 Subject: [PATCH] Multiple file download for browsers that support download attribute --- filemanager/js/app.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/filemanager/js/app.js b/filemanager/js/app.js index ac07069726..ec00eddc94 100644 --- a/filemanager/js/app.js +++ b/filemanager/js/app.js @@ -450,10 +450,31 @@ app.classes.filemanager = AppJS.extend( */ force_download: function(_action, _senders) { - var data = egw.dataGetUIDdata(_senders[0].id); - var url = data ? data.data.download_url : '/webdav.php'+this.id2path(_senders[0].id); - if (url[0] == '/') url = egw.link(url); - window.location = url+"?download"; + for(var i = 0; i < _senders.length; i++) + { + var data = egw.dataGetUIDdata(_senders[i].id); + var url = data ? data.data.download_url : '/webdav.php'+this.id2path(_senders[i].id); + if (url[0] == '/') url = egw.link(url); + + var a = document.createElement('a'); + if(typeof a.download == "undefined") + { + window.location = url+"?download"; + return false; + } + + // Multiple file download for those that support it + a = $j(a) + .prop('href', url) + .prop('download', data ? data.data.name : "") + .appendTo(this.et2.getDOMNode()); + + var evt = document.createEvent('MouseEvent'); + evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); + a[0].dispatchEvent(evt); + a.remove(); + } + return false; }, /**