all files / pdfviewer/navigation/ page-navigation.js

34.21% Statements 13/38
0% Branches 0/15
20% Functions 2/10
34.21% Lines 13/38
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                                                                                      
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Navigation = (function () {
        function Navigation(viewer, viewerBase) {
            this.pdfViewer = viewer;
            this.pdfViewerBase = viewerBase;
        }
        Navigation.prototype.goToNextPage = function () {
            this.pageNumber = this.pdfViewerBase.currentPageNumber;
            this.pageNumber++;
            if (this.pageNumber <= this.pdfViewerBase.pageCount) {
                this.pdfViewerBase.updateScrollTop(this.pageNumber - 1);
            }
        };
        Navigation.prototype.goToPreviousPage = function () {
            this.pageNumber = this.pdfViewerBase.currentPageNumber;
            this.pageNumber--;
            if (this.pageNumber > 0) {
                this.pdfViewerBase.updateScrollTop(this.pageNumber - 1);
            }
        };
        Navigation.prototype.goToPage = function (pageNumber) {
            if (pageNumber > 0 && pageNumber <= this.pdfViewerBase.pageCount && this.pdfViewerBase.currentPageNumber !== pageNumber) {
                this.pdfViewerBase.updateScrollTop(pageNumber - 1);
                if (this.pdfViewer.enableThumbnail) {
                    this.pdfViewer.thumbnailViewModule.updateScrollTopForThumbnail(pageNumber - 1);
                }
            }
            if (this.pdfViewer.magnificationModule) {
                this.pdfViewer.magnificationModule.resizeCanvas(pageNumber);
            }
            var textLayer = document.getElementById(this.pdfViewer.element.id + '_textLayer_' + (pageNumber - 1));
            if (textLayer) {
                textLayer.style.display = 'block';
            }
        };
        Navigation.prototype.goToFirstPage = function () {
            this.pageNumber = 0;
            this.pdfViewerBase.updateScrollTop(this.pageNumber);
        };
        Navigation.prototype.goToLastPage = function () {
            this.pageNumber = this.pdfViewerBase.pageCount - 1;
            this.pdfViewerBase.updateScrollTop(this.pageNumber);
        };
        Navigation.prototype.destroy = function () {
            this.pageNumber = 0;
        };
        Navigation.prototype.getModuleName = function () {
            return 'Navigation';
        };
        return Navigation;
    }());
    exports.Navigation = Navigation;
});