- files_reader v1.1, now supports PDF, see CHANGELOG.md and README.md
for change information
|
@ -1,4 +1,4 @@
|
|||
## UNRELEASED
|
||||
## 1.1 - 2018-01-18
|
||||
### Added
|
||||
- Reader now supports PDF
|
||||
- PDF double page spreads are supported
|
||||
|
@ -8,6 +8,7 @@
|
|||
### Changed
|
||||
- #38: moved declarations in js/ready.js one level lower to work around a bug in the Palemoon browser
|
||||
- new version bitjs archive tools, fixes compatibility problems with some CBR files
|
||||
- increased maximum supported version for OC and NC
|
||||
|
||||
## 1.0.1 - 2017-03-19
|
||||
### Fixed
|
||||
|
|
|
@ -1,26 +1,30 @@
|
|||
files_reader
|
||||
------------
|
||||
|
||||
Reader is an ebook reader based on pure javascript renderers. It works for books formatted according to the following standards:
|
||||
Reader is an ebook reader based on pure javascript renderers. It works for publications formatted according to the following standards:
|
||||
|
||||
- [Epub]
|
||||
- [PDF]
|
||||
- [CBR and CBZ] ('comics')
|
||||
|
||||
For Epub Reader uses the futurepress [epub.js] renderer to provide near-native looks, especially when used full-screen. Turn pages by pressing the left/right hand side of the screen/window or using the cursor keys (if you have those), use the sidebar to browse through chapters or bookmarks and add annotations.
|
||||
|
||||
PDF is handled by Mozilla's [pdf.js] renderer in combination with a custom reader app to enable side-by-side display, batch search and more. Controls are like those used in the Epub renderer with a few exceptions, e.g. night mode has not been implemented yet.
|
||||
|
||||
CBR and CBZ are supported using a custom renderer inspired by [balaclark]'s work. As with Epub, books can be navigated using the keyboard as well as mouse or touch navigation. Reader generates a visual index of all pages, show in the sidebar (thumbnail generation can be disabled for low-memory and/or -speed devices). As CBx files are often of varying quality, a set of image enhancement filters are provided.
|
||||
|
||||
# Features
|
||||
Reader remembers the last-visited page in a book and returns to that page when the book is re-opened. As all settings are stored on the server these features are device-independent, ie. you can start reading on a mobile device, continue on a PC to finish the book on a tablet.
|
||||
### Text-based formats
|
||||
|
||||
### Text-based formats incl. PDF
|
||||
|
||||
- seamless full-screen mode supported on browsers which allow full user-control, ie. not on Apple)
|
||||
- single- and double-page viewing mode
|
||||
- user-configurable font and colour settings
|
||||
- night mode, toggled by clicking the book title/author on top of the viewer
|
||||
- night mode, toggled by clicking the book title/author on top of the viewer (not yet implemented for PDF)
|
||||
- full-text search with keyword highlighting
|
||||
- bookmarks (with automatic snippet generation)
|
||||
- annotations
|
||||
- annotations (not yet implemented for PDF)
|
||||
- keyboard and pointer/touch-based navigation
|
||||
|
||||
### CBR/CBZ ('Comics')
|
||||
|
@ -32,6 +36,8 @@ Reader remembers the last-visited page in a book and returns to that page when t
|
|||
- visual index (thumbnail size user-configurable, can be disabled for low-memory or -cpu devices)
|
||||
- keyboard and pointer/touch-based navigation
|
||||
|
||||
PDF support is still somewhat rough around the edges, not all features have been implemented yet. There is a known cosmetical issue in that in spread mode the (invisible but selectable) text layer for the left page is offset from the left when opening a document. As soon as a page is turned this problem disappears.
|
||||
|
||||
### Keyboard navigation
|
||||
Reader supports both pointer/touch-based as well as keyboard-based navigation. Pointer/touch based is mostly self-explanatory,
|
||||
|
||||
|
@ -54,7 +60,7 @@ Reader supports both pointer/touch-based as well as keyboard-based navigation. P
|
|||
|
||||
### Defaults and Preferences
|
||||
|
||||
Reader stores __defaults__ - settings which are independent of _fileId_ (ie. independent of the book currently open) - and __preferences__ - _fileId_-dependent (ie. different for every book) - on the server. Defaults are not shared between renderers, ie. the CBR renderer does not share defaults with the EPUB renderer. Defaults and preferences are removed from the server when the associated book or user is deleted.
|
||||
Reader stores __defaults__ - settings which are independent of _fileId_ (ie. independent of the book currently open) - and __preferences__ - _fileId_-dependent (ie. different for every book) - on the server. Defaults are not shared between renderers, ie. the CBR renderer does not share defaults with the EPUB or PDF renderer. Defaults and preferences are removed from the server when the associated book or user is deleted.
|
||||
|
||||
### Annotations and Bookmarks
|
||||
|
||||
|
@ -75,6 +81,14 @@ Search on small-screen device|![Search on small-screen device][SS07]
|
|||
As close to full-screen as you can get on iOS|![As close to full-screen as you can get on iOS][SS08]
|
||||
Android supports true fullscreen (as do most other systems)|![Android supports true fullscreen (as do most other systems)][SS09]
|
||||
|
||||
### PDF
|
||||
| | |
|
||||
---|---
|
||||
Reader showing PDF Reference document in spread mode (pages side by side)|![Reader showing PDF Reference document in spread mode (pages side by side)][SS20]
|
||||
Search through a document, showing all results in the sidebar|![Search through a document, showing all results in the sidebar][SS19]
|
||||
Dropdown showing page format options - spread, single page, page width and zoom options|![Dropdown showing page format options - spread, single page, page width and zoom options][SS21]
|
||||
Reader showing PDF in spread mode, thumbnails in the sidebar|![Reader showing PDF in spread mode, thumbnails in the sidebar][SS22]
|
||||
|
||||
|
||||
### CBR/CBZ
|
||||
| | |
|
||||
|
@ -95,6 +109,7 @@ The same Android device showing a zoomed-in part of a page|![The same Android de
|
|||
[Epub]: http://idpf.org/epub
|
||||
[CBR and CBZ]: https://wiki.mobileread.com/wiki/CBR_and_CBZ
|
||||
[balaclark]: https://github.com/balaclark/HTML5-Comic-Book-Reader
|
||||
[pdf.js]: https://github.com/mozilla/pdf.js
|
||||
[SS01]: https://raw.githubusercontent.com/Yetangitu/owncloud-apps/master/screenshots/files_reader-1.png "Reader showing day/nighyt mode"
|
||||
[SS02]: https://raw.githubusercontent.com/Yetangitu/owncloud-apps/master/screenshots/files_reader-3.png "Single page full screen on a small-screen device"
|
||||
[SS03]: https://raw.githubusercontent.com/Yetangitu/owncloud-apps/master/screenshots/photo_2017-03-15_17-21-39.jpg "Day mode color selector"
|
||||
|
@ -113,3 +128,9 @@ The same Android device showing a zoomed-in part of a page|![The same Android de
|
|||
[SS16]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/photo_2017-03-15_17-22-10.jpg?raw=true "Same page, zoomed in"
|
||||
[SS17]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/photo_2017-03-15_18-28-54.jpg?raw=true "Small-screen, low memory (Android) device showing full-page book cover"
|
||||
[SS18]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/photo_2017-03-15_18-28-56.jpg?raw=true "The same Android device showing a zoomed-in part of a page"
|
||||
[SS19]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/files_reader_PDF_001.png?raw=true "Search through a document, showing all results in the sidebar"
|
||||
[SS20]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/files_reader_PDF_002.png?raw=true "Reader showing PDF Reference document in spread mode (pages side by side)"
|
||||
[SS21]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/files_reader_PDF_005.png?raw=true "Dropdown showing page format options - spread, single page, page width and zoom options"
|
||||
[SS22]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/files_reader_PDF_006.png?raw=true "Reader showing PDF in spread mode, thumbnails in the sidebar"
|
||||
|
||||
|
||||
|
|
|
@ -5,28 +5,32 @@
|
|||
<namespace>Files_Reader</namespace>
|
||||
<summary>A multi-format browser-based ebook reader, supports EPUB and CBR/CBZ</summary>
|
||||
<description>
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
# Reader
|
||||
Reader is an ebook reader based on pure javascript renderers. It works for books formatted according to the following standards:
|
||||
Reader is an ebook reader based on pure javascript renderers. It works for publications formatted according to the following standards:
|
||||
|
||||
- [Epub]
|
||||
- [PDF]
|
||||
- [CBR and CBZ] ('comics')
|
||||
|
||||
For Epub Reader uses the futurepress [epub.js] renderer to provide near-native looks, especially when used full-screen. Turn pages by pressing the left/right hand side of the screen/window or using the cursor keys (if you have those), use the sidebar to browse through chapters or bookmarks and add annotations.
|
||||
|
||||
PDF is handled by Mozilla's [pdf.js] renderer in combination with a custom reader app to enable side-by-side display, batch search and more. Controls are like those used in the Epub renderer with a few exceptions, e.g. night mode has not been implemented yet.
|
||||
|
||||
CBR and CBZ are supported using a custom renderer inspired by [balaclark]'s work. As with Epub, books can be navigated using the keyboard as well as mouse or touch navigation. Reader generates a visual index of all pages, show in the sidebar (thumbnail generation can be disabled for low-memory and/or -speed devices). As CBx files are often of varying quality, a set of image enhancement filters are provided.
|
||||
|
||||
# Features
|
||||
Reader remembers the last-visited page in a book and returns to that page when the book is re-opened. As all settings are stored on the server these features are device-independent, ie. you can start reading on a mobile device, continue on a PC to finish the book on a tablet.
|
||||
### Text-based formats
|
||||
|
||||
### Text-based formats incl. PDF
|
||||
|
||||
- seamless full-screen mode supported on browsers which allow full user-control, ie. not on Apple)
|
||||
- single- and double-page viewing mode
|
||||
- user-configurable font and colour settings
|
||||
- night mode, toggled by clicking the book title/author on top of the viewer
|
||||
- night mode, toggled by clicking the book title/author on top of the viewer (not yet implemented for PDF)
|
||||
- full-text search with keyword highlighting
|
||||
- bookmarks (with automatic snippet generation)
|
||||
- annotations
|
||||
- annotations (not yet implemented for PDF)
|
||||
- keyboard and pointer/touch-based navigation
|
||||
|
||||
### CBR/CBZ ('Comics')
|
||||
|
@ -38,6 +42,8 @@ Reader remembers the last-visited page in a book and returns to that page when t
|
|||
- visual index (thumbnail size user-configurable, can be disabled for low-memory or -cpu devices)
|
||||
- keyboard and pointer/touch-based navigation
|
||||
|
||||
PDF support is still somewhat rough around the edges, not all features have been implemented yet. There is a known cosmetical issue in that in spread mode the (invisible but selectable) text layer for the left page is offset from the left when opening a document. As soon as a page is turned this problem disappears.
|
||||
|
||||
### Keyboard navigation
|
||||
Reader supports both pointer/touch-based as well as keyboard-based navigation. Pointer/touch based is mostly self-explanatory,
|
||||
|
||||
|
@ -60,7 +66,7 @@ Reader supports both pointer/touch-based as well as keyboard-based navigation. P
|
|||
|
||||
### Defaults and Preferences
|
||||
|
||||
Reader stores __defaults__ - settings which are independent of _fileId_ (ie. independent of the book currently open) - and __preferences__ - _fileId_-dependent (ie. different for every book) - on the server. Defaults are not shared between renderers, ie. the CBR renderer does not share defaults with the EPUB renderer. Defaults and preferences are removed from the server when the associated book or user is deleted.
|
||||
Reader stores __defaults__ - settings which are independent of _fileId_ (ie. independent of the book currently open) - and __preferences__ - _fileId_-dependent (ie. different for every book) - on the server. Defaults are not shared between renderers, ie. the CBR renderer does not share defaults with the EPUB or PDF renderer. Defaults and preferences are removed from the server when the associated book or user is deleted.
|
||||
|
||||
### Annotations and Bookmarks
|
||||
|
||||
|
@ -81,6 +87,14 @@ Search on small-screen device|![Search on small-screen device][SS07]
|
|||
As close to full-screen as you can get on iOS|![As close to full-screen as you can get on iOS][SS08]
|
||||
Android supports true fullscreen (as do most other systems)|![Android supports true fullscreen (as do most other systems)][SS09]
|
||||
|
||||
### PDF
|
||||
| | |
|
||||
---|---
|
||||
Reader showing PDF Reference document in spread mode (pages side by side)|![Reader showing PDF Reference document in spread mode (pages side by side)][SS20]
|
||||
Search through a document, showing all results in the sidebar|![Search through a document, showing all results in the sidebar][SS19]
|
||||
Dropdown showing page format options - spread, single page, page width and zoom options|![Dropdown showing page format options - spread, single page, page width and zoom options][SS21]
|
||||
Reader showing PDF in spread mode, thumbnails in the sidebar|![Reader showing PDF in spread mode, thumbnails in the sidebar][SS22]
|
||||
|
||||
|
||||
### CBR/CBZ
|
||||
| | |
|
||||
|
@ -101,6 +115,7 @@ The same Android device showing a zoomed-in part of a page|![The same Android de
|
|||
[Epub]: http://idpf.org/epub
|
||||
[CBR and CBZ]: https://wiki.mobileread.com/wiki/CBR_and_CBZ
|
||||
[balaclark]: https://github.com/balaclark/HTML5-Comic-Book-Reader
|
||||
[pdf.js]: https://github.com/mozilla/pdf.js
|
||||
[SS01]: https://raw.githubusercontent.com/Yetangitu/owncloud-apps/master/screenshots/files_reader-1.png "Reader showing day/nighyt mode"
|
||||
[SS02]: https://raw.githubusercontent.com/Yetangitu/owncloud-apps/master/screenshots/files_reader-3.png "Single page full screen on a small-screen device"
|
||||
[SS03]: https://raw.githubusercontent.com/Yetangitu/owncloud-apps/master/screenshots/photo_2017-03-15_17-21-39.jpg "Day mode color selector"
|
||||
|
@ -119,9 +134,13 @@ The same Android device showing a zoomed-in part of a page|![The same Android de
|
|||
[SS16]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/photo_2017-03-15_17-22-10.jpg?raw=true "Same page, zoomed in"
|
||||
[SS17]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/photo_2017-03-15_18-28-54.jpg?raw=true "Small-screen, low memory (Android) device showing full-page book cover"
|
||||
[SS18]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/photo_2017-03-15_18-28-56.jpg?raw=true "The same Android device showing a zoomed-in part of a page"
|
||||
[SS19]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/files_reader_PDF_001.png?raw=true "Search through a document, showing all results in the sidebar"
|
||||
[SS20]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/files_reader_PDF_002.png?raw=true "Reader showing PDF Reference document in spread mode (pages side by side)"
|
||||
[SS21]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/files_reader_PDF_005.png?raw=true "Dropdown showing page format options - spread, single page, page width and zoom options"
|
||||
[SS22]: https://github.com/Yetangitu/owncloud-apps/blob/master/screenshots/files_reader_PDF_006.png?raw=true "Reader showing PDF in spread mode, thumbnails in the sidebar"
|
||||
]]>
|
||||
</description>
|
||||
<version>1.0.1</version>
|
||||
<version>1.1</version>
|
||||
<licence>AGPL</licence>
|
||||
<author>Frank de Lange</author>
|
||||
<documentation>
|
||||
|
@ -140,8 +159,8 @@ The same Android device showing a zoomed-in part of a page|![The same Android de
|
|||
<filesystem/>
|
||||
</types>
|
||||
<dependencies>
|
||||
<owncloud min-version="8.1" max-version="9.2" />
|
||||
<nextcloud min-version="8.1" max-version="12"/>
|
||||
<owncloud min-version="8.1" max-version="10" />
|
||||
<nextcloud min-version="8.1" max-version="13"/>
|
||||
<database>pgsql</database>
|
||||
<database>sqlite</database>
|
||||
<database>mysql</database>
|
||||
|
|
|
@ -25,6 +25,8 @@ document.onreadystatechange = function () {
|
|||
options.session.basePath = $session.data('basepath');
|
||||
options.session.downloadLink = $session.data('downloadlink');
|
||||
|
||||
console.log(options.session.basePath);
|
||||
|
||||
|
||||
/* functions return jquery promises */
|
||||
options.session.getPreference = function(name) {
|
||||
|
@ -142,6 +144,7 @@ document.onreadystatechange = function () {
|
|||
// start pdf.js renderer
|
||||
function renderPdf(file, options) {
|
||||
PDFJS.filePath = "vendor/pdfjs/";
|
||||
PDFJS.imageResourcesPath = "vendor/pdfjs/css/images/";
|
||||
PDFJS.workerSrc = options.session.basePath + 'vendor/pdfjs/lib/pdf.worker.js';
|
||||
|
||||
var reader = pdfReader(file, options);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
?>
|
||||
|
||||
<html dir="ltr">
|
||||
<head class="session" data-nonce='<?php p($nonce);?>' data-downloadlink='<?php print_unescaped($downloadLink);?>' data-fileid='<?php print_unescaped($fileId);?>' data-filetype='<?php print_unescaped($fileType);?>' data-filename='<?php print_unescaped($fileName);?>' data-version='<?php print_unescaped($version);?>' data-basepath='<?php p($urlGenerator->linkTo('files_reader',''));?>' data-scope='<?php print_unescaped($scope);?>' data-cursor='<?php print_unescaped($cursor);?>' data-defaults='<?php print_unescaped($defaults);?>' data-preferences='<?php print_unescaped($preferences);?>' data-metadata='<?php print_unescaped($metadata);?>' data-annotations='<?php print_unescaped($annotations);?>'>
|
||||
<head class="session" data-nonce='<?php p($nonce);?>' data-downloadlink='<?php print_unescaped($downloadLink);?>' data-fileid='<?php print_unescaped($fileId);?>' data-filetype='<?php print_unescaped($fileType);?>' data-filename='<?php print_unescaped($fileName);?>' data-version='<?php print_unescaped($version);?>' data-basepath='<?php p($urlGenerator->linkTo("files_reader",""));?>' data-scope='<?php print_unescaped($scope);?>' data-cursor='<?php print_unescaped($cursor);?>' data-defaults='<?php print_unescaped($defaults);?>' data-preferences='<?php print_unescaped($preferences);?>' data-metadata='<?php print_unescaped($metadata);?>' data-annotations='<?php print_unescaped($annotations);?>'>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
?>
|
||||
|
||||
<html dir="ltr">
|
||||
<head class="session" data-nonce='<?php p($nonce);?>' data-downloadlink='<?php print_unescaped($downloadLink);?>' data-fileid='<?php print_unescaped($fileId);?>' data-filetype='<?php print_unescaped($fileType);?>' data-filename='<?php print_unescaped($fileName);?>' data-version='<?php print_unescaped($version);?>' data-basepath='<?php p($urlGenerator->linkTo('files_reader',''));?>' data-scope='<?php print_unescaped($scope);?>' data-cursor='<?php print_unescaped($cursor);?>' data-defaults='<?php print_unescaped($defaults);?>' data-preferences='<?php print_unescaped($preferences);?>' data-metadata='<?php print_unescaped($metadata);?>' data-annotations='<?php print_unescaped($annotations);?>'>
|
||||
<head class="session" data-nonce='<?php p($nonce);?>' data-downloadlink='<?php print_unescaped($downloadLink);?>' data-fileid='<?php print_unescaped($fileId);?>' data-filetype='<?php print_unescaped($fileType);?>' data-filename='<?php print_unescaped($fileName);?>' data-version='<?php print_unescaped($version);?>' data-basepath='<?php p($urlGenerator->linkTo("files_reader",""));?>' data-scope='<?php print_unescaped($scope);?>' data-cursor='<?php print_unescaped($cursor);?>' data-defaults='<?php print_unescaped($defaults);?>' data-preferences='<?php print_unescaped($preferences);?>' data-metadata='<?php print_unescaped($metadata);?>' data-annotations='<?php print_unescaped($annotations);?>'>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
?>
|
||||
|
||||
<html dir="ltr">
|
||||
<head class="session" data-nonce='<?php p($nonce);?>' data-downloadlink='<?php print_unescaped($downloadLink);?>' data-fileid='<?php print_unescaped($fileId);?>' data-filetype='<?php print_unescaped($fileType);?>' data-filename='<?php print_unescaped($fileName);?>' data-version='<?php print_unescaped($version);?>' data-basepath='<?php p($urlGenerator->linkTo('files_reader',''));?>' data-scope='<?php print_unescaped($scope);?>' data-cursor='<?php print_unescaped($cursor);?>' data-defaults='<?php print_unescaped($defaults);?>' data-preferences='<?php print_unescaped($preferences);?>' data-metadata='<?php print_unescaped($metadata);?>' data-annotations='<?php print_unescaped($annotations);?>'>
|
||||
<head class="session" data-nonce='<?php p($nonce);?>' data-downloadlink='<?php print_unescaped($downloadLink);?>' data-fileid='<?php print_unescaped($fileId);?>' data-filetype='<?php print_unescaped($fileType);?>' data-filename='<?php print_unescaped($fileName);?>' data-version='<?php print_unescaped($version);?>' data-basepath='<?php p($urlGenerator->linkTo("files_reader",""));?>' data-scope='<?php print_unescaped($scope);?>' data-cursor='<?php print_unescaped($cursor);?>' data-defaults='<?php print_unescaped($defaults);?>' data-preferences='<?php print_unescaped($preferences);?>' data-metadata='<?php print_unescaped($metadata);?>' data-annotations='<?php print_unescaped($annotations);?>'>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
|
@ -40,14 +40,17 @@
|
|||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/icomoon/style.css')) ?>?v=<?php p($version) ?>">
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/main.css')) ?>?v=<?php p($version) ?>">
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/sidebar.css')) ?>?v=<?php p($version) ?>">
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/popup.css')) ?>?v=<?php p($version) ?>">
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/text_layer_builder.css')) ?>?v=<?php p($version) ?>">
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/annotation_layer_builder.css')) ?>?v=<?php p($version) ?>">
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/epubjs/libs/jquery.min.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/bartaz/jquery.highlight.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/jquery/put-delete.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/sindresorhus/screenfull.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/lib/pdf.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/pdf.reader.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/services/eventbus_service.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/services/link_service.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/services/simple_link_service.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/progress_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/textlayer_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/search_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
|
@ -57,6 +60,9 @@
|
|||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/controls_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/toc_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/outline_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/annotationlayer_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/notes_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/controllers/bookmarks_controller.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
<?php if ($idevice): ?>
|
||||
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/idevice.css')) ?>?v=<?php p($version) ?>">
|
||||
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/bgrins/spectrum.js')) ?>?v=<?php p($version) ?>"> </script>
|
||||
|
@ -87,7 +93,9 @@
|
|||
<button id="show-Outline" class="show_view icon-format_list_numbered" title="Outline" data-view="Outline"></button>
|
||||
<button id="show-Bookmarks" class="show_view icon-turned_in" title="Bookmarks" data-view="Bookmarks"></button>
|
||||
<button id="show-Search" class="show_view icon-search" title="Search" data-view="Search"></button>
|
||||
<!-- notes not implemented yet
|
||||
<button id="show-Notes" class="show_view icon-comment" title="Notes" data-view="Notes"></button>
|
||||
-->
|
||||
<button id="show-Settings" class="show_view icon-settings" title="Settings" data-view="Settings"></button>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
|
@ -119,6 +127,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!-- notes not implemented yet
|
||||
<div id="notesView" class="notes-view view">
|
||||
<div>
|
||||
<div class="notes-input">
|
||||
|
@ -129,46 +138,9 @@
|
|||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<div id="settingsView" class="settings-view view">
|
||||
<fieldset class="settings-container" name="font-settings">
|
||||
<legend>font</legend>
|
||||
<div class="control-group">
|
||||
<div>
|
||||
<input type="checkbox" id="custom_font_family" name="font_family">
|
||||
<label for="custom_font_family">custom font</label>
|
||||
<select id="font_family" disabled="">
|
||||
<option value="verdana, trebuchet, droid sans serif, sans, sans-serif"> sans </option>
|
||||
<option value="georgia, times new roman, droid serif, serif"> serif </option>
|
||||
<option value="monospace"> monospace </option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="custom_font_size" name="font_size">
|
||||
<label for="custom_font_size">font size</label>
|
||||
<input type="number" id="font_size" value="100" min="50" max="150" disabled=""> %
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="custom_font_weight" name="font_weight">
|
||||
<label for="custom_font_weight">font weight</label>
|
||||
<select id="font_weight" disabled="">
|
||||
<option value="100">thin</option>
|
||||
<option value="200">extra light</option>
|
||||
<option value="300">light</option>
|
||||
<option value="400">normal</option>
|
||||
<option value="500">medium</option>
|
||||
<option value="600">semi-bold</option>
|
||||
<option value="700">bold</option>
|
||||
<option value="800">extra bold</option>
|
||||
<option value="900">black</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="font_example" class="user font_example">
|
||||
<div>
|
||||
Et nos esse veri viri scire volemus
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<!-- font settings not implemented yet
|
||||
<fieldset class="settings-container" name="colour-settings">
|
||||
<legend>colors</legend>
|
||||
<fieldset>
|
||||
|
@ -209,24 +181,9 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
-->
|
||||
<fieldset class="settings-container" name="display-settings">
|
||||
<legend>display</legend>
|
||||
<fieldset>
|
||||
<legend>page width</legend>
|
||||
<div class="control-group center-box">
|
||||
maximum <input type="number" id="page_width" value="72" min="25" max="200"> characters
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="maximize_page" name="maximize_page">
|
||||
<label for="custom_margins">maximize page area</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="sidebarReflow" name="sidebarReflow">
|
||||
<label for="sidebarReflow">
|
||||
reflow text when sidebars are open
|
||||
</label>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<input type="checkbox" id="touch_nav" name="touch_nav">
|
||||
<label for="touch_nav">
|
||||
|
@ -335,8 +292,12 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="viewer" class="flex">
|
||||
<canvas id="left" class="viewer"></canvas><div id="text_left" class="textLayer"></div>
|
||||
<canvas id="right" class="viewer"></canvas><div id="text_right" class="textLayer"></div>
|
||||
<canvas id="left" class="viewer"></canvas>
|
||||
<div id="text_left" class="textLayer"></div>
|
||||
<div id="annotations_left" class="annotationLayer"></div>
|
||||
<canvas id="right" class="viewer"></canvas>
|
||||
<div id="text_right" class="textLayer"></div>
|
||||
<div id="annotations_right" class="annotationLayer"></div>
|
||||
</div>
|
||||
<div id="next" class="arrow">
|
||||
<div class="translucent">
|
||||
|
|
BIN
files_reader/vendor/pdfjs/controllers/.bookmarks_controller.js.swp
vendored
Normal file
59
files_reader/vendor/pdfjs/controllers/annotationlayer_controller.js
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
PDFJS.Reader.AnnotationLayerController = function (options, reader) {
|
||||
|
||||
this.reader = reader;
|
||||
this.annotationDiv = options.annotationDiv;
|
||||
this.pdfPage = options.pdfPage;
|
||||
this.renderInteractiveForms = options.renderInteractiveForms;
|
||||
this.linkService = options.linkService;
|
||||
this.downloadManager = options.downloadManager;
|
||||
|
||||
this.div = null;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
PDFJS.Reader.AnnotationLayerController.prototype.render = function (viewport, intent) {
|
||||
var self = this;
|
||||
var parameters = {
|
||||
intent: (intent === undefined ? 'display' : intent),
|
||||
};
|
||||
|
||||
this.pdfPage.getAnnotations(parameters).then(function (annotations) {
|
||||
viewport = viewport.clone({ dontFlip: true });
|
||||
parameters = {
|
||||
viewport: viewport,
|
||||
div: self.div,
|
||||
annotations: annotations,
|
||||
page: self.pdfPage,
|
||||
renderInteractiveForms: self.renderInteractiveForms,
|
||||
linkService: self.linkService,
|
||||
downloadManager: self.downloadManager,
|
||||
};
|
||||
|
||||
if (self.div) {
|
||||
// If an annotationLayer already exists, refresh its children's
|
||||
// transformation matrices.
|
||||
PDFJS.AnnotationLayer.update(parameters);
|
||||
} else {
|
||||
// Create an annotation layer div and render the annotations
|
||||
// if there is at least one annotation.
|
||||
if (annotations.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.div = self.annotationDiv;
|
||||
parameters.div = self.div;
|
||||
|
||||
PDFJS.AnnotationLayer.render(parameters);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.AnnotationLayerController.prototype.hide = function () {
|
||||
|
||||
if (!this.div) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.div.setAttribute('hidden', 'true');
|
||||
};
|
|
@ -1,6 +1,7 @@
|
|||
PDFJS.reader.BookmarksController = function() {
|
||||
|
||||
var reader = this,
|
||||
eventBus = this.eventBus,
|
||||
book = this.book,
|
||||
annotations = reader.settings.annotations;
|
||||
|
||||
|
@ -18,6 +19,54 @@ PDFJS.reader.BookmarksController = function() {
|
|||
|
||||
var addBookmarkItem = function (bookmark) {
|
||||
$list.append(reader.NotesController.createItem(bookmark));
|
||||
reader.settings.session.setBookmark(bookmark.id, bookmark.anchor, bookmark.type, bookmark);
|
||||
};
|
||||
|
||||
var addBookmark = function (pageNum) {
|
||||
var bookmark = new reader.Annotation(
|
||||
"bookmark",
|
||||
pageNum,
|
||||
null,
|
||||
pageToId(pageNum)
|
||||
);
|
||||
|
||||
addBookmarkItem(bookmark);
|
||||
};
|
||||
|
||||
var removeBookmark = function (pageNum) {
|
||||
var id = pageToId(pageNum);
|
||||
console.log("ID", id);
|
||||
|
||||
if (isBookmarked(id)) {
|
||||
delete reader.settings.annotations[id];
|
||||
reader.settings.session.deleteBookmark(id);
|
||||
if (id === pageToId(reader.settings.currentPage)) {
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
eventBus.on('bookmarkremoved', function removeBookmark1(e) {
|
||||
var id = e.id,
|
||||
$item = $("#"+id);
|
||||
|
||||
$item.remove();
|
||||
|
||||
if (id === pageToId(reader.settings.currentPage)) {
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
}
|
||||
});
|
||||
|
||||
var pageToId = function (pageNum) {
|
||||
return "page_" + pageNum;
|
||||
};
|
||||
|
||||
var isBookmarked = function (pageNum) {
|
||||
return (reader.settings.annotations[pageToId(pageNum)] !== undefined);
|
||||
};
|
||||
|
||||
for (var bookmark in annotations) {
|
||||
|
@ -25,31 +74,13 @@ PDFJS.reader.BookmarksController = function() {
|
|||
addBookmarkItem(annotations[bookmark]);
|
||||
};
|
||||
|
||||
this.on("reader:bookmarkcreated", function (bookmark) {
|
||||
addBookmarkItem(bookmark);
|
||||
});
|
||||
|
||||
this.on("reader:bookmarkremoved", function (id) {
|
||||
var $item = $("#"+id),
|
||||
cfi = reader.book.getCurrentLocationCfi(),
|
||||
cfi_id = reader.cfiToId(cfi);
|
||||
|
||||
$item.remove();
|
||||
|
||||
if(cfi_id === id) {
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
}
|
||||
});
|
||||
|
||||
this.on("reader:gotobookmark", function (bookmark) {
|
||||
if (bookmark && bookmark.value)
|
||||
book.gotoCfi(bookmark.value);
|
||||
});
|
||||
|
||||
return {
|
||||
"show" : show,
|
||||
"hide" : hide
|
||||
"hide" : hide,
|
||||
"addItem" : addBookmarkItem,
|
||||
"addBookmark" : addBookmark,
|
||||
"removeBookmark" : removeBookmark,
|
||||
"pageToId" : pageToId,
|
||||
"isBookmarked" : isBookmarked
|
||||
};
|
||||
};
|
||||
|
|
|
@ -121,15 +121,16 @@ PDFJS.reader.ControlsController = function(book) {
|
|||
});
|
||||
|
||||
$bookmark.on("click", function() {
|
||||
var cfi = reader.book.getCurrentLocationCfi();
|
||||
var currentPage = reader.settings.currentPage,
|
||||
bmc = reader.BookmarksController;
|
||||
|
||||
if(!(reader.isBookmarked(cfi))) { //-- Add bookmark
|
||||
reader.addBookmark(cfi);
|
||||
if(!bmc.isBookmarked(currentPage)) { //-- Add bookmark
|
||||
bmc.addBookmark(currentPage);
|
||||
$bookmark
|
||||
.addClass("icon-turned_in")
|
||||
.removeClass("icon-turned_in_not");
|
||||
} else { //-- Remove Bookmark
|
||||
reader.removeBookmark(cfi);
|
||||
bmc.removeBookmark(currentPage);
|
||||
$bookmark
|
||||
.removeClass("icon-turned_in")
|
||||
.addClass("icon-turned_in_not");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
PDFJS.reader.NotesController = function() {
|
||||
PDFJS.reader.NotesController = function(book) {
|
||||
|
||||
var book = this.book,
|
||||
reader = this,
|
||||
|
@ -9,10 +9,10 @@ PDFJS.reader.NotesController = function() {
|
|||
$next = $("#next"),
|
||||
$prev = $("#prev"),
|
||||
$touch_nav = $("#touch_nav"),
|
||||
$viewer = $("#viewer"),
|
||||
annotations = reader.settings.annotations,
|
||||
renderer = book.renderer,
|
||||
popups = [],
|
||||
epubcfi = new PDFJS.EpubCFI();
|
||||
popups = [];
|
||||
|
||||
var show = function() {
|
||||
$notesView.addClass('open');
|
||||
|
@ -31,8 +31,8 @@ PDFJS.reader.NotesController = function() {
|
|||
var range,
|
||||
textNode,
|
||||
offset,
|
||||
doc = book.renderer.doc,
|
||||
cfi,
|
||||
doc = document,
|
||||
loc,
|
||||
annotation;
|
||||
|
||||
// standard
|
||||
|
@ -47,6 +47,9 @@ PDFJS.reader.NotesController = function() {
|
|||
offset = range.startOffset;
|
||||
}
|
||||
|
||||
console.log("textNode", textNode, "offset", offset);
|
||||
console.log(e);
|
||||
|
||||
if (textNode.nodeType !== 3) {
|
||||
for (var i=0; i < textNode.childNodes.length; i++) {
|
||||
if (textNode.childNodes[i].nodeType == 3) {
|
||||
|
@ -64,9 +67,9 @@ PDFJS.reader.NotesController = function() {
|
|||
offset += 1; // After the period
|
||||
}
|
||||
|
||||
cfi = epubcfi.generateCfiFromTextNode(textNode, offset, book.renderer.currentChapter.cfiBase);
|
||||
loc = "";
|
||||
|
||||
annotation = new reader.Annotation('annotation', cfi, $text.val());
|
||||
annotation = new reader.Annotation('annotation', loc, $text.val());
|
||||
|
||||
// save...
|
||||
reader.addAnnotation(annotation);
|
||||
|
@ -87,6 +90,16 @@ PDFJS.reader.NotesController = function() {
|
|||
|
||||
var addAnnotationItem = function(annotation) {
|
||||
$notes.append(createItem(annotation));
|
||||
reader.settings.session.setBookmark(annotation.id, annotation.anchor, annotation.type, annotation);
|
||||
};
|
||||
|
||||
var removeAnnotation = function (id) {
|
||||
|
||||
if (annotations[id] !== undefined) {
|
||||
deleteAnnotationItem(id);
|
||||
delete annotations[id];
|
||||
reader.settings.session.deleteBookmark(id);
|
||||
}
|
||||
};
|
||||
|
||||
var deleteAnnotationItem = function (id) {
|
||||
|
@ -133,24 +146,14 @@ PDFJS.reader.NotesController = function() {
|
|||
link.href = "#"+annotation.anchor;
|
||||
|
||||
link.onclick = function(){
|
||||
book.gotoCfi(annotation.anchor);
|
||||
reader.queuePage(annotation.anchor);
|
||||
return false;
|
||||
};
|
||||
|
||||
del.onclick = function() {
|
||||
var id = this.parentNode.parentNode.getAttribute("id");
|
||||
//var marker = book.renderer.doc.getElementById("note-" + id);
|
||||
// remove note from collection...
|
||||
//reader.removeAnnotation(id);
|
||||
// ... and remove the marker...
|
||||
//if (marker) {
|
||||
// marker.remove();
|
||||
// renumberMarkers();
|
||||
//}
|
||||
// ...and finally remove the HTML representation
|
||||
//this.parentNode.parentNode.remove();
|
||||
//renumberMarkers();
|
||||
reader.removeAnnotation(id);
|
||||
console.log("ID", id);
|
||||
removeAnnotation(id);
|
||||
};
|
||||
|
||||
save.onclick = function() {
|
||||
|
@ -241,7 +244,7 @@ PDFJS.reader.NotesController = function() {
|
|||
mark.innerHTML = findIndex(annotation.id) + "[Reader]";
|
||||
|
||||
marker.appendChild(mark);
|
||||
epubcfi.addMarker(annotation.anchor, doc, marker);
|
||||
// epubcfi.addMarker(annotation.anchor, doc, marker);
|
||||
|
||||
markerEvents(marker, annotation.body);
|
||||
renumberMarkers();
|
||||
|
@ -251,17 +254,17 @@ PDFJS.reader.NotesController = function() {
|
|||
for (var note in annotations) {
|
||||
if (annotations.hasOwnProperty(note)) {
|
||||
var chapter = renderer.currentChapter;
|
||||
var cfi = epubcfi.parse(annotations[note].anchor);
|
||||
if(cfi.spinePos === chapter.spinePos) {
|
||||
try {
|
||||
var marker = book.renderer.doc.getElementById("note-" + annotations[note].id);
|
||||
if (marker !== undefined) {
|
||||
marker.innerHTML = findIndex(annotations[note].id) + "[Reader]";
|
||||
}
|
||||
} catch(e) {
|
||||
console.log("renumbering of markers failed", annotations[note].anchor);
|
||||
}
|
||||
}
|
||||
// var cfi = epubcfi.parse(annotations[note].anchor);
|
||||
// if(cfi.spinePos === chapter.spinePos) {
|
||||
// try {
|
||||
// var marker = book.renderer.doc.getElementById("note-" + annotations[note].id);
|
||||
// if (marker !== undefined) {
|
||||
// marker.innerHTML = findIndex(annotations[note].id) + "[Reader]";
|
||||
// }
|
||||
// } catch(e) {
|
||||
// console.log("renumbering of markers failed", annotations[note].anchor);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -406,7 +409,7 @@ PDFJS.reader.NotesController = function() {
|
|||
$prev.addClass("restore_touch_nav");
|
||||
}
|
||||
// listen for selection
|
||||
book.on("renderer:click", insertAtPoint);
|
||||
$viewer.on("click", insertAtPoint);
|
||||
} else {
|
||||
$text.prop("disabled", false);
|
||||
$anchor.removeClass("icon-location_off");
|
||||
|
@ -416,7 +419,8 @@ PDFJS.reader.NotesController = function() {
|
|||
$prev.addClass("touch_nav");
|
||||
$next.addClass("touch_nav");
|
||||
}
|
||||
book.off("renderer:click", insertAtPoint);
|
||||
|
||||
$viewer.off("click", insertAtPoint);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -425,36 +429,11 @@ PDFJS.reader.NotesController = function() {
|
|||
addAnnotationItem(annotations[note]);
|
||||
};
|
||||
|
||||
this.on("reader:annotationcreated", function (note) {
|
||||
addAnnotationItem(note);
|
||||
});
|
||||
|
||||
this.on("reader:annotationremoved", function (id) {
|
||||
deleteAnnotationItem(id);
|
||||
});
|
||||
|
||||
// replace markers for annotations
|
||||
renderer.registerHook("beforeChapterDisplay", function(callback, renderer){
|
||||
var chapter = renderer.currentChapter;
|
||||
for (var note in annotations) {
|
||||
if (annotations.hasOwnProperty(note) && (annotations[note].type === "annotation")) {
|
||||
var cfi = epubcfi.parse(annotations[note].anchor);
|
||||
if(cfi.spinePos === chapter.spinePos) {
|
||||
try {
|
||||
placeMarker(annotations[note]);
|
||||
} catch(e) {
|
||||
console.log("anchoring failed", annotations[note].anchor);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
callback();
|
||||
}, true);
|
||||
|
||||
|
||||
return {
|
||||
"show" : show,
|
||||
"hide" : hide,
|
||||
"createItem": createItem
|
||||
"createItem": createItem,
|
||||
"addItem" : addAnnotationItem,
|
||||
"removeAnnotation" : removeAnnotation
|
||||
};
|
||||
};
|
||||
|
|
|
@ -464,6 +464,7 @@ PDFJS.reader.SearchController = function () {
|
|||
var root = document.getElementById("searchResults"),
|
||||
item,
|
||||
match,
|
||||
matchlist,
|
||||
i;
|
||||
|
||||
item = root.getElementsByClassName("selected");
|
||||
|
@ -472,12 +473,13 @@ PDFJS.reader.SearchController = function () {
|
|||
|
||||
match = document.getElementById("match:" + selected.pageIdx + ":" + selected.matchIdx);
|
||||
match.classList.add("selected");
|
||||
match = document.getElementsByClassName("match:" + selected.pageIdx + ":" + selected.matchIdx);
|
||||
for (i = 0; i < match.length; i++)
|
||||
match[i].classList.add("selected_again");
|
||||
|
||||
|
||||
updateMatchCounter(match.dataset.index);
|
||||
|
||||
//matchlist = document.getElementsByClassName("match:" + selected.pageIdx + ":" + selected.matchIdx);
|
||||
//for (i = 0; i < matchlist.length; i++)
|
||||
// matchlist[i].classList.add("selected_again");
|
||||
|
||||
if (!reader.isVisible(match))
|
||||
match.scrollIntoView();
|
||||
|
||||
|
|
153
files_reader/vendor/pdfjs/css/annotation_layer_builder.css
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
/* Copyright 2014 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
.annotationLayer {
|
||||
position: absolute;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.annotationLayer section {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.annotationLayer .linkAnnotation > a {
|
||||
position: absolute;
|
||||
font-size: 1em;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.annotationLayer .linkAnnotation > a /* -ms-a */ {
|
||||
background: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7") 0 0 repeat;
|
||||
}
|
||||
|
||||
.annotationLayer .linkAnnotation > a:hover {
|
||||
opacity: 0.2;
|
||||
background: #ff0;
|
||||
box-shadow: 0px 2px 10px #ff0;
|
||||
}
|
||||
|
||||
.annotationLayer .textAnnotation img {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input,
|
||||
.annotationLayer .textWidgetAnnotation textarea,
|
||||
.annotationLayer .choiceWidgetAnnotation select,
|
||||
.annotationLayer .buttonWidgetAnnotation.checkBox input,
|
||||
.annotationLayer .buttonWidgetAnnotation.radioButton input {
|
||||
background-color: rgba(0, 54, 255, 0.13);
|
||||
border: 1px solid transparent;
|
||||
box-sizing: border-box;
|
||||
font-size: 9px;
|
||||
height: 100%;
|
||||
padding: 0 3px;
|
||||
vertical-align: top;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation textarea {
|
||||
font: message-box;
|
||||
font-size: 9px;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input[disabled],
|
||||
.annotationLayer .textWidgetAnnotation textarea[disabled],
|
||||
.annotationLayer .choiceWidgetAnnotation select[disabled],
|
||||
.annotationLayer .buttonWidgetAnnotation.checkBox input[disabled],
|
||||
.annotationLayer .buttonWidgetAnnotation.radioButton input[disabled] {
|
||||
background: none;
|
||||
border: 1px solid transparent;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input:hover,
|
||||
.annotationLayer .textWidgetAnnotation textarea:hover,
|
||||
.annotationLayer .choiceWidgetAnnotation select:hover,
|
||||
.annotationLayer .buttonWidgetAnnotation.checkBox input:hover,
|
||||
.annotationLayer .buttonWidgetAnnotation.radioButton input:hover {
|
||||
border: 1px solid #000;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input:focus,
|
||||
.annotationLayer .textWidgetAnnotation textarea:focus,
|
||||
.annotationLayer .choiceWidgetAnnotation select:focus {
|
||||
background: none;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input.comb {
|
||||
font-family: monospace;
|
||||
padding-left: 2px;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input.comb:focus {
|
||||
/*
|
||||
* Letter spacing is placed on the right side of each character. Hence, the
|
||||
* letter spacing of the last character may be placed outside the visible
|
||||
* area, causing horizontal scrolling. We avoid this by extending the width
|
||||
* when the element has focus and revert this when it loses focus.
|
||||
*/
|
||||
width: 115%;
|
||||
}
|
||||
|
||||
.annotationLayer .buttonWidgetAnnotation.checkBox input,
|
||||
.annotationLayer .buttonWidgetAnnotation.radioButton input {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
-ms-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.annotationLayer .popupWrapper {
|
||||
position: absolute;
|
||||
width: 20em;
|
||||
}
|
||||
|
||||
.annotationLayer .popup {
|
||||
position: absolute;
|
||||
z-index: 200;
|
||||
max-width: 20em;
|
||||
background-color: #FFFF99;
|
||||
box-shadow: 0px 2px 5px #333;
|
||||
border-radius: 2px;
|
||||
padding: 0.6em;
|
||||
margin-left: 5px;
|
||||
cursor: pointer;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.annotationLayer .popup h1 {
|
||||
font-size: 1em;
|
||||
border-bottom: 1px solid #000000;
|
||||
padding-bottom: 0.2em;
|
||||
}
|
||||
|
||||
.annotationLayer .popup p {
|
||||
padding-top: 0.2em;
|
||||
}
|
||||
|
||||
.annotationLayer .highlightAnnotation,
|
||||
.annotationLayer .underlineAnnotation,
|
||||
.annotationLayer .squigglyAnnotation,
|
||||
.annotationLayer .strikeoutAnnotation,
|
||||
.annotationLayer .fileAttachmentAnnotation {
|
||||
cursor: pointer;
|
||||
}
|
11
files_reader/vendor/pdfjs/css/images/annotation-check.svg
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
<path
|
||||
d="M 1.5006714,23.536225 6.8925879,18.994244 14.585721,26.037937 34.019683,4.5410479 38.499329,9.2235032 14.585721,35.458952 z"
|
||||
id="path4"
|
||||
style="fill:#ffff00;fill-opacity:1;stroke:#000000;stroke-width:1.25402856;stroke-opacity:1" />
|
||||
</svg>
|
After Width: | Height: | Size: 415 B |
16
files_reader/vendor/pdfjs/css/images/annotation-comment.svg
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
height="40"
|
||||
width="40"
|
||||
viewBox="0 0 40 40">
|
||||
<rect
|
||||
style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
width="33.76017"
|
||||
height="33.76017"
|
||||
x="3.119915"
|
||||
y="3.119915" />
|
||||
<path
|
||||
d="m 20.677967,8.54499 c -7.342801,0 -13.295293,4.954293 -13.295293,11.065751 0,2.088793 0.3647173,3.484376 1.575539,5.150563 L 6.0267418,31.45501 13.560595,29.011117 c 2.221262,1.387962 4.125932,1.665377 7.117372,1.665377 7.3428,0 13.295291,-4.954295 13.295291,-11.065753 0,-6.111458 -5.952491,-11.065751 -13.295291,-11.065751 z"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.93031836;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"/>
|
||||
</svg>
|
After Width: | Height: | Size: 883 B |
26
files_reader/vendor/pdfjs/css/images/annotation-help.svg
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
<g
|
||||
transform="translate(0,-60)"
|
||||
id="layer1">
|
||||
<rect
|
||||
width="36.460953"
|
||||
height="34.805603"
|
||||
x="1.7695236"
|
||||
y="62.597198"
|
||||
style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.30826771;stroke-opacity:1" />
|
||||
<g
|
||||
transform="matrix(0.88763677,0,0,0.88763677,2.2472646,8.9890584)">
|
||||
<path
|
||||
d="M 20,64.526342 C 11.454135,64.526342 4.5263421,71.454135 4.5263421,80 4.5263421,88.545865 11.454135,95.473658 20,95.473658 28.545865,95.473658 35.473658,88.545865 35.473658,80 35.473658,71.454135 28.545865,64.526342 20,64.526342 z m -0.408738,9.488564 c 3.527079,0 6.393832,2.84061 6.393832,6.335441 0,3.494831 -2.866753,6.335441 -6.393832,6.335441 -3.527079,0 -6.393832,-2.84061 -6.393832,-6.335441 0,-3.494831 2.866753,-6.335441 6.393832,-6.335441 z"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.02768445;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
<path
|
||||
d="m 7.2335209,71.819938 4.9702591,4.161823 c -1.679956,2.581606 -1.443939,6.069592 0.159325,8.677725 l -5.1263071,3.424463 c 0.67516,1.231452 3.0166401,3.547686 4.2331971,4.194757 l 3.907728,-4.567277 c 2.541952,1.45975 5.730694,1.392161 8.438683,-0.12614 l 3.469517,6.108336 c 1.129779,-0.44367 4.742234,-3.449633 5.416358,-5.003859 l -5.46204,-4.415541 c 1.44319,-2.424098 1.651175,-5.267515 0.557303,-7.748623 l 5.903195,-3.833951 C 33.14257,71.704996 30.616217,69.018606 29.02952,67.99296 l -4.118813,4.981678 C 22.411934,71.205099 18.900853,70.937534 16.041319,72.32916 l -3.595408,-5.322091 c -1.345962,0.579488 -4.1293881,2.921233 -5.2123901,4.812869 z m 8.1010311,3.426672 c 2.75284,-2.446266 6.769149,-2.144694 9.048998,0.420874 2.279848,2.56557 2.113919,6.596919 -0.638924,9.043185 -2.752841,2.446267 -6.775754,2.13726 -9.055604,-0.428308 -2.279851,-2.565568 -2.107313,-6.589485 0.64553,-9.035751 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
10
files_reader/vendor/pdfjs/css/images/annotation-insert.svg
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64">
|
||||
<path
|
||||
d="M 32.003143,1.4044602 57.432701,62.632577 6.5672991,62.627924 z"
|
||||
style="fill:#ffff00;fill-opacity:0.94117647;fill-rule:nonzero;stroke:#000000;stroke-width:1.00493038;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
</svg>
|
After Width: | Height: | Size: 408 B |
11
files_reader/vendor/pdfjs/css/images/annotation-key.svg
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64">
|
||||
<path
|
||||
d="M 25.470843,9.4933766 C 25.30219,12.141818 30.139101,14.445969 34.704831,13.529144 40.62635,12.541995 41.398833,7.3856498 35.97505,5.777863 31.400921,4.1549155 25.157674,6.5445892 25.470843,9.4933766 z M 4.5246282,17.652051 C 4.068249,11.832873 9.2742983,5.9270407 18.437379,3.0977088 29.751911,-0.87185184 45.495663,1.4008022 53.603953,7.1104009 c 9.275765,6.1889221 7.158128,16.2079421 -3.171076,21.5939521 -1.784316,1.635815 -6.380222,1.21421 -7.068351,3.186186 -1.04003,0.972427 -1.288046,2.050158 -1.232864,3.168203 1.015111,2.000108 -3.831548,1.633216 -3.270553,3.759574 0.589477,5.264544 -0.179276,10.53738 -0.362842,15.806257 -0.492006,2.184998 1.163456,4.574232 -0.734888,6.610642 -2.482919,2.325184 -7.30604,2.189143 -9.193497,-0.274767 -2.733688,-1.740626 -8.254447,-3.615254 -6.104247,-6.339626 3.468112,-1.708686 -2.116197,-3.449897 0.431242,-5.080274 5.058402,-1.39256 -2.393215,-2.304318 -0.146889,-4.334645 3.069198,-0.977415 2.056986,-2.518352 -0.219121,-3.540397 1.876567,-1.807151 1.484149,-4.868919 -2.565455,-5.942205 0.150866,-1.805474 2.905737,-4.136876 -1.679967,-5.20493 C 10.260902,27.882167 4.6872697,22.95045 4.5245945,17.652051 z"
|
||||
id="path604"
|
||||
style="fill:#ffff00;fill-opacity:1;stroke:#000000;stroke-width:1.72665179;stroke-opacity:1" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
11
files_reader/vendor/pdfjs/css/images/annotation-newparagraph.svg
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64">
|
||||
<path
|
||||
d="M 32.003143,10.913072 57.432701,53.086929 6.567299,53.083723 z"
|
||||
id="path2985"
|
||||
style="fill:#ffff00;fill-opacity:0.94117647;fill-rule:nonzero;stroke:#000000;stroke-width:0.83403099;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
</svg>
|
After Width: | Height: | Size: 426 B |
7
files_reader/vendor/pdfjs/css/images/annotation-noicon.svg
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
</svg>
|
After Width: | Height: | Size: 158 B |
42
files_reader/vendor/pdfjs/css/images/annotation-note.svg
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
<rect
|
||||
width="36.075428"
|
||||
height="31.096582"
|
||||
x="1.962286"
|
||||
y="4.4517088"
|
||||
id="rect4"
|
||||
style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.23004246;stroke-opacity:1" />
|
||||
<rect
|
||||
width="27.96859"
|
||||
height="1.5012145"
|
||||
x="6.0157046"
|
||||
y="10.285"
|
||||
id="rect6"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
<rect
|
||||
width="27.96859"
|
||||
height="0.85783684"
|
||||
x="6.0157056"
|
||||
y="23.21689"
|
||||
id="rect8"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
<rect
|
||||
width="27.96859"
|
||||
height="0.85783684"
|
||||
x="5.8130345"
|
||||
y="28.964394"
|
||||
id="rect10"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
<rect
|
||||
width="27.96859"
|
||||
height="0.85783684"
|
||||
x="6.0157046"
|
||||
y="17.426493"
|
||||
id="rect12"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
</svg>
|
After Width: | Height: | Size: 1 KiB |
16
files_reader/vendor/pdfjs/css/images/annotation-paragraph.svg
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
<rect
|
||||
width="33.76017"
|
||||
height="33.76017"
|
||||
x="3.119915"
|
||||
y="3.119915"
|
||||
style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
<path
|
||||
d="m 17.692678,34.50206 0,-16.182224 c -1.930515,-0.103225 -3.455824,-0.730383 -4.57593,-1.881473 -1.12011,-1.151067 -1.680164,-2.619596 -1.680164,-4.405591 0,-1.992435 0.621995,-3.5796849 1.865988,-4.7617553 1.243989,-1.1820288 3.06352,-1.7730536 5.458598,-1.7730764 l 9.802246,0 0,2.6789711 -2.229895,0 0,26.3251486 -2.632515,0 0,-26.3251486 -3.45324,0 0,26.3251486 z"
|
||||
style="font-size:29.42051125px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.07795751;stroke-opacity:1;font-family:Arial;-inkscape-font-specification:Arial" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
2
files_reader/vendor/pdfjs/css/sidebar.css
vendored
|
@ -62,7 +62,7 @@
|
|||
/* font-size: 1em; */
|
||||
padding: 0.4em 0.2em;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
/* height: 100%; */
|
||||
}
|
||||
|
||||
.mobile .sidebar div > button {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
overflow: hidden;
|
||||
/* overflow: hidden; */
|
||||
opacity: 0.2;
|
||||
line-height: 1.0;
|
||||
}
|
||||
|
|
387
files_reader/vendor/pdfjs/pdf.reader.js
vendored
|
@ -41,6 +41,8 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
canvasLimit: 0,
|
||||
cssZoomOnly: false, // true || false, only zoom using CSS, render document at 100% size
|
||||
textSelect: true, // true || false, add selectable text layer
|
||||
annotationLayer: true, // true || false. show PDF annotations
|
||||
mergeAnnotations: true,// true || false, merge PDF annotations into bookmarks/annotations
|
||||
doubleBuffer: true, // true || false, draw to off-screen canvas
|
||||
cacheNext: true, // true || false, pre-render next page (by creathing thumbnail))
|
||||
numPages: 0,
|
||||
|
@ -86,9 +88,26 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
annotations: {},
|
||||
customStyles: {},
|
||||
activeStyles: {},
|
||||
session: {}
|
||||
session: {
|
||||
getCursor: function() {},
|
||||
setCursor: function(value) {},
|
||||
getBookmark: function(name, type) {},
|
||||
setBookmark: function(name, value, type, content) {},
|
||||
getDefault: function(name) {},
|
||||
setDefault: function(name, value) {},
|
||||
getPreference: function(name) {},
|
||||
setPreference: function(name, value) {}
|
||||
}
|
||||
});
|
||||
|
||||
// event bus service
|
||||
var eventBus = new PDFJS.Reader.EventBus();
|
||||
this.eventBus = eventBus;
|
||||
|
||||
// link service
|
||||
var linkService = new PDFJS.Reader.LinkService( { eventBus: this.eventBus }, reader);
|
||||
this.linkService = linkService;
|
||||
|
||||
// used for annotations and bookmarks
|
||||
this.Annotation = function (type, anchor, body, id) {
|
||||
this.id = id || PDFJS.core.uuid();
|
||||
|
@ -112,7 +131,9 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
canvas: document.getElementById("left"),
|
||||
ctx: document.getElementById("left").getContext('2d'),
|
||||
textdiv: document.getElementById("text_left"),
|
||||
annotationdiv: document.getElementById("annotations_left"),
|
||||
textLayer: null,
|
||||
annotationLayer: null,
|
||||
renderTask: null,
|
||||
oscanvas: null,
|
||||
osctx: null,
|
||||
|
@ -122,7 +143,9 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
canvas: document.getElementById("right"),
|
||||
ctx: document.getElementById("right").getContext('2d'),
|
||||
textdiv: document.getElementById("text_right"),
|
||||
annotationdiv: document.getElementById("annotations_right"),
|
||||
textLayer: null,
|
||||
annotationLayer: null,
|
||||
renderTask: null,
|
||||
oscanvas: null,
|
||||
osctx: null,
|
||||
|
@ -194,74 +217,127 @@ PDFJS.Reader = function(bookPath, _options) {
|
|||
reader.ProgressController.setProgress(progress);
|
||||
};
|
||||
|
||||
loadingTask.then(
|
||||
loadingTask.then(
|
||||
|
||||
function(_book) {
|
||||
reader.book = book = _book;
|
||||
//console.log(book);
|
||||
reader.settings.numPages = reader.book.numPages;
|
||||
document.getElementById('total_pages').textContent = reader.settings.numPages;
|
||||
if(!$.isEmptyObject(reader.settings.session.cursor)) {
|
||||
console.log("setting cursor:", reader.settings.session.cursor);
|
||||
reader.settings.currentPage = parseInt(reader.settings.session.cursor.anchor);
|
||||
function(_book) {
|
||||
reader.book = book = _book;
|
||||
//console.log(book);
|
||||
reader.settings.numPages = reader.book.numPages;
|
||||
document.getElementById('total_pages').textContent = reader.settings.numPages;
|
||||
console.log(reader.settings);
|
||||
console.log("numPages",reader.settings.numPages);
|
||||
console.log("cursor",reader.settings.session.cursor);
|
||||
if(!$.isEmptyObject(reader.settings.session.cursor)
|
||||
&& (reader.settings.session.cursor.value !== null)
|
||||
&& (reader.settings.session.cursor.value < reader.settings.numPages)) {
|
||||
console.log("setting cursor:", reader.settings.session.cursor);
|
||||
reader.settings.currentPage = parseInt(reader.settings.session.cursor.value);
|
||||
}
|
||||
|
||||
var firstPagePromise = book.getPage(1);
|
||||
reader.firstPagePromise = firstPagePromise;
|
||||
|
||||
reader.linkService.setDocument(book, location.href.split('#')[0]);
|
||||
|
||||
// set labels
|
||||
reader.book.getPageLabels().then(function (labels) {
|
||||
if (labels) {
|
||||
for (var i = 0; i < labels.length; i++) {
|
||||
if (labels[i] !== (i + 1).toString()) {
|
||||
reader.pageLabels[i + 1] = labels[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
reader.ReaderController = PDFJS.reader.ReaderController.call(reader, book);
|
||||
reader.SettingsController = PDFJS.reader.SettingsController.call(reader, book);
|
||||
reader.ControlsController = PDFJS.reader.ControlsController.call(reader, book);
|
||||
reader.SidebarController = PDFJS.reader.SidebarController.call(reader, book);
|
||||
|
||||
reader.queuePage(reader.settings.currentPage);
|
||||
reader.ReaderController.hideLoader();
|
||||
reader.ProgressController.hide();
|
||||
|
||||
reader.book.getOutline().then(function (outline) {
|
||||
reader.OutlineController = PDFJS.reader.OutlineController.call(reader, outline);
|
||||
});
|
||||
reader.book.getMetadata().then(function (metadata) {
|
||||
console.log("metadata", metadata);
|
||||
reader.settings.pdfMetadata = metadata;
|
||||
});
|
||||
reader.book.getAttachments().then(function (attachments) {
|
||||
console.log("attachments", attachments);
|
||||
});
|
||||
|
||||
reader.book.getStats().then(function (stats) {
|
||||
console.log("stats", stats);
|
||||
});
|
||||
|
||||
// BookmarksController depends on NotesController so load NotesController first
|
||||
reader.NotesController = PDFJS.reader.NotesController.call(reader, book);
|
||||
reader.BookmarksController = PDFJS.reader.BookmarksController.call(reader, book);
|
||||
|
||||
if (reader.settings.mergeAnnotations) {
|
||||
reader.firstPagePromise.then(function() {
|
||||
var numPages = reader.settings.numPages;
|
||||
|
||||
function extractAnnotations(pageIndex) {
|
||||
reader.book.getPage(pageIndex).then(function(page) {
|
||||
page.getAnnotations().then(function(annotations) {
|
||||
if (annotations.length > 0) {
|
||||
for (var annotation in annotations) {
|
||||
if (annotations.hasOwnProperty(annotation) && !annotations[annotation].parentId) {
|
||||
var ann = annotations[annotation],
|
||||
type = (ann.contents && ann.contents !== "") ? "annotation" : "bookmark",
|
||||
item;
|
||||
|
||||
item = new reader.Annotation(
|
||||
type,
|
||||
pageIndex,
|
||||
ann.contents,
|
||||
ann.id || PDFJS.core.uuid()
|
||||
);
|
||||
console.log(ann);
|
||||
|
||||
if (type === "annotation") {
|
||||
reader.NotesController.addItem(item);
|
||||
} else {
|
||||
reader.BookmarksController.addItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if ((pageIndex + 1) <= reader.settings.numPages) {
|
||||
extractAnnotations(pageIndex + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
extractAnnotations(1);
|
||||
});
|
||||
}
|
||||
|
||||
var firstPagePromise = book.getPage(1);
|
||||
reader.firstPagePromise = firstPagePromise;
|
||||
reader.SearchController = PDFJS.reader.SearchController.call(reader, book);
|
||||
//reader.MetaController = PDFJS.reader.MetaController.call(reader, meta);
|
||||
reader.TocController = PDFJS.reader.TocController.call(reader, book);
|
||||
},
|
||||
function getDocumentError(exception) {
|
||||
var message = exception && exception.message;
|
||||
var errormsg = "An error occurred while loading the PDF";
|
||||
if (exception instanceof PDFJS.InvalidPDFException) {
|
||||
errormsg = "Invalid or corrupted PDF file";
|
||||
} else if (exception instanceof PDFJS.MissingPDFException) {
|
||||
errormsg = "Missing PDF file";
|
||||
} else if (exception instanceof PDFJS.UnexpectedResponseException) {
|
||||
errormsg = "Unexpected server response";
|
||||
}
|
||||
|
||||
// set labels
|
||||
reader.book.getPageLabels().then(function (labels) {
|
||||
if (labels) {
|
||||
for (var i = 0; i < labels.length; i++) {
|
||||
if (labels[i] !== (i + 1).toString()) {
|
||||
reader.pageLabels[i + 1] = labels[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
reader.ReaderController = PDFJS.reader.ReaderController.call(reader, book);
|
||||
reader.SettingsController = PDFJS.reader.SettingsController.call(reader, book);
|
||||
reader.ControlsController = PDFJS.reader.ControlsController.call(reader, book);
|
||||
reader.SidebarController = PDFJS.reader.SidebarController.call(reader, book);
|
||||
|
||||
reader.queuePage(reader.settings.currentPage);
|
||||
reader.ReaderController.hideLoader();
|
||||
reader.ProgressController.hide();
|
||||
|
||||
reader.book.getOutline().then(function (outline) {
|
||||
reader.OutlineController = PDFJS.reader.OutlineController.call(reader, outline);
|
||||
});
|
||||
reader.book.getMetadata().then(function (metadata) {
|
||||
console.log("metadata", metadata);
|
||||
reader.settings.pdfMetadata = metadata;
|
||||
});
|
||||
reader.book.getAttachments().then(function (attachments) {
|
||||
console.log("attachments", attachments);
|
||||
});
|
||||
|
||||
// BookmarksController depends on NotesController so load NotesController first
|
||||
//reader.NotesController = PDFJS.reader.NotesController.call(reader, book);
|
||||
//reader.BookmarksController = PDFJS.reader.BookmarksController.call(reader, book);
|
||||
reader.SearchController = PDFJS.reader.SearchController.call(reader, book);
|
||||
//reader.MetaController = PDFJS.reader.MetaController.call(reader, meta);
|
||||
reader.TocController = PDFJS.reader.TocController.call(reader, book);
|
||||
},
|
||||
function getDocumentError(exception) {
|
||||
var message = exception && exception.message;
|
||||
var errormsg = "An error occurred while loading the PDF";
|
||||
if (exception instanceof PDFJS.InvalidPDFException) {
|
||||
errormsg = "Invalid or corrupted PDF file";
|
||||
} else if (exception instanceof PDFJS.MissingPDFException) {
|
||||
errormsg = "Missing PDF file";
|
||||
} else if (exception instanceof PDFJS.UnexpectedResponseException) {
|
||||
errormsg = "Unexpected server response";
|
||||
}
|
||||
|
||||
console.log("Reader: ", errormsg);
|
||||
reader.ProgressController.setMessage(errormsg, "download", "error");
|
||||
}
|
||||
);
|
||||
console.log("Reader: ", errormsg);
|
||||
reader.ProgressController.setMessage(errormsg, "download", "error");
|
||||
}
|
||||
);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
@ -395,6 +471,10 @@ PDFJS.Reader.prototype.cancelRender = function (index) {
|
|||
resourcelst.textLayer.cancel();
|
||||
resourcelst.textLayer = null;
|
||||
}
|
||||
|
||||
if (resourcelst.annotationLayer) {
|
||||
resourcelst.annotationLayer = null;
|
||||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
||||
|
@ -408,6 +488,7 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
oscanvas, // off-screen canvas
|
||||
osctx, // off-screen context
|
||||
textdiv,
|
||||
annotationdiv,
|
||||
textLayer,
|
||||
outputscale,
|
||||
max_view_width,
|
||||
|
@ -431,15 +512,17 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
resourcelst,
|
||||
swap_orientation,
|
||||
double_buffer,
|
||||
cache_next;
|
||||
cache_next,
|
||||
pageShift;
|
||||
|
||||
max_view_width = window.innerWidth;
|
||||
max_view_height = window.innerHeight;
|
||||
|
||||
if (this.settings.zoomLevel === "spread") {
|
||||
|
||||
// show second canvas
|
||||
// show second canvas and textlayer
|
||||
reader.resourcelst[1].canvas.style.display = "block";
|
||||
reader.resourcelst[1].textdiv.style.display = "block";
|
||||
max_view_width /= 2;
|
||||
// select canvas and ctx based on pageNum, pageShift and oddPageRight
|
||||
pageShift = 2;
|
||||
|
@ -449,10 +532,15 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
} else {
|
||||
|
||||
index = 0;
|
||||
pageShift = 1;
|
||||
// hide second canvas
|
||||
reader.resourcelst[1].canvas.style.display = "none";
|
||||
// hide second text layer
|
||||
reader.resourcelst[1].textdiv.style.display = "none";
|
||||
// clear text layer
|
||||
reader.resourcelst[1].textdiv.innerHTML = "";
|
||||
// clear annotation layer
|
||||
reader.resourcelst[1].annotationdiv.innerHTML = "";
|
||||
// clear page number
|
||||
reader.resourcelst[1].pageNum = null;
|
||||
|
||||
|
@ -468,12 +556,14 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
canvas = resourcelst.canvas;
|
||||
ctx = resourcelst.ctx;
|
||||
textdiv = resourcelst.textdiv;
|
||||
annotationdiv = resourcelst.annotationdiv;
|
||||
outputscale = reader.getOutputScale(resourcelst.ctx);
|
||||
fraction = reader.approximateFraction(outputscale);
|
||||
double_buffer = reader.settings.doubleBuffer;
|
||||
cache_next = reader.settings.cacheNext;
|
||||
|
||||
textdiv.innerHTML = "";
|
||||
annotationdiv.innerHTML = "";
|
||||
|
||||
if (pageNum <= this.settings.numPages && pageNum >= 1) {
|
||||
|
||||
|
@ -487,12 +577,20 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
resourcelst.textLayer = null;
|
||||
}
|
||||
|
||||
if (resourcelst.annotationLayer) {
|
||||
//resourcelst.annotationLayer.hide();
|
||||
resourcelst.annotationLayer = null;
|
||||
}
|
||||
|
||||
resourcelst.pageNum = pageNum;
|
||||
|
||||
if (reader.cancelPage[pageNum])
|
||||
delete reader.cancelPage[pageNum];
|
||||
|
||||
this.book.getPage(pageNum).then(function(page) {
|
||||
page.getAnnotations().then(function (annotations) {
|
||||
console.log("annotations", annotations);
|
||||
});
|
||||
//console.log(page);
|
||||
page_rotation = page.rotate;
|
||||
rotation = (page_rotation + reader.settings.rotation) % 360;
|
||||
|
@ -576,9 +674,6 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
}
|
||||
}
|
||||
|
||||
//console.log("outputscale: " + outputscale);
|
||||
//console.log("canvas w x h: " + canvas.width + " x " + canvas.height);
|
||||
|
||||
transform = (outputscale === 1)
|
||||
? null
|
||||
: [outputscale, 0, 0, outputscale, 0, 0];
|
||||
|
@ -595,7 +690,7 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
/* textlayer */
|
||||
if (reader.settings.textSelect) {
|
||||
textdiv.style.width = reader.roundToDivide(viewport.width, fraction[1]) + 'px';
|
||||
textdiv.style.height = reader.roundToDivide(viewport.height, fraction[1]) + 'px';
|
||||
textdiv.style.height = 0;
|
||||
offset = $(canvas).offset();
|
||||
$(textdiv).offset({
|
||||
top: offset.top,
|
||||
|
@ -613,9 +708,29 @@ PDFJS.Reader.prototype.renderPage = function(pageNum) {
|
|||
} else {
|
||||
resourcelst.textLayer = textLayer = null;
|
||||
}
|
||||
|
||||
/* /textLayer */
|
||||
|
||||
/* annotationLayer */
|
||||
if (reader.settings.annotationLayer) {
|
||||
annotationdiv.style.width = reader.roundToDivide(viewport.width, fraction[1]) + 'px';
|
||||
//annotationdiv.style.height = reader.roundToDivide(viewport.height, fraction[1]) + 'px';
|
||||
annotationdiv.style.height = 0;
|
||||
offset = $(canvas).offset();
|
||||
$(annotationdiv).offset({
|
||||
top: offset.top,
|
||||
left: offset.left
|
||||
});
|
||||
resourcelst.annotationLayer = new PDFJS.Reader.AnnotationLayerController({
|
||||
annotationDiv: annotationdiv,
|
||||
pdfPage: page,
|
||||
renderInteractiveForms: false,
|
||||
linkService: reader.linkService,
|
||||
downloadManager: null
|
||||
}, reader);
|
||||
resourcelst.annotationLayer.render(viewport, 'display');
|
||||
}
|
||||
/* /annotationLayer */
|
||||
|
||||
if (double_buffer) {
|
||||
resourcelst.oscanvas = oscanvas = document.createElement("canvas");
|
||||
resourcelst.osctx = context = osctx = oscanvas.getContext('2d');
|
||||
|
@ -688,6 +803,7 @@ PDFJS.Reader.prototype.queuePage = function(page) {
|
|||
reader.settings.currentPage = page;
|
||||
|
||||
reader.ControlsController.setCurrentPage(page);
|
||||
reader.settings.session.setCursor(page);
|
||||
|
||||
if (typeof reader.renderQueue === 'number') {
|
||||
window.clearTimeout(reader.renderQueue);
|
||||
|
@ -843,104 +959,6 @@ PDFJS.Reader.prototype.getPageLabel = function (page) {
|
|||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.navigateTo = function (destination) {
|
||||
|
||||
var reader = this,
|
||||
destString = "",
|
||||
destinationPromise,
|
||||
goToDestination;
|
||||
|
||||
goToDestination = function (destRef) {
|
||||
|
||||
var pageNumber;
|
||||
|
||||
if (destRef instanceof Object) {
|
||||
|
||||
pageNumber = reader.cachedPageNum(destRef);
|
||||
} else if ((destRef | 0) === destRef) { // Integer
|
||||
pageNumber = destRef + 1;
|
||||
} else {
|
||||
console.error('PDFJS.Reader.navigateTo: "' + destRef
|
||||
+ '" is not a valid destination reference.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (pageNumber) {
|
||||
|
||||
if (pageNumber < 1 || pageNumber > reader.settings.numPages) {
|
||||
console.error('PDFJS.Reader.navigateTo: "' + pageNumber
|
||||
+ '" is a non-existent page number.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
reader.queuePage(pageNumber);
|
||||
|
||||
} else {
|
||||
|
||||
reader.book.getPageIndex(destRef).then(function (pageIndex) {
|
||||
|
||||
reader.cachePageRef(pageIndex + 1, destRef);
|
||||
goToDestination(destRef);
|
||||
}).catch(function () {
|
||||
console.error('PDFJS.Reader.navigateTo: "' + destRef
|
||||
+ '" is not a valid page reference.');
|
||||
|
||||
return;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof destination === 'string') {
|
||||
|
||||
destString = destination;
|
||||
destinationPromise = reader.book.getDestination(destination);
|
||||
|
||||
} else {
|
||||
|
||||
destinationPromise = Promise.resolve(destination);
|
||||
|
||||
}
|
||||
|
||||
destinationPromise.then(function (_destination) {
|
||||
|
||||
destination = _destination;
|
||||
|
||||
if (!(destination instanceof Array)) {
|
||||
|
||||
console.error('PDFJS.Reader.navigateTo: "' + destination
|
||||
+ '" is not a valid destination array.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
goToDestination(destination[0]);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.pageRefStr = function (pageRef) {
|
||||
|
||||
return pageRef.num + ' ' + pageRef.gen + ' R';
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.cachePageRef = function (pageNum, pageRef) {
|
||||
|
||||
var reader = this,
|
||||
refStr;
|
||||
|
||||
reader.pageRefs[reader.pageRefStr(pageRef)] = pageNum;
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.cachedPageNum = function (pageRef) {
|
||||
|
||||
var reader = this;
|
||||
|
||||
return (reader.pageRefs[reader.pageRefStr(pageRef)])
|
||||
|| null;
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.getPageTextContent = function (pageIndex) {
|
||||
|
||||
var reader = this,
|
||||
|
@ -953,28 +971,6 @@ PDFJS.Reader.prototype.getPageTextContent = function (pageIndex) {
|
|||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.getDestinationHash = function (destination) {
|
||||
|
||||
var url = location.href.split('#')[0],
|
||||
str;
|
||||
|
||||
if (typeof destination === 'string') {
|
||||
|
||||
url += "#"
|
||||
+ (parseInt(destination) === destination)
|
||||
? "nameddest="
|
||||
: ""
|
||||
+ escape(destination);
|
||||
|
||||
} else if (destination instanceof Array) {
|
||||
|
||||
url += "#"
|
||||
+ escape(JSON.stringify(destination));
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
PDFJS.Reader.prototype.setStyles = function (element, item) {
|
||||
|
||||
var styleStr = "";
|
||||
|
@ -996,6 +992,7 @@ PDFJS.Reader.prototype.setStyles = function (element, item) {
|
|||
PDFJS.Reader.prototype.bindLink = function (element, item) {
|
||||
|
||||
var reader = this,
|
||||
linkService = this.linkService,
|
||||
destination = item.dest;
|
||||
|
||||
if (item.url) {
|
||||
|
@ -1010,10 +1007,12 @@ PDFJS.Reader.prototype.bindLink = function (element, item) {
|
|||
return;
|
||||
} else {
|
||||
|
||||
element.href = reader.getDestinationHash(destination);
|
||||
//element.href = reader.getDestinationHash(destination);
|
||||
element.href = linkService.getDestinationHash(destination);
|
||||
element.onclick = function () {
|
||||
if (destination) {
|
||||
reader.navigateTo(destination);
|
||||
//reader._navigateTo(destination);
|
||||
linkService.navigateTo(destination);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
39
files_reader/vendor/pdfjs/services/eventbus_service.js
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
PDFJS.Reader.EventBus = function () {
|
||||
|
||||
this._listeners = Object.create(null);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
PDFJS.Reader.EventBus.prototype.on = function (eventName, listener) {
|
||||
var eventListeners = this._listeners[eventName];
|
||||
if (!eventListeners) {
|
||||
eventListeners = [];
|
||||
this._listeners[eventName] = eventListeners;
|
||||
}
|
||||
eventListeners.push(listener);
|
||||
};
|
||||
|
||||
PDFJS.Reader.EventBus.prototype.off = function (eventName, listener) {
|
||||
var eventListeners = this._listeners[eventName];
|
||||
var i;
|
||||
if (!eventListeners || ((i = eventListeners.indexOf(listener)) < 0)) {
|
||||
return;
|
||||
}
|
||||
eventListeners.splice(i, 1);
|
||||
};
|
||||
|
||||
PDFJS.Reader.EventBus.prototype.dispatch = function (eventName) {
|
||||
var eventListeners = this._listeners[eventName];
|
||||
if (!eventListeners || eventListeners.length === 0) {
|
||||
return;
|
||||
}
|
||||
// Passing all arguments after the eventName to the listeners.
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
// Making copy of the listeners array in case if it will be modified
|
||||
// during dispatch.
|
||||
eventListeners.slice(0).forEach(function (listener) {
|
||||
listener.apply(null, args);
|
||||
});
|
||||
};
|
||||
|
360
files_reader/vendor/pdfjs/services/link_service.js
vendored
Normal file
|
@ -0,0 +1,360 @@
|
|||
PDFJS.Reader.LinkService = function (options, reader) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
this.eventBus = options.eventBus || reader.eventBus;
|
||||
this.reader = reader;
|
||||
this.baseUrl = null;
|
||||
this.pdfDocument = null;
|
||||
this.pdfHistory = null;
|
||||
this.pageRefs = null;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Object.defineProperties(PDFJS.Reader.LinkService, {
|
||||
'pagesCount': {
|
||||
get: function () { return this.pdfDocument ? this.pdfDocument.numPages : 0; }
|
||||
},
|
||||
'page': {
|
||||
get: function () { return reader.settings.currentPage; },
|
||||
set: function(value) { reader.settings.currentPage = value; }
|
||||
}
|
||||
});
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.setDocument = function (pdfDocument, baseUrl) {
|
||||
|
||||
this.baseUrl = baseUrl;
|
||||
this.pdfDocument = pdfDocument;
|
||||
this.pageRefs = Object.create(null);
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.setHistory = function (pdfHistory) {
|
||||
|
||||
this.pdfHistory = pdfHistory;
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.navigateTo = function (destination) {
|
||||
|
||||
var self = this,
|
||||
destString = "",
|
||||
destinationPromise,
|
||||
goToDestination;
|
||||
|
||||
goToDestination = function (destRef) {
|
||||
|
||||
var pageNumber;
|
||||
|
||||
if (destRef instanceof Object) {
|
||||
pageNumber = self._cachedPageNum(destRef);
|
||||
} else if ((destRef | 0) === destRef) { // Integer
|
||||
pageNumber = destRef + 1;
|
||||
} else {
|
||||
console.error('PDFJS.Reader.LinkService.navigateTo: "' + destRef
|
||||
+ '" is not a valid destination reference.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (pageNumber) {
|
||||
|
||||
if (pageNumber < 1 || pageNumber > self.pagesCount) {
|
||||
console.error('PDFJS.Reader.LinkService.navigateTo: "' + pageNumber
|
||||
+ '" is a non-existent page number.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self.reader.queuePage(pageNumber);
|
||||
|
||||
} else {
|
||||
|
||||
self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
|
||||
self.cachePageRef(pageIndex + 1, destRef);
|
||||
goToDestination(destRef);
|
||||
}).catch(function () {
|
||||
console.error('PDFJS.Reader.LinkService.navigateTo: "', destRef,
|
||||
'" is not a valid page reference.');
|
||||
|
||||
return;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof destination === 'string') {
|
||||
|
||||
destString = destination;
|
||||
destinationPromise = self.pdfDocument.getDestination(destination);
|
||||
|
||||
} else {
|
||||
|
||||
destinationPromise = Promise.resolve(destination);
|
||||
|
||||
}
|
||||
|
||||
destinationPromise.then(function (_destination) {
|
||||
|
||||
destination = _destination;
|
||||
|
||||
if (!(destination instanceof Array)) {
|
||||
|
||||
console.error('PDFJS.Reader.LinkService.navigateTo: "' + destination
|
||||
+ '" is not a valid destination array.');
|
||||
|
||||
return;
|
||||
}
|
||||
goToDestination(destination[0]);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.getDestinationHash = function (destination) {
|
||||
|
||||
var url = this.baseUrl,
|
||||
str;
|
||||
|
||||
if (typeof destination === 'string') {
|
||||
|
||||
url += "#"
|
||||
+ (parseInt(destination) === destination)
|
||||
? "nameddest="
|
||||
: ""
|
||||
+ escape(destination);
|
||||
|
||||
} else if (destination instanceof Array) {
|
||||
|
||||
url += "#"
|
||||
+ escape(JSON.stringify(destination));
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.setHash = function (hash) {
|
||||
var reader = this,
|
||||
pageNumber,
|
||||
dest;
|
||||
|
||||
if (hash.indexOf('=') >= 0) {
|
||||
var params = parseQueryString(hash);
|
||||
if ('search' in params) {
|
||||
this.eventBus.dispatch('findfromurlhash', {
|
||||
source: this,
|
||||
query: params['search'].replace(/"/g, ''),
|
||||
phraseSearch: (params['phrase'] === 'true')
|
||||
});
|
||||
}
|
||||
// borrowing syntax from "Parameters for Opening PDF Files"
|
||||
if ('nameddest' in params) {
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.updateNextHashParam(params.nameddest);
|
||||
}
|
||||
this.navigateTo(params.nameddest);
|
||||
return;
|
||||
}
|
||||
if ('page' in params) {
|
||||
pageNumber = (params.page | 0) || 1;
|
||||
}
|
||||
if ('zoom' in params) {
|
||||
// Build the destination array.
|
||||
var zoomArgs = params.zoom.split(','); // scale,left,top
|
||||
var zoomArg = zoomArgs[0];
|
||||
var zoomArgNumber = parseFloat(zoomArg);
|
||||
|
||||
if (zoomArg.indexOf('Fit') === -1) {
|
||||
// If the zoomArg is a number, it has to get divided by 100. If it's
|
||||
// a string, it should stay as it is.
|
||||
dest = [null, { name: 'XYZ' },
|
||||
zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null,
|
||||
zoomArgs.length > 2 ? (zoomArgs[2] | 0) : null,
|
||||
(zoomArgNumber ? zoomArgNumber / 100 : zoomArg)];
|
||||
} else {
|
||||
if (zoomArg === 'Fit' || zoomArg === 'FitB') {
|
||||
dest = [null, { name: zoomArg }];
|
||||
} else if ((zoomArg === 'FitH' || zoomArg === 'FitBH') ||
|
||||
(zoomArg === 'FitV' || zoomArg === 'FitBV')) {
|
||||
dest = [null, { name: zoomArg },
|
||||
zoomArgs.length > 1 ? (zoomArgs[1] | 0) : null];
|
||||
} else if (zoomArg === 'FitR') {
|
||||
if (zoomArgs.length !== 5) {
|
||||
console.error('PDFLinkService_setHash: ' +
|
||||
'Not enough parameters for \'FitR\'.');
|
||||
} else {
|
||||
dest = [null, { name: zoomArg },
|
||||
(zoomArgs[1] | 0), (zoomArgs[2] | 0),
|
||||
(zoomArgs[3] | 0), (zoomArgs[4] | 0)];
|
||||
}
|
||||
} else {
|
||||
console.error('PDFLinkService_setHash: \'' + zoomArg +
|
||||
'\' is not a valid zoom value.');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dest) {
|
||||
|
||||
reader.queuePage(pageNumber || this.page);
|
||||
|
||||
} else if (pageNumber) {
|
||||
this.page = pageNumber; // simple page
|
||||
}
|
||||
if ('pagemode' in params) {
|
||||
this.eventBus.dispatch('pagemode', {
|
||||
source: this,
|
||||
mode: params.pagemode
|
||||
});
|
||||
}
|
||||
} else { // Named (or explicit) destination.
|
||||
if ((typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) &&
|
||||
isPageNumber(hash) && hash <= this.pagesCount) {
|
||||
console.warn('PDFLinkService_setHash: specifying a page number ' +
|
||||
'directly after the hash symbol (#) is deprecated, ' +
|
||||
'please use the "#page=' + hash + '" form instead.');
|
||||
this.page = hash | 0;
|
||||
}
|
||||
|
||||
dest = unescape(hash);
|
||||
try {
|
||||
dest = JSON.parse(dest);
|
||||
|
||||
if (!(dest instanceof Array)) {
|
||||
// Avoid incorrectly rejecting a valid named destination, such as
|
||||
// e.g. "4.3" or "true", because `JSON.parse` converted its type.
|
||||
dest = dest.toString();
|
||||
}
|
||||
} catch (ex) {}
|
||||
|
||||
if (typeof dest === 'string' || this.isValidExplicitDestination(dest)) {
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.updateNextHashParam(dest);
|
||||
}
|
||||
this.navigateTo(dest);
|
||||
return;
|
||||
}
|
||||
console.error('PDFLinkService_setHash: \'' + unescape(hash) +
|
||||
'\' is not a valid destination.');
|
||||
}
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.executeNamedAction = function (action) {
|
||||
// See PDF reference, table 8.45 - Named action
|
||||
switch (action) {
|
||||
case 'GoBack':
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.back();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'GoForward':
|
||||
if (this.pdfHistory) {
|
||||
this.pdfHistory.forward();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'NextPage':
|
||||
if (this.page < this.pagesCount) {
|
||||
this.page++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'PrevPage':
|
||||
if (this.page > 1) {
|
||||
this.page--;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'LastPage':
|
||||
this.page = this.pagesCount;
|
||||
break;
|
||||
|
||||
case 'FirstPage':
|
||||
this.page = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break; // No action according to spec
|
||||
}
|
||||
|
||||
this.eventBus.dispatch('namedaction', {
|
||||
source: this,
|
||||
action: action
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.onFileAttachmentAnnotation = function (params) {
|
||||
this.eventBus.dispatch('fileattachmentannotation', {
|
||||
source: this,
|
||||
id: params.id,
|
||||
filename: params.filename,
|
||||
content: params.content,
|
||||
});
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.pageRefStr = function (pageRef) {
|
||||
|
||||
return pageRef.num + ' ' + pageRef.gen + ' R';
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.cachePageRef = function (pageNum, pageRef) {
|
||||
|
||||
this.pageRefs[this.pageRefStr(pageRef)] = pageNum;
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype._cachedPageNum = function (pageRef) {
|
||||
|
||||
return (this.pageRefs[this.pageRefStr(pageRef)])
|
||||
|| null;
|
||||
};
|
||||
|
||||
PDFJS.Reader.LinkService.prototype.isValidExplicitDestination = function (dest) {
|
||||
if (!(dest instanceof Array)) {
|
||||
return false;
|
||||
}
|
||||
var destLength = dest.length, allowNull = true;
|
||||
if (destLength < 2) {
|
||||
return false;
|
||||
}
|
||||
var page = dest[0];
|
||||
if (!(typeof page === 'object' &&
|
||||
typeof page.num === 'number' && (page.num | 0) === page.num &&
|
||||
typeof page.gen === 'number' && (page.gen | 0) === page.gen) &&
|
||||
!(typeof page === 'number' && (page | 0) === page && page >= 0)) {
|
||||
return false;
|
||||
}
|
||||
var zoom = dest[1];
|
||||
if (!(typeof zoom === 'object' && typeof zoom.name === 'string')) {
|
||||
return false;
|
||||
}
|
||||
switch (zoom.name) {
|
||||
case 'XYZ':
|
||||
if (destLength !== 5) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'Fit':
|
||||
case 'FitB':
|
||||
return destLength === 2;
|
||||
case 'FitH':
|
||||
case 'FitBH':
|
||||
case 'FitV':
|
||||
case 'FitBV':
|
||||
if (destLength !== 3) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'FitR':
|
||||
if (destLength !== 6) {
|
||||
return false;
|
||||
}
|
||||
allowNull = false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
for (var i = 2; i < destLength; i++) {
|
||||
var param = dest[i];
|
||||
if (!(typeof param === 'number' || (allowNull && param === null))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
34
files_reader/vendor/pdfjs/services/simple_link_service.js
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
PDFJS.Reader.SimpleLinkService = function () {
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Object.defineProperties(PDFJS.Reader.SimpleLinkService, {
|
||||
'page': {
|
||||
get: function () { return 0; },
|
||||
set: function(value) {}
|
||||
}
|
||||
});
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.navigateTo = function (destUrl) {
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.getDestinationHash = function (destination) {
|
||||
return "#";
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.getAnchorUrl = function (anchor) {
|
||||
return "#";
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.setHash = function (hash) {
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.executeNamedAction = function (action) {
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.onFileAttachmentAnnotation = function (params) {
|
||||
};
|
||||
|
||||
PDFJS.Reader.SimpleLinkService.prototype.cachePageRef = function (pageNum, pageRef) {
|
||||
};
|