Convert some occurrences, in the /web folder, of classList.{add, remove} to classList.toggle with the "force" parameter

This commit is contained in:
Jonas Jenwald 2018-10-12 15:29:45 +02:00
parent 4cde844ffe
commit ea4db64f41
4 changed files with 11 additions and 25 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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');
}
});
}

View File

@ -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() {