2020-03-13 15:44:24 +05:30
|
|
|
<script>
|
2020-04-22 19:07:51 +05:30
|
|
|
import { GlDeprecatedButton } from '@gitlab/ui';
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-04-22 19:07:51 +05:30
|
|
|
GlDeprecatedButton,
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
position: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2020-04-22 19:07:51 +05:30
|
|
|
definitionPathPrefix: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
offsetLeft: 0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
positionStyles() {
|
|
|
|
return {
|
|
|
|
left: `${this.position.x - this.offsetLeft}px`,
|
|
|
|
top: `${this.position.y + this.position.height}px`,
|
|
|
|
};
|
|
|
|
},
|
2020-04-22 19:07:51 +05:30
|
|
|
definitionPath() {
|
|
|
|
return (
|
|
|
|
this.data.definition_path && `${this.definitionPathPrefix}/${this.data.definition_path}`
|
|
|
|
);
|
|
|
|
},
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
position: {
|
|
|
|
handler() {
|
|
|
|
this.$nextTick(() => this.updateOffsetLeft());
|
|
|
|
},
|
|
|
|
deep: true,
|
|
|
|
immediate: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
updateOffsetLeft() {
|
|
|
|
this.offsetLeft = Math.max(
|
|
|
|
0,
|
|
|
|
this.$el.offsetLeft + this.$el.offsetWidth - window.innerWidth + 20,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
colorScheme: gon?.user_color_scheme,
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
:style="positionStyles"
|
|
|
|
class="popover code-navigation-popover popover-font-size-normal gl-popover bs-popover-bottom show"
|
|
|
|
>
|
|
|
|
<div :style="{ left: `${offsetLeft}px` }" class="arrow"></div>
|
|
|
|
<div v-for="(hover, index) in data.hover" :key="index" class="border-bottom">
|
|
|
|
<pre
|
|
|
|
v-if="hover.language"
|
|
|
|
ref="code-output"
|
|
|
|
:class="$options.colorScheme"
|
|
|
|
class="border-0 bg-transparent m-0 code highlight"
|
|
|
|
v-html="hover.value"
|
|
|
|
></pre>
|
|
|
|
<p v-else ref="doc-output" class="p-3 m-0">
|
|
|
|
{{ hover.value }}
|
|
|
|
</p>
|
|
|
|
</div>
|
2020-04-22 19:07:51 +05:30
|
|
|
<div v-if="definitionPath" class="popover-body">
|
|
|
|
<gl-deprecated-button :href="definitionPath" target="_blank" class="w-100" variant="default">
|
2020-03-13 15:44:24 +05:30
|
|
|
{{ __('Go to definition') }}
|
2020-04-22 19:07:51 +05:30
|
|
|
</gl-deprecated-button>
|
2020-03-13 15:44:24 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|