Commit aa2d6eec authored by Filipa Lacerda's avatar Filipa Lacerda

Improvements after review

parent 6789befb
......@@ -137,7 +137,7 @@
break;
case 'projects:pipelines:builds':
case 'projects:pipelines:show':
const controllerAction = document.querySelector('.js-pipeline-container').dataset.controllerAction;
const { controllerAction } = document.querySelector('.js-pipeline-container').dataset;
new gl.Pipelines({
initTabs: true,
......
......@@ -6,17 +6,15 @@ Element.prototype.closest = Element.prototype.closest || function closest(select
return selectedElement.matches(selector) ? selectedElement : Element.prototype.closest(selector, selectedElement.parentElement);
};
if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function (s) {
const matches = (this.document || this.ownerDocument).querySelectorAll(s);
let i = matches.length;
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1;
};
}
Element.prototype.matches = Element.prototype.matches ||
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function (s) {
const matches = (this.document || this.ownerDocument).querySelectorAll(s);
let i = matches.length;
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1;
};
......@@ -53,16 +53,18 @@
this.defaultAction = this.options.defaultAction;
this.action = this.options.action || this.defaultAction;
this.currentLocation = window.location;
if (this.action === 'show') {
this.action = this.defaultAction;
}
this.currentLocation = window.location;
const tabSelector = `${this.options.parentEl} a[data-toggle="tab"]`;
// since this is a custom event we need jQuery :(
$(document)
.off('shown.bs.tab', `${this.options.parentEl} a[data-toggle="tab"]`)
.on('shown.bs.tab', `${this.options.parentEl} a[data-toggle="tab"]`, evt => this.tabShown(evt));
.off('shown.bs.tab', tabSelector)
.on('shown.bs.tab', tabSelector, e => this.tabShown(e));
this.activateTab(this.action);
}
......@@ -90,7 +92,7 @@
copySource.replace(/\/+$/, '');
const newState = copySource + this.currentLocation.search + this.currentLocation.hash;
const newState = `${copySource}${this.currentLocation.search}${this.currentLocation.hash}`;
history.replaceState({
turbolinks: true,
......
......@@ -7,7 +7,7 @@
constructor(options) {
if (options.initTabs && options.tabsOptions) {
new window.gl.LinkedTabs(options.tabsOptions);
new global.LinkedTabs(options.tabsOptions);
}
this.addMarginToBuildColumns();
......
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