[Pkg-owncloud-commits] [owncloud] 60/85: Fix public download link when zip download is disabled

David Prévot taffit at moszumanska.debian.org
Tue Jun 17 19:12:45 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch 6.0
in repository owncloud.

commit 8ef1542ad02d71e6475d7de91a51498262c2dfec
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Thu Jun 12 17:29:55 2014 +0200

    Fix public download link when zip download is disabled
    
    When zip download is disabled, the public download action defined in
    public.js is overridden by the one in fileactions.js because of the JS
    loading order.
    
    This quick fix prevents the override to happen when a download action is
    already defined.
    
    There are additional changes that were required to make the download
    action icon work when registered from the public page.
---
 apps/files/js/fileactions.js    | 11 ++++++++---
 apps/files_sharing/js/public.js |  8 ++++++--
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 9fea7f5..21011a8 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -163,13 +163,18 @@ var FileActions = {
 };
 
 $(document).ready(function () {
+	var hasDownloadAction = false;
+	var downloadScope;
 	if ($('#allowZipDownload').val() == 1) {
-		var downloadScope = 'all';
+		downloadScope = 'all';
 	} else {
-		var downloadScope = 'file';
+		downloadScope = 'file';
 	}
 
-	if (typeof disableDownloadActions == 'undefined' || !disableDownloadActions) {
+	hasDownloadAction = FileActions.actions[downloadScope] && FileActions.actions[downloadScope].Download;
+
+	// do not override download action if it exists (might have been registered by an app already)
+	if ((typeof disableDownloadActions == 'undefined' || !disableDownloadActions) && !hasDownloadAction) {
 		FileActions.register(downloadScope, 'Download', OC.PERMISSION_READ, function () {
 			return OC.imagePath('core', 'actions/download');
 		}, function (filename) {
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 730649c..0696f8f 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -25,13 +25,17 @@ $(document).ready(function() {
 				window.location = $(tr).find('a.name').attr('href');
 			}
 		});
-		FileActions.register('file', 'Download', OC.PERMISSION_READ, '', function(filename) {
+		FileActions.register('file', 'Download', OC.PERMISSION_READ, function() {
+			return OC.imagePath('core', 'actions/download');
+		}, function(filename) {
 			var tr = FileList.findFileEl(filename);
 			if (tr.length > 0) {
 				window.location = $(tr).find('a.name').attr('href');
 			}
 		});
-		FileActions.register('dir', 'Download', OC.PERMISSION_READ, '', function(filename) {
+		FileActions.register('dir', 'Download', OC.PERMISSION_READ, function() {
+			return OC.imagePath('core', 'actions/download');
+		}, function(filename) {
 			var tr = FileList.findFileEl(filename);
 			if (tr.length > 0) {
 				window.location = $(tr).find('a.name').attr('href')+'&download';

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list