Commit Graph

49 Commits

Author SHA1 Message Date
Jonas Jenwald
2e044bf646 Prepare the MOZCENTRAL viewer for receiving zoom events from the browser UI (bug 786674, bug 1177385)
This lays the necessary foundation for handling zoom events originating within the browser itself, rather than in the viewer. Please note that this will also require a follow-up patch to `mozilla-central`, such that the viewer is actually notified when zooming occurs.
2019-03-21 12:42:04 +01:00
Jonas Jenwald
5bb7f4b615 Convert PDFDataRangeTransport to an ES6 class 2018-10-20 17:15:27 +02:00
Jonas Jenwald
f29b4d1116 Clear all find highlights when the findbar is closed (issue 7468)
Please note that this will require a `mozilla-central` follow-up patch, in order for this to work in the built-in Firefox PDF viewer as well.
2018-09-26 10:20:45 +02:00
Jonas Jenwald
fafd8819bc Enable forwarding, in FirefoxCom, of the matchesCount to the browser findbar (bug 1062025)
This depends on https://bugzilla.mozilla.org/show_bug.cgi?id=1062025 landing in `mozilla-central` first, since https://searchfox.org/mozilla-central/rev/37663bb87004167184de6f2afa6b05875eb0528e/browser/extensions/pdfjs/content/PdfStreamConverter.jsm#719,740 would otherwise throw for the unknown event name.
2018-09-15 23:45:38 +02:00
Jonas Jenwald
6d804d657f Add initial support for "Whole words" searching in the viewer
As outlined in https://bugzilla.mozilla.org/show_bug.cgi?id=1282759 the internal Firefox name for the feature is `entireWord`, hence that name is used here as well for consistency (with "Whole words" being limited to the UI).

Given existing limitations of the PDF.js search functionality, e.g. the existing problems of searching across "new lines", there's some edge-cases where "Whole words" searching will ignore (valid) results.
However, considering that this is a pre-existing issue related to the way that the find controller joins text-content together, that shouldn't have to block this new feature in my opionion.

*Please note:* In order to enable this feature in the `MOZCENTRAL` version, a small follow-up patch for [PdfjsChromeUtils.jsm](https://hg.mozilla.org/mozilla-central/file/tip/browser/extensions/pdfjs/content/PdfjsChromeUtils.jsm) will be required once this has landed in `mozilla-central`.
2018-09-10 11:59:29 +02:00
Jonas Jenwald
c9a2564882 Display the index of the currently active search result in the matches counter of the findbar (issue 6993, bug 1062025)
For the `PDFFindBar` implementation, similar to the native Firefox findbar, the matches count displayed is now limited to a (hopefully) reasonable value.

*Please note:* In order to enable this feature in the `MOZCENTRAL` version, a follow-up patch will be required once this has landed in `mozilla-central`.
2018-09-08 21:50:22 +02:00
Jonas Jenwald
233b3274bf Refactor the Preferences classes to utilize async methods rather than manually returning Promises 2018-09-03 09:52:36 +02:00
Jonas Jenwald
b0fa02e845 Refactor the IL10n implementations to utilize async methods rather than manually returning Promises
This changes the methods signatures of `GenericL10n`, `MozL10n`, and `NullL10n`.
2018-09-03 09:52:36 +02:00
Jonas Jenwald
a9ce4e8417 Stop exposing the URL polyfill in the global scope
This moves/exposes the `URL` polyfill similarily to the existing `ReadableStream` polyfill, rather than exposing it globally, to avoid interfering with any "outside" code.
Both the `URL` and `ReadableStream` polyfills are now exposed on the `pdfjsLib` object, such that they are accessible to the viewer components.
Furthermore, the `no-restricted-globals` ESLint rule is also enabled to prevent accidental usage of the native `URL`/`ReadableStream` implementations directly in the `src/` and `web/` folders; see also https://eslint.org/docs/rules/no-restricted-globals

Addresses the remaining TODO in https://github.com/mozilla/pdf.js/projects/6
2018-07-04 09:16:28 +02:00
Jonas Jenwald
513412c92e Add a new getLanguage method to the various IL10n implementations 2018-03-25 18:49:46 +02:00
Jonas Jenwald
1d03ad0060 Move the disableCreateObjectURL option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:17 +01:00
Jonas Jenwald
74ffd1d865 Pass in the PDFJS.locale option to ExternalServices.createL10n
This allows us to remove an otherwise unnecessary `PDFJS` dependency from the `web/genericcom.js` file.
2018-02-13 16:56:56 +01:00
Jonas Jenwald
aaff3385ee ES6-ify the code in web/firefoxcom.js
These changes consists mainly of replacing `var` with `let`/`const`, and finally converting the `DownloadManager` to a proper class.
2017-09-10 12:51:33 +02:00
Jonas Jenwald
223c429357 Fix inconsistent spacing and trailing commas in objects in web/ files, so we can enable the comma-dangle and object-curly-spacing ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing

Given that we currently have quite inconsistent object formatting, fixing this in in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.

*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.

```diff
diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index 002dbf29..1de4e530 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -420,8 +420,8 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
     setPageLabel: function PDFThumbnailView_setPageLabel(label) {
       this.pageLabel = (typeof label === 'string' ? label : null);

-      this.l10n.get('thumb_page_title', { page: this.pageId, }, 'Page {{page}}').
-          then((msg) => {
+      this.l10n.get('thumb_page_title', { page: this.pageId, },
+                    'Page {{page}}').then((msg) => {
         this.anchor.title = msg;
       });

diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js
index 160e0410..6495fc5e 100644
--- a/web/secondary_toolbar.js
+++ b/web/secondary_toolbar.js
@@ -65,7 +65,8 @@ class SecondaryToolbar {
       { element: options.printButton, eventName: 'print', close: true, },
       { element: options.downloadButton, eventName: 'download', close: true, },
       { element: options.viewBookmarkButton, eventName: null, close: true, },
-      { element: options.firstPageButton, eventName: 'firstpage', close: true, },
+      { element: options.firstPageButton, eventName: 'firstpage',
+        close: true, },
       { element: options.lastPageButton, eventName: 'lastpage', close: true, },
       { element: options.pageRotateCwButton, eventName: 'rotatecw',
         close: false, },
@@ -76,7 +77,7 @@ class SecondaryToolbar {
       { element: options.cursorHandToolButton, eventName: 'switchcursortool',
         eventDetails: { tool: CursorTool.HAND, }, close: true, },
       { element: options.documentPropertiesButton,
-        eventName: 'documentproperties', close: true, }
+        eventName: 'documentproperties', close: true, },
     ];
     this.items = {
       firstPage: options.firstPageButton,
```
2017-06-01 12:47:47 +02:00
Yury Delendik
5438ce9b98 Wraps mozL10n to async calls; splits firefox and generic l10n libs. 2017-05-31 09:22:25 -05:00
Yury Delendik
66c8893815 Removes last UMDs from the modules. 2017-05-31 07:14:17 -05:00
Jonas Jenwald
f27b5013e2 Replace unnecessary bind(this) statements with arrow functions in web/ files
By using `let`, which is block-scoped, instead of `var` in a couple of places we're able to get rid of additional `bind` calls.
2017-05-04 17:13:09 +02:00
Jonas Jenwald
2a0207ccaf Enable the object-shorthand ESLint rule in web
Please see http://eslint.org/docs/rules/object-shorthand.

For the most part, these changes are of the search-and-replace kind, and the previously enabled `no-undef` rule should complement the tests in helping ensure that no stupid errors crept into to the patch.
2017-04-29 20:29:04 +02:00
Jonas Jenwald
c5f9193777 Convert the Preferences to an ES6 class 2017-04-23 21:14:58 +02:00
Yury Delendik
8e681ce3e2 Change amd to cjs path in ES6 modules 2017-04-14 10:32:36 -05:00
Jonas Jenwald
b2c3f8f081 Convert a number of import * as pdfjsLib from 'pdfjs-web/pdfjs'; cases to only specify the necessary imports
Rather than always importing everything from the `web/pdfjs.js`, similar to all other imports we can just choose what we actually need.
2017-04-09 11:55:48 +02:00
Jonas Jenwald
3b35c15d42 Convert the files in the /web folder to ES6 modules
Note that as discussed on IRC, this makes the viewer slightly slower to load *only* in `gulp server` mode, however the difference seem slight enough that I think it will be fine.
2017-04-09 11:55:48 +02:00
Jonas Jenwald
4626fc8342 Enable the spaced-comment ESLint rule
Please see http://eslint.org/docs/rules/spaced-comment.

Note that the exceptions added for `line` comments are intended to still allow use of the old preprocessor without linting errors.
Also, I took the opportunity to improve the grammar slightly (w.r.t. capitalization and punctuation) for comments touched in the patch.
2017-01-19 16:41:59 +01:00
Jonas Jenwald
70c1a6b120 [Bug 1331081] omit addEventListener/removeEventListener's third parameter when it's false
Upstream changes from https://bugzilla.mozilla.org/show_bug.cgi?id=1331081; this patch also covers one file, `pdf_print_service.js`, that's not present in mozilla-central.

Fixes 7962.
2017-01-17 17:50:21 +01:00
Jonas Jenwald
328e7397ea Fix errors reported by the no-extra-bind ESLint rule
http://eslint.org/docs/rules/no-extra-bind
2016-12-12 20:35:50 +01:00
Yury Delendik
0576c9c6c6 Replaces all preprocessor directives with PDFJSDev calls. 2016-10-14 10:57:53 -05:00
jazzy-em
0a347ec04d Added multiple term search functionality (with default phrase search) 2016-05-26 18:24:58 +05:00
Yury Delendik
3e6e294fd4 Refactors PDFFindBar and FirefoxCom find events. 2016-04-28 07:11:40 -05:00
Yury Delendik
148102b626 Refactors firefoxcom dependency on app and l10n. 2016-04-24 08:25:55 -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
Yury Delendik
1e3e14e6b2 Exposes all functional members via lib exports and use them in viewer. 2016-04-07 13:46:07 -05:00
Manas
a2ba1b8189 Uses editorconfig to maintain consistent coding styles
Removes the following as they unnecessary
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
2015-11-14 07:32:18 +05:30
Collin Anderson
54e984c763 cleaned whitespace 2015-02-17 11:07:37 -05:00
Yury Delendik
68b037ffb0 Add preprocessor directives for the extension; and refactor FirefoxCom callback 2014-05-28 10:24:06 -05:00
Samuel Chantaraud
25ee0e8572 Preliminary attachments support
Added a partial Filespec support
Added getAttachments in API
Added a new attachments view in UI (with a new icon by @shorlander)
2014-04-18 12:11:00 -04:00
Jonas Jenwald
4c9c43f82b Modify {get, set}Preferences in PdfStreamConverter.jsm to support async 2014-04-03 10:17:35 +02:00
Jonas Jenwald
c920372ff2 Rewrite 'Preferences' to make it async 2014-04-03 10:08:33 +02:00
Brendan Dahl
48323b8066 Merge pull request #4225 from Snuffleupagus/prefs-v3
Improve handling of preferences in Firefox
2014-03-10 10:39:56 -07:00
Jonas Jenwald
6df9cc46b4 Fix coding style in web/firefoxcom.js 2014-03-09 11:51:15 +01:00
Jonas Jenwald
c158894d94 Improve handling of preferences in Firefox 2014-03-05 11:58:12 +01:00
Yury Delendik
5bf3e44e30 Introduces LegacyPromise; polyfills DOM Promise 2014-01-03 18:17:05 -06:00
Jonas Jenwald
60610cd625 Implement default preferences 2013-11-18 23:51:06 +01:00
Yury Delendik
81c8730e4b Restoring PR 3455 functionality 2013-07-12 17:00:43 -05:00
Yury Delendik
ef658bf5f1 Refactoring download button logic 2013-07-12 13:14:13 -05:00
vyv03354
07491f584f Replace getUserData()/setUserData() with CustomEvents 2013-02-06 23:31:50 +09:00
Yury Delendik
81f8f92696 Adds web/* and test/* for jshint target 2013-02-04 12:01:19 -06:00
Brendan Dahl
332ae4ce41 Change to the Apache v2 license. 2012-08-31 15:48:21 -07:00
Brendan Dahl
11be208388 Move firefoxcom to its own file. 2012-08-01 15:31:25 -07:00