pdf.js/web
Jonas Jenwald 2ed3591b22 Make PDFFindController less confusing to use, by allowing searching to start when setDocument is called
*This patch is based on something that I noticed while working on PR 10126.*

The recent re-factoring of `PDFFindController` brought many improvements, among those the fact that access to `BaseViewer` is no longer required. However, with these changes there's one thing which now strikes me as not particularly user-friendly[1]: The fact that in order for searching to actually work, `PDFFindController.setDocument` must be called *and* a 'pagesinit' event must be dispatched (from somewhere).

For all other viewer components, calling the `setDocument` method[2] is enough in order for the component to actually be usable.
The `PDFFindController` thus stands out quite a bit, and it also becomes difficult to work with in any sort of custom implementation. For example: Imagine someone trying to use `PDFFindController` separately from the viewer[3], which *should* now be relatively simple given the re-factoring, and thus having to (somehow) figure out that they'll also need to manually dispatch a 'pagesinit' event for searching to work.

Note that the above even affects the unit-tests, where an out-of-place 'pagesinit' event is being used.
To attempt to address these problems, I'm thus suggesting that *only* `setDocument` should be used to indicate that searching may start. For the default viewer and/or the viewer components, `BaseViewer.setDocument` will now call `PDFFindController.setDocument` when the document is ready, thus requiring no outside configuration anymore[4]. For custom implementation, and the unit-tests, it's now as simple as just calling `PDFFindController.setDocument` to allow searching to start.

---
[1] I should have caught this during review of PR 10099, but unfortunately it's sometimes not until you actually work with the code in question that things like these become clear.

[2] Assuming, obviously, that the viewer component in question actually implements such a method :-)

[3] There's even a very recent issue, filed by someone trying to do just that.

[4] Short of providing a `PDFFindController` instance when creating a `BaseViewer` instance, of course.
2018-10-04 10:28:50 +02:00
..
images Add spread modes to web viewer 2018-05-14 23:10:32 -04:00
.eslintrc Provide custom messages for the no-restricted-globals ESLint rule, and refactor the .eslintrc files (PR 9868 follow-up) 2018-07-23 14:10:13 +02:00
.gitignore Remove obselete file from .gitignore 2015-01-26 16:44:45 +01:00
annotation_layer_builder.css Clean up browser-specific CSS 2018-04-04 00:25:12 +02:00
annotation_layer_builder.js Move the imageResourcesPath option to a BaseViewer/PDFPageView/AnnotationLayerBuilder option 2018-02-13 14:28:38 +01:00
app_options.js Add general support for re-dispatching events, on EventBus instances, to the DOM 2018-08-30 17:28:12 +02:00
app.js Make PDFFindController less confusing to use, by allowing searching to start when setDocument is called 2018-10-04 10:28:50 +02:00
base_viewer.js Make PDFFindController less confusing to use, by allowing searching to start when setDocument is called 2018-10-04 10:28:50 +02:00
chrome-i18n-allow-access-to-file-urls.json Add translations of "Allow access to file URLs" 2015-08-14 18:59:55 +02:00
chromecom.js Refactor the Preferences classes to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
compressed.tracemonkey-pldi-09.pdf Add Makefile. Move some files around to make building the website easier. 2011-07-05 10:53:57 -07:00
debugger.js Replace String.prototype.substr() occurrences with String.prototype.substring() 2018-09-28 11:41:07 +02:00
default_preferences.json Add general support for re-dispatching events, on EventBus instances, to the DOM 2018-08-30 17:28:12 +02:00
dom_events.js Add general support for re-dispatching events, on EventBus instances, to the DOM 2018-08-30 17:28:12 +02:00
download_manager.js Stop exposing the URL polyfill in the global scope 2018-07-04 09:16:28 +02:00
firefox_print_service.js Use let/const instead of var in the printing code 2017-10-22 16:13:14 +02:00
firefoxcom.js Clear all find highlights when the findbar is closed (issue 7468) 2018-09-26 10:20:45 +02:00
genericcom.js Refactor the Preferences classes to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
genericl10n.js Refactor the IL10n implementations to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
grab_to_pan.js Enable the no-var ESLint rule in the /web folder 2017-11-05 16:53:47 +01:00
interfaces.js Attempt to simplify the fileattachmentannotation event dispatching 2018-10-01 15:09:08 +02:00
overlay_manager.js Refactor the OverlayManager to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
password_prompt.js Change var to let, and use object destructuring, in a couple of previously class converted web/*.js files 2017-07-03 11:22:49 +02:00
pdf_attachment_viewer.js Move the disableCreateObjectURL option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:17 +01:00
pdf_cursor_tools.js Simplify resetting of the SecondaryToolbar Scroll/Spread mode buttons, and add a missing comment in PDFCursorTools 2018-07-08 10:55:56 +02:00
pdf_document_properties.js Implement the setDocument method for the find controller 2018-09-30 16:57:40 +02:00
pdf_find_bar.js Attempt to simplify the signature of the PDFFindBar constructor, by moving the eventBus parameter from the options object 2018-10-02 12:57:07 +02:00
pdf_find_controller.js Make PDFFindController less confusing to use, by allowing searching to start when setDocument is called 2018-10-04 10:28:50 +02:00
pdf_find_utils.js Add initial support for "Whole words" searching in the viewer 2018-09-10 11:59:29 +02:00
pdf_history.js Replace the remaining occurences of instanceof Array with Array.isArray() 2018-07-09 13:17:41 +02:00
pdf_link_service.js Attempt to simplify the fileattachmentannotation event dispatching 2018-10-01 15:09:08 +02:00
pdf_outline_viewer.js Attempt to simplify the signature of the PDFSidebar constructor, by moving the eventBus parameter from the options object and removing the PDFOutlineViewer dependency 2018-10-02 13:14:11 +02:00
pdf_page_view.js Dispatch a 'pagecancelled' event, in PDFPageView.cancelRendering, when rendering is cancelled 2018-09-23 22:34:39 +02:00
pdf_presentation_mode.js Add source parameters to all remaining EventBus.dispatch calls that are currently missing those 2018-08-30 10:39:32 +02:00
pdf_print_service.js Stop exposing the URL polyfill in the global scope 2018-07-04 09:16:28 +02:00
pdf_rendering_queue.js Replace a few occurences of var with let in already ES6 converted web/ files 2017-10-22 16:23:38 +02:00
pdf_sidebar_resizer.js Only resize the sidebar with the left mouse button 2017-12-02 19:05:17 +01:00
pdf_sidebar.js Attempt to simplify the signature of the PDFSidebar constructor, by moving the eventBus parameter from the options object and removing the PDFOutlineViewer dependency 2018-10-02 13:14:11 +02:00
pdf_single_page_viewer.js Re-factor updating of Scroll/Spread modes, and place all the code in BaseViewer with overrides (as necessary) in the extending classes 2018-06-30 12:36:56 +02:00
pdf_thumbnail_view.js Refactor PDFThumbnailViewer.scrollThumbnailIntoView to avoid unnecessary DOM look-ups 2018-02-09 14:43:11 +01:00
pdf_thumbnail_viewer.js Replace the remaining occurences of instanceof Array with Array.isArray() 2018-07-09 13:17:41 +02:00
pdf_viewer.component.js [api-major] Completely remove the global PDFJS object 2018-03-01 18:13:27 +01:00
pdf_viewer.css Add spread modes to web viewer 2018-05-14 23:10:32 -04:00
pdf_viewer.js Re-factor updating of Scroll/Spread modes, and place all the code in BaseViewer with overrides (as necessary) in the extending classes 2018-06-30 12:36:56 +02:00
pdfjs.js Use ES6 notation, and replace var with let, in web/pdf_viewer.component.js and web/pdfjs.js 2017-11-05 16:53:47 +01:00
preferences.js Refactor the Preferences classes to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
secondary_toolbar.js Temporarily disable the Spread mode buttons when horizontal scrolling is enabled 2018-07-08 12:11:03 +02:00
text_layer_builder.css Clean up browser-specific CSS 2018-04-04 00:25:12 +02:00
text_layer_builder.js Use the updatetextlayermatches event for highlighting matches on a page 2018-09-30 16:57:18 +02:00
toolbar.js Add source parameters to all remaining EventBus.dispatch calls that are currently missing those 2018-08-30 10:39:32 +02:00
ui_utils.js Prevent getPDFFileNameFromURL from breaking if the url parameter is not a string 2018-09-30 12:28:59 +02:00
view_history.js Refactor the ViewHistory to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
viewer_compatibility.js Remove the disableFullscreen hack for embedded IE 11 (issue 9585) 2018-06-14 12:25:28 +02:00
viewer-snippet-chrome-extension.html Wraps mozL10n to async calls; splits firefox and generic l10n libs. 2017-05-31 09:22:25 -05:00
viewer-snippet-chrome-overlays.html [CRX] Add file chooser as fallback (fixes #9411) 2018-03-21 18:21:46 +01:00
viewer-snippet-firefox-extension.html Wraps mozL10n to async calls; splits firefox and generic l10n libs. 2017-05-31 09:22:25 -05:00
viewer-snippet-minified.html Remove XHTML leftovers from the viewer HTML files 2016-02-14 13:23:34 +01:00
viewer-snippet.html Wraps mozL10n to async calls; splits firefox and generic l10n libs. 2017-05-31 09:22:25 -05:00
viewer.css Hide the Scroll/Spread mode buttons when the viewer is a PDFSinglePageViewer instance 2018-07-08 12:08:48 +02:00
viewer.html Add initial support for "Whole words" searching in the viewer 2018-09-10 11:59:29 +02:00
viewer.js Remove unused findStatusIcon property from PDFFindBar instances 2018-09-10 11:59:30 +02:00