Skip to content

Convert the secondary toolbar to a class #7313

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

Merged
merged 1 commit into from
May 11, 2016

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented May 10, 2016

Furthermore we:

  • extract listener binding into two separate methods;
  • create a getter for the open state of the secondary toolbar;
  • improve the naming of methods and buttons to be more consistent and descriptive;
  • add JSDoc comments;
  • refactor the click binding code to remove all event handler methods and separate button member variables.

This patch is easier to review with the ?w=1 flag.

@timvandermeij timvandermeij force-pushed the secondary-toolbar-class branch 4 times, most recently from c71b6c1 to 41e7a0a Compare May 11, 2016 00:00

// Bind the event listeners for click and hand tool actions.
this.bindClickListeners();
this.bindHandToolListener();
Copy link
Collaborator

@Snuffleupagus Snuffleupagus May 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to do a proper review later on, but just a drive-by comment so far: Let's make these methods "private", i.e. this._bind... (with the associated JSDoc comments).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the new commit.

@timvandermeij timvandermeij force-pushed the secondary-toolbar-class branch from 41e7a0a to 26dc176 Compare May 11, 2016 12:53
this.toolbar = options.toolbar;
this.buttonContainer = this.toolbar.firstElementChild;

// Define the toolbar buttons.
this.toggleButton = options.toggleButton;
this.presentationModeButton = options.presentationModeButton;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a minor (existing) inconsistency, where some of the options have ...Button on the end, and others don't. This is likely to be for "historical reasons", but since you're touching this code anyway, it'd be nice to make this more consistent :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the new commit.

Copy link
Collaborator

@Snuffleupagus Snuffleupagus May 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!
However, looking at the updated patch, the "Button" suffix everywhere makes the code look a bit busy. So, do we actually need it, or could we remove it for all SecondaryToolbar buttons?

I'm really sorry about not suggesting this previously, so if you do not want to remove the "...Button" part from all strings in this patch, I will not insist on this change!

Copy link
Contributor Author

@timvandermeij timvandermeij May 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the Button suffix looks better, especially when comparing cases such as this.print versus this.printButton and this.download versus this.downloadButton. For me, the Button suffix makes it more clear that it is actually a reference to a button object, instead of an action like printing or downloading. I do see that this is a personal preference though.

To resolve the concern somewhat, I managed to get rid of the separate member variables for the buttons altogether by moving the button array to the constructor. This makes it look cleaner because we do not have to mention all the buttons twice anymore. I only had to pass in the hand tool button to the _bindHandToolListener method as that was the only method that actually used one of the button member variables.

Fun fact: after this change we have exactly +178 −178 line changes for this patch :-)

@timvandermeij timvandermeij force-pushed the secondary-toolbar-class branch 4 times, most recently from eb7f807 to ad415c9 Compare May 11, 2016 15:23
* @property {HTMLButtonElement} toggleHandToolButton - Button to toggle the
* hand tool.
* @property {HTMLButtonElement} documentPropertiesButton - Button to toggle the
* visibility of the document properties overlay.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really a toggle, so e.g. "Button for opening the document properties dialog" might be better here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the new commit.

@timvandermeij timvandermeij force-pushed the secondary-toolbar-class branch from ad415c9 to f4ae277 Compare May 11, 2016 18:57
@timvandermeij
Copy link
Contributor Author

/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/caa752fa9224791/output.txt

@Snuffleupagus
Copy link
Collaborator

Fun fact: after this change we have exactly +178 −178 line changes for this patch :-)

That's really nice!
I'm sorry about going back and forth a bit in my review comments, but once I started looking at the code I noticed that there were a number of opportunities to clean up some old stuff.

This is looking much better now, thank you for the patch (and patience)!

@Snuffleupagus Snuffleupagus merged commit 12a9397 into mozilla:master May 11, 2016
@timvandermeij timvandermeij deleted the secondary-toolbar-class branch May 11, 2016 22:20
@timvandermeij
Copy link
Contributor Author

No worries, I'm really happy with how this turned out after your comments!

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.

3 participants