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

52 lines
1.5 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';
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
}
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
}
// 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
});
}
// eslint-disable-next-line class-methods-use-this
setupTooltips() {
$('.js-artifact-tree-tooltip').tooltip({
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 => {
$(e.currentTarget)
.find('.js-artifact-tree-tooltip')
.tooltip('show');
2018-03-17 18:26:18 +05:30
})
2018-12-13 13:39:08 +05:30
.on('mouseleave', e => {
$(e.currentTarget)
.find('.js-artifact-tree-tooltip')
.tooltip('hide');
2018-03-17 18:26:18 +05:30
});
}
}