Commit Graph

90 Commits

Author SHA1 Message Date
Yury Delendik
bca1aebeac Merge pull request #7458 from Snuffleupagus/updateUIToolbar
Consolidate updating of various Toolbar state (e.g. page and scale) in one method in `PDFViewerApplication`
2016-07-08 12:34:39 -05:00
Jonas Jenwald
cb6a7e5503 Remove handling of fallback arguments from PDFViewerApplication.open
The method signature was improved in PR 6546, which was included in the `1.2.109` release from last November.
Hence I think that we should now be able to remove the fallback code for the old method signature. Note that this patch now throws an `Error` in `GENERIC` builds, to clearly indicate that the `open` callsite must be modified.
2016-07-02 11:31:32 +02:00
Jonas Jenwald
2f127df97b Add back moz-specific fullscreen support code for ´MOZCENTRAL` builds (bug 1268749, PR 7273 follow-up)
In PR 7273, we simplified the `MOZCENTRAL` specific check for fullscreen support. Unfortunately I've just, by coincidence, found out about https://bugzilla.mozilla.org/show_bug.cgi?id=1268749, which disabled the unprefixed fullscreen support in release versions of Firefox. If we do nothing, this will lead to Presentation Mode being unavailable in future Firefox releases.

This patch should fix things for now, and I'm afraid that we'll need to uplift it to Firefox 49 as well.
2016-07-01 14:11:58 +02:00
Jonas Jenwald
dd0fe10a52 Consolidate updating of various Toolbar state (e.g. page and scale) in one method in PDFViewerApplication
With the changes in PR 7289, we no longer dispatch a 'pagechanging' event on load. Since most PDF documents open on the first page, this means that the `previous` and `firstPage` buttons are no longer correctly disabled.
To avoid this, this patch moves the code that updates various UI toolbar state into one method, which is then called on document initialization and from the various existing event handling functions.
2016-06-29 22:36:45 +02:00
Tim van der Meij
f97d52182a Merge pull request #7341 from Snuffleupagus/getDestinationHash-Array
[api-minor] Improve handling of links that are using explicit destination arrays
2016-06-09 00:29:10 +02:00
Yury Delendik
5aefce6ba6 Merge pull request #5579 from jazzy-em/master
Added multiple term search functionality (with default phrase search)
2016-05-27 14:23:26 -05:00
jazzy-em
0a347ec04d Added multiple term search functionality (with default phrase search) 2016-05-26 18:24:58 +05:00
Jonas Jenwald
b354682dd6 [api-minor] Let LinkAnnotation/PDFLinkService_getDestinationHash return a stringified version of the destination array for explicit destinations
Currently for explicit destinations, compared to named destinations, we manually try to build a hash that often times is a quite poor representation of the *actual* destination. (Currently this only, kind of, works for `\XYZ` destinations.)
For PDF files using explicit destinations, this can make it difficult/impossible to obtain a link to a specific section of the document through the URL.

Note that in practice most PDF files, especially newer ones, use named destinations and these are thus unnaffected by this patch.
This patch also fixes an existing issue in `PDFLinkService_getDestinationHash`, where a named destination consisting of only a number would not be handled correctly.

With the added, and already existing, type checks in place for destinations, I really don't think that this patch exposes any "sensitive" internal destination code not already accessible through normal hash parameters.

*Please note:* Just trying to improve the algorithm that generates the hash is unfortunately not possible in general, since there are a number of cases where it will simply never work well.

 - First of all, note that `getDestinationHash` currently relies on the `_pagesRefCache`, hence it's possible that the hash returned is empty during e.g. ranged/streamed loading of a PDF file.

 - Second of all, the currently computed hash is actually dependent on the document rotation. With named destinations, the fetched internal destination array is rotational invariant (as it should be), but this will not hold in general for the hash. We can easily avoid this issue by using a stringified destination array.

 - Third of all, note that according to the PDF specification[1], `GoToR` destinations may actually contain explicit destination arrays. Since we cannot really construct a hash in `annotation.js`, we currently have no good way to support those. Even though this case seems *very* rare in practice (I've not actually seen such a PDF file), it's in the specification, and this patch allows us to support that for "free".

---
[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1951685
2016-05-21 14:14:07 +02:00
Tim van der Meij
db46829ef7 Merge pull request #7316 from timvandermeij/remove-unused
Remove unused variables
2016-05-21 14:07:33 +02:00
Tim van der Meij
f4ae277355 Convert the secondary toolbar to a class 2016-05-11 20:53:39 +02:00
Tim van der Meij
6a7012aaca Remove unused variables
These have been found using `gulp lint` in combination with the `unused:
true` parameter for JSHint. Unfortunately there are too many false
positives to enable this feature, but now that most globals have been
removed because of the conversion to UMD the results are much more
useful than before.
2016-05-11 16:11:13 +02:00
Yury Delendik
a4c81c203b Enables debugger only when needed. 2016-05-09 18:18:43 -05:00
Yury Delendik
d20002b6b1 Merge pull request #7273 from Snuffleupagus/issue-7270
Prevent "Prefixed Fullscreen API is deprecated." warnings in the MOZCENTRAL version (issue 7270)
2016-04-29 10:37:11 -05:00
Jonas Jenwald
9dd6017901 Prevent "Prefixed Fullscreen API is deprecated." warnings in the MOZCENTRAL version (issue 7270)
We're already, since quite some time, using the standard Fullscreen API provided that it's available in the browser. The warning is only caused by the code that checks if the Fullscreen API is supported.

This patch uses a simple preprocessor tag to avoid the warning, since I'm assuming that in general, we want to try and remain backwards compatible with the prefixed versions of the Fullscreen API.

Fixes 7270.
2016-04-29 17:28:24 +02:00
Yury Delendik
4a2c76a34f Adds pre and post UI control change events. 2016-04-29 10:05:04 -05:00
Yury Delendik
eb3d1ca003 Removes circular dependency of secondary toolbar on app.js. 2016-04-28 15:04:09 -05:00
Jonas Jenwald
61a4c740d2 Merge pull request #7254 from yurydelendik/eventbus
Introducing EventBus for the viewer UI.
2016-04-28 15:19:49 +02:00
Yury Delendik
3e6e294fd4 Refactors PDFFindBar and FirefoxCom find events. 2016-04-28 07:11:40 -05:00
Yury Delendik
7fd3db9977 Adds EventBus. 2016-04-28 06:57:24 -05:00
Yury Delendik
5568a19ee3 Moves bundle target/task to gulpfile.js 2016-04-24 08:37:39 -05:00
Yury Delendik
3132941948 Removes app.js dependency on mozPrintCallback_polyfill.js. 2016-04-24 08:25:55 -05:00
Yury Delendik
3b21b51716 Refactors preferences and PDF opening related chromecom code. 2016-04-24 08:25:55 -05:00
Yury Delendik
148102b626 Refactors firefoxcom dependency on app and l10n. 2016-04-24 08:25:55 -05:00
Yury Delendik
81fc46e666 Refactors FindController dependencies. 2016-04-24 08:25:55 -05:00
Yury Delendik
b6c74f2056 Moves all document.getElementById lookups into viewer.js 2016-04-21 11:39:11 -05:00
Tim van der Meij
2b7137ba0a Convert the password prompt to a class
Furthermore we introduce two new methods named `setCallback` and
`setReason` so external code does not change the properties of the class
directly. Finally we update various names of properties and methods to
be more self-explanatory.
2016-04-21 14:06:10 +02:00
Tim van der Meij
b0aca31de8 Convert the hand tool to a class 2016-04-16 19:20:37 +02:00
Jonas Jenwald
7f90f5bfed Merge pull request #7206 from Snuffleupagus/viewer-expose-non-classes-on-PDFViewerApplication
Expose a few non-classes on `PDFViewerApplication`
2016-04-16 16:43:22 +02:00
Jonas Jenwald
9dfda2b908 Expose a few non-classes on PDFViewerApplication
With the recent PR 7172, which made the viewer modular, there's now a couple of modules that are no longer easily accessible (e.g. through the console).
This can make testing/debugging more difficult, and means that e.g. https://github.com/mozilla/pdf.js/wiki/Debugging-PDF.js#enabling no longer works in the generic viewer.

For now, as a simple solution, this patch just exposes those non-classes on `PDFViewerApplication` to ensure that they are available, and to avoid polluting the `window` scope.
2016-04-16 16:23:21 +02:00
Ankit Aggarwal
6ceda3f290 web/viewer.js: Persist the state of sidebar
Persist the state of content sidebar while browsing away from viewer and
initializing the same on returning back to the viewer. The state is saved
in persistent store preferences and used upon viewer initialization.

Fixes #6935
2016-04-16 10:17:42 +02:00
Jonas Jenwald
5657d082c7 Dispatch a sidebarviewchanged event in PDFSidebar when the view changes
We cannot piggy-back on the `updateviewarea` event in order to update the stored sidebar state, since there're a number of cases where opening/switching the sidebar view won't fire a `updateviewarea` event.
Note that `updateviewarea` only fires when the position changes in the *viewer*, which means that it won't fire if e.g. the viewer is narrow, such that the sidebar overlays the document transparently; or when switching views, without the document position also changing.

This patch also moves the handling of `forceOpen` parameter in `PDFSidebar_switchView`, to prevent triggering back-to-back rendering and dispatching of events.
2016-04-16 10:10:28 +02:00
Yury Delendik
50fe8e7c75 Removes PDFView global and pagerender event support. 2016-04-13 10:11:43 -05:00
Yury Delendik
4165cedc9f Replace pdfjsLib with module that represents pdf.js. 2016-04-13 10:11:34 -05:00
Yury Delendik
006e8fb59d Introduces UMD headers to the web/ folder. 2016-04-13 10:09:48 -05:00
Jonas Jenwald
514210814d Prevent the *entire* viewer from zooming, when quickly switching from scrolling to zooming using the mousewheel (PR 7097 followup)
This is a regression from PR 7097.

(Also, out of scope for this PR, but I think that a `setTimeout` value of `1000 ms` is too large. Switching from scrolling to zooming can fell sluggish, and give the impression that nothing happens.)
2016-04-07 21:04:52 +02:00
Brendan Dahl
f351eb23aa Merge pull request #7097 from prometheansacrifice/zoom-due-to-scroll-inertia
Prevents document zooming if still scrolling and meta keys pressed (Issue #7022)
2016-04-07 11:52:10 -07:00
Yury Delendik
1e3e14e6b2 Exposes all functional members via lib exports and use them in viewer. 2016-04-07 13:46:07 -05:00
Manas
6878d7c6d3 Disables zooming when the stream of events that don't have meta/ctrl
keys active at the outset, for 1000ms
2016-04-07 22:18:46 +05:30
Yury Delendik
313b418a20 Prepare viewer.js for async loading and module separation. 2016-04-01 10:29:44 -05:00
Yury Delendik
b371785fbb Rename web/viewer.js -> web/app.js 2016-04-01 10:27:16 -05:00