function hidePDFviewer() {
showPDFviewer.shown = false;
$('table').show();
$('#controls').html(showPDFviewer.oldcode);
$("#viewer").remove();
$("#loading").remove()
$("#editor").show();
document.title = showPDFviewer.lastTitle;
PDFView.active=false;
$('iframe').remove();
}
function showPDFviewer(dir,filename){
if(!showPDFviewer.shown){
$("#editor").hide();
var url = OC.filePath('files','ajax','download.php')+'?files='+encodeURIComponent(filename)+"&dir="+encodeURIComponent(dir);
$('table').hide();
function im(path) { return OC.filePath('files_pdfviewer','js','pdfjs/web/images/'+path); }
showPDFviewer.oldcode = $("#controls").html();
$("#controls").empty();
$("#controls").html('
/----');
var oldcontent = $("#content").html();
$("#content").html(oldcontent+'Loading... 0%
');
showPDFviewer.lastTitle = document.title;
if(!showPDFviewer.loaded){
OC.addScript( 'files_pdfviewer', 'pdfjs/build/pdf',function(){
OC.addScript( 'files_pdfviewer', 'pdfview',function(){
showPDFviewer.loaded=true;
PDFJS.workerSrc = OC.filePath('files_pdfviewer','js','pdfjs/build/pdf.js');
PDFView.Ptitle = filename;
PDFView.open(url,1.00);
PDFView.active=true;
});
});
}else{
PDFView.Ptitle = filename;
PDFView.open(url,1.00);
PDFView.active=true;
}
$("#pageWidthOption").attr("selected","selected");
showPDFviewer.shown = true;
}
}
showPDFviewer.shown=false;
showPDFviewer.oldCode='';
showPDFviewer.lastTitle='';
showPDFviewer.loaded=false;
$(document).ready(function(){
if(!$.browser.msie){//doesnt work on IE
if(location.href.indexOf("files")!=-1) {
PDFJS.workerSrc = OC.filePath('files_pdfviewer','js','pdfjs/build/pdf.js');
if(typeof FileActions!=='undefined'){
FileActions.register('application/pdf','Edit','',function(filename){
showPDFviewer($('#dir').val(),filename);
});
FileActions.setDefault('application/pdf','Edit');
}
}
}
});