Browse Source

Prevent searching during load from breaking the find functionality

Jonas 12 years ago
parent
commit
54dfe05e30
  1. 20
      web/pdf_find_controller.js
  2. 4
      web/viewer.js

20
web/pdf_find_controller.js

@ -64,6 +64,8 @@ var PDFFindController = { @@ -64,6 +64,8 @@ var PDFFindController = {
integratedFind: false,
firstPagePromise: new PDFJS.Promise(),
initialize: function(options) {
if(typeof PDFFindBar === 'undefined' || PDFFindBar === null) {
throw 'PDFFindController cannot be initialized ' +
@ -172,15 +174,17 @@ var PDFFindController = { @@ -172,15 +174,17 @@ var PDFFindController = {
this.state = e.detail;
this.updateUIState(FindStates.FIND_PENDING);
this.extractText();
this.firstPagePromise.then(function() {
this.extractText();
clearTimeout(this.findTimeout);
if (e.type === 'find') {
// Only trigger the find action after 250ms of silence.
this.findTimeout = setTimeout(this.nextMatch.bind(this), 250);
} else {
this.nextMatch();
}
clearTimeout(this.findTimeout);
if (e.type === 'find') {
// Only trigger the find action after 250ms of silence.
this.findTimeout = setTimeout(this.nextMatch.bind(this), 250);
} else {
this.nextMatch();
}
}.bind(this));
},
updatePage: function(idx) {

4
web/viewer.js

@ -162,8 +162,6 @@ var Settings = (function SettingsClosure() { @@ -162,8 +162,6 @@ var Settings = (function SettingsClosure() {
var cache = new Cache(CACHE_SIZE);
var currentPageNumber = 1;
// TODO: Enable the FindBar *AFTER* the pagesPromise in the load function
// got resolved
//#include pdf_find_bar.js
//#include pdf_find_controller.js
//#include pdf_history.js
@ -941,6 +939,8 @@ var PDFView = { @@ -941,6 +939,8 @@ var PDFView = {
pagePromises.push(pagePromise);
}
PDFFindController.firstPagePromise.resolve();
PDFJS.Promise.all(pagePromises).then(function(pages) {
pagesPromise.resolve(pages);
});

Loading…
Cancel
Save