2018-07-13 14:52:08 +00:00
|
|
|
<script>
|
|
|
|
import $ from 'jquery';
|
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
|
|
|
import { inserted } from '~/feature_highlight/feature_highlight_helper';
|
|
|
|
import { mouseenter, debouncedMouseleave, togglePopover } from '~/shared/popover';
|
|
|
|
|
2018-08-03 15:14:05 +00:00
|
|
|
/**
|
|
|
|
* Render a button with a question mark icon
|
|
|
|
* On hover shows a popover. The popover will be dismissed on mouseleave
|
|
|
|
*/
|
2018-07-13 14:52:08 +00:00
|
|
|
export default {
|
2018-08-03 15:14:05 +00:00
|
|
|
name: 'HelpPopover',
|
2018-07-13 14:52:08 +00:00
|
|
|
components: {
|
|
|
|
Icon,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
options: {
|
|
|
|
type: Object,
|
2018-08-03 15:14:05 +00:00
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
2018-07-13 14:52:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
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>
|
2018-11-16 20:07:38 +00:00
|
|
|
<button type="button" class="btn btn-blank btn-transparent btn-help" tabindex="0">
|
2018-07-13 14:52:08 +00:00
|
|
|
<icon name="question" />
|
|
|
|
</button>
|
|
|
|
</template>
|