-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Added more preferences for the available hash parameters. #4851
Conversation
@@ -1727,7 +1741,7 @@ function webViewerInitialized() { | |||
} | |||
|
|||
if ('useOnlyCssZoom' in hashParams) { | |||
USE_ONLY_CSS_ZOOM = (hashParams['useOnlyCssZoom'] === 'true'); | |||
PDFJS.useCssZoom = (hashParams['useOnlyCssZoom'] === 'true'); |
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.
Given that the hash parameter is called useOnlyCssZoom
, it seems a bit strange, and inconsistent, that the preference is then called useCssZoom
.
If I understand correctly, the reason for the name useOnlyCssZoom
would be that we use CSS zooming before re-rendering. But with the parameter set, we don't re-render and instead use only CSS zooming, hence the name.
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.
I named it this way in #4792 :)
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.
I see; but I don't really agree with that name ;-)
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.
Also, do we actually need to introduce this property on PDFJS
(given that it's only used in the viewer)?
If we keep this change, this needs to be changed as well: https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L46, otherwise we break the B2G viewer.
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.
@Snuffleupagus do we need to rename useOnlyCssZoom
?
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.
Ok yep. I wasn't sure what B2G was. I will do the change.
I agree with you @Snuffleupagus that it is inconsistent. I have also noticed that enabledWebgl is also inconsistent because the hash param is actually just webgl ...
FIxes #4792 |
Could you add useCssZoom at https://github.com/mozilla/pdf.js/blob/master/src/display/api.js ? Also change line viewer.js at L45. |
Yep, ill do the above changes, just confirming if I should rename useCssZoom to useOnlyCssZoom or not? |
I don't think it matters much, but let's rename hash parameter to useCssZoom. |
I think from @Snuffleupagus comment above it actually makes sense to me to call |
@@ -228,6 +227,21 @@ var PDFView = { | |||
}, function rejected(reason) {}), | |||
Preferences.get('sidebarViewOnLoad').then(function resolved(value) { | |||
self.preferenceSidebarViewOnLoad = value; | |||
}, function rejected(reason) {}), |
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.
Let's move all .then(function resolved(value) { self.preferenceSidebarViewOnLoad = value; }, function rejected(reason) {})
after Promise.all(...)
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.
You mean just move the sidebarViewOnLoad to be after the Promise.all call. Something like this?
var initializedPromise = Promise.all([
Preferences.get('enableWebGL').then(function resolved(value) {
PDFJS.disableWebGL = !value;
}, function rejected(reason) {}),
......
......
.....
// TODO move more preferences and other async stuff here
]).Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
self.preferenceSidebarViewOnLoad = value;
}, function rejected(reason) {});
I was also wondering if there is a way to specify the rejected
fn for all the promises inside the Promise.all([...])
call rather than specifying it for each promise?
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.
sorry, I meant only reject part (too many then's):
var initializedPromise = Promise.all([
Preferences.get('enableWebGL').then(function resolved(value) {
PDFJS.disableWebGL = !value;
}),
Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
self.preferenceSidebarViewOnLoad = value;
}),
....
]).catch(function (reason) { });
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.
Yep that's what i was wondering about, thanks! Will do that change now.
okay, let's use |
* @var {boolean} | ||
*/ | ||
PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ? | ||
false : PDFJS.useOnlyCssZoom); |
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.
Nit: add two more spaces to the indentation.
Unfortunately this will still not work in B2G, since the preference values will override the values set here: https://github.com/orionhealth/pdf.js/blob/4792-addprefhashparam/web/viewer.js#L44-L47. var DEFAULT_PREFERENCES = {
showPreviousViewOnLoad: true,
defaultZoomValue: '',
sidebarViewOnLoad: 0,
enableHandToolOnLoad: false,
enableWebGL: false,
disableRange: false,
disableAutoFetch: false,
disableFontFace: false,
//#if B2G
// disableTextLayer: true,
// useOnlyCssZoom: true
//#else
disableTextLayer: false
useOnlyCssZoom: false
//#endif
}; Edit: Once you have addressed the comments, please squash the commits. See https://github.com/mozilla/pdf.js/wiki/Squashing-Commits. |
// TODO move more preferences and other async stuff here | ||
]); | ||
], function (reason) {}); |
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.
According to #4851 (comment), this should be:
]).catch(function (reason) {});
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.
Yep, i will do the changes in the above comments and squash the commits.
/botio-windows preview |
From: Bot.io (Windows)ReceivedCommand cmd_preview from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/c0f700a3afeed34/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/c0f700a3afeed34/output.txt Total script time: 0.88 mins Published
|
disableAutoFetch: false, | ||
disableFontFace: false, | ||
//#if B2G | ||
// disableTextLayer: true, |
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.
nit: unindent by two space -- preprocessor replaces '//' with spaces. the same below
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.
@yurydelendik Ok yep, will do that. To me it read better having them indented but ye I don't mind.
So this is how you reckon it should be?
//#if B2G
//disableTextLayer: true,
//useOnlyCssZoom: true
//#else
disableTextLayer: false,
useOnlyCssZoom: false
//#endif
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.
yep
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.
see line 318 at the generated code at http://107.22.172.223:8877/c0f700a3afeed34/web/viewer.js
Looks good with comment above addressed. |
@Eyesonly88 Could you squash the commits again? |
yep ok, will do that now. |
@yurydelendik Could you check/merge this? |
Looks good. Thanks you for the patch |
Added more preferences for the available hash parameters.
No description provided.