Blame view
sources/apps/files_pdfviewer/js/loader.js
2.69 KB
|
6d9380f96
|
1 |
/* globals FileList, FileActions */ |
|
d1bafeea1
|
2 |
function hidePDFviewer() {
|
|
d1bafeea1
|
3 |
$('#pdframe, #pdfbar').remove();
|
|
6d9380f96
|
4 5 |
if ($('#isPublic').val() && $('#filesApp').val()){
$('#controls').removeClass('hidden');
|
|
d1bafeea1
|
6 |
} |
|
6d9380f96
|
7 8 9 |
FileList.setViewerMode(false);
// replace the controls with our own
$('#app-content #controls').removeClass('hidden');
|
|
d1bafeea1
|
10 |
} |
|
6d9380f96
|
11 |
function showPDFviewer(dir, filename) {
|
|
d1bafeea1
|
12 13 |
if(!showPDFviewer.shown) {
var $iframe;
|
|
d1bafeea1
|
14 |
var viewer = OC.linkTo('files_pdfviewer', 'viewer.php')+'?dir='+encodeURIComponent(dir).replace(/%2F/g, '/')+'&file='+encodeURIComponent(filename);
|
|
6d9380f96
|
15 |
$iframe = $('<iframe id="pdframe" style="width:100%;height:100%;display:block;position:absolute;top:0;" src="'+viewer+'" sandbox="allow-scripts allow-same-origin" /><div id="pdfbar"><a id="close" title="Close">X</a></div>');
|
|
d1bafeea1
|
16 17 18 |
if ($('#isPublic').val()) {
// force the preview to adjust its height
$('#preview').append($iframe).css({height: '100%'});
|
|
6d9380f96
|
19 20 21 22 23 24 |
$('body').css({height: '100%'});
$('footer').addClass('hidden');
$('#imgframe').addClass('hidden');
$('.directLink').addClass('hidden');
$('.directDownload').addClass('hidden');
$('#controls').addClass('hidden');
|
|
d1bafeea1
|
25 |
} else {
|
|
6d9380f96
|
26 27 |
FileList.setViewerMode(true);
$('#app-content').append($iframe);
|
|
d1bafeea1
|
28 |
} |
|
6d9380f96
|
29 |
|
|
d1bafeea1
|
30 |
$("#pageWidthOption").attr("selected","selected");
|
|
6d9380f96
|
31 32 |
// replace the controls with our own
$('#app-content #controls').addClass('hidden');
|
|
d1bafeea1
|
33 34 35 36 37 38 39 |
$('#pdfbar').css({position:'absolute',top:'6px',right:'5px'});
// if a filelist is present, the PDF viewer can be closed to go back there
if ($('#fileList').length) {
$('#close').css({display:'block',padding:'0 5px',color:'#BBBBBB','font-weight':'900','font-size':'16px',height:'18px',background:'transparent'}).click(function(){
hidePDFviewer();
});
} else {
|
|
6d9380f96
|
40 |
$('#close').addClass('hidden');
|
|
d1bafeea1
|
41 42 |
} } |
|
d1bafeea1
|
43 44 45 |
} showPDFviewer.oldCode=''; showPDFviewer.lastTitle=''; |
|
6d9380f96
|
46 |
|
|
d1bafeea1
|
47 |
$(document).ready(function(){
|
|
6d9380f96
|
48 49 50 51 52 53 54 55 56 57 58 59 |
// The PDF viewer doesn't work in Internet Explorer 8 and below
if(!$.browser.msie || ($.browser.msie && $.browser.version >= 9)){
var sharingToken = $('#sharingToken').val();
// Logged-in view
if ($('#filesApp').val() && typeof FileActions !=='undefined'){
FileActions.register('application/pdf','Edit', OC.PERMISSION_READ, '',function(filename){
if($('#isPublic').val()) {
showPDFviewer('', encodeURIComponent(sharingToken)+"&files="+encodeURIComponent(filename)+"&path="+encodeURIComponent(FileList.getCurrentDirectory()));
} else {
showPDFviewer(encodeURIComponent(FileList.getCurrentDirectory()), encodeURIComponent(filename));
}
|
|
d1bafeea1
|
60 61 62 |
});
FileActions.setDefault('application/pdf','Edit');
}
|
|
6d9380f96
|
63 64 65 66 67 |
// Public view
if ($('#isPublic').val() && $('#mimetype').val() === 'application/pdf') {
showPDFviewer('', sharingToken);
}
|
|
d1bafeea1
|
68 69 |
} }); |