2018-11-18 11:00:15 +05:30
|
|
|
<script>
|
|
|
|
import $ from 'jquery';
|
2020-11-24 15:15:51 +05:30
|
|
|
import { GlIcon } from '@gitlab/ui';
|
2018-11-18 11:00:15 +05:30
|
|
|
import { inserted } from '~/feature_highlight/feature_highlight_helper';
|
|
|
|
import { mouseenter, debouncedMouseleave, togglePopover } from '~/shared/popover';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a button with a question mark icon
|
|
|
|
* On hover shows a popover. The popover will be dismissed on mouseleave
|
|
|
|
*/
|
|
|
|
export default {
|
|
|
|
name: 'HelpPopover',
|
|
|
|
components: {
|
2020-11-24 15:15:51 +05:30
|
|
|
GlIcon,
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
options: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
const $el = $(this.$el);
|
|
|
|
|
|
|
|
$el
|
|
|
|
.popover({
|
|
|
|
html: true,
|
|
|
|
trigger: 'focus',
|
|
|
|
container: 'body',
|
|
|
|
placement: 'top',
|
|
|
|
template:
|
|
|
|
'<div class="popover" role="tooltip"><div class="arrow"></div><p class="popover-header"></p><div class="popover-body"></div></div>',
|
|
|
|
...this.options,
|
|
|
|
})
|
|
|
|
.on('mouseenter', mouseenter)
|
|
|
|
.on('mouseleave', debouncedMouseleave(300))
|
|
|
|
.on('inserted.bs.popover', inserted)
|
|
|
|
.on('show.bs.popover', () => {
|
|
|
|
window.addEventListener('scroll', togglePopover.bind($el, false), { once: true });
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
2019-02-15 15:39:39 +05:30
|
|
|
<button type="button" class="btn btn-blank btn-transparent btn-help" tabindex="0">
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-icon name="question" />
|
2018-11-18 11:00:15 +05:30
|
|
|
</button>
|
|
|
|
</template>
|