Skip to content

Commit

Permalink
Merge pull request #10138 from Snuffleupagus/toolbar-pageScaleValue
Browse files Browse the repository at this point in the history
Ensure that `Toolbar.setPageScale` always sets the `pageScaleValue` property to a valid value
  • Loading branch information
timvandermeij authored Oct 5, 2018
2 parents 3c6d0a8 + a4d4364 commit d4469da
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions web/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Toolbar {
}

setPageScale(pageScaleValue, pageScale) {
this.pageScaleValue = pageScaleValue;
this.pageScaleValue = (pageScaleValue || pageScale).toString();
this.pageScale = pageScale;
this._updateUIState(false);
}
Expand Down Expand Up @@ -169,9 +169,7 @@ class Toolbar {
// Don't update the UI state until we localize the toolbar.
return;
}
let { pageNumber, pagesCount, items, } = this;
let scaleValue = (this.pageScaleValue || this.pageScale).toString();
let scale = this.pageScale;
const { pageNumber, pagesCount, pageScaleValue, pageScale, items, } = this;

if (resetNumPages) {
if (this.hasPageLabels) {
Expand Down Expand Up @@ -199,17 +197,17 @@ class Toolbar {
items.previous.disabled = (pageNumber <= 1);
items.next.disabled = (pageNumber >= pagesCount);

items.zoomOut.disabled = (scale <= MIN_SCALE);
items.zoomIn.disabled = (scale >= MAX_SCALE);
items.zoomOut.disabled = (pageScale <= MIN_SCALE);
items.zoomIn.disabled = (pageScale >= MAX_SCALE);

let customScale = Math.round(scale * 10000) / 100;
let customScale = Math.round(pageScale * 10000) / 100;
this.l10n.get('page_scale_percent', { scale: customScale, },
'{{scale}}%').then((msg) => {
let options = items.scaleSelect.options;
let predefinedValueFound = false;
for (let i = 0, ii = options.length; i < ii; i++) {
let option = options[i];
if (option.value !== scaleValue) {
if (option.value !== pageScaleValue) {
option.selected = false;
continue;
}
Expand Down

0 comments on commit d4469da

Please sign in to comment.