diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-10-28 20:22:06 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-04-02 15:33:47 +0200 |
commit | 0be9de5df558232e12e2f582af5d08e1f488ba90 (patch) | |
tree | de37dea2e23dd28f631948295979980ec774027f /apps/files/js/file-upload.js | |
parent | 268206cec55921d2d0309469ebd5d9533e4f79ee (diff) | |
download | nextcloud-server-0be9de5df558232e12e2f582af5d08e1f488ba90.tar.gz nextcloud-server-0be9de5df558232e12e2f582af5d08e1f488ba90.zip |
Files, trashbin, public apps use ajax/JSON for the file list
Files app:
- removed file list template, now rendering list from JSON response
- FileList.addFile/addDir is now FileList.add() and takes a JS map with all required
arguments instead of having a long number of function arguments
- added unit tests for many FileList operations
- fixed newfile.php, newfolder.php and rename.php to return the file's
full JSON on success
- removed obsolete/unused undo code
- removed download_url / loading options, now using
Files.getDownloadUrl() for that
- server side now uses Helper::getFileInfo() to prepare file JSON response
- previews are now client-side only
Breadcrumbs are now JS only:
- Added BreadCrumb class to handle breadcrumb rendering and events
- Added unit test for BreadCrumb class
- Moved all relevant JS functions to the BreadCrumb class
Public page now uses ajax to load the file list:
- Added Helper class in sharing app to make it easier to authenticate
and retrieve the file's real path
- Added ajax/list.php to retrieve the file list
- Fixed FileActions and FileList to work with the ajax list
Core:
- Fixed file picker dialog to use the same list format as files app
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r-- | apps/files/js/file-upload.js | 61 |
1 files changed, 6 insertions, 55 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 371c83e742c..e5d1eacbd14 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -180,7 +180,7 @@ OC.Upload = { }, init: function() { - if ( $('#file_upload_start').exists() && $('#file_upload_start').is(':visible')) { + if ( $('#file_upload_start').exists() ) { var file_upload_param = { dropZone: $('#content'), // restrict dropZone to content div @@ -483,28 +483,6 @@ OC.Upload = { $('#file_upload_start').attr('multiple', 'multiple'); } - //if the breadcrumb is to long, start by replacing foldernames with '...' except for the current folder - var crumb=$('div.crumb').first(); - while($('div.controls').height() > 40 && crumb.next('div.crumb').length > 0) { - crumb.children('a').text('...'); - crumb = crumb.next('div.crumb'); - } - //if that isn't enough, start removing items from the breacrumb except for the current folder and it's parent - var crumb = $('div.crumb').first(); - var next = crumb.next('div.crumb'); - while($('div.controls').height()>40 && next.next('div.crumb').length > 0) { - crumb.remove(); - crumb = next; - next = crumb.next('div.crumb'); - } - //still not enough, start shorting down the current folder name - var crumb=$('div.crumb>a').last(); - while($('div.controls').height() > 40 && crumb.text().length > 6) { - var text=crumb.text(); - text = text.substr(0,text.length-6)+'...'; - crumb.text(text); - } - $(document).click(function(ev) { // do not close when clicking in the dropdown if ($(ev.target).closest('#new').length){ @@ -617,21 +595,7 @@ OC.Upload = { {dir:$('#dir').val(), filename:name}, function(result) { if (result.status === 'success') { - var date = new Date(); - // TODO: ideally addFile should be able to receive - // all attributes and set them automatically, - // and also auto-load the preview - var tr = FileList.addFile(name, 0, date, false, hidden); - tr.attr('data-size', result.data.size); - tr.attr('data-mime', result.data.mime); - tr.attr('data-id', result.data.id); - tr.attr('data-etag', result.data.etag); - tr.find('.filesize').text(humanFileSize(result.data.size)); - var path = getPathForPreview(name); - Files.lazyLoadPreview(path, result.data.mime, function(previewpath) { - tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); - }, null, null, result.data.etag); - FileActions.display(tr.find('td.filename'), true); + FileList.add(result.data, {hidden: hidden, insert: true}); } else { OC.dialogs.alert(result.data.message, t('core', 'Could not create file')); } @@ -644,10 +608,7 @@ OC.Upload = { {dir:$('#dir').val(), foldername:name}, function(result) { if (result.status === 'success') { - var date=new Date(); - FileList.addDir(name, 0, date, hidden); - var tr = FileList.findFileEl(name); - tr.attr('data-id', result.data.id); + FileList.add(result.data, {hidden: hidden, insert: true}); } else { OC.dialogs.alert(result.data.message, t('core', 'Could not create folder')); } @@ -682,20 +643,10 @@ OC.Upload = { } }); eventSource.listen('success',function(data) { - var mime = data.mime; - var size = data.size; - var id = data.id; + var file = data; $('#uploadprogressbar').fadeOut(); - var date = new Date(); - FileList.addFile(localName, size, date, false, hidden); - var tr = FileList.findFileEl(localName); - tr.data('mime', mime).data('id', id); - tr.attr('data-id', id); - var path = $('#dir').val()+'/'+localName; - Files.lazyLoadPreview(path, mime, function(previewpath) { - tr.find('td.filename').attr('style', 'background-image:url('+previewpath+')'); - }, null, null, data.etag); - FileActions.display(tr.find('td.filename'), true); + + FileList.add(file, {hidden: hidden, insert: true}); }); eventSource.listen('error',function(error) { $('#uploadprogressbar').fadeOut(); |