Skip to content
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

Move the sidebar related code from viewer.js into PDFSidebar #7038

Merged
merged 2 commits into from
Feb 28, 2016
Merged

Move the sidebar related code from viewer.js into PDFSidebar #7038

merged 2 commits into from
Feb 28, 2016

Conversation

Snuffleupagus
Copy link
Collaborator

These patches follow in the steps of many previous PRs, which moved code out of viewer.js and into separate classes/files. Please refer to the commit messages for more details.

Besides the clean-up, this is also necessary to prevent Preferences/ViewHistory from "fighting" each-other on document load, when addressing issue #6935.
First of all, we currently don't track the state of the sidebar, besides open/close. Second of all, just adding a ViewHistory setting could lead to weird/unintuitive behaviour when both a preference and setting exists. An easy solution to the above, based on these patches, could then be e.g. https://gist.github.com/Snuffleupagus/7aa031391399962846b0.

@timvandermeij Is this something that you would be willing to review?

@timvandermeij
Copy link
Contributor

This looks really nice! It does need a rebase after landing a previous PR. Could you rebase it?

…iewer.js, rename the classes, and refactor their `render` methods

Changes `PDFOutlineView`/`PDFAttachmentView` to be initialized once, since we're always creating them, and refactor their `render` methods to instead pass in the `outline`/`attachments`.

For consistency with other "classes", the `PDFOutlineView`/`PDFAttachmentView` are renamed to `PDFOutlineViewer`/`PDFAttachmentViewer`.

Also, make sure that the outline/attachments are reset when the document is closed. Currently we keep the old ones around until the `getOutline`/`getAttachments` API calls are resolved for a new document.
The sidebar code has, except for minor fixes/additions (such as attachments), been largely untouch for years.
To avoid having a bunch of sidebar code sprinkled throughout viewer.js, this patch moves the sidebar code into a separate file (pdf_sidebar.js), similar to how most other functionality has been moved in the last few years.

Besides simply moving code around, this patch also has the added benefit that we now keep track of the sidebar state (not just opened/closed).
This now makes it possible to handle both `Preferences` *and* `ViewHistory` settings for the sidebar state in a cleaner way, preventing strange and confusing interactions between the two.
@Snuffleupagus
Copy link
Collaborator Author

This looks really nice! It does need a rebase after landing a previous PR. Could you rebase it?

Done, and thanks for the other reviews!

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/241838708f3dcd3/output.txt

timvandermeij added a commit that referenced this pull request Feb 28, 2016
Move the sidebar related code from viewer.js into `PDFSidebar`
@timvandermeij timvandermeij merged commit 9ff6c83 into mozilla:master Feb 28, 2016
@timvandermeij
Copy link
Contributor

Awesome work! This really is much cleaner than before.

@Snuffleupagus
Copy link
Collaborator Author

Thank you so much for reviewing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants