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

52 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-11-08 19:23:39 +05:30
/* eslint-disable func-names, prefer-arrow-callback */
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-01-03 12:48:30 +05:30
import { convertPermissionToBoolean } 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() {
2018-12-13 13:39:08 +05:30
$('.top-block').on('click', '.download', function(e) {
2017-08-17 22:00:37 +05:30
return e.stopPropagation();
});
2018-12-13 13:39:08 +05:30
return $('.tree-holder').on('click', 'tr[data-link] a', function(e) {
2017-08-17 22:00:37 +05:30
return e.stopImmediatePropagation();
});
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-01-03 12:48:30 +05:30
visitUrl(this.dataset.link, convertPermissionToBoolean(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
});
}
}