gitlab-org--gitlab-foss/app/assets/javascripts/pipeline.js.es6

37 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-08-17 17:41:24 -04:00
(function() {
function addMarginToBuild () {
const $secondChildBuildNode = $('.build:nth-child(2)');
const $firstChildBuildNode = $secondChildBuildNode.prev('.build');
// const $previousBuildColumn = $secondChildBuildNode.closest('.stage-column').prev('.stage-column');
if ($secondChildBuildNode.length) {
$secondChildBuildNode.closest('.stage-column').addClass('left-margin');
$firstChildBuildNode.addClass('left-connector');
}
}
2016-08-17 17:41:24 -04:00
function 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 $icon = $(this).find('.fa');
2016-08-17 17:41:24 -04:00
$($pipelineBtn).add($pipelineGraph).toggleClass('graph-collapsed');
2016-08-17 17:41:24 -04:00
const graphCollapsed = $pipelineGraph.hasClass('graph-collapsed');
const expandIcon = 'fa-caret-down';
const hideIcon = 'fa-caret-up';
if(graphCollapsed) {
$btnText.text('Expand');
$icon.removeClass(hideIcon).addClass(expandIcon);
} else {
$btnText.text('Hide');
$icon.removeClass(expandIcon).addClass(hideIcon);
}
2016-08-17 17:41:24 -04:00
}
2016-08-17 17:41:24 -04:00
$(document).on('click', '.toggle-pipeline-btn', toggleGraph);
$(document).on('ready', addMarginToBuild);
2016-08-17 17:41:24 -04:00
})();