2011-12-27 15:36:51 +04:00
|
|
|
function hidePDFviewer() {
|
2011-12-27 17:18:03 +04:00
|
|
|
showPDFviewer.shown = false;
|
|
|
|
$('table').show();
|
|
|
|
$('#controls').html(showPDFviewer.oldcode);
|
|
|
|
$("#viewer").remove();
|
|
|
|
$("#loading").remove()
|
2012-01-15 01:25:07 +04:00
|
|
|
$("#editor").show();
|
2011-12-27 17:18:03 +04:00
|
|
|
document.title = showPDFviewer.lastTitle;
|
2012-01-15 00:38:33 +04:00
|
|
|
PDFView.active=false;
|
2012-01-15 01:25:07 +04:00
|
|
|
$('iframe').remove();
|
2011-12-27 15:36:51 +04:00
|
|
|
}
|
2011-12-27 17:18:03 +04:00
|
|
|
|
2011-12-27 15:36:51 +04:00
|
|
|
function showPDFviewer(dir,filename){
|
2011-12-27 17:18:03 +04:00
|
|
|
if(!showPDFviewer.shown){
|
2011-12-27 17:09:22 +04:00
|
|
|
$("#editor").hide();
|
2012-06-16 21:48:33 +04:00
|
|
|
var url = OC.filePath('files','ajax','download.php')+encodeURIComponent('?files='+encodeURIComponent(filename)+"&dir="+encodeURIComponent(dir));
|
2011-12-27 17:09:22 +04:00
|
|
|
$('table').hide();
|
|
|
|
function im(path) { return OC.filePath('files_pdfviewer','js','pdfjs/web/images/'+path); }
|
2011-12-27 17:18:03 +04:00
|
|
|
showPDFviewer.oldcode = $("#controls").html();
|
2011-12-27 17:09:22 +04:00
|
|
|
$("#controls").empty();
|
|
|
|
$("#controls").html('<button id="previous" onclick="PDFView.page--;" oncontextmenu="return false;"><img src="'+im('go-up.svg')+'" align="top" height="10"/>Previous</button><button id="next" onclick="PDFView.page++;" oncontextmenu="return false;"><img src="'+im('go-down.svg')+'" align="top" height="10"/>Next</button><div class="separator"></div><input style="width:25px;" type="number" id="pageNumber" onchange="PDFView.page = this.value;" value="1" size="4" min="1" /><span>/</span><span id="numPages">--</span><div class="separator"></div><button id="zoomOut" title="Zoom Out" onclick="PDFView.zoomOut();" oncontextmenu="return false;"><img src="'+im('zoom-out.svg')+'" align="top" height="10"/></button><button id="zoomIn" title="Zoom In" onclick="PDFView.zoomIn();" oncontextmenu="return false;"><img src="'+im('zoom-in.svg')+
|
|
|
|
'" align="top" height="10"/></button><div class="separator"></div><select id="scaleSelect" onchange="PDFView.parseScale(this.value);" oncontextmenu="return false;"><option id="customScaleOption" value="custom"></option><option value="0.5">50%</option><option value="0.75">75%</option><option value="1">100%</option><option value="1.25" selected="selected">125%</option><option value="1.5">150%</option><option value="2">200%</option><option id="pageWidthOption" value="page-width">Page Width</option><option id="pageFitOption" value="page-fit">Page Fit</option></select><div class="separator"></div><button id="print" onclick="window.print();" oncontextmenu="return false;"><img src="'+im('document-print.svg')+'" align="top" height="10"/>Print</button><button id="download" title="Download" onclick="PDFView.download();" oncontextmenu="return false;">'+
|
|
|
|
'<img src="'+im('download.svg')+'" align="top" height="10"/>Download</button><button id="close" title="Close viewer" onclick="hidePDFviewer();" oncontextmenu="return false;">x</button><span id="info">--</span></div>');
|
2011-12-27 17:18:03 +04:00
|
|
|
var oldcontent = $("#content").html();
|
|
|
|
$("#content").html(oldcontent+'<div id="loading">Loading... 0%</div><div id="viewer"></div>');
|
|
|
|
showPDFviewer.lastTitle = document.title;
|
2012-06-12 02:49:40 +04:00
|
|
|
PDFView.Ptitle = filename;
|
|
|
|
PDFView.open(url,1.00);
|
|
|
|
PDFView.active=true;
|
2011-12-27 17:09:22 +04:00
|
|
|
$("#pageWidthOption").attr("selected","selected");
|
2011-12-27 17:18:03 +04:00
|
|
|
showPDFviewer.shown = true;
|
2011-12-27 15:36:51 +04:00
|
|
|
}
|
|
|
|
}
|
2011-12-27 17:18:03 +04:00
|
|
|
showPDFviewer.shown=false;
|
|
|
|
showPDFviewer.oldCode='';
|
|
|
|
showPDFviewer.lastTitle='';
|
2011-12-27 15:36:51 +04:00
|
|
|
|
|
|
|
$(document).ready(function(){
|
2012-02-08 19:28:59 +04:00
|
|
|
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');
|
|
|
|
}
|
2011-12-27 17:18:03 +04:00
|
|
|
}
|
2011-12-27 15:36:51 +04:00
|
|
|
}
|
|
|
|
});
|