Files
luos/resources/assets/js/components/utils/CustomTooltip.vue

80 lines
1.9 KiB
Vue
Raw Normal View History

<template>
<span
2021-08-17 21:48:08 +00:00
:id="`label-${data.id}`"
@mouseover="hoverHandler"
v-b-tooltip.hover
@mouseleave="unhoverHandler"
v-bind:class="{highlightText: isHighlight}"
>
2021-08-20 03:50:06 +00:00
{{ data.title }}
2021-08-27 14:37:31 +00:00
<b-tooltip :target="`label-${data.page}`" :ref="`tooltip-${data.page}`">
2021-08-20 03:50:06 +00:00
{{ labelTooltip }}
</b-tooltip>
</span>
</template>
<script>
import api from "./../../api/index";
export default {
name: "CustomTooltip",
props: {
data: Object
},
data() {
return {
labelTooltip: "",
hovering: "",
show: false,
menuMap: {
CASES_INBOX: "inbox",
CASES_DRAFT: "draft",
CASES_PAUSED: "paused",
CASES_SELFSERVICE: "unassigned"
2021-08-20 03:50:06 +00:00
},
isHighlight: false
2021-08-20 03:50:06 +00:00
};
},
methods: {
/**
* Delay the hover event
*/
hoverHandler() {
this.hovering = setTimeout(() => { this.setTooltip() }, 3000);
},
/**
* Reset the delay and hide the tooltip
*/
unhoverHandler() {
2021-08-27 14:37:31 +00:00
let key = `tooltip-${this.data.page}`;
this.labelTooltip = "";
2021-08-20 03:50:06 +00:00
this.$refs[key].$emit("close");
clearTimeout(this.hovering);
},
/**
* Set the label to show in the tooltip
2021-08-20 03:50:06 +00:00
*/
setTooltip() {
let that = this;
2021-08-27 14:37:31 +00:00
api.menu.getTooltip(that.data.page).then((response) => {
let key = `tooltip-${that.data.page}`;
2021-08-20 03:50:06 +00:00
that.labelTooltip = response.data.label;
that.$refs[key].$emit("open");
that.isHighlight = false;
2021-08-20 03:50:06 +00:00
});
},
/**
* Set bold the label
*/
setHighlight() {
this.isHighlight = true;
}
2021-08-20 03:50:06 +00:00
},
};
</script>
<style>
.highlightText {
font-weight: 900;
}
</style>