From fab4102c51e92c5e33725c69ec984b8912a9aee1 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 14 Oct 2013 17:47:38 +0200 Subject: Disabled ajax mode for public files view Ajax loading is not supported yet for public files view. This fix disabled the history API, ajax loading and ajax directory switch in public mode until it is implemented properly. --- apps/files/js/filelist.js | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'apps/files/js/filelist.js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a9297996778..ccc4b1401ad 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -677,6 +677,7 @@ var FileList={ }; $(document).ready(function(){ + var isPublic = !!$('#isPublic').val(); // handle upload events var file_upload_start = $('#file_upload_start'); @@ -924,29 +925,32 @@ $(document).ready(function(){ return (params && params.dir) || '/'; } - // fallback to hashchange when no history support - if (!window.history.pushState){ - $(window).on('hashchange', function(){ - FileList.changeDirectory(parseCurrentDirFromUrl(), false); - }); - } - window.onpopstate = function(e){ - var targetDir; - if (e.state && e.state.dir){ - targetDir = e.state.dir; - } - else{ - // read from URL - targetDir = parseCurrentDirFromUrl(); + // disable ajax/history API for public app (TODO: until it gets ported) + if (!isPublic){ + // fallback to hashchange when no history support + if (!window.history.pushState){ + $(window).on('hashchange', function(){ + FileList.changeDirectory(parseCurrentDirFromUrl(), false); + }); } - if (targetDir){ - FileList.changeDirectory(targetDir, false); + window.onpopstate = function(e){ + var targetDir; + if (e.state && e.state.dir){ + targetDir = e.state.dir; + } + else{ + // read from URL + targetDir = parseCurrentDirFromUrl(); + } + if (targetDir){ + FileList.changeDirectory(targetDir, false); + } } - } - if (parseInt($('#ajaxLoad').val(), 10) === 1){ - // need to initially switch the dir to the one from the hash (IE8) - FileList.changeDirectory(parseCurrentDirFromUrl(), false, true); + if (parseInt($('#ajaxLoad').val(), 10) === 1){ + // need to initially switch the dir to the one from the hash (IE8) + FileList.changeDirectory(parseCurrentDirFromUrl(), false, true); + } } FileList.createFileSummary(); -- cgit v1.2.3 From 92e646413a8b2df3c16306b75deab506b6eb4ec2 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 15 Oct 2013 15:54:16 +0200 Subject: Fixed drag and drop onto folders Fixes #5351 --- apps/files/js/filelist.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'apps/files/js/filelist.js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a9297996778..02de2f2415e 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -698,11 +698,23 @@ $(document).ready(function(){ // array index 0 contains the max files size // array index 1 contains the request token // array index 2 contains the directory - var parentDir = formArray[2]['value']; - if (parentDir === '/') { - formArray[2]['value'] += dir; - } else { - formArray[2]['value'] += '/' + dir; + if (formArray.length){ + var parentDir = formArray[2]['value']; + if (parentDir === '/') { + formArray[2]['value'] += dir; + } else { + formArray[2]['value'] += '/' + dir; + } + } + else{ + var parentDir = $('#dir').val() || ''; + if (parentDir[parentDir.length - 1] != '/'){ + parentDir += '/'; + } + return [ + {name: 'dir', value: parentDir + dir}, + {name: 'requesttoken', value: oc_requesttoken} + ]; } return formArray; -- cgit v1.2.3 From c6f14001bb2ca1b035760e62c57281b164e55795 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 15 Oct 2013 16:14:23 +0200 Subject: Fixed drag and drop upload to breadcrumb --- apps/files/js/filelist.js | 48 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'apps/files/js/filelist.js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 02de2f2415e..fa26e2bfb7e 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -684,40 +684,32 @@ $(document).ready(function(){ file_upload_start.on('fileuploaddrop', function(e, data) { OC.Upload.log('filelist handle fileuploaddrop', e, data); - var dropTarget = $(e.originalEvent.target).closest('tr'); - if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder + var dropTarget = $(e.originalEvent.target).closest('tr, .crumb'); + if(dropTarget && (dropTarget.data('type') === 'dir' || dropTarget.hasClass('crumb'))) { // drag&drop upload to folder // remember as context data.context = dropTarget; var dir = dropTarget.data('file'); + // if from file list, need to prepend parent dir + if (dir){ + var parentDir = $('#dir').val() || '/'; + if (parentDir[parentDir.length - 1] != '/'){ + parentDir += '/'; + } + dir = parentDir + dir; + } + else{ + // read full path from crumb + dir = dropTarget.data('dir') || '/'; + } // update folder in form data.formData = function(form) { - var formArray = form.serializeArray(); - // array index 0 contains the max files size - // array index 1 contains the request token - // array index 2 contains the directory - if (formArray.length){ - var parentDir = formArray[2]['value']; - if (parentDir === '/') { - formArray[2]['value'] += dir; - } else { - formArray[2]['value'] += '/' + dir; - } - } - else{ - var parentDir = $('#dir').val() || ''; - if (parentDir[parentDir.length - 1] != '/'){ - parentDir += '/'; - } - return [ - {name: 'dir', value: parentDir + dir}, - {name: 'requesttoken', value: oc_requesttoken} - ]; - } - - return formArray; + return [ + {name: 'dir', value: dir}, + {name: 'requesttoken', value: oc_requesttoken} + ]; }; } @@ -795,6 +787,10 @@ $(document).ready(function(){ data.context.find('td.filesize').text(humanFileSize(size)); } else { + // only append new file if dragged onto current dir's crumb (last) + if (data.context && data.context.hasClass('crumb') && !data.context.hasClass('last')){ + return; + } // add as stand-alone row to filelist var size=t('files', 'Pending'); -- cgit v1.2.3