From 5beca59b9c277d479b899e59920acb57a5d81983 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Thu, 4 Oct 2012 14:31:06 +0200 Subject: check if element really exists before calling it. (e.g. for public shared files view, elements like "navigation" doesn't exist) --- apps/files/js/files.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 0c00fe8c922..414dfb03cdc 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -195,6 +195,8 @@ $(document).ready(function() { e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone }); + if ( document.getElementById("file_upload_start") ) { + $(function() { $('.file_upload_start').fileupload({ dropZone: $('#content'), // restrict dropZone to content div @@ -408,7 +410,8 @@ $(document).ready(function() { } }) }); - + } + $.assocArraySize = function(obj) { // http://stackoverflow.com/a/6700/11236 var size = 0, key; @@ -592,7 +595,10 @@ $(document).ready(function() { var lastWidth = 0; var breadcrumbs = []; - var breadcrumbsWidth = $('#navigation').get(0).offsetWidth; + var breadcrumbsWidth = 0; + if ( document.getElementById("navigation") ) { + breadcrumbsWidth = $('#navigation').get(0).offsetWidth; + } var hiddenBreadcrumbs = 0; $.each($('.crumb'), function(index, breadcrumb) { -- cgit v1.2.3 From 5e2bce24b4d7576f2503edb762afd6cbe3caccea Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Fri, 5 Oct 2012 16:12:04 +0200 Subject: enable user to download selected files from publically shared directory --- apps/files/js/files.js | 7 ++++++- apps/files_sharing/public.php | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 414dfb03cdc..e4037454520 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -178,7 +178,12 @@ $(document).ready(function() { var dir=$('#dir').val()||'/'; $('#notification').text(t('files','generating ZIP-file, it may take some time.')); $('#notification').fadeIn(); - window.location=OC.filePath('files', 'ajax', 'download.php') + '?'+ $.param({ dir: dir, files: files }); + // use special download URL if provided, e.g. for public shared files + if ( (downloadURL = document.getElementById("downloadURL")) ) { + window.location=downloadURL.value+"&download&files="+files; + } else { + window.location=OC.filePath('files', 'ajax', 'download.php') + '?'+ $.param({ dir: dir, files: files }); + } return false; }); diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 67b2dca8c9e..34340102a9e 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -83,7 +83,9 @@ if (isset($_GET['file']) || isset($_GET['dir'])) { // Download the file if (isset($_GET['download'])) { if (isset($_GET['dir'])) { - if (isset($_GET['path']) && $_GET['path'] != '' ) { // download a file from a shared directory + if ( isset($_GET['files']) ) { // download selected files + OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); + } else if (isset($_GET['path']) && $_GET['path'] != '' ) { // download a file from a shared directory OC_Files::get('', $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); } else { // download the whole shared directory OC_Files::get($path, '', $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); -- cgit v1.2.3 From 4b446f3eddd31829b844b09b8169a85350b26d2b Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sun, 7 Oct 2012 17:17:37 -0400 Subject: Revert part of 5beca59b, fixes file upload bug oc-1926 --- apps/files/js/files.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index e4037454520..c7f4c4ce080 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -200,8 +200,6 @@ $(document).ready(function() { e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone }); - if ( document.getElementById("file_upload_start") ) { - $(function() { $('.file_upload_start').fileupload({ dropZone: $('#content'), // restrict dropZone to content div @@ -415,8 +413,7 @@ $(document).ready(function() { } }) }); - } - + $.assocArraySize = function(obj) { // http://stackoverflow.com/a/6700/11236 var size = 0, key; -- cgit v1.2.3 From 4dba91838ff24202fa7e184469074b61a4872d1e Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Mon, 8 Oct 2012 10:28:29 +0200 Subject: add ID to upload form and check if ID exist to avoid loading invalid javascript code for read-only views. --- apps/files/js/files.js | 5 +++-- apps/files/templates/index.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index c7f4c4ce080..b36e46813dc 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -199,7 +199,8 @@ $(document).ready(function() { $(document).bind('drop dragover', function (e) { e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone }); - + + if ( document.getElementById("data-upload-form") ) { $(function() { $('.file_upload_start').fileupload({ dropZone: $('#content'), // restrict dropZone to content div @@ -413,7 +414,7 @@ $(document).ready(function() { } }) }); - + } $.assocArraySize = function(obj) { // http://stackoverflow.com/a/6700/11236 var size = 0, key; diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index aff484f0a7a..d49f2f4d5d3 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -12,7 +12,7 @@
-
+ -- cgit v1.2.3