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

This commit is contained in:
Luke "Jared" Bennett 2016-10-17 19:06:56 +00:00 committed by Luke Bennett
parent 60eca5f7b5
commit c1be12d0fc
No known key found for this signature in database
GPG key ID: A738E9C68D3BF31A

View file

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