diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-23 09:38:01 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-23 09:38:01 +0100 |
commit | 79bbda994bb8dd2231f68f57785237f79f86f6c7 (patch) | |
tree | 65585aed0d21cc679cdf7e2509efd6fa3d33b458 /apps/files/js/files.js | |
parent | 2f89eef334bd445a7e046d845d5d5d1b3e4b6b8c (diff) | |
parent | 418fefc93c3332c77ec617ef108138efb6a34544 (diff) | |
download | nextcloud-server-79bbda994bb8dd2231f68f57785237f79f86f6c7.tar.gz nextcloud-server-79bbda994bb8dd2231f68f57785237f79f86f6c7.zip |
Merge pull request #16902 from owncloud/jsocclient
Web UI uses Webdav instead of ajax/* calls
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r-- | apps/files/js/files.js | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index ae38511ec05..e33b8354437 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -136,13 +136,27 @@ /** * Returns the download URL of the given file(s) - * @param filename string or array of file names to download - * @param dir optional directory in which the file name is, defaults to the current directory + * @param {string} filename string or array of file names to download + * @param {string} [dir] optional directory in which the file name is, defaults to the current directory + * @param {bool} [isDir=false] whether the given filename is a directory and might need a special URL */ - getDownloadUrl: function(filename, dir) { - if ($.isArray(filename)) { + getDownloadUrl: function(filename, dir, isDir) { + if (!_.isArray(filename) && !isDir) { + var pathSections = dir.split('/'); + pathSections.push(filename); + var encodedPath = ''; + _.each(pathSections, function(section) { + if (section !== '') { + encodedPath += '/' + encodeURIComponent(section); + } + }); + return OC.linkToRemoteBase('webdav') + encodedPath; + } + + if (_.isArray(filename)) { filename = JSON.stringify(filename); } + var params = { dir: dir, files: filename @@ -193,7 +207,7 @@ */ lazyLoadPreview : function(path, mime, ready, width, height, etag) { console.warn('DEPRECATED: please use lazyLoadPreview() from an OCA.Files.FileList instance'); - return OCA.Files.App.fileList.lazyLoadPreview({ + return FileList.lazyLoadPreview({ path: path, mime: mime, callback: ready, @@ -356,8 +370,10 @@ scanFiles.scanning=false; // TODO: move to FileList var createDragShadow = function(event) { + // FIXME: inject file list instance somehow + /* global FileList, Files */ + //select dragged file - var FileList = OCA.Files.App.fileList; var isDragSelected = $(event.target).parents('tr').find('td input:first').prop('checked'); if (!isDragSelected) { //select dragged file @@ -394,7 +410,7 @@ var createDragShadow = function(event) { .css('background-image', 'url(' + OC.imagePath('core', 'filetypes/folder.png') + ')'); } else { var path = dir + '/' + elem.name; - OCA.Files.App.files.lazyLoadPreview(path, elem.mime, function(previewpath) { + Files.lazyLoadPreview(path, elem.mimetype, function(previewpath) { newtr.find('td.filename') .css('background-image', 'url(' + previewpath + ')'); }, null, null, elem.etag); @@ -441,7 +457,7 @@ var folderDropOptions = { hoverClass: "canDrop", drop: function( event, ui ) { // don't allow moving a file into a selected folder - var FileList = OCA.Files.App.fileList; + /* global FileList */ if ($(event.target).parents('tr').find('td input:first').prop('checked') === true) { return false; } |