Browse Source

PDF.js version 1.8.316 - See mozilla/pdf.js@b0a796ced30d5295cffe468bdf6b0d287c0b1e5a

master v1.8.316
pdfjsbot 8 years ago
parent
commit
9c9a11bba3
  1. 2
      bower.json
  2. 12
      build/pdf.combined.js
  3. 12
      build/pdf.js
  4. 4
      build/pdf.min.js
  5. 4
      build/pdf.worker.js
  6. 4
      lib/display/api.js
  7. 4
      lib/display/global.js
  8. 4
      lib/pdf.js
  9. 4
      lib/pdf.worker.js
  10. 40
      lib/web/app.js
  11. 6
      lib/web/debugger.js
  12. 15
      lib/web/firefoxcom.js
  13. 12
      lib/web/hand_tool.js
  14. 70
      lib/web/overlay_manager.js
  15. 16
      lib/web/pdf_attachment_viewer.js
  16. 12
      lib/web/pdf_find_controller.js
  17. 22
      lib/web/pdf_print_service.js
  18. 20
      lib/web/pdf_thumbnail_viewer.js
  19. 15
      lib/web/pdf_viewer.js
  20. 25
      lib/web/secondary_toolbar.js
  21. 10
      lib/web/text_layer_builder.js
  22. 2
      package.json
  23. 37
      web/pdf_viewer.js

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.8.314", "version": "1.8.316",
"main": [ "main": [
"build/pdf.js", "build/pdf.js",
"build/pdf.worker.js" "build/pdf.worker.js"

12
build/pdf.combined.js

@ -12773,8 +12773,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.314'; exports.version = version = '1.8.316';
exports.build = build = '3adda80f'; exports.build = build = 'b0a796ce';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;
@ -28178,8 +28178,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.314'; PDFJS.version = '1.8.316';
PDFJS.build = '3adda80f'; PDFJS.build = 'b0a796ce';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
@ -43765,8 +43765,8 @@ exports.TilingPattern = TilingPattern;
"use strict"; "use strict";
var pdfjsVersion = '1.8.314'; var pdfjsVersion = '1.8.316';
var pdfjsBuild = '3adda80f'; var pdfjsBuild = 'b0a796ce';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(26); var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
var pdfjsDisplayAPI = __w_pdfjs_require__(10); var pdfjsDisplayAPI = __w_pdfjs_require__(10);

12
build/pdf.js

@ -3480,8 +3480,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.314'; exports.version = version = '1.8.316';
exports.build = build = '3adda80f'; exports.build = build = 'b0a796ce';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;
@ -5453,8 +5453,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.314'; PDFJS.version = '1.8.316';
PDFJS.build = '3adda80f'; PDFJS.build = 'b0a796ce';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
@ -7949,8 +7949,8 @@ exports.TilingPattern = TilingPattern;
"use strict"; "use strict";
var pdfjsVersion = '1.8.314'; var pdfjsVersion = '1.8.316';
var pdfjsBuild = '3adda80f'; var pdfjsBuild = 'b0a796ce';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(9); var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
var pdfjsDisplayAPI = __w_pdfjs_require__(3); var pdfjsDisplayAPI = __w_pdfjs_require__(3);

4
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

4
build/pdf.worker.js vendored

@ -37131,8 +37131,8 @@ exports.Type1Parser = Type1Parser;
"use strict"; "use strict";
var pdfjsVersion = '1.8.314'; var pdfjsVersion = '1.8.316';
var pdfjsBuild = '3adda80f'; var pdfjsBuild = 'b0a796ce';
var pdfjsCoreWorker = __w_pdfjs_require__(8); var pdfjsCoreWorker = __w_pdfjs_require__(8);
{ {
__w_pdfjs_require__(19); __w_pdfjs_require__(19);

4
lib/display/api.js

@ -1405,8 +1405,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.314'; exports.version = version = '1.8.316';
exports.build = build = '3adda80f'; exports.build = build = 'b0a796ce';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;

4
lib/display/global.js

@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.314'; PDFJS.version = '1.8.316';
PDFJS.build = '3adda80f'; PDFJS.build = 'b0a796ce';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {

4
lib/pdf.js

@ -14,8 +14,8 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '1.8.314'; var pdfjsVersion = '1.8.316';
var pdfjsBuild = '3adda80f'; var pdfjsBuild = 'b0a796ce';
var pdfjsSharedUtil = require('./shared/util.js'); var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js'); var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js'); var pdfjsDisplayAPI = require('./display/api.js');

4
lib/pdf.worker.js vendored

@ -14,8 +14,8 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '1.8.314'; var pdfjsVersion = '1.8.316';
var pdfjsBuild = '3adda80f'; var pdfjsBuild = 'b0a796ce';
var pdfjsCoreWorker = require('./core/worker.js'); var pdfjsCoreWorker = require('./core/worker.js');
{ {
require('./core/network.js'); require('./core/network.js');

40
lib/web/app.js

@ -561,6 +561,8 @@ var PDFViewerApplication = {
errorMoreInfo.value = moreInfoText; errorMoreInfo.value = moreInfoText;
}, },
progress: function pdfViewProgress(level) { progress: function pdfViewProgress(level) {
var _this4 = this;
var percent = Math.round(level * 100); var percent = Math.round(level * 100);
if (percent > this.loadingBar.percent || isNaN(percent)) { if (percent > this.loadingBar.percent || isNaN(percent)) {
this.loadingBar.percent = percent; this.loadingBar.percent = percent;
@ -571,14 +573,14 @@ var PDFViewerApplication = {
} }
this.loadingBar.show(); this.loadingBar.show();
this.disableAutoFetchLoadingBarTimeout = setTimeout(function () { this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
this.loadingBar.hide(); _this4.loadingBar.hide();
this.disableAutoFetchLoadingBarTimeout = null; _this4.disableAutoFetchLoadingBarTimeout = null;
}.bind(this), DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT); }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
} }
} }
}, },
load: function pdfViewLoad(pdfDocument, scale) { load: function pdfViewLoad(pdfDocument, scale) {
var _this4 = this; var _this5 = this;
var self = this; var self = this;
scale = scale || _ui_utils.UNKNOWN_SCALE; scale = scale || _ui_utils.UNKNOWN_SCALE;
@ -621,14 +623,14 @@ var PDFViewerApplication = {
} }
} }
var initialParams = { var initialParams = {
destination: _this4.initialDestination, destination: _this5.initialDestination,
bookmark: _this4.initialBookmark, bookmark: _this5.initialBookmark,
hash: null hash: null
}; };
var storedHash = _this4.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this4.viewerPrefs['defaultZoomValue'] : null; var storedHash = _this5.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this5.viewerPrefs['defaultZoomValue'] : null;
var sidebarView = _this4.viewerPrefs['sidebarViewOnLoad']; var sidebarView = _this5.viewerPrefs['sidebarViewOnLoad'];
new Promise(function (resolve, reject) { new Promise(function (resolve, reject) {
if (!_this4.viewerPrefs['showPreviousViewOnLoad']) { if (!_this5.viewerPrefs['showPreviousViewOnLoad']) {
resolve(); resolve();
return; return;
} }
@ -644,33 +646,33 @@ var PDFViewerApplication = {
resolve(); resolve();
return; return;
} }
storedHash = 'page=' + values.page + '&zoom=' + (_this4.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop; storedHash = 'page=' + values.page + '&zoom=' + (_this5.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
sidebarView = _this4.viewerPrefs['sidebarViewOnLoad'] || values.sidebarView | 0; sidebarView = _this5.viewerPrefs['sidebarViewOnLoad'] || values.sidebarView | 0;
resolve(); resolve();
}).catch(function () { }).catch(function () {
resolve(); resolve();
}); });
}).then(function () { }).then(function () {
_this4.setInitialView(storedHash, { _this5.setInitialView(storedHash, {
sidebarView: sidebarView, sidebarView: sidebarView,
scale: scale scale: scale
}); });
initialParams.hash = storedHash; initialParams.hash = storedHash;
if (!_this4.isViewerEmbedded) { if (!_this5.isViewerEmbedded) {
_this4.pdfViewer.focus(); _this5.pdfViewer.focus();
} }
return pagesPromise; return pagesPromise;
}).then(function () { }).then(function () {
if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) { if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) {
return; return;
} }
if (_this4.hasEqualPageSizes) { if (_this5.hasEqualPageSizes) {
return; return;
} }
_this4.initialDestination = initialParams.destination; _this5.initialDestination = initialParams.destination;
_this4.initialBookmark = initialParams.bookmark; _this5.initialBookmark = initialParams.bookmark;
_this4.pdfViewer.currentScaleValue = _this4.pdfViewer.currentScaleValue; _this5.pdfViewer.currentScaleValue = _this5.pdfViewer.currentScaleValue;
_this4.setInitialView(initialParams.hash); _this5.setInitialView(initialParams.hash);
}); });
}); });
pdfDocument.getPageLabels().then(function (labels) { pdfDocument.getPageLabels().then(function (labels) {

6
lib/web/debugger.js

@ -90,6 +90,8 @@ var FontInspector = function FontInspectorClosure() {
} }
}, },
fontAdded: function fontAdded(fontObj, url) { fontAdded: function fontAdded(fontObj, url) {
var _this = this;
function properties(obj, list) { function properties(obj, list) {
var moreInfo = document.createElement('table'); var moreInfo = document.createElement('table');
for (var i = 0; i < list.length; i++) { for (var i = 0; i < list.length; i++) {
@ -142,10 +144,10 @@ var FontInspector = function FontInspectorClosure() {
font.appendChild(moreInfo); font.appendChild(moreInfo);
fonts.appendChild(font); fonts.appendChild(font);
setTimeout(function () { setTimeout(function () {
if (this.active) { if (_this.active) {
resetSelection(); resetSelection();
} }
}.bind(this), 2000); }, 2000);
} }
}; };
}(); }();

15
lib/web/firefoxcom.js

@ -96,17 +96,20 @@ var DownloadManager = function DownloadManagerClosure() {
}); });
}, },
download: function DownloadManager_download(blob, url, filename) { download: function DownloadManager_download(blob, url, filename) {
var _this = this;
var blobUrl = window.URL.createObjectURL(blob); var blobUrl = window.URL.createObjectURL(blob);
var onResponse = function onResponse(err) {
if (err && _this.onerror) {
_this.onerror(err);
}
window.URL.revokeObjectURL(blobUrl);
};
FirefoxCom.request('download', { FirefoxCom.request('download', {
blobUrl: blobUrl, blobUrl: blobUrl,
originalUrl: url, originalUrl: url,
filename: filename filename: filename
}, function response(err) { }, onResponse);
if (err && this.onerror) {
this.onerror(err);
}
window.URL.revokeObjectURL(blobUrl);
}.bind(this));
} }
}; };
return DownloadManager; return DownloadManager;

12
lib/web/hand_tool.js

@ -43,16 +43,16 @@ var HandTool = function HandToolClosure() {
_this.handTool.activate(); _this.handTool.activate();
} }
}).catch(function rejected(reason) {}); }).catch(function rejected(reason) {});
this.eventBus.on('presentationmodechanged', function (e) { this.eventBus.on('presentationmodechanged', function (evt) {
if (e.switchInProgress) { if (evt.switchInProgress) {
return; return;
} }
if (e.active) { if (evt.active) {
this.enterPresentationMode(); _this.enterPresentationMode();
} else { } else {
this.exitPresentationMode(); _this.exitPresentationMode();
} }
}.bind(this)); });
} }
HandTool.prototype = { HandTool.prototype = {
get isActive() { get isActive() {

70
lib/web/overlay_manager.js

@ -20,78 +20,86 @@ Object.defineProperty(exports, "__esModule", {
var OverlayManager = { var OverlayManager = {
overlays: {}, overlays: {},
active: null, active: null,
register: function overlayManagerRegister(name, element, callerCloseMethod, canForceClose) { register: function register(name, element, callerCloseMethod, canForceClose) {
var _this = this;
return new Promise(function (resolve) { return new Promise(function (resolve) {
var container; var container;
if (!name || !element || !(container = element.parentNode)) { if (!name || !element || !(container = element.parentNode)) {
throw new Error('Not enough parameters.'); throw new Error('Not enough parameters.');
} else if (this.overlays[name]) { } else if (_this.overlays[name]) {
throw new Error('The overlay is already registered.'); throw new Error('The overlay is already registered.');
} }
this.overlays[name] = { _this.overlays[name] = {
element: element, element: element,
container: container, container: container,
callerCloseMethod: callerCloseMethod || null, callerCloseMethod: callerCloseMethod || null,
canForceClose: canForceClose || false canForceClose: canForceClose || false
}; };
resolve(); resolve();
}.bind(this)); });
}, },
unregister: function overlayManagerUnregister(name) { unregister: function unregister(name) {
var _this2 = this;
return new Promise(function (resolve) { return new Promise(function (resolve) {
if (!this.overlays[name]) { if (!_this2.overlays[name]) {
throw new Error('The overlay does not exist.'); throw new Error('The overlay does not exist.');
} else if (this.active === name) { } else if (_this2.active === name) {
throw new Error('The overlay cannot be removed while it is active.'); throw new Error('The overlay cannot be removed while it is active.');
} }
delete this.overlays[name]; delete _this2.overlays[name];
resolve(); resolve();
}.bind(this)); });
}, },
open: function overlayManagerOpen(name) { open: function open(name) {
var _this3 = this;
return new Promise(function (resolve) { return new Promise(function (resolve) {
if (!this.overlays[name]) { if (!_this3.overlays[name]) {
throw new Error('The overlay does not exist.'); throw new Error('The overlay does not exist.');
} else if (this.active) { } else if (_this3.active) {
if (this.overlays[name].canForceClose) { if (_this3.overlays[name].canForceClose) {
this._closeThroughCaller(); _this3._closeThroughCaller();
} else if (this.active === name) { } else if (_this3.active === name) {
throw new Error('The overlay is already active.'); throw new Error('The overlay is already active.');
} else { } else {
throw new Error('Another overlay is currently active.'); throw new Error('Another overlay is currently active.');
} }
} }
this.active = name; _this3.active = name;
this.overlays[this.active].element.classList.remove('hidden'); _this3.overlays[_this3.active].element.classList.remove('hidden');
this.overlays[this.active].container.classList.remove('hidden'); _this3.overlays[_this3.active].container.classList.remove('hidden');
window.addEventListener('keydown', this._keyDown); window.addEventListener('keydown', _this3._keyDown);
resolve(); resolve();
}.bind(this)); });
}, },
close: function overlayManagerClose(name) { close: function close(name) {
var _this4 = this;
return new Promise(function (resolve) { return new Promise(function (resolve) {
if (!this.overlays[name]) { if (!_this4.overlays[name]) {
throw new Error('The overlay does not exist.'); throw new Error('The overlay does not exist.');
} else if (!this.active) { } else if (!_this4.active) {
throw new Error('The overlay is currently not active.'); throw new Error('The overlay is currently not active.');
} else if (this.active !== name) { } else if (_this4.active !== name) {
throw new Error('Another overlay is currently active.'); throw new Error('Another overlay is currently active.');
} }
this.overlays[this.active].container.classList.add('hidden'); _this4.overlays[_this4.active].container.classList.add('hidden');
this.overlays[this.active].element.classList.add('hidden'); _this4.overlays[_this4.active].element.classList.add('hidden');
this.active = null; _this4.active = null;
window.removeEventListener('keydown', this._keyDown); window.removeEventListener('keydown', _this4._keyDown);
resolve(); resolve();
}.bind(this)); });
}, },
_keyDown: function overlayManager_keyDown(evt) { _keyDown: function _keyDown(evt) {
var self = OverlayManager; var self = OverlayManager;
if (self.active && evt.keyCode === 27) { if (self.active && evt.keyCode === 27) {
self._closeThroughCaller(); self._closeThroughCaller();
evt.preventDefault(); evt.preventDefault();
} }
}, },
_closeThroughCaller: function overlayManager_closeThroughCaller() { _closeThroughCaller: function _closeThroughCaller() {
if (this.overlays[this.active].callerCloseMethod) { if (this.overlays[this.active].callerCloseMethod) {
this.overlays[this.active].callerCloseMethod(); this.overlays[this.active].callerCloseMethod();
} }

16
lib/web/pdf_attachment_viewer.js

@ -123,9 +123,15 @@ var PDFAttachmentViewer = function () {
} }
}, { }, {
key: '_appendAttachment', key: '_appendAttachment',
value: function _appendAttachment(item) { value: function _appendAttachment(_ref) {
this._renderedCapability.promise.then(function (id, filename, content) { var _this2 = this;
var attachments = this.attachments;
var id = _ref.id,
filename = _ref.filename,
content = _ref.content;
this._renderedCapability.promise.then(function () {
var attachments = _this2.attachments;
if (!attachments) { if (!attachments) {
attachments = Object.create(null); attachments = Object.create(null);
} else { } else {
@ -139,11 +145,11 @@ var PDFAttachmentViewer = function () {
filename: filename, filename: filename,
content: content content: content
}; };
this.render({ _this2.render({
attachments: attachments, attachments: attachments,
keepRenderedCapability: true keepRenderedCapability: true
}); });
}.bind(this, item.id, item.filename, item.content)); });
} }
}]); }]);

12
lib/web/pdf_find_controller.js

@ -220,20 +220,22 @@ var PDFFindController = function PDFFindControllerClosure() {
extractPageText(0); extractPageText(0);
}, },
executeCommand: function PDFFindController_executeCommand(cmd, state) { executeCommand: function PDFFindController_executeCommand(cmd, state) {
var _this2 = this;
if (this.state === null || cmd !== 'findagain') { if (this.state === null || cmd !== 'findagain') {
this.dirtyMatch = true; this.dirtyMatch = true;
} }
this.state = state; this.state = state;
this.updateUIState(FindStates.FIND_PENDING); this.updateUIState(FindStates.FIND_PENDING);
this._firstPagePromise.then(function () { this._firstPagePromise.then(function () {
this.extractText(); _this2.extractText();
clearTimeout(this.findTimeout); clearTimeout(_this2.findTimeout);
if (cmd === 'find') { if (cmd === 'find') {
this.findTimeout = setTimeout(this.nextMatch.bind(this), 250); _this2.findTimeout = setTimeout(_this2.nextMatch.bind(_this2), 250);
} else { } else {
this.nextMatch(); _this2.nextMatch();
} }
}.bind(this)); });
}, },
updatePage: function PDFFindController_updatePage(index) { updatePage: function PDFFindController_updatePage(index) {
if (this.selected.pageIdx === index) { if (this.selected.pageIdx === index) {

22
lib/web/pdf_print_service.js

@ -99,20 +99,22 @@ PDFPrintService.prototype = {
}); });
}, },
renderPages: function renderPages() { renderPages: function renderPages() {
var _this = this;
var pageCount = this.pagesOverview.length; var pageCount = this.pagesOverview.length;
var renderNextPage = function (resolve, reject) { var renderNextPage = function renderNextPage(resolve, reject) {
this.throwIfInactive(); _this.throwIfInactive();
if (++this.currentPage >= pageCount) { if (++_this.currentPage >= pageCount) {
renderProgress(pageCount, pageCount); renderProgress(pageCount, pageCount);
resolve(); resolve();
return; return;
} }
var index = this.currentPage; var index = _this.currentPage;
renderProgress(index, pageCount); renderProgress(index, pageCount);
renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index]).then(this.useRenderedPage.bind(this)).then(function () { renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
renderNextPage(resolve, reject); renderNextPage(resolve, reject);
}, reject); }, reject);
}.bind(this); };
return new Promise(renderNextPage); return new Promise(renderNextPage);
}, },
useRenderedPage: function useRenderedPage(printItem) { useRenderedPage: function useRenderedPage(printItem) {
@ -137,17 +139,19 @@ PDFPrintService.prototype = {
}); });
}, },
performPrint: function performPrint() { performPrint: function performPrint() {
var _this2 = this;
this.throwIfInactive(); this.throwIfInactive();
return new Promise(function (resolve) { return new Promise(function (resolve) {
setTimeout(function () { setTimeout(function () {
if (!this.active) { if (!_this2.active) {
resolve(); resolve();
return; return;
} }
print.call(window); print.call(window);
setTimeout(resolve, 20); setTimeout(resolve, 20);
}.bind(this), 0); }, 0);
}.bind(this)); });
}, },
get active() { get active() {

20
lib/web/pdf_thumbnail_viewer.js

@ -87,6 +87,8 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
this.container.textContent = ''; this.container.textContent = '';
}, },
setDocument: function PDFThumbnailViewer_setDocument(pdfDocument) { setDocument: function PDFThumbnailViewer_setDocument(pdfDocument) {
var _this = this;
if (this.pdfDocument) { if (this.pdfDocument) {
this._cancelRendering(); this._cancelRendering();
this._resetView(); this._resetView();
@ -100,16 +102,16 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
var viewport = firstPage.getViewport(1.0); var viewport = firstPage.getViewport(1.0);
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) { for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({ var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
container: this.container, container: _this.container,
id: pageNum, id: pageNum,
defaultViewport: viewport.clone(), defaultViewport: viewport.clone(),
linkService: this.linkService, linkService: _this.linkService,
renderingQueue: this.renderingQueue, renderingQueue: _this.renderingQueue,
disableCanvasToImageConversion: false disableCanvasToImageConversion: false
}); });
this.thumbnails.push(thumbnail); _this.thumbnails.push(thumbnail);
} }
}.bind(this)); });
}, },
_cancelRendering: function PDFThumbnailViewer_cancelRendering() { _cancelRendering: function PDFThumbnailViewer_cancelRendering() {
for (var i = 0, ii = this.thumbnails.length; i < ii; i++) { for (var i = 0, ii = this.thumbnails.length; i < ii; i++) {
@ -137,7 +139,7 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
} }
}, },
_ensurePdfPageLoaded: function _ensurePdfPageLoaded(thumbView) { _ensurePdfPageLoaded: function _ensurePdfPageLoaded(thumbView) {
var _this = this; var _this2 = this;
if (thumbView.pdfPage) { if (thumbView.pdfPage) {
return Promise.resolve(thumbView.pdfPage); return Promise.resolve(thumbView.pdfPage);
@ -148,20 +150,20 @@ var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
} }
var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) { var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
thumbView.setPdfPage(pdfPage); thumbView.setPdfPage(pdfPage);
_this._pagesRequests[pageNumber] = null; _this2._pagesRequests[pageNumber] = null;
return pdfPage; return pdfPage;
}); });
this._pagesRequests[pageNumber] = promise; this._pagesRequests[pageNumber] = promise;
return promise; return promise;
}, },
forceRendering: function forceRendering() { forceRendering: function forceRendering() {
var _this2 = this; var _this3 = this;
var visibleThumbs = this._getVisibleThumbs(); var visibleThumbs = this._getVisibleThumbs();
var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this.thumbnails, this.scroll.down); var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this.thumbnails, this.scroll.down);
if (thumbView) { if (thumbView) {
this._ensurePdfPageLoaded(thumbView).then(function () { this._ensurePdfPageLoaded(thumbView).then(function () {
_this2.renderingQueue.renderView(thumbView); _this3.renderingQueue.renderView(thumbView);
}); });
return true; return true;
} }

15
lib/web/pdf_viewer.js

@ -271,17 +271,22 @@ var PDFViewer = function pdfViewer() {
return; return;
} }
var getPagesLeft = pagesCount; var getPagesLeft = pagesCount;
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) { var _loop = function _loop(_pageNum) {
var pageView = this._pages[pageNum - 1]; pdfDocument.getPage(_pageNum).then(function (pdfPage) {
var pageView = _this._pages[_pageNum - 1];
if (!pageView.pdfPage) { if (!pageView.pdfPage) {
pageView.setPdfPage(pdfPage); pageView.setPdfPage(pdfPage);
} }
this.linkService.cachePageRef(pageNum, pdfPage.ref); _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
if (--getPagesLeft === 0) { if (--getPagesLeft === 0) {
pagesCapability.resolve(); pagesCapability.resolve();
} }
}.bind(_this, pageNum)); });
};
for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
_loop(_pageNum);
} }
}); });
_this.eventBus.dispatch('pagesinit', { source: _this }); _this.eventBus.dispatch('pagesinit', { source: _this });

25
lib/web/secondary_toolbar.js

@ -112,19 +112,28 @@ var SecondaryToolbar = function SecondaryToolbarClosure() {
items.pageRotateCcw.disabled = this.pagesCount === 0; items.pageRotateCcw.disabled = this.pagesCount === 0;
}, },
_bindClickListeners: function SecondaryToolbar_bindClickListeners() { _bindClickListeners: function SecondaryToolbar_bindClickListeners() {
var _this = this;
this.toggleButton.addEventListener('click', this.toggle.bind(this)); this.toggleButton.addEventListener('click', this.toggle.bind(this));
for (var button in this.buttons) {
var element = this.buttons[button].element; var _loop = function _loop(button) {
var eventName = this.buttons[button].eventName; var _buttons$button = _this.buttons[button],
var close = this.buttons[button].close; element = _buttons$button.element,
element.addEventListener('click', function (eventName, close) { eventName = _buttons$button.eventName,
close = _buttons$button.close;
element.addEventListener('click', function (evt) {
if (eventName !== null) { if (eventName !== null) {
this.eventBus.dispatch(eventName, { source: this }); _this.eventBus.dispatch(eventName, { source: _this });
} }
if (close) { if (close) {
this.close(); _this.close();
} }
}.bind(this, eventName, close)); });
};
for (var button in this.buttons) {
_loop(button);
} }
}, },
_bindHandToolListener: function SecondaryToolbar_bindHandToolListener(toggleHandToolButton) { _bindHandToolListener: function SecondaryToolbar_bindHandToolListener(toggleHandToolButton) {

10
lib/web/text_layer_builder.js

@ -55,6 +55,8 @@ var TextLayerBuilder = function TextLayerBuilderClosure() {
}); });
}, },
render: function TextLayerBuilder_render(timeout) { render: function TextLayerBuilder_render(timeout) {
var _this = this;
if (!this.textContent || this.renderingDone) { if (!this.textContent || this.renderingDone) {
return; return;
} }
@ -70,10 +72,10 @@ var TextLayerBuilder = function TextLayerBuilderClosure() {
enhanceTextSelection: this.enhanceTextSelection enhanceTextSelection: this.enhanceTextSelection
}); });
this.textLayerRenderTask.promise.then(function () { this.textLayerRenderTask.promise.then(function () {
this.textLayerDiv.appendChild(textLayerFrag); _this.textLayerDiv.appendChild(textLayerFrag);
this._finishRendering(); _this._finishRendering();
this.updateMatches(); _this.updateMatches();
}.bind(this), function (reason) {}); }, function (reason) {});
}, },
cancel: function TextLayerBuilder_cancel() { cancel: function TextLayerBuilder_cancel() {
if (this.textLayerRenderTask) { if (this.textLayerRenderTask) {

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.8.314", "version": "1.8.316",
"main": "build/pdf.js", "main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.", "description": "Generic build of Mozilla's PDF.js library.",
"keywords": [ "keywords": [

37
web/pdf_viewer.js

@ -1632,6 +1632,8 @@ var TextLayerBuilder = function TextLayerBuilderClosure() {
}); });
}, },
render: function TextLayerBuilder_render(timeout) { render: function TextLayerBuilder_render(timeout) {
var _this = this;
if (!this.textContent || this.renderingDone) { if (!this.textContent || this.renderingDone) {
return; return;
} }
@ -1647,10 +1649,10 @@ var TextLayerBuilder = function TextLayerBuilderClosure() {
enhanceTextSelection: this.enhanceTextSelection enhanceTextSelection: this.enhanceTextSelection
}); });
this.textLayerRenderTask.promise.then(function () { this.textLayerRenderTask.promise.then(function () {
this.textLayerDiv.appendChild(textLayerFrag); _this.textLayerDiv.appendChild(textLayerFrag);
this._finishRendering(); _this._finishRendering();
this.updateMatches(); _this.updateMatches();
}.bind(this), function (reason) {}); }, function (reason) {});
}, },
cancel: function TextLayerBuilder_cancel() { cancel: function TextLayerBuilder_cancel() {
if (this.textLayerRenderTask) { if (this.textLayerRenderTask) {
@ -2286,20 +2288,22 @@ var PDFFindController = function PDFFindControllerClosure() {
extractPageText(0); extractPageText(0);
}, },
executeCommand: function PDFFindController_executeCommand(cmd, state) { executeCommand: function PDFFindController_executeCommand(cmd, state) {
var _this2 = this;
if (this.state === null || cmd !== 'findagain') { if (this.state === null || cmd !== 'findagain') {
this.dirtyMatch = true; this.dirtyMatch = true;
} }
this.state = state; this.state = state;
this.updateUIState(FindStates.FIND_PENDING); this.updateUIState(FindStates.FIND_PENDING);
this._firstPagePromise.then(function () { this._firstPagePromise.then(function () {
this.extractText(); _this2.extractText();
clearTimeout(this.findTimeout); clearTimeout(_this2.findTimeout);
if (cmd === 'find') { if (cmd === 'find') {
this.findTimeout = setTimeout(this.nextMatch.bind(this), 250); _this2.findTimeout = setTimeout(_this2.nextMatch.bind(_this2), 250);
} else { } else {
this.nextMatch(); _this2.nextMatch();
} }
}.bind(this)); });
}, },
updatePage: function PDFFindController_updatePage(index) { updatePage: function PDFFindController_updatePage(index) {
if (this.selected.pageIdx === index) { if (this.selected.pageIdx === index) {
@ -3016,17 +3020,22 @@ var PDFViewer = function pdfViewer() {
return; return;
} }
var getPagesLeft = pagesCount; var getPagesLeft = pagesCount;
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) { var _loop = function _loop(_pageNum) {
var pageView = this._pages[pageNum - 1]; pdfDocument.getPage(_pageNum).then(function (pdfPage) {
var pageView = _this._pages[_pageNum - 1];
if (!pageView.pdfPage) { if (!pageView.pdfPage) {
pageView.setPdfPage(pdfPage); pageView.setPdfPage(pdfPage);
} }
this.linkService.cachePageRef(pageNum, pdfPage.ref); _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
if (--getPagesLeft === 0) { if (--getPagesLeft === 0) {
pagesCapability.resolve(); pagesCapability.resolve();
} }
}.bind(_this, pageNum)); });
};
for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
_loop(_pageNum);
} }
}); });
_this.eventBus.dispatch('pagesinit', { source: _this }); _this.eventBus.dispatch('pagesinit', { source: _this });

Loading…
Cancel
Save