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) { _updateScrollMode(pageNumber = null) {
const scrollMode = this._scrollMode, viewer = this.viewer; const scrollMode = this._scrollMode, viewer = this.viewer;
if (scrollMode === ScrollMode.HORIZONTAL) { viewer.classList.toggle('scrollHorizontal',
viewer.classList.add('scrollHorizontal'); scrollMode === ScrollMode.HORIZONTAL);
} else { viewer.classList.toggle('scrollWrapped',
viewer.classList.remove('scrollHorizontal'); scrollMode === ScrollMode.WRAPPED);
}
if (scrollMode === ScrollMode.WRAPPED) {
viewer.classList.add('scrollWrapped');
} else {
viewer.classList.remove('scrollWrapped');
}
if (!this.pdfDocument || !pageNumber) { if (!this.pdfDocument || !pageNumber) {
return; return;

View File

@ -132,13 +132,9 @@ class PDFFindBar {
break; break;
} }
if (notFound) { this.findField.classList.toggle('notFound', notFound);
this.findField.classList.add('notFound');
} else {
this.findField.classList.remove('notFound');
}
this.findField.setAttribute('data-status', status); this.findField.setAttribute('data-status', status);
Promise.resolve(findMsg).then((msg) => { Promise.resolve(findMsg).then((msg) => {
this.findMsg.textContent = msg; this.findMsg.textContent = msg;
this._adjustWidth(); this._adjustWidth();

View File

@ -123,11 +123,11 @@ class SecondaryToolbar {
// current `BaseViewer` instance (in particular `PDFSinglePageViewer`). // current `BaseViewer` instance (in particular `PDFSinglePageViewer`).
this.eventBus.on('baseviewerinit', (evt) => { this.eventBus.on('baseviewerinit', (evt) => {
if (evt.source instanceof PDFSinglePageViewer) { if (evt.source instanceof PDFSinglePageViewer) {
this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons'); this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons',
this.toolbarButtonContainer.classList.add('hiddenSpreadModeButtons'); 'hiddenSpreadModeButtons');
} else { } else {
this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons'); this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons',
this.toolbarButtonContainer.classList.remove('hiddenSpreadModeButtons'); 'hiddenSpreadModeButtons');
} }
}); });
} }

View File

@ -224,11 +224,7 @@ class Toolbar {
updateLoadingIndicatorState(loading = false) { updateLoadingIndicatorState(loading = false) {
let pageNumberInput = this.items.pageNumber; let pageNumberInput = this.items.pageNumber;
if (loading) { pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR);
} else {
pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR);
}
} }
_adjustScaleWidth() { _adjustScaleWidth() {