Commit c1be12d0 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett Committed by Luke Bennett

Tidied up pipelines.js.es6 and removed jQuery where acceptable.

parent 60eca5f7
...@@ -2,20 +2,22 @@ ...@@ -2,20 +2,22 @@
class Pipelines { class Pipelines {
constructor() { constructor() {
$(document).off('click', '.toggle-pipeline-btn').on('click', '.toggle-pipeline-btn', this.toggleGraph); this.initGraphToggle();
this.addMarginToBuildColumns(); this.addMarginToBuildColumns();
} }
toggleGraph() { initGraphToggle() {
const $pipelineBtn = $(this).closest('.toggle-pipeline-btn'); this.toggleButton = document.querySelector('.toggle-pipeline-btn');
const $pipelineGraph = $(this).closest('.row-content-block').next('.pipeline-graph'); this.toggleButtonText = this.toggleButton.querySelector('.toggle-btn-text');
const $btnText = $(this).find('.toggle-btn-text'); this.pipelineGraph = document.querySelector('.pipeline-graph');
const graphCollapsed = $pipelineGraph.hasClass('graph-collapsed'); this.toggleButton.addEventListener('click', this.toggleGraph.bind(this));
}
$($pipelineBtn).add($pipelineGraph).toggleClass('graph-collapsed');
graphCollapsed ? $btnText.text('Hide') : $btnText.text('Expand') toggleGraph() {
const graphCollapsed = this.pipelineGraph.classList.contains('graph-collapsed');
this.toggleButton.classList.toggle('graph-collapsed');
this.pipelineGraph.classList.toggle('graph-collapsed');
graphCollapsed ? this.toggleButtonText.textContent = 'Hide' : this.toggleButtonText.textContent = 'Expand';
} }
addMarginToBuildColumns() { addMarginToBuildColumns() {
...@@ -31,7 +33,7 @@ ...@@ -31,7 +33,7 @@
if ($('.build', $this).length === 1) $this.addClass('no-margin'); if ($('.build', $this).length === 1) $this.addClass('no-margin');
}); });
} }
$('.pipeline-graph').removeClass('hidden'); this.pipelineGraph.classList.remove('hidden');
} }
} }
......
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