<?php
//load the required files
-//OC_Util::addStyle( 'files_texteditor', 'style' );
-//OC_Util::addScript( 'files_texteditor', 'editor');
OC_Util::addScript( 'files_pdfviewer', 'viewer');
OC_Util::addStyle( 'files_pdfviewer', 'viewer');
OC_Util::addScript( 'files_pdfviewer', 'pdfjs/build/pdf');
var currentPageNumber = 1;
var PDFView = {
+ active: false,
pages: [],
thumbnails: [],
currentScale: kDefaultScale,
navigateTo: function pdfViewNavigateTo(dest) {
if (typeof dest === 'string')
+ if(!this.destinations || ! this.destinations[dest]){
+ return; // invalid destination
+ }
dest = this.destinations[dest];
if (!(dest instanceof Array))
return; // invalid destination
}
window.addEventListener('scroll', function webViewerScroll(evt) {
+ if(!PDFView.active){
+ return;
+ }
updateViewarea();
}, true);
window.addEventListener('resize', function webViewerResize(evt) {
+ if(!PDFView.active){
+ return;
+ }
if (document.getElementById('pageWidthOption').selected ||
document.getElementById('pageFitOption').selected)
PDFView.parseScale(document.getElementById('scaleSelect').value);
});
window.addEventListener('hashchange', function webViewerHashchange(evt) {
+ if(!PDFView.active){
+ return;
+ }
PDFView.setHash(document.location.hash.substring(1));
});
window.addEventListener('change', function webViewerChange(evt) {
+ if(!PDFView.active){
+ return;
+ }
var files = evt.target.files;
if (!files || files.length == 0)
return;
}, true);
window.addEventListener('scalechange', function scalechange(evt) {
+ if(!PDFView.active){
+ return;
+ }
var customScaleOption = document.getElementById('customScaleOption');
customScaleOption.selected = false;
}, true);
window.addEventListener('pagechange', function pagechange(evt) {
+ if(!PDFView.active){
+ return;
+ }
var page = evt.pageNumber;
if (document.getElementById('pageNumber').value != page)
document.getElementById('pageNumber').value = page;
}, true);
window.addEventListener('keydown', function keydown(evt) {
+ if(!PDFView.active){
+ return;
+ }
var curElement = document.activeElement;
var controlsElement = document.getElementById('controls2');
while (curElement) {
$("#viewer").remove();
$("#loading").remove()
document.title = showPDFviewer.lastTitle;
+ PDFView.active=false;
}
function showPDFviewer(dir,filename){
var oldcontent = $("#content").html();
$("#content").html(oldcontent+'<div id="loading">Loading... 0%</div><div id="viewer"></div>');
showPDFviewer.lastTitle = document.title;
- PDFView.Ptitle = filename;
- PDFView.open(url,1.00);
+ 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='';
-
-var extrahtml = '<li id="extra" style="display:none;"><a title="" href="'+OC.webroot+"/apps/files_pdfviewer/lastopened.php"+'" style="background-image:url(/owncloud/apps/files_pdfviewer/css/history.png)">Last opened</a></li>';
+showPDFviewer.loaded=false;
$(document).ready(function(){
if(location.href.indexOf("files")!=-1) {