viewer_is_shown = false; function hidePDFviewer() { viewer_is_shown = false; $('table').show(); $('#controls').html(oldcode); $("#viewer").remove(); $("#loading").remove() $("#controls").css({top:"3.5em",height:"2.8em",zIndex:200}); document.title = lastTitle; } function showPDFviewer(dir,filename){ if(!viewer_is_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); } oldcode = $("#controls").html(); $("#controls").empty(); $("#controls").html('  
/ --
--
'); oldcontent = $("#content").html(); $("#content").html(oldcontent+'
Loading... 0%
'); $("#controls").css({top:"0px",height:"3.5em",zIndex:200}); lastTitle = document.title; PDFView.Ptitle = filename; PDFView.open(url,1.00); $("#pageWidthOption").attr("selected","selected"); $("header").css({zIndex:0}); viewer_is_shown = true; } } var extrahtml = ''; $(document).ready(function(){ 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'); } OC.search.customResults.Text=function(row,item){ var text=item.link.substr(item.link.indexOf('file=')+5); var a=row.find('a'); a.data('file',text); a.attr('href','#'); a.click(function(){ var file=text.split('/').pop(); var dir=text.substr(0,text.length-file.length-1); showFileEditor(dir,file); }); } } });