loader.js
1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function hidePDFviewer() {
$('#content table').show();
$("#controls").show();
$("#editor").show();
$('#pdframe, #pdfbar').remove();
if ($('#isPublic').val()){
$('#preview').css({height: null});
}
}
function showPDFviewer(dir,filename){
if(!showPDFviewer.shown){
var $iframe;
$("#editor").hide();
$('#content table').hide();
$("#controls").hide();
var oldcontent = $("#content").html();
var viewer = OC.linkTo('files_pdfviewer', 'viewer.php')+'?dir='+encodeURIComponent(dir).replace(/%2F/g, '/')+'&file='+encodeURIComponent(filename.replace('&', '%26'));
$iframe = $('<iframe id="pdframe" style="width:100%;height:100%;display:block;" src="'+viewer+'" /><div id="pdfbar"><a id="close" title="Close">X</a></div>');
if ($('#isPublic').val()){
// force the preview to adjust its height
$('#preview').append($iframe).css({height: '100%'});
}
else{
$('#content').append($iframe);
}
$("#pageWidthOption").attr("selected","selected");
$('#pdfbar').css({position:'absolute',top:'5px',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',height:'18px',background:'transparent'}).click(function(){
hidePDFviewer();
});
}
else{
$('#close').css({display:'none'});
}
}
}
showPDFviewer.oldCode='';
showPDFviewer.lastTitle='';
$(document).ready(function(){
// doesn't work in IE or public link mode
if(!$.browser.msie && !$('#isPublic').val()){
if ($('#filesApp').val() && typeof FileActions!=='undefined'){
FileActions.register('application/pdf','Edit', OC.PERMISSION_READ, '',function(filename){
showPDFviewer($('#dir').val(),filename);
});
FileActions.setDefault('application/pdf','Edit');
}
}
});