Skip to content

Commit a60beef

Browse files
authored
Disable pdf viewer if collabora is available on hide download sh… (#154)
Disable pdf viewer if collabora is available on hide download shares
2 parents d93977d + 2cea2d5 commit a60beef

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

js/previewplugin.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
*
99
*/
1010

11+
var isSecureViewerAvailable = function () {
12+
return $('#hideDownload').val() === 'true' && typeof OCA.RichDocuments !== 'undefined';
13+
};
14+
1115
(function(OCA) {
1216

1317
OCA.FilesPdfViewer = OCA.FilesPdfViewer || {};
@@ -77,6 +81,10 @@
7781
// if a filelist is present, the PDF viewer can be closed to go back there
7882
$('#pdframe').load(function(){
7983
var iframe = $('#pdframe').contents();
84+
if ($('#hideDownload').val() === 'true') {
85+
iframe.find('.toolbarButton.download').hide()
86+
iframe.find('.toolbarButton.print').hide()
87+
}
8088
if ($('#fileList').length)
8189
{
8290
iframe.find('#secondaryToolbarClose').click(function() {
@@ -117,6 +125,9 @@
117125
*/
118126
_extendFileActions: function(fileActions) {
119127
var self = this;
128+
if (isSecureViewerAvailable()) {
129+
return;
130+
}
120131
fileActions.registerAction({
121132
name: 'view',
122133
displayName: 'Favorite',
@@ -139,7 +150,7 @@ OC.Plugins.register('OCA.Files.FileList', OCA.FilesPdfViewer.PreviewPlugin);
139150

140151
// FIXME: Hack for single public file view since it is not attached to the fileslist
141152
$(document).ready(function(){
142-
if ($('#isPublic').val() && $('#mimetype').val() === 'application/pdf') {
153+
if ($('#isPublic').val() && $('#mimetype').val() === 'application/pdf' && !isSecureViewerAvailable()) {
143154
$.urlParam = function(name){
144155
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
145156
if (results == null) {

0 commit comments

Comments
 (0)