Skip to content

Commit

Permalink
Ensure that Scroll/Spread mode buttons are correctly reset, when the …
Browse files Browse the repository at this point in the history
…document is closed

Since the Scroll/Spread modes are now document specific, as all other properties such as page/scale/rotation, ensure that the toolbar is always correctly reset.
  • Loading branch information
Snuffleupagus committed Jun 30, 2018
1 parent 588cca2 commit e0fe635
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions web/secondary_toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ class SecondaryToolbar {
this.pageNumber = 0;
this.pagesCount = 0;
this._updateUIState();

// Reset the Scroll/Spread buttons too, since they're document specific.
this.eventBus.dispatch('resetscrollmode', { source: this, });
this.eventBus.dispatch('resetspreadmode', { source: this, });
}

_updateUIState() {
Expand Down Expand Up @@ -189,7 +193,7 @@ class SecondaryToolbar {
}

_bindScrollModeListener(buttons) {
this.eventBus.on('scrollmodechanged', function(evt) {
function scrollModeChanged(evt) {
buttons.scrollVerticalButton.classList.remove('toggled');
buttons.scrollHorizontalButton.classList.remove('toggled');
buttons.scrollWrappedButton.classList.remove('toggled');
Expand All @@ -205,11 +209,18 @@ class SecondaryToolbar {
buttons.scrollWrappedButton.classList.add('toggled');
break;
}
}
this.eventBus.on('scrollmodechanged', scrollModeChanged);

this.eventBus.on('resetscrollmode', (evt) => {
if (evt.source === this) {
scrollModeChanged({ mode: ScrollMode.VERTICAL, });
}
});
}

_bindSpreadModeListener(buttons) {
this.eventBus.on('spreadmodechanged', function(evt) {
function spreadModeChanged(evt) {
buttons.spreadNoneButton.classList.remove('toggled');
buttons.spreadOddButton.classList.remove('toggled');
buttons.spreadEvenButton.classList.remove('toggled');
Expand All @@ -225,6 +236,13 @@ class SecondaryToolbar {
buttons.spreadEvenButton.classList.add('toggled');
break;
}
}
this.eventBus.on('spreadmodechanged', spreadModeChanged);

this.eventBus.on('resetspreadmode', (evt) => {
if (evt.source === this) {
spreadModeChanged({ mode: SpreadMode.NONE, });
}
});
}

Expand Down

0 comments on commit e0fe635

Please sign in to comment.