debian-mirror-gitlab/app/assets/javascripts/build_artifacts.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2021-01-03 14:25:43 +05:30
import { hide, initTooltips, show } from '~/tooltips';
2021-03-11 19:13:27 +05:30
import { parseBoolean } from './lib/utils/common_utils';
import { visitUrl } from './lib/utils/url_utility';
2016-09-13 17:45:13 +05:30
2018-03-17 18:26:18 +05:30
export default class BuildArtifacts {
constructor() {
2017-08-17 22:00:37 +05:30
this.disablePropagation();
this.setupEntryClick();
2018-03-17 18:26:18 +05:30
this.setupTooltips();
2017-08-17 22:00:37 +05:30
}
2021-01-03 14:25:43 +05:30
2018-03-17 18:26:18 +05:30
// eslint-disable-next-line class-methods-use-this
disablePropagation() {
2021-03-08 18:12:59 +05:30
$('.top-block').on('click', '.download', (e) => {
2019-12-21 20:55:43 +05:30
e.stopPropagation();
2017-08-17 22:00:37 +05:30
});
2021-03-08 18:12:59 +05:30
return $('.tree-holder').on('click', 'tr[data-link] a', (e) => {
2019-12-21 20:55:43 +05:30
e.stopImmediatePropagation();
2017-08-17 22:00:37 +05:30
});
2018-03-17 18:26:18 +05:30
}
2021-01-03 14:25:43 +05:30
2018-03-17 18:26:18 +05:30
// eslint-disable-next-line class-methods-use-this
setupEntryClick() {
2023-06-20 00:43:36 +05:30
// eslint-disable-next-line func-names
2021-03-08 18:12:59 +05:30
return $('.tree-holder').on('click', 'tr[data-link]', function () {
2019-02-15 15:39:39 +05:30
visitUrl(this.dataset.link, parseBoolean(this.dataset.externalLink));
2018-03-17 18:26:18 +05:30
});
}
2021-01-03 14:25:43 +05:30
2018-03-17 18:26:18 +05:30
// eslint-disable-next-line class-methods-use-this
setupTooltips() {
2021-01-03 14:25:43 +05:30
initTooltips({
2018-03-17 18:26:18 +05:30
placement: 'bottom',
// Stop the tooltip from hiding when we stop hovering the element directly
// We handle all the showing/hiding below
trigger: 'manual',
2017-08-17 22:00:37 +05:30
});
2016-09-13 17:45:13 +05:30
2018-03-17 18:26:18 +05:30
// We want the tooltip to show if you hover anywhere on the row
// But be placed below and in the middle of the file name
$('.js-artifact-tree-row')
2021-03-08 18:12:59 +05:30
.on('mouseenter', (e) => {
2021-01-03 14:25:43 +05:30
const $el = $(e.currentTarget).find('.js-artifact-tree-tooltip');
show($el);
2018-03-17 18:26:18 +05:30
})
2021-03-08 18:12:59 +05:30
.on('mouseleave', (e) => {
2021-01-03 14:25:43 +05:30
const $el = $(e.currentTarget).find('.js-artifact-tree-tooltip');
hide($el);
2018-03-17 18:26:18 +05:30
});
}
}