From 2cea2d5ea392279e5838416bde31c7fac97bd296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 29 Jul 2019 12:40:31 +0200 Subject: Hide download button and disable pdf viewer if collabora is available on download only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- js/previewplugin.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/previewplugin.js b/js/previewplugin.js index ad3b338..eb82a16 100644 --- a/js/previewplugin.js +++ b/js/previewplugin.js @@ -8,6 +8,10 @@ * */ +var isSecureViewerAvailable = function () { + return $('#hideDownload').val() === 'true' && typeof OCA.RichDocuments !== 'undefined'; +}; + (function(OCA) { OCA.FilesPdfViewer = OCA.FilesPdfViewer || {}; @@ -77,6 +81,10 @@ // if a filelist is present, the PDF viewer can be closed to go back there $('#pdframe').load(function(){ var iframe = $('#pdframe').contents(); + if ($('#hideDownload').val() === 'true') { + iframe.find('.toolbarButton.download').hide() + iframe.find('.toolbarButton.print').hide() + } if ($('#fileList').length) { iframe.find('#secondaryToolbarClose').click(function() { @@ -117,6 +125,9 @@ */ _extendFileActions: function(fileActions) { var self = this; + if (isSecureViewerAvailable()) { + return; + } fileActions.registerAction({ name: 'view', displayName: 'Favorite', @@ -139,7 +150,7 @@ OC.Plugins.register('OCA.Files.FileList', OCA.FilesPdfViewer.PreviewPlugin); // FIXME: Hack for single public file view since it is not attached to the fileslist $(document).ready(function(){ - if ($('#isPublic').val() && $('#mimetype').val() === 'application/pdf') { + if ($('#isPublic').val() && $('#mimetype').val() === 'application/pdf' && !isSecureViewerAvailable()) { $.urlParam = function(name){ var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); if (results == null) { -- cgit v1.2.3