diff options
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/fileactions.js | 2 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 57 |
2 files changed, 26 insertions, 33 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index b9cd9816d4c..2edb45f544c 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -244,7 +244,7 @@ this.register(downloadScope, 'Download', OC.PERMISSION_READ, function () { return OC.imagePath('core', 'actions/download'); }, function (filename) { - var url = OCA.Files.Files.getDownloadUrl(filename, fileList.getCurrentDirectory()); + var url = fileList.getDownloadUrl(filename, fileList.getCurrentDirectory()); if (url) { OC.redirect(url); } diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 38766e2b801..72e1a688041 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -522,12 +522,6 @@ mime = mime || 'httpd/unix-directory'; } - // user should always be able to rename a share mount point - var allowRename = 0; - if (fileData.isShareMountPoint) { - allowRename = OC.PERMISSION_UPDATE; - } - //containing tr var tr = $('<tr></tr>').attr({ "data-id" : fileData.id, @@ -537,7 +531,7 @@ "data-mime": mime, "data-mtime": mtime, "data-etag": fileData.etag, - "data-permissions": fileData.permissions | allowRename || this.getDirectoryPermissions() + "data-permissions": fileData.permissions || this.getDirectoryPermissions() }); if (type === 'dir') { @@ -936,7 +930,7 @@ /** * Lazy load a file's preview. - * + * * @param path path of the file * @param mime mime type * @param callback callback function to call when the image was loaded @@ -1184,10 +1178,22 @@ event.preventDefault(); try { var newName = input.val(); + input.tipsy('hide'); + form.remove(); + if (newName !== oldname) { checkInput(); - // mark as loading + // mark as loading (temp element) td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); + tr.attr('data-file', newName); + var basename = newName; + if (newName.indexOf('.') > 0 && tr.data('type') !== 'dir') { + basename = newName.substr(0, newName.lastIndexOf('.')); + } + td.find('a.name span.nametext').text(basename); + td.children('a.name').show(); + tr.find('.fileactions, .action').addClass('hidden'); + $.ajax({ url: OC.filePath('files','ajax','rename.php'), data: { @@ -1207,30 +1213,17 @@ // reinsert row self.files.splice(tr.index(), 1); tr.remove(); - self.add(fileInfo); + self.add(fileInfo, {updateSummary: false}); + self.$fileList.trigger($.Event('fileActionsReady')); } }); + } else { + // add back the old file info when cancelled + self.files.splice(tr.index(), 1); + tr.remove(); + self.add(oldFileInfo, {updateSummary: false}); + self.$fileList.trigger($.Event('fileActionsReady')); } - input.tipsy('hide'); - tr.data('renaming',false); - tr.attr('data-file', newName); - var path = td.children('a.name').attr('href'); - // FIXME this will fail if the path contains the filename. - td.children('a.name').attr('href', path.replace(encodeURIComponent(oldname), encodeURIComponent(newName))); - var basename = newName; - if (newName.indexOf('.') > 0 && tr.data('type') !== 'dir') { - basename = newName.substr(0, newName.lastIndexOf('.')); - } - td.find('a.name span.nametext').text(basename); - if (newName.indexOf('.') > 0 && tr.data('type') !== 'dir') { - if ( ! td.find('a.name span.extension').exists() ) { - td.find('a.name span.nametext').append('<span class="extension"></span>'); - } - td.find('a.name span.extension').text(newName.substr(newName.lastIndexOf('.'))); - } - form.remove(); - self.fileActions.display( tr.find('td.filename'), true); - td.children('a.name').show(); } catch (error) { input.attr('title', error); input.tipsy({gravity: 'w', trigger: 'manual'}); @@ -1640,7 +1633,7 @@ if (fileDirectory.length === 1) { fileDirectory = fileDirectory[0]; - // Get the directory + // Get the directory var fd = self.findFileEl(fileDirectory); if (fd.length === 0) { var dir = { @@ -1656,7 +1649,7 @@ } else { fileDirectory = fileDirectory[0]; } - + fileDirectory = self.findFileEl(fileDirectory); // update folder size |