Commit 6cbc305d authored by Mike Greiling's avatar Mike Greiling

prefer es6 string interpolation over concatination

parent 2e217bc8
...@@ -88,9 +88,9 @@ ...@@ -88,9 +88,9 @@
} }
tabShown(event) { tabShown(event) {
var $target, action, navBarHeight; const $target = $(event.target);
$target = $(event.target); const action = $target.data('action');
action = $target.data('action');
if (action === 'commits') { if (action === 'commits') {
this.loadCommits($target.attr('href')); this.loadCommits($target.attr('href'));
this.expandView(); this.expandView();
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
if (this.diffViewType() === 'parallel') { if (this.diffViewType() === 'parallel') {
this.expandViewContainer(); this.expandViewContainer();
} }
navBarHeight = $('.navbar-gitlab').outerHeight(); const navBarHeight = $('.navbar-gitlab').outerHeight();
$.scrollTo(".merge-request-details .merge-request-tabs", { $.scrollTo(".merge-request-details .merge-request-tabs", {
offset: -navBarHeight offset: -navBarHeight
}); });
...@@ -125,12 +125,12 @@ ...@@ -125,12 +125,12 @@
} }
scrollToElement(container) { scrollToElement(container) {
var $el, navBarHeight;
if (window.location.hash) { if (window.location.hash) {
navBarHeight = $('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight() + document.querySelector('.js-tabs-affix').offsetHeight; const navBarHeight = $('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight() + document.querySelector('.js-tabs-affix').offsetHeight;
$el = $(container + " " + window.location.hash + ":not(.match)"); const navBarHeight = $('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight();
const $el = $(`${container} ${window.location.hash}:not(.match)`);
if ($el.length) { if ($el.length) {
return $.scrollTo(container + " " + window.location.hash + ":not(.match)", { $.scrollTo($el[0], {
offset: -navBarHeight offset: -navBarHeight
}); });
} }
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
action = 'notes'; action = 'notes';
} }
// important note: the .tab('show') method triggers 'shown.bs.tab' event itself // important note: the .tab('show') method triggers 'shown.bs.tab' event itself
$(".merge-request-tabs a[data-action='" + action + "']").tab('show'); $(`.merge-request-tabs a[data-action='${action}']`).tab('show');
} }
// Replaces the current Merge Request-specific action in the URL with a new one // Replaces the current Merge Request-specific action in the URL with a new one
...@@ -167,19 +167,20 @@ ...@@ -167,19 +167,20 @@
// //
// Returns the new URL String // Returns the new URL String
setCurrentAction(action) { setCurrentAction(action) {
var new_state;
// Normalize action, just to be safe // Normalize action, just to be safe
if (action === 'show') { if (action === 'show') {
action = 'notes'; action = 'notes';
} }
this.currentAction = action; this.currentAction = action;
// Remove a trailing '/commits' '/diffs' '/builds' '/pipelines' '/new' '/new/diffs' // Remove a trailing '/commits' '/diffs' '/builds' '/pipelines' '/new' '/new/diffs'
new_state = this._location.pathname.replace(/\/(commits|diffs|builds|pipelines|new|new\/diffs)(\.html)?\/?$/, ''); let new_state = this._location.pathname.replace(/\/(commits|diffs|builds|pipelines|new|new\/diffs)(\.html)?\/?$/, '');
// Append the new action if we're on a tab other than 'notes' // Append the new action if we're on a tab other than 'notes'
if (action !== 'notes') { if (action !== 'notes') {
new_state += "/" + action; new_state += `/${action}`;
} }
// Ensure parameters and hash come along for the ride // Ensure parameters and hash come along for the ride
new_state += this._location.search + this._location.hash; new_state += this._location.search + this._location.hash;
...@@ -200,7 +201,7 @@ ...@@ -200,7 +201,7 @@
return; return;
} }
this.ajaxGet({ this.ajaxGet({
url: source + ".json", url: `${source}.json`,
success: (data) => { success: (data) => {
document.querySelector("div#commits").innerHTML = data.html; document.querySelector("div#commits").innerHTML = data.html;
gl.utils.localTimeAgo($('.js-timeago', 'div#commits')); gl.utils.localTimeAgo($('.js-timeago', 'div#commits'));
...@@ -217,11 +218,11 @@ ...@@ -217,11 +218,11 @@
// We extract pathname for the current Changes tab anchor href // We extract pathname for the current Changes tab anchor href
// some pages like MergeRequestsController#new has query parameters on that anchor // some pages like MergeRequestsController#new has query parameters on that anchor
var url = document.createElement('a'); const url = document.createElement('a');
url.href = source; url.href = source;
this.ajaxGet({ this.ajaxGet({
url: (url.pathname + ".json") + this._location.search, url: `${url.pathname}.json${this._location.search}`,
success: (data) => { success: (data) => {
$('#diffs').html(data.html); $('#diffs').html(data.html);
...@@ -248,7 +249,7 @@ ...@@ -248,7 +249,7 @@
return; return;
} }
this.ajaxGet({ this.ajaxGet({
url: source + ".json", url: `${source}.json`,
success: (data) => { success: (data) => {
document.querySelector("div#builds").innerHTML = data.html; document.querySelector("div#builds").innerHTML = data.html;
gl.utils.localTimeAgo($('.js-timeago', 'div#builds')); gl.utils.localTimeAgo($('.js-timeago', 'div#builds'));
...@@ -264,7 +265,7 @@ ...@@ -264,7 +265,7 @@
return; return;
} }
this.ajaxGet({ this.ajaxGet({
url: source + ".json", url: `${source}.json`,
success: (data) => { success: (data) => {
$('#pipelines').html(data.html); $('#pipelines').html(data.html);
gl.utils.localTimeAgo($('.js-timeago', '#pipelines')); gl.utils.localTimeAgo($('.js-timeago', '#pipelines'));
...@@ -282,7 +283,7 @@ ...@@ -282,7 +283,7 @@
} }
ajaxGet(options) { ajaxGet(options) {
var defaults = { const defaults = {
beforeSend: () => this.toggleLoading(true), beforeSend: () => this.toggleLoading(true),
complete: () => this.toggleLoading(false), complete: () => this.toggleLoading(false),
dataType: 'json', dataType: 'json',
...@@ -301,7 +302,7 @@ ...@@ -301,7 +302,7 @@
} }
expandViewContainer() { expandViewContainer() {
var $wrapper = $('.content-wrapper .container-fluid'); const $wrapper = $('.content-wrapper .container-fluid');
if (this.fixedLayoutPref === null) { if (this.fixedLayoutPref === null) {
this.fixedLayoutPref = $wrapper.hasClass('container-limited'); this.fixedLayoutPref = $wrapper.hasClass('container-limited');
} }
...@@ -316,8 +317,7 @@ ...@@ -316,8 +317,7 @@
} }
shrinkView() { shrinkView() {
var $gutterIcon; const $gutterIcon = $('.js-sidebar-toggle i:visible');
$gutterIcon = $('.js-sidebar-toggle i:visible');
// Wait until listeners are set // Wait until listeners are set
setTimeout(() => { setTimeout(() => {
...@@ -330,11 +330,10 @@ ...@@ -330,11 +330,10 @@
// Expand the issuable sidebar unless the user explicitly collapsed it // Expand the issuable sidebar unless the user explicitly collapsed it
expandView() { expandView() {
var $gutterIcon;
if (Cookies.get('collapsed_gutter') === 'true') { if (Cookies.get('collapsed_gutter') === 'true') {
return; return;
} }
$gutterIcon = $('.js-sidebar-toggle i:visible'); const $gutterIcon = $('.js-sidebar-toggle i:visible');
// Wait until listeners are set // Wait until listeners are set
setTimeout(() => { setTimeout(() => {
...@@ -346,15 +345,15 @@ ...@@ -346,15 +345,15 @@
} }
initAffix() { initAffix() {
var $tabs = $('.js-tabs-affix'); const $tabs = $('.js-tabs-affix');
// Screen space on small screens is usually very sparse // Screen space on small screens is usually very sparse
// So we dont affix the tabs on these // So we dont affix the tabs on these
if (Breakpoints.get().getBreakpointSize() === 'xs' || !$tabs.length) return; if (Breakpoints.get().getBreakpointSize() === 'xs' || !$tabs.length) return;
var $diffTabs = $('#diff-notes-app'), const $diffTabs = $('#diff-notes-app');
$fixedNav = $('.navbar-fixed-top'), const $fixedNav = $('.navbar-fixed-top');
$layoutNav = $('.layout-nav'); const $layoutNav = $('.layout-nav');
$tabs.off('affix.bs.affix affix-top.bs.affix') $tabs.off('affix.bs.affix affix-top.bs.affix')
.affix({ offset: { .affix({ offset: {
......
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