Move handling of the 'pagemode' hash parameter into viewer.js
to restore the functionality
This regressed in 0ef6212b64
.
Since the 'pagemode' hash parameter requires certain viewer functionality (e.g. thumbnails and an outline) in order to work, it seemed reasonable to move the functionality from `pdf_link_service.js` into `viewer.js`.
Similar to `namedaction`, this patch makes use of an event to forward the 'pagemode' parameter.
This commit is contained in:
parent
47aec956da
commit
5c26e5e2cd
@ -228,13 +228,11 @@ var PDFLinkService = (function () {
|
||||
this.page = pageNumber; // simple page
|
||||
}
|
||||
if ('pagemode' in params) {
|
||||
if (params.pagemode === 'thumbs' || params.pagemode === 'bookmarks' ||
|
||||
params.pagemode === 'attachments') {
|
||||
this.switchSidebarView((params.pagemode === 'bookmarks' ?
|
||||
'outline' : params.pagemode), true);
|
||||
} else if (params.pagemode === 'none' && this.sidebarOpen) {
|
||||
document.getElementById('sidebarToggle').click();
|
||||
}
|
||||
var event = document.createEvent('CustomEvent');
|
||||
event.initCustomEvent('pagemode', true, true, {
|
||||
mode: params.pagemode,
|
||||
});
|
||||
this.pdfViewer.container.dispatchEvent(event);
|
||||
}
|
||||
} else if (/^\d+$/.test(hash)) { // page number
|
||||
this.page = hash;
|
||||
|
@ -1566,6 +1566,30 @@ document.addEventListener('textlayerrendered', function (e) {
|
||||
//#endif
|
||||
}, true);
|
||||
|
||||
document.addEventListener('pagemode', function (evt) {
|
||||
if (!PDFViewerApplication.initialized) {
|
||||
return;
|
||||
}
|
||||
// Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`.
|
||||
var mode = evt.detail.mode;
|
||||
switch (mode) {
|
||||
case 'bookmarks':
|
||||
// Note: Our code calls this property 'outline', even though the
|
||||
// Open Parameter specification calls it 'bookmarks'.
|
||||
mode = 'outline';
|
||||
/* falls through */
|
||||
case 'thumbs':
|
||||
case 'attachments':
|
||||
PDFViewerApplication.switchSidebarView(mode, true);
|
||||
break;
|
||||
case 'none':
|
||||
if (PDFViewerApplication.sidebarOpen) {
|
||||
document.getElementById('sidebarToggle').click();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, true);
|
||||
|
||||
document.addEventListener('namedaction', function (e) {
|
||||
// Processing couple of named actions that might be useful.
|
||||
// See also PDFLinkService.executeNamedAction
|
||||
|
Loading…
Reference in New Issue
Block a user