Commit aa2d6eec authored by Filipa Lacerda's avatar Filipa Lacerda

Improvements after review

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