summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob/viewer
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-04-20 17:56:24 -0500
committerDouwe Maan <douwe@selenight.nl>2017-04-27 12:23:26 -0500
commitcc3e488c984abe220cbecb35b61af5b04d93f90d (patch)
treeb563d5f6e19f57043fb10f17a8a563102e7a0488 /app/assets/javascripts/blob/viewer
parent36e7b322a765fa29a764f2ef1c2f0d28b27a569e (diff)
downloadgitlab-ce-cc3e488c984abe220cbecb35b61af5b04d93f90d.tar.gz
Satisfy eslint
Diffstat (limited to 'app/assets/javascripts/blob/viewer')
-rw-r--r--app/assets/javascripts/blob/viewer/index.js25
1 files changed, 7 insertions, 18 deletions
diff --git a/app/assets/javascripts/blob/viewer/index.js b/app/assets/javascripts/blob/viewer/index.js
index 47c20d60446..a322351219c 100644
--- a/app/assets/javascripts/blob/viewer/index.js
+++ b/app/assets/javascripts/blob/viewer/index.js
@@ -1,4 +1,4 @@
-``/* 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}'])`);
@@ -113,18 +107,13 @@ export default class BlobViewer {
if (oldViewer) {
oldViewer.classList.add('hidden');
}
-
+
newViewer.classList.remove('hidden');
this.activeViewer = newViewer;
this.toggleCopyButtonState();
- return new Promise((resolve, reject) => {
- this.loadViewer(newViewer, resolve, reject);
- })
- .catch(() => {
- new Flash('Error loading file');
- });
+ this.loadViewer(newViewer);
}
}