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
|
this.page = pageNumber; // simple page
|
||||||
}
|
}
|
||||||
if ('pagemode' in params) {
|
if ('pagemode' in params) {
|
||||||
if (params.pagemode === 'thumbs' || params.pagemode === 'bookmarks' ||
|
var event = document.createEvent('CustomEvent');
|
||||||
params.pagemode === 'attachments') {
|
event.initCustomEvent('pagemode', true, true, {
|
||||||
this.switchSidebarView((params.pagemode === 'bookmarks' ?
|
mode: params.pagemode,
|
||||||
'outline' : params.pagemode), true);
|
});
|
||||||
} else if (params.pagemode === 'none' && this.sidebarOpen) {
|
this.pdfViewer.container.dispatchEvent(event);
|
||||||
document.getElementById('sidebarToggle').click();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (/^\d+$/.test(hash)) { // page number
|
} else if (/^\d+$/.test(hash)) { // page number
|
||||||
this.page = hash;
|
this.page = hash;
|
||||||
|
|||||||
@ -1566,6 +1566,30 @@ document.addEventListener('textlayerrendered', function (e) {
|
|||||||
//#endif
|
//#endif
|
||||||
}, true);
|
}, 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) {
|
document.addEventListener('namedaction', function (e) {
|
||||||
// Processing couple of named actions that might be useful.
|
// Processing couple of named actions that might be useful.
|
||||||
// See also PDFLinkService.executeNamedAction
|
// See also PDFLinkService.executeNamedAction
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user