diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-03-21 14:05:08 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-03-21 14:05:08 +0100 |
commit | 6ff96b34ad0462ad05c34633ccd08236b93bf195 (patch) | |
tree | 1acd7eb869d512b5a3fc9502961a98591ea20cfa /apps/files/js/files.js | |
parent | e139f7c863d5971a6386070148496cb0f70ad04e (diff) | |
parent | 37af74efb3e3511b2d6eacef67dc90f22a685bd3 (diff) | |
download | nextcloud-server-6ff96b34ad0462ad05c34633ccd08236b93bf195.tar.gz nextcloud-server-6ff96b34ad0462ad05c34633ccd08236b93bf195.zip |
Merge branch 'master' into load-apps-proper-master
Conflicts:
apps/files/ajax/rawlist.php
cron.php
ocs/v1.php
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r-- | apps/files/js/files.js | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index a535700c1b3..1186a72a44f 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -87,9 +87,12 @@ var Files = { * Throws a string exception with an error message if * the file name is not valid */ - isFileNameValid: function (name) { + isFileNameValid: function (name, root) { var trimmedName = name.trim(); - if (trimmedName === '.' || trimmedName === '..') { + if (trimmedName === '.' + || trimmedName === '..' + || (root === '/' && trimmedName.toLowerCase() === 'shared')) + { throw t('files', '"{name}" is an invalid file name.', {name: name}); } else if (trimmedName.length === 0) { throw t('files', 'File name cannot be empty.'); @@ -364,23 +367,26 @@ $(document).ready(function() { }); $('.download').click('click',function(event) { - var files=getSelectedFilesTrash('name'); - var fileslist = JSON.stringify(files); - var dir=$('#dir').val()||'/'; - OC.Notification.show(t('files','Your download is being prepared. This might take some time if the files are big.')); - // use special download URL if provided, e.g. for public shared files - var downloadURL = document.getElementById("downloadURL"); - if ( downloadURL ) { - window.location = downloadURL.value+"&download&files=" + encodeURIComponent(fileslist); - } else { - window.location = OC.filePath('files', 'ajax', 'download.php') + '?'+ $.param({ dir: dir, files: fileslist }); + var files; + var dir = FileList.getCurrentDirectory(); + if (FileList.isAllSelected()) { + files = OC.basename(dir); + dir = OC.dirname(dir) || '/'; + } + else { + files = getSelectedFilesTrash('name'); } + OC.Notification.show(t('files','Your download is being prepared. This might take some time if the files are big.')); + OC.redirect(FileList.getDownloadUrl(files, dir)); return false; }); $('.delete-selected').click(function(event) { var files=getSelectedFilesTrash('name'); event.preventDefault(); + if (FileList.isAllSelected()) { + files = null; + } FileList.do_delete(files); return false; }); @@ -405,7 +411,7 @@ $(document).ready(function() { Files.resizeBreadcrumbs(width, true); // display storage warnings - setTimeout ( "Files.displayStorageWarnings()", 100 ); + setTimeout(Files.displayStorageWarnings, 100); OC.Notification.setDefault(Files.displayStorageWarnings); // only possible at the moment if user is logged in @@ -731,6 +737,9 @@ Files.getMimeIcon = function(mime, ready) { ready(Files.getMimeIcon.cache[mime]); } else { $.get( OC.filePath('files','ajax','mimeicon.php'), {mime: mime}, function(path) { + if(SVGSupport()){ + path = path.substr(0, path.length-4) + '.svg'; + } Files.getMimeIcon.cache[mime]=path; ready(Files.getMimeIcon.cache[mime]); }); @@ -774,19 +783,22 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { if ( $('#isPublic').length ) { urlSpec.t = $('#dirToken').val(); - previewURL = OC.Router.generate('core_ajax_public_preview', urlSpec); + previewURL = OC.generateUrl('/publicpreview.png?') + $.param(urlSpec); } else { - previewURL = OC.Router.generate('core_ajax_preview', urlSpec); + previewURL = OC.generateUrl('/core/preview.png?') + $.param(urlSpec); } previewURL = previewURL.replace('(', '%28'); previewURL = previewURL.replace(')', '%29'); + previewURL += '&forceIcon=0'; // preload image to prevent delay // this will make the browser cache the image var img = new Image(); img.onload = function(){ - //set preview thumbnail URL - ready(previewURL); + // if loading the preview image failed (no preview for the mimetype) then img.width will < 5 + if (img.width > 5) { + ready(previewURL); + } } img.src = previewURL; }); |