Skip to content

Commit

Permalink
Convert some occurrences, in the /web folder, of `classList.{add, r…
Browse files Browse the repository at this point in the history
…emove}` to `classList.toggle` with the "force" parameter
  • Loading branch information
Snuffleupagus committed Oct 12, 2018
1 parent 4cde844 commit ea4db64
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
14 changes: 4 additions & 10 deletions web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1038,16 +1038,10 @@ class BaseViewer {
_updateScrollMode(pageNumber = null) {
const scrollMode = this._scrollMode, viewer = this.viewer;

if (scrollMode === ScrollMode.HORIZONTAL) {
viewer.classList.add('scrollHorizontal');
} else {
viewer.classList.remove('scrollHorizontal');
}
if (scrollMode === ScrollMode.WRAPPED) {
viewer.classList.add('scrollWrapped');
} else {
viewer.classList.remove('scrollWrapped');
}
viewer.classList.toggle('scrollHorizontal',
scrollMode === ScrollMode.HORIZONTAL);
viewer.classList.toggle('scrollWrapped',
scrollMode === ScrollMode.WRAPPED);

if (!this.pdfDocument || !pageNumber) {
return;
Expand Down
8 changes: 2 additions & 6 deletions web/pdf_find_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,9 @@ class PDFFindBar {
break;
}

if (notFound) {
this.findField.classList.add('notFound');
} else {
this.findField.classList.remove('notFound');
}

this.findField.classList.toggle('notFound', notFound);
this.findField.setAttribute('data-status', status);

Promise.resolve(findMsg).then((msg) => {
this.findMsg.textContent = msg;
this._adjustWidth();
Expand Down
8 changes: 4 additions & 4 deletions web/secondary_toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ class SecondaryToolbar {
// current `BaseViewer` instance (in particular `PDFSinglePageViewer`).
this.eventBus.on('baseviewerinit', (evt) => {
if (evt.source instanceof PDFSinglePageViewer) {
this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons');
this.toolbarButtonContainer.classList.add('hiddenSpreadModeButtons');
this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons',
'hiddenSpreadModeButtons');
} else {
this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons');
this.toolbarButtonContainer.classList.remove('hiddenSpreadModeButtons');
this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons',
'hiddenSpreadModeButtons');
}
});
}
Expand Down
6 changes: 1 addition & 5 deletions web/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,7 @@ class Toolbar {
updateLoadingIndicatorState(loading = false) {
let pageNumberInput = this.items.pageNumber;

if (loading) {
pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR);
} else {
pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR);
}
pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
}

_adjustScaleWidth() {
Expand Down

0 comments on commit ea4db64

Please sign in to comment.