Preliminary attachments support
Added a partial Filespec support Added getAttachments in API Added a new attachments view in UI (with a new icon by @shorlander)
This commit is contained in:
parent
4379f16346
commit
25ee0e8572
extensions/firefox/content
l10n
src
web
@ -227,7 +227,8 @@ ChromeActions.prototype = {
|
|||||||
// the original url.
|
// the original url.
|
||||||
var originalUri = NetUtil.newURI(data.originalUrl);
|
var originalUri = NetUtil.newURI(data.originalUrl);
|
||||||
var filename = data.filename;
|
var filename = data.filename;
|
||||||
if (typeof filename !== 'string' || !/\.pdf$/i.test(filename)) {
|
if (typeof filename !== 'string' ||
|
||||||
|
(!/\.pdf$/i.test(filename) && !data.isAttachment)) {
|
||||||
filename = 'document.pdf';
|
filename = 'document.pdf';
|
||||||
}
|
}
|
||||||
var blobUri = data.blobUrl ? NetUtil.newURI(data.blobUrl) : originalUri;
|
var blobUri = data.blobUrl ? NetUtil.newURI(data.blobUrl) : originalUri;
|
||||||
@ -273,7 +274,8 @@ ChromeActions.prototype = {
|
|||||||
var listener = {
|
var listener = {
|
||||||
extListener: null,
|
extListener: null,
|
||||||
onStartRequest: function(aRequest, aContext) {
|
onStartRequest: function(aRequest, aContext) {
|
||||||
this.extListener = extHelperAppSvc.doContent('application/pdf',
|
this.extListener = extHelperAppSvc.doContent((data.isAttachment ? '' :
|
||||||
|
'application/pdf'),
|
||||||
aRequest, frontWindow, false);
|
aRequest, frontWindow, false);
|
||||||
this.extListener.onStartRequest(aRequest, aContext);
|
this.extListener.onStartRequest(aRequest, aContext);
|
||||||
},
|
},
|
||||||
|
@ -89,6 +89,8 @@ toggle_sidebar.title=Toggle Sidebar
|
|||||||
toggle_sidebar_label=Toggle Sidebar
|
toggle_sidebar_label=Toggle Sidebar
|
||||||
outline.title=Show Document Outline
|
outline.title=Show Document Outline
|
||||||
outline_label=Document Outline
|
outline_label=Document Outline
|
||||||
|
attachments.title=Show Attachments
|
||||||
|
attachments_label=Attachments
|
||||||
thumbs.title=Show Thumbnails
|
thumbs.title=Show Thumbnails
|
||||||
thumbs_label=Thumbnails
|
thumbs_label=Thumbnails
|
||||||
findbar.title=Find in Document
|
findbar.title=Find in Document
|
||||||
|
@ -64,6 +64,8 @@ toggle_sidebar.title=Afficher/Masquer le panneau latéral
|
|||||||
toggle_sidebar_label=Afficher/Masquer le panneau latéral
|
toggle_sidebar_label=Afficher/Masquer le panneau latéral
|
||||||
outline.title=Afficher les signets
|
outline.title=Afficher les signets
|
||||||
outline_label=Signets du document
|
outline_label=Signets du document
|
||||||
|
attachments.title=Afficher les pièces jointes
|
||||||
|
attachments_label=Pièces jointes
|
||||||
thumbs.title=Afficher les vignettes
|
thumbs.title=Afficher les vignettes
|
||||||
thumbs_label=Vignettes
|
thumbs_label=Vignettes
|
||||||
findbar.title=Rechercher dans le document
|
findbar.title=Rechercher dans le document
|
||||||
|
115
src/core/obj.js
115
src/core/obj.js
@ -454,6 +454,30 @@ var Catalog = (function CatalogClosure() {
|
|||||||
}
|
}
|
||||||
return shadow(this, 'destinations', dests);
|
return shadow(this, 'destinations', dests);
|
||||||
},
|
},
|
||||||
|
get attachments() {
|
||||||
|
var xref = this.xref;
|
||||||
|
var attachments, nameTreeRef;
|
||||||
|
var obj = this.catDict.get('Names');
|
||||||
|
if (obj) {
|
||||||
|
nameTreeRef = obj.getRaw('EmbeddedFiles');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameTreeRef) {
|
||||||
|
var nameTree = new NameTree(nameTreeRef, xref);
|
||||||
|
var names = nameTree.getAll();
|
||||||
|
for (var name in names) {
|
||||||
|
if (!names.hasOwnProperty(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var fs = new FileSpec(names[name], xref);
|
||||||
|
if (!attachments) {
|
||||||
|
attachments = {};
|
||||||
|
}
|
||||||
|
attachments[stringToPDFString(name)] = fs.serializable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return shadow(this, 'attachments', attachments);
|
||||||
|
},
|
||||||
get javaScript() {
|
get javaScript() {
|
||||||
var xref = this.xref;
|
var xref = this.xref;
|
||||||
var obj = this.catDict.get('Names');
|
var obj = this.catDict.get('Names');
|
||||||
@ -1315,6 +1339,97 @@ var NameTree = (function NameTreeClosure() {
|
|||||||
return NameTree;
|
return NameTree;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "A PDF file can refer to the contents of another file by using a File
|
||||||
|
* Specification (PDF 1.1)", see the spec (7.11) for more details.
|
||||||
|
* NOTE: Only embedded files are supported (as part of the attachments support)
|
||||||
|
* TODO: support the 'URL' file system (with caching if !/V), portable
|
||||||
|
* collections attributes and related files (/RF)
|
||||||
|
*/
|
||||||
|
var FileSpec = (function FileSpecClosure() {
|
||||||
|
function FileSpec(root, xref) {
|
||||||
|
if (!root || !isDict(root)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.xref = xref;
|
||||||
|
this.root = root;
|
||||||
|
if (root.has('FS')) {
|
||||||
|
this.fs = root.get('FS');
|
||||||
|
}
|
||||||
|
this.description = root.has('Desc') ?
|
||||||
|
stringToPDFString(root.get('Desc')) :
|
||||||
|
'';
|
||||||
|
if (root.has('RF')) {
|
||||||
|
warn('Related file specifications are not supported');
|
||||||
|
}
|
||||||
|
this.contentAvailable = true;
|
||||||
|
if (!root.has('EF')) {
|
||||||
|
this.contentAvailable = false;
|
||||||
|
warn('Non-embedded file specifications are not supported');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickPlatformItem(dict) {
|
||||||
|
// Look for the filename in this order:
|
||||||
|
// UF, F, Unix, Mac, DOS
|
||||||
|
if (dict.has('UF')) {
|
||||||
|
return dict.get('UF');
|
||||||
|
} else if (dict.has('F')) {
|
||||||
|
return dict.get('F');
|
||||||
|
} else if (dict.has('Unix')) {
|
||||||
|
return dict.get('Unix');
|
||||||
|
} else if (dict.has('Mac')) {
|
||||||
|
return dict.get('Mac');
|
||||||
|
} else if (dict.has('DOS')) {
|
||||||
|
return dict.get('DOS');
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileSpec.prototype = {
|
||||||
|
get filename() {
|
||||||
|
if (!this._filename && this.root) {
|
||||||
|
var filename = pickPlatformItem(this.root) || 'unnamed';
|
||||||
|
this._filename = stringToPDFString(filename).
|
||||||
|
replace(/\\\\/g, '\\').
|
||||||
|
replace(/\\\//g, '/').
|
||||||
|
replace(/\\/g, '/');
|
||||||
|
}
|
||||||
|
return this._filename;
|
||||||
|
},
|
||||||
|
get content() {
|
||||||
|
if (!this.contentAvailable) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!this.contentRef && this.root) {
|
||||||
|
this.contentRef = pickPlatformItem(this.root.get('EF'));
|
||||||
|
}
|
||||||
|
var content = null;
|
||||||
|
if (this.contentRef) {
|
||||||
|
var xref = this.xref;
|
||||||
|
var fileObj = xref.fetchIfRef(this.contentRef);
|
||||||
|
if (fileObj && isStream(fileObj)) {
|
||||||
|
content = fileObj.getBytes();
|
||||||
|
} else {
|
||||||
|
warn('Embedded file specification points to non-existing/invalid ' +
|
||||||
|
'content');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
warn('Embedded file specification does not have a content');
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
},
|
||||||
|
get serializable() {
|
||||||
|
return {
|
||||||
|
filename: this.filename,
|
||||||
|
content: this.content
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return FileSpec;
|
||||||
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper for loading missing data in object graphs. It traverses the graph
|
* A helper for loading missing data in object graphs. It traverses the graph
|
||||||
* depth first and queues up any objects that have missing data. Once it has
|
* depth first and queues up any objects that have missing data. Once it has
|
||||||
|
@ -306,6 +306,14 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
handler.on('GetAttachments',
|
||||||
|
function wphSetupGetAttachments(data, deferred) {
|
||||||
|
pdfManager.ensureCatalog('attachments').then(function(attachments) {
|
||||||
|
deferred.resolve(attachments);
|
||||||
|
}, deferred.reject);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
handler.on('GetData', function wphSetupGetData(data, deferred) {
|
handler.on('GetData', function wphSetupGetData(data, deferred) {
|
||||||
pdfManager.requestLoadedStream();
|
pdfManager.requestLoadedStream();
|
||||||
pdfManager.onLoadedStream().then(function(stream) {
|
pdfManager.onLoadedStream().then(function(stream) {
|
||||||
|
@ -259,6 +259,13 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
|||||||
getDestinations: function PDFDocumentProxy_getDestinations() {
|
getDestinations: function PDFDocumentProxy_getDestinations() {
|
||||||
return this.transport.getDestinations();
|
return this.transport.getDestinations();
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @return {Promise} A promise that is resolved with a lookup table for
|
||||||
|
* mapping named attachments to their content.
|
||||||
|
*/
|
||||||
|
getAttachments: function PDFDocumentProxy_getAttachments() {
|
||||||
|
return this.transport.getAttachments();
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* @return {Promise} A promise that is resolved with an array of all the
|
* @return {Promise} A promise that is resolved with an array of all the
|
||||||
* JavaScript strings in the name tree.
|
* JavaScript strings in the name tree.
|
||||||
@ -1046,6 +1053,16 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getAttachments: function WorkerTransport_getAttachments() {
|
||||||
|
var promise = new PDFJS.LegacyPromise();
|
||||||
|
this.messageHandler.send('GetAttachments', null,
|
||||||
|
function transportAttachments(attachments) {
|
||||||
|
promise.resolve(attachments);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return promise;
|
||||||
|
},
|
||||||
|
|
||||||
startCleanup: function WorkerTransport_startCleanup() {
|
startCleanup: function WorkerTransport_startCleanup() {
|
||||||
this.messageHandler.send('Cleanup', null,
|
this.messageHandler.send('Cleanup', null,
|
||||||
function endCleanup() {
|
function endCleanup() {
|
||||||
|
@ -66,6 +66,13 @@ var DownloadManager = (function DownloadManagerClosure() {
|
|||||||
download(url + '#pdfjs.action=download', filename);
|
download(url + '#pdfjs.action=download', filename);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
downloadData: function DownloadManager_downloadData(data, filename,
|
||||||
|
contentType) {
|
||||||
|
|
||||||
|
var blobUrl = PDFJS.createObjectURL(data, contentType);
|
||||||
|
download(blobUrl, filename);
|
||||||
|
},
|
||||||
|
|
||||||
download: function DownloadManager_download(blob, url, filename) {
|
download: function DownloadManager_download(blob, url, filename) {
|
||||||
if (!URL) {
|
if (!URL) {
|
||||||
// URL.createObjectURL is not supported
|
// URL.createObjectURL is not supported
|
||||||
|
@ -83,6 +83,18 @@ var DownloadManager = (function DownloadManagerClosure() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
downloadData: function DownloadManager_downloadData(data, filename,
|
||||||
|
contentType) {
|
||||||
|
var blobUrl = PDFJS.createObjectURL(data, contentType);
|
||||||
|
|
||||||
|
FirefoxCom.request('download', {
|
||||||
|
blobUrl: blobUrl,
|
||||||
|
originalUrl: blobUrl,
|
||||||
|
filename: filename,
|
||||||
|
isAttachment: true
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
download: function DownloadManager_download(blob, url, filename) {
|
download: function DownloadManager_download(blob, url, filename) {
|
||||||
var blobUrl = window.URL.createObjectURL(blob);
|
var blobUrl = window.URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
BIN
web/images/toolbarButton-viewAttachments.png
Normal file
BIN
web/images/toolbarButton-viewAttachments.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 384 B |
BIN
web/images/toolbarButton-viewAttachments@2x.png
Normal file
BIN
web/images/toolbarButton-viewAttachments@2x.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 871 B |
@ -602,6 +602,9 @@ html[dir='rtl'] .splitToolbarButton > .toolbarButton {
|
|||||||
0 0 1px hsla(0,0%,0%,.05);
|
0 0 1px hsla(0,0%,0%,.05);
|
||||||
z-index: 199;
|
z-index: 199;
|
||||||
}
|
}
|
||||||
|
.splitToolbarButton > .toolbarButton {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
html[dir='ltr'] .splitToolbarButton > .toolbarButton:first-child,
|
html[dir='ltr'] .splitToolbarButton > .toolbarButton:first-child,
|
||||||
html[dir='rtl'] .splitToolbarButton > .toolbarButton:last-child {
|
html[dir='rtl'] .splitToolbarButton > .toolbarButton:last-child {
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -948,6 +951,10 @@ html[dir="rtl"] #viewOutline.toolbarButton::before {
|
|||||||
content: url(images/toolbarButton-viewOutline-rtl.png);
|
content: url(images/toolbarButton-viewOutline-rtl.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#viewAttachments.toolbarButton::before {
|
||||||
|
content: url(images/toolbarButton-viewAttachments.png);
|
||||||
|
}
|
||||||
|
|
||||||
#viewFind.toolbarButton::before {
|
#viewFind.toolbarButton::before {
|
||||||
content: url(images/toolbarButton-search.png);
|
content: url(images/toolbarButton-search.png);
|
||||||
}
|
}
|
||||||
@ -1165,7 +1172,8 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
|||||||
color: hsla(0,0%,100%,1);
|
color: hsla(0,0%,100%,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#outlineView {
|
#outlineView,
|
||||||
|
#attachmentsView {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 192px;
|
width: 192px;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -1185,7 +1193,8 @@ html[dir='rtl'] .outlineItem > .outlineItems {
|
|||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.outlineItem > a {
|
.outlineItem > a,
|
||||||
|
.attachmentsItem > a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
min-width: 95%;
|
min-width: 95%;
|
||||||
@ -1199,15 +1208,18 @@ html[dir='rtl'] .outlineItem > .outlineItems {
|
|||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
html[dir='ltr'] .outlineItem > a {
|
html[dir='ltr'] .outlineItem > a,
|
||||||
|
html[dir='ltr'] .attachmentsItem > a {
|
||||||
padding: 2px 0 5px 10px;
|
padding: 2px 0 5px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
html[dir='rtl'] .outlineItem > a {
|
html[dir='rtl'] .outlineItem > a,
|
||||||
|
html[dir='rtl'] .attachmentsItem > a {
|
||||||
padding: 2px 10px 5px 0;
|
padding: 2px 10px 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.outlineItem > a:hover {
|
.outlineItem > a:hover,
|
||||||
|
.attachmentsItem > a:hover {
|
||||||
background-color: hsla(0,0%,100%,.02);
|
background-color: hsla(0,0%,100%,.02);
|
||||||
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
@ -1746,6 +1758,10 @@ html[dir='rtl'] #documentPropertiesContainer .row > * {
|
|||||||
content: url(images/toolbarButton-viewOutline-rtl@2x.png);
|
content: url(images/toolbarButton-viewOutline-rtl@2x.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#viewAttachments.toolbarButton::before {
|
||||||
|
content: url(images/toolbarButton-viewAttachments@2x.png);
|
||||||
|
}
|
||||||
|
|
||||||
#viewFind.toolbarButton::before {
|
#viewFind.toolbarButton::before {
|
||||||
content: url(images/toolbarButton-search@2x.png);
|
content: url(images/toolbarButton-search@2x.png);
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,9 @@ http://sourceforge.net/adobe/cmap/wiki/License/
|
|||||||
<button id="viewOutline" class="toolbarButton group" title="Show Document Outline" tabindex="3" data-l10n-id="outline">
|
<button id="viewOutline" class="toolbarButton group" title="Show Document Outline" tabindex="3" data-l10n-id="outline">
|
||||||
<span data-l10n-id="outline_label">Document Outline</span>
|
<span data-l10n-id="outline_label">Document Outline</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button id="viewAttachments" class="toolbarButton group" title="Show Attachments" tabindex="4" data-l10n-id="attachments">
|
||||||
|
<span data-l10n-id="attachments_label">Attachments</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="sidebarContent">
|
<div id="sidebarContent">
|
||||||
@ -112,6 +115,8 @@ http://sourceforge.net/adobe/cmap/wiki/License/
|
|||||||
</div>
|
</div>
|
||||||
<div id="outlineView" class="hidden">
|
<div id="outlineView" class="hidden">
|
||||||
</div>
|
</div>
|
||||||
|
<div id="attachmentsView" class="hidden">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- sidebarContainer -->
|
</div> <!-- sidebarContainer -->
|
||||||
|
|
||||||
@ -137,53 +142,53 @@ http://sourceforge.net/adobe/cmap/wiki/License/
|
|||||||
|
|
||||||
<div id="secondaryToolbar" class="secondaryToolbar hidden doorHangerRight">
|
<div id="secondaryToolbar" class="secondaryToolbar hidden doorHangerRight">
|
||||||
<div id="secondaryToolbarButtonContainer">
|
<div id="secondaryToolbarButtonContainer">
|
||||||
<button id="secondaryPresentationMode" class="secondaryToolbarButton presentationMode visibleLargeView" title="Switch to Presentation Mode" tabindex="18" data-l10n-id="presentation_mode">
|
<button id="secondaryPresentationMode" class="secondaryToolbarButton presentationMode visibleLargeView" title="Switch to Presentation Mode" tabindex="19" data-l10n-id="presentation_mode">
|
||||||
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
|
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button id="secondaryOpenFile" class="secondaryToolbarButton openFile visibleLargeView" title="Open File" tabindex="19" data-l10n-id="open_file">
|
<button id="secondaryOpenFile" class="secondaryToolbarButton openFile visibleLargeView" title="Open File" tabindex="20" data-l10n-id="open_file">
|
||||||
<span data-l10n-id="open_file_label">Open</span>
|
<span data-l10n-id="open_file_label">Open</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button id="secondaryPrint" class="secondaryToolbarButton print visibleMediumView" title="Print" tabindex="20" data-l10n-id="print">
|
<button id="secondaryPrint" class="secondaryToolbarButton print visibleMediumView" title="Print" tabindex="21" data-l10n-id="print">
|
||||||
<span data-l10n-id="print_label">Print</span>
|
<span data-l10n-id="print_label">Print</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button id="secondaryDownload" class="secondaryToolbarButton download visibleMediumView" title="Download" tabindex="21" data-l10n-id="download">
|
<button id="secondaryDownload" class="secondaryToolbarButton download visibleMediumView" title="Download" tabindex="22" data-l10n-id="download">
|
||||||
<span data-l10n-id="download_label">Download</span>
|
<span data-l10n-id="download_label">Download</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark visibleSmallView" title="Current view (copy or open in new window)" tabindex="22" data-l10n-id="bookmark">
|
<a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark visibleSmallView" title="Current view (copy or open in new window)" tabindex="23" data-l10n-id="bookmark">
|
||||||
<span data-l10n-id="bookmark_label">Current View</span>
|
<span data-l10n-id="bookmark_label">Current View</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="horizontalToolbarSeparator visibleLargeView"></div>
|
<div class="horizontalToolbarSeparator visibleLargeView"></div>
|
||||||
|
|
||||||
<button id="firstPage" class="secondaryToolbarButton firstPage" title="Go to First Page" tabindex="23" data-l10n-id="first_page">
|
<button id="firstPage" class="secondaryToolbarButton firstPage" title="Go to First Page" tabindex="24" data-l10n-id="first_page">
|
||||||
<span data-l10n-id="first_page_label">Go to First Page</span>
|
<span data-l10n-id="first_page_label">Go to First Page</span>
|
||||||
</button>
|
</button>
|
||||||
<button id="lastPage" class="secondaryToolbarButton lastPage" title="Go to Last Page" tabindex="24" data-l10n-id="last_page">
|
<button id="lastPage" class="secondaryToolbarButton lastPage" title="Go to Last Page" tabindex="25" data-l10n-id="last_page">
|
||||||
<span data-l10n-id="last_page_label">Go to Last Page</span>
|
<span data-l10n-id="last_page_label">Go to Last Page</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="horizontalToolbarSeparator"></div>
|
<div class="horizontalToolbarSeparator"></div>
|
||||||
|
|
||||||
<button id="pageRotateCw" class="secondaryToolbarButton rotateCw" title="Rotate Clockwise" tabindex="25" data-l10n-id="page_rotate_cw">
|
<button id="pageRotateCw" class="secondaryToolbarButton rotateCw" title="Rotate Clockwise" tabindex="26" data-l10n-id="page_rotate_cw">
|
||||||
<span data-l10n-id="page_rotate_cw_label">Rotate Clockwise</span>
|
<span data-l10n-id="page_rotate_cw_label">Rotate Clockwise</span>
|
||||||
</button>
|
</button>
|
||||||
<button id="pageRotateCcw" class="secondaryToolbarButton rotateCcw" title="Rotate Counterclockwise" tabindex="26" data-l10n-id="page_rotate_ccw">
|
<button id="pageRotateCcw" class="secondaryToolbarButton rotateCcw" title="Rotate Counterclockwise" tabindex="27" data-l10n-id="page_rotate_ccw">
|
||||||
<span data-l10n-id="page_rotate_ccw_label">Rotate Counterclockwise</span>
|
<span data-l10n-id="page_rotate_ccw_label">Rotate Counterclockwise</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="horizontalToolbarSeparator"></div>
|
<div class="horizontalToolbarSeparator"></div>
|
||||||
|
|
||||||
<button id="toggleHandTool" class="secondaryToolbarButton handTool" title="Enable hand tool" tabindex="27" data-l10n-id="hand_tool_enable">
|
<button id="toggleHandTool" class="secondaryToolbarButton handTool" title="Enable hand tool" tabindex="28" data-l10n-id="hand_tool_enable">
|
||||||
<span data-l10n-id="hand_tool_enable_label">Enable hand tool</span>
|
<span data-l10n-id="hand_tool_enable_label">Enable hand tool</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="horizontalToolbarSeparator"></div>
|
<div class="horizontalToolbarSeparator"></div>
|
||||||
|
|
||||||
<button id="documentProperties" class="secondaryToolbarButton documentProperties" title="Document Properties…" tabindex="28" data-l10n-id="document_properties">
|
<button id="documentProperties" class="secondaryToolbarButton documentProperties" title="Document Properties…" tabindex="29" data-l10n-id="document_properties">
|
||||||
<span data-l10n-id="document_properties_label">Document Properties…</span>
|
<span data-l10n-id="document_properties_label">Document Properties…</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -193,66 +198,66 @@ http://sourceforge.net/adobe/cmap/wiki/License/
|
|||||||
<div id="toolbarContainer">
|
<div id="toolbarContainer">
|
||||||
<div id="toolbarViewer">
|
<div id="toolbarViewer">
|
||||||
<div id="toolbarViewerLeft">
|
<div id="toolbarViewerLeft">
|
||||||
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="4" data-l10n-id="toggle_sidebar">
|
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="5" data-l10n-id="toggle_sidebar">
|
||||||
<span data-l10n-id="toggle_sidebar_label">Toggle Sidebar</span>
|
<span data-l10n-id="toggle_sidebar_label">Toggle Sidebar</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="toolbarButtonSpacer"></div>
|
<div class="toolbarButtonSpacer"></div>
|
||||||
<button id="viewFind" class="toolbarButton group hiddenSmallView" title="Find in Document" tabindex="5" data-l10n-id="findbar">
|
<button id="viewFind" class="toolbarButton group hiddenSmallView" title="Find in Document" tabindex="6" data-l10n-id="findbar">
|
||||||
<span data-l10n-id="findbar_label">Find</span>
|
<span data-l10n-id="findbar_label">Find</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="splitToolbarButton">
|
<div class="splitToolbarButton">
|
||||||
<button class="toolbarButton pageUp" title="Previous Page" id="previous" tabindex="6" data-l10n-id="previous">
|
<button class="toolbarButton pageUp" title="Previous Page" id="previous" tabindex="7" data-l10n-id="previous">
|
||||||
<span data-l10n-id="previous_label">Previous</span>
|
<span data-l10n-id="previous_label">Previous</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="splitToolbarButtonSeparator"></div>
|
<div class="splitToolbarButtonSeparator"></div>
|
||||||
<button class="toolbarButton pageDown" title="Next Page" id="next" tabindex="7" data-l10n-id="next">
|
<button class="toolbarButton pageDown" title="Next Page" id="next" tabindex="8" data-l10n-id="next">
|
||||||
<span data-l10n-id="next_label">Next</span>
|
<span data-l10n-id="next_label">Next</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<label id="pageNumberLabel" class="toolbarLabel" for="pageNumber" data-l10n-id="page_label">Page: </label>
|
<label id="pageNumberLabel" class="toolbarLabel" for="pageNumber" data-l10n-id="page_label">Page: </label>
|
||||||
<input type="number" id="pageNumber" class="toolbarField pageNumber" value="1" size="4" min="1" tabindex="8">
|
<input type="number" id="pageNumber" class="toolbarField pageNumber" value="1" size="4" min="1" tabindex="9">
|
||||||
<span id="numPages" class="toolbarLabel"></span>
|
<span id="numPages" class="toolbarLabel"></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="toolbarViewerRight">
|
<div id="toolbarViewerRight">
|
||||||
<button id="presentationMode" class="toolbarButton presentationMode hiddenLargeView" title="Switch to Presentation Mode" tabindex="12" data-l10n-id="presentation_mode">
|
<button id="presentationMode" class="toolbarButton presentationMode hiddenLargeView" title="Switch to Presentation Mode" tabindex="13" data-l10n-id="presentation_mode">
|
||||||
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
|
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button id="openFile" class="toolbarButton openFile hiddenLargeView" title="Open File" tabindex="13" data-l10n-id="open_file">
|
<button id="openFile" class="toolbarButton openFile hiddenLargeView" title="Open File" tabindex="14" data-l10n-id="open_file">
|
||||||
<span data-l10n-id="open_file_label">Open</span>
|
<span data-l10n-id="open_file_label">Open</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button id="print" class="toolbarButton print hiddenMediumView" title="Print" tabindex="14" data-l10n-id="print">
|
<button id="print" class="toolbarButton print hiddenMediumView" title="Print" tabindex="15" data-l10n-id="print">
|
||||||
<span data-l10n-id="print_label">Print</span>
|
<span data-l10n-id="print_label">Print</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button id="download" class="toolbarButton download hiddenMediumView" title="Download" tabindex="15" data-l10n-id="download">
|
<button id="download" class="toolbarButton download hiddenMediumView" title="Download" tabindex="16" data-l10n-id="download">
|
||||||
<span data-l10n-id="download_label">Download</span>
|
<span data-l10n-id="download_label">Download</span>
|
||||||
</button>
|
</button>
|
||||||
<!-- <div class="toolbarButtonSpacer"></div> -->
|
<!-- <div class="toolbarButtonSpacer"></div> -->
|
||||||
<a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="16" data-l10n-id="bookmark">
|
<a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="17" data-l10n-id="bookmark">
|
||||||
<span data-l10n-id="bookmark_label">Current View</span>
|
<span data-l10n-id="bookmark_label">Current View</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="verticalToolbarSeparator hiddenSmallView"></div>
|
<div class="verticalToolbarSeparator hiddenSmallView"></div>
|
||||||
|
|
||||||
<button id="secondaryToolbarToggle" class="toolbarButton" title="Tools" tabindex="17" data-l10n-id="tools">
|
<button id="secondaryToolbarToggle" class="toolbarButton" title="Tools" tabindex="18" data-l10n-id="tools">
|
||||||
<span data-l10n-id="tools_label">Tools</span>
|
<span data-l10n-id="tools_label">Tools</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="outerCenter">
|
<div class="outerCenter">
|
||||||
<div class="innerCenter" id="toolbarViewerMiddle">
|
<div class="innerCenter" id="toolbarViewerMiddle">
|
||||||
<div class="splitToolbarButton">
|
<div class="splitToolbarButton">
|
||||||
<button id="zoomOut" class="toolbarButton zoomOut" title="Zoom Out" tabindex="9" data-l10n-id="zoom_out">
|
<button id="zoomOut" class="toolbarButton zoomOut" title="Zoom Out" tabindex="10" data-l10n-id="zoom_out">
|
||||||
<span data-l10n-id="zoom_out_label">Zoom Out</span>
|
<span data-l10n-id="zoom_out_label">Zoom Out</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="splitToolbarButtonSeparator"></div>
|
<div class="splitToolbarButtonSeparator"></div>
|
||||||
<button id="zoomIn" class="toolbarButton zoomIn" title="Zoom In" tabindex="10" data-l10n-id="zoom_in">
|
<button id="zoomIn" class="toolbarButton zoomIn" title="Zoom In" tabindex="11" data-l10n-id="zoom_in">
|
||||||
<span data-l10n-id="zoom_in_label">Zoom In</span>
|
<span data-l10n-id="zoom_in_label">Zoom In</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<span id="scaleSelectContainer" class="dropdownToolbarButton">
|
<span id="scaleSelectContainer" class="dropdownToolbarButton">
|
||||||
<select id="scaleSelect" title="Zoom" tabindex="11" data-l10n-id="zoom">
|
<select id="scaleSelect" title="Zoom" tabindex="12" data-l10n-id="zoom">
|
||||||
<option id="pageAutoOption" title="" value="auto" selected="selected" data-l10n-id="page_scale_auto">Automatic Zoom</option>
|
<option id="pageAutoOption" title="" value="auto" selected="selected" data-l10n-id="page_scale_auto">Automatic Zoom</option>
|
||||||
<option id="pageActualOption" title="" value="page-actual" data-l10n-id="page_scale_actual">Actual Size</option>
|
<option id="pageActualOption" title="" value="page-actual" data-l10n-id="page_scale_actual">Actual Size</option>
|
||||||
<option id="pageFitOption" title="" value="page-fit" data-l10n-id="page_scale_fit">Fit Page</option>
|
<option id="pageFitOption" title="" value="page-fit" data-l10n-id="page_scale_fit">Fit Page</option>
|
||||||
|
@ -1094,6 +1094,10 @@ var PDFView = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
pdfDocument.getAttachments().then(function(attachments) {
|
||||||
|
self.attachments = new DocumentAttachmentsView(attachments);
|
||||||
|
document.getElementById('viewAttachments').disabled = !attachments;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
pdfDocument.getMetadata().then(function(data) {
|
pdfDocument.getMetadata().then(function(data) {
|
||||||
@ -1337,12 +1341,14 @@ var PDFView = {
|
|||||||
}
|
}
|
||||||
if ('pagemode' in params) {
|
if ('pagemode' in params) {
|
||||||
var toggle = document.getElementById('sidebarToggle');
|
var toggle = document.getElementById('sidebarToggle');
|
||||||
if (params.pagemode === 'thumbs' || params.pagemode === 'bookmarks') {
|
if (params.pagemode === 'thumbs' || params.pagemode === 'bookmarks' ||
|
||||||
|
params.pagemode === 'attachments') {
|
||||||
if (!this.sidebarOpen) {
|
if (!this.sidebarOpen) {
|
||||||
toggle.click();
|
toggle.click();
|
||||||
}
|
}
|
||||||
this.switchSidebarView(params.pagemode === 'thumbs' ?
|
this.switchSidebarView(params.pagemode === 'bookmarks' ?
|
||||||
'thumbs' : 'outline');
|
'outline' :
|
||||||
|
params.pagemode);
|
||||||
} else if (params.pagemode === 'none' && this.sidebarOpen) {
|
} else if (params.pagemode === 'none' && this.sidebarOpen) {
|
||||||
toggle.click();
|
toggle.click();
|
||||||
}
|
}
|
||||||
@ -1358,24 +1364,28 @@ var PDFView = {
|
|||||||
switchSidebarView: function pdfViewSwitchSidebarView(view) {
|
switchSidebarView: function pdfViewSwitchSidebarView(view) {
|
||||||
var thumbsView = document.getElementById('thumbnailView');
|
var thumbsView = document.getElementById('thumbnailView');
|
||||||
var outlineView = document.getElementById('outlineView');
|
var outlineView = document.getElementById('outlineView');
|
||||||
|
var attachmentsView = document.getElementById('attachmentsView');
|
||||||
|
|
||||||
var thumbsButton = document.getElementById('viewThumbnail');
|
var thumbsButton = document.getElementById('viewThumbnail');
|
||||||
var outlineButton = document.getElementById('viewOutline');
|
var outlineButton = document.getElementById('viewOutline');
|
||||||
|
var attachmentsButton = document.getElementById('viewAttachments');
|
||||||
|
|
||||||
switch (view) {
|
switch (view) {
|
||||||
case 'thumbs':
|
case 'thumbs':
|
||||||
var wasOutlineViewVisible = thumbsView.classList.contains('hidden');
|
var wasAnotherViewVisible = thumbsView.classList.contains('hidden');
|
||||||
|
|
||||||
thumbsButton.classList.add('toggled');
|
thumbsButton.classList.add('toggled');
|
||||||
outlineButton.classList.remove('toggled');
|
outlineButton.classList.remove('toggled');
|
||||||
|
attachmentsButton.classList.remove('toggled');
|
||||||
thumbsView.classList.remove('hidden');
|
thumbsView.classList.remove('hidden');
|
||||||
outlineView.classList.add('hidden');
|
outlineView.classList.add('hidden');
|
||||||
|
attachmentsView.classList.add('hidden');
|
||||||
|
|
||||||
PDFView.renderHighestPriority();
|
PDFView.renderHighestPriority();
|
||||||
|
|
||||||
if (wasOutlineViewVisible) {
|
if (wasAnotherViewVisible) {
|
||||||
// Ensure that the thumbnail of the current page is visible
|
// Ensure that the thumbnail of the current page is visible
|
||||||
// when switching from the outline view.
|
// when switching from another view.
|
||||||
scrollIntoView(document.getElementById('thumbnailContainer' +
|
scrollIntoView(document.getElementById('thumbnailContainer' +
|
||||||
this.page));
|
this.page));
|
||||||
}
|
}
|
||||||
@ -1384,13 +1394,28 @@ var PDFView = {
|
|||||||
case 'outline':
|
case 'outline':
|
||||||
thumbsButton.classList.remove('toggled');
|
thumbsButton.classList.remove('toggled');
|
||||||
outlineButton.classList.add('toggled');
|
outlineButton.classList.add('toggled');
|
||||||
|
attachmentsButton.classList.remove('toggled');
|
||||||
thumbsView.classList.add('hidden');
|
thumbsView.classList.add('hidden');
|
||||||
outlineView.classList.remove('hidden');
|
outlineView.classList.remove('hidden');
|
||||||
|
attachmentsView.classList.add('hidden');
|
||||||
|
|
||||||
if (outlineButton.getAttribute('disabled')) {
|
if (outlineButton.getAttribute('disabled')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'attachments':
|
||||||
|
thumbsButton.classList.remove('toggled');
|
||||||
|
outlineButton.classList.remove('toggled');
|
||||||
|
attachmentsButton.classList.add('toggled');
|
||||||
|
thumbsView.classList.add('hidden');
|
||||||
|
outlineView.classList.add('hidden');
|
||||||
|
attachmentsView.classList.remove('hidden');
|
||||||
|
|
||||||
|
if (attachmentsButton.getAttribute('disabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1656,6 +1681,44 @@ var DocumentOutlineView = function documentOutlineView(outline) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var DocumentAttachmentsView = function documentAttachmentsView(attachments) {
|
||||||
|
var attachmentsView = document.getElementById('attachmentsView');
|
||||||
|
while (attachmentsView.firstChild) {
|
||||||
|
attachmentsView.removeChild(attachmentsView.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!attachments) {
|
||||||
|
if (!attachmentsView.classList.contains('hidden')) {
|
||||||
|
PDFView.switchSidebarView('thumbs');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindItemLink(domObj, item) {
|
||||||
|
domObj.href = '#';
|
||||||
|
domObj.onclick = function documentAttachmentsViewOnclick(e) {
|
||||||
|
var downloadManager = new DownloadManager();
|
||||||
|
downloadManager.downloadData(item.content, getFileName(item.filename),
|
||||||
|
'');
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var names = Object.keys(attachments).sort(function(a,b) {
|
||||||
|
return a.toLowerCase().localeCompare(b.toLowerCase());
|
||||||
|
});
|
||||||
|
for (var i = 0, ii = names.length; i < ii; i++) {
|
||||||
|
var item = attachments[names[i]];
|
||||||
|
var div = document.createElement('div');
|
||||||
|
div.className = 'attachmentsItem';
|
||||||
|
var a = document.createElement('a');
|
||||||
|
bindItemLink(a, item);
|
||||||
|
a.textContent = getFileName(item.filename);
|
||||||
|
div.appendChild(a);
|
||||||
|
attachmentsView.appendChild(div);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//#if CHROME
|
//#if CHROME
|
||||||
//(function rewriteUrlClosure() {
|
//(function rewriteUrlClosure() {
|
||||||
// // Run this code outside DOMContentLoaded to make sure that the URL
|
// // Run this code outside DOMContentLoaded to make sure that the URL
|
||||||
@ -1848,6 +1911,11 @@ function webViewerInitialized() {
|
|||||||
PDFView.switchSidebarView('outline');
|
PDFView.switchSidebarView('outline');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('viewAttachments').addEventListener('click',
|
||||||
|
function() {
|
||||||
|
PDFView.switchSidebarView('attachments');
|
||||||
|
});
|
||||||
|
|
||||||
document.getElementById('previous').addEventListener('click',
|
document.getElementById('previous').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
PDFView.page--;
|
PDFView.page--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user