From fc105cf1415cf4124f69d40419b5c52307e993a2 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 28 Jul 2016 15:35:45 +0200 Subject: reusing the original form did not work so well via xhr upload - let us create a new form for this action. revert progressbar- only works nice in firefox --- view/js/mod_cloud.js | 20 ++++++++++++-------- view/tpl/cloud_actionspanel.tpl | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'view') diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index f7f9092c0..ea1ce35a7 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -22,6 +22,7 @@ function UploadInit() { if (xhr.upload) { // file select + fileselect.attr("multiple", 'multiple'); fileselect.on("change", UploadFileSelectHandler); // file submit @@ -64,27 +65,30 @@ function DragDropUploadFileSelectHandler(e) { // file selection via input function UploadFileSelectHandler(e) { // fetch FileList object - if(e.type === 'click') { + if(e.target.id === 'upload-submit') { e.preventDefault(); var files = e.data[0].files; } - else { + if(e.target.id === 'files-upload') { + $('.new-upload').remove(); var files = e.target.files; } - $('.new-upload').remove(); + // process all File objects for (var i = 0, f; f = files[i]; i++) { - prepareHtml(f, i); - if(e.type === 'click') + if(e.target.id === 'files-upload') + prepareHtml(f, i); + if(e.target.id === 'upload-submit') { UploadFile(f, i); + } } } function prepareHtml(f, i) { $("#cloud-index tr:nth-child(2)").after( - '' + + '' + '' + '' + f.name + '' + '' + @@ -182,8 +186,8 @@ function UploadFile(file, idx) { // POST to the entire cloud path xhr.open('post', window.location.pathname, true); - var data = new FormData(document.getElementById("ajax-upload-files")); - + var data = new FormData(); + data.append('sabreAction', 'put'); data.append('file', file); xhr.send(data); diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index 8976b3007..eaa613dc4 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -13,7 +13,7 @@
- +
-- cgit v1.2.3