-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement core support for named actions, and some viewer functionality #3057
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2427,6 +2427,53 @@ var PageView = function pageView(container, id, scale, | |
}; | ||
link.className = 'internalLink'; | ||
} | ||
function bindNamedAction(link, action) { | ||
link.onclick = function pageViewSetupNamedActionOnClick() { | ||
// See PDF reference, table 8.45 - Named action | ||
console.log('Click with action', action); | ||
switch (action) { | ||
case 'GoToPage': | ||
document.getElementById('pageNumber').focus(); | ||
break; | ||
|
||
case 'GoBack': | ||
PDFHistory.back(); | ||
// TODO implement | ||
break; | ||
|
||
case 'GoForward': | ||
PDFHistory.forward(); | ||
// TODO implement | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove TODO |
||
break; | ||
|
||
case 'Find': | ||
PDFFindBar.toggle(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep the supported-integrated find check: if is not supported allow to toggle internal find bar, if it's supported do nothing |
||
break; | ||
|
||
case 'NextPage': | ||
PDFView.page++; | ||
break; | ||
|
||
case 'PrevPage': | ||
PDFView.page--; | ||
break; | ||
|
||
case 'LastPage': | ||
PDFView.page = PDFView.pages.length; | ||
break; | ||
|
||
case 'FirstPage': | ||
PDFView.page = 1; | ||
break; | ||
|
||
default: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add 'break' after the comment below or delete default branch |
||
// No action according to spec | ||
} | ||
|
||
return false; | ||
}; | ||
link.className = 'internalLink'; | ||
} | ||
|
||
pdfPage.getAnnotations().then(function(annotationsData) { | ||
viewport = viewport.clone({ dontFlip: true }); | ||
|
@@ -2460,7 +2507,11 @@ var PageView = function pageView(container, id, scale, | |
CustomStyle.setProp('transformOrigin', element, transformOriginStr); | ||
|
||
if (data.subtype === 'Link' && !data.url) { | ||
bindLink(element, ('dest' in data) ? data.dest : null); | ||
if (data.action) { | ||
bindNamedAction(element, data.action); | ||
} else { | ||
bindLink(element, ('dest' in data) ? data.dest : null); | ||
} | ||
} | ||
|
||
annotationsDiv.appendChild(element); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove TODO