debian-mirror-gitlab/app/assets/javascripts/vue_shared/directives/tooltip.js

31 lines
673 B
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2019-07-31 22:56:46 +05:30
import '~/commons/bootstrap';
2018-05-09 12:01:36 +05:30
2017-09-10 17:25:29 +05:30
export default {
bind(el) {
2019-09-30 21:07:59 +05:30
const glTooltipDelay = localStorage.getItem('gl-tooltip-delay');
const delay = glTooltipDelay ? JSON.parse(glTooltipDelay) : 0;
2018-11-08 19:23:39 +05:30
$(el).tooltip({
trigger: 'hover',
2019-09-30 21:07:59 +05:30
delay,
2018-11-08 19:23:39 +05:30
});
2017-09-10 17:25:29 +05:30
},
componentUpdated(el) {
2018-11-08 19:23:39 +05:30
$(el).tooltip('_fixTitle');
2018-12-13 13:39:08 +05:30
// update visible tooltips
const tooltipInstance = $(el).data('bs.tooltip');
const tip = tooltipInstance.getTipElement();
tooltipInstance.setElementContent(
$(tip.querySelectorAll('.tooltip-inner')),
tooltipInstance.getTitle(),
);
2017-09-10 17:25:29 +05:30
},
unbind(el) {
2018-11-08 19:23:39 +05:30
$(el).tooltip('dispose');
2017-09-10 17:25:29 +05:30
},
};