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

56 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-12-21 20:55:43 +05:30
/* eslint-disable func-names */
2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2018-03-17 18:26:18 +05:30
import { visitUrl } from './lib/utils/url_utility';
2019-02-15 15:39:39 +05:30
import { parseBoolean } from './lib/utils/common_utils';
2021-01-03 14:25:43 +05:30
import { hide, initTooltips, show } from '~/tooltips';
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() {
2019-12-21 20:55:43 +05:30
$('.top-block').on('click', '.download', e => {
e.stopPropagation();
2017-08-17 22:00:37 +05:30
});
2019-12-21 20:55:43 +05:30
return $('.tree-holder').on('click', 'tr[data-link] a', e => {
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() {
2018-12-13 13:39:08 +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')
2018-12-13 13:39:08 +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
})
2018-12-13 13:39:08 +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
});
}
}