1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00
Conflicts:
	pdf.js
This commit is contained in:
notmasteryet 2011-09-28 20:55:06 -05:00
commit 078433fecd
7 changed files with 479 additions and 439 deletions

View file

@ -107,15 +107,18 @@ var PDFView = {
document.title = url;
getPdf({url: url, progress: PDFView.progressLevel}, function(data) {
document.getElementById('loading').style.display = 'none';
PDFView.load(data, scale);
});
},
progressLevel: function(evt) {
var p = Math.round((evt.loaded / evt.total) * 100);
document.getElementById('loading').innerHTML = 'Loading... ' + p + '%';
getPdf(
{
url: url,
progress: function getPdfProgress(evt) {
if (evt.lengthComputable)
PDFView.progress(evt.loaded / evt.total);
},
error: PDFView.error
},
function getPdfLoad(data) {
PDFView.load(data, scale);
});
},
navigateTo: function(dest) {
@ -134,7 +137,21 @@ var PDFView = {
}
},
error: function() {
var loadingIndicator = document.getElementById('loading');
loadingIndicator.innerHTML = 'Error';
},
progress: function(level) {
var percent = Math.round(level * 100);
var loadingIndicator = document.getElementById('loading');
loadingIndicator.innerHTML = 'Loading... ' + percent + '%';
},
load: function(data, scale) {
var loadingIndicator = document.getElementById('loading');
loadingIndicator.style.display = 'none';
var sidebar = document.getElementById('sidebarView');
sidebar.parentNode.scrollTop = 0;
@ -482,10 +499,18 @@ window.addEventListener('load', function(evt) {
document.getElementById('fileInput').value = null;
}, true);
window.addEventListener('pdfloaded', function(evt) {
window.addEventListener('pdfload', function(evt) {
PDFView.load(evt.detail);
}, true);
window.addEventListener('pdfprogress', function(evt) {
PDFView.progress(evt.detail);
}, true);
window.addEventListener('pdferror', function(evt) {
PDFView.error();
}, true);
function updateViewarea() {
var visiblePages = PDFView.getVisiblePages();
for (var i = 0; i < visiblePages.length; i++) {