Skip to content

Commit

Permalink
Refactors PDFHistory.
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik committed Apr 18, 2015
1 parent b2a57c9 commit 0cb074d
Show file tree
Hide file tree
Showing 5 changed files with 366 additions and 316 deletions.
16 changes: 15 additions & 1 deletion extensions/b2g/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var MAX_SCALE = 10.0;
var PDFViewerApplication = {
pdfDocument: null,
pdfViewer: null,
pdfHistory: null,
pdfLinkService: null,
loading: true,
updateScaleControls: false,

Expand All @@ -44,6 +46,8 @@ var PDFViewerApplication = {
// Document loaded, specifying document for the viewer.
this.pdfDocument = pdfDocument;
this.pdfViewer.setDocument(pdfDocument);
this.pdfLinkService.setDocument(pdfDocument);
this.pdfHistory.initialize(pdfDocument.fingerprint);
}.bind(this));
},

Expand Down Expand Up @@ -103,11 +107,21 @@ var PDFViewerApplication = {
},

initUI: function pdfViewInitUI() {
var linkService = new PDFJS.PDFLinkService();
this.pdfLinkService = linkService;

var container = document.getElementById('viewerContainer');
var pdfViewer = new PDFJS.PDFViewer({
container: container
container: container,
linkService: linkService
});
this.pdfViewer = pdfViewer;
linkService.setViewer(pdfViewer);

this.pdfHistory = new PDFJS.PDFHistory({
linkService: linkService
});
linkService.setHistory(this.pdfHistory);

container.addEventListener('pagesinit', function () {
// we can use pdfViewer now, e.g. let's change default scale.
Expand Down
11 changes: 11 additions & 0 deletions web/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ IPDFLinkService.prototype = {
cachePageRef: function (pageNum, pageRef) {},
};

/**
* @interface
*/
function IPDFHistory() {}
IPDFHistory.prototype = {
forward: function () {},
back: function () {},
push: function (params) {},
updateNextHashParam: function (hash) {},
};

/**
* @interface
*/
Expand Down
Loading

0 comments on commit 0cb074d

Please sign in to comment.