Commit cc3e488c authored by Douwe Maan's avatar Douwe Maan

Satisfy eslint

parent 36e7b322
``/* eslint-disable no-new */
/* eslint-disable no-new */
/* global Flash */
export default class BlobViewer {
constructor() {
......@@ -50,7 +50,7 @@ export default class BlobViewer {
if (this.simpleViewer.getAttribute('data-loaded')) {
this.copySourceBtn.setAttribute('title', 'Copy source to clipboard');
this.copySourceBtn.classList.remove('disabled');
} else if (this.activeViewer == this.simpleViewer) {
} else if (this.activeViewer === this.simpleViewer) {
this.copySourceBtn.setAttribute('title', 'Wait for the source to load to copy it to the clipboard');
this.copySourceBtn.classList.add('disabled');
} else {
......@@ -61,12 +61,11 @@ export default class BlobViewer {
$(this.copySourceBtn).tooltip('fixTitle');
}
loadViewer(viewerParam, resolve, reject) {
loadViewer(viewerParam) {
const viewer = viewerParam;
const url = viewer.getAttribute('data-url');
if (!url || viewer.getAttribute('data-loaded') || viewer.getAttribute('data-loading')) {
if (resolve) resolve();
return;
}
......@@ -76,9 +75,6 @@ export default class BlobViewer {
url,
dataType: 'JSON',
})
.fail(() => {
if (reject) reject();
})
.done((data) => {
viewer.innerHTML = data.html;
$(viewer).syntaxHighlight();
......@@ -88,16 +84,14 @@ export default class BlobViewer {
this.$blobContentHolder.trigger('highlight:line');
this.toggleCopyButtonState();
if (resolve) resolve();
});
}
switchToViewer(name) {
const newViewer = document.querySelector(`.blob-viewer[data-type='${name}']`);
if (this.activeViewer == newViewer) return;
if (this.activeViewer === newViewer) return;
const oldButton = document.querySelector('.js-blob-viewer-switcher.active')
const oldButton = document.querySelector('.js-blob-viewer-switcher.active');
const newButton = document.querySelector(`.js-blob-viewer-switcher[data-viewer='${name}']`);
const oldViewer = document.querySelector(`.blob-viewer:not([data-type='${name}'])`);
......@@ -120,11 +114,6 @@ export default class BlobViewer {
this.toggleCopyButtonState();
return new Promise((resolve, reject) => {
this.loadViewer(newViewer, resolve, reject);
})
.catch(() => {
new Flash('Error loading file');
});
this.loadViewer(newViewer);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment