From 5bff1c8ad1708cff4a61ef28a62901efc617ef01 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 27 Dec 2011 14:18:03 +0100 Subject: [PATCH] some coding style fixes for the pdf viewer --- apps/files_pdfviewer/js/viewer.js | 57 +++++++++++++------------------ 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/apps/files_pdfviewer/js/viewer.js b/apps/files_pdfviewer/js/viewer.js index 94aae4e5ac2..314a08b27e6 100755 --- a/apps/files_pdfviewer/js/viewer.js +++ b/apps/files_pdfviewer/js/viewer.js @@ -1,55 +1,46 @@ -viewer_is_shown = false; function hidePDFviewer() { - viewer_is_shown = false; - $('table').show(); - $('#controls').html(oldcode); - $("#viewer").remove(); - $("#loading").remove() - document.title = lastTitle; + showPDFviewer.shown = false; + $('table').show(); + $('#controls').html(showPDFviewer.oldcode); + $("#viewer").remove(); + $("#loading").remove() + document.title = showPDFviewer.lastTitle; } + function showPDFviewer(dir,filename){ - if(!viewer_is_shown){ + 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); } - oldcode = $("#controls").html(); + showPDFviewer.oldcode = $("#controls").html(); $("#controls").empty(); $("#controls").html('
/--
--'); - oldcontent = $("#content").html(); - $("#content").html(oldcontent+'
Loading... 0%
'); - lastTitle = document.title; + var oldcontent = $("#content").html(); + $("#content").html(oldcontent+'
Loading... 0%
'); + showPDFviewer.lastTitle = document.title; PDFView.Ptitle = filename; PDFView.open(url,1.00); $("#pageWidthOption").attr("selected","selected"); - $("header").css({zIndex:0}); - viewer_is_shown = true; + showPDFviewer.shown = true; } } +showPDFviewer.shown=false; +showPDFviewer.oldCode=''; +showPDFviewer.lastTitle=''; 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); - }); + 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'); + } } - } }); -- 2.39.5