2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2019-07-31 22:56:46 +05:30
|
|
|
import '~/commons/bootstrap';
|
2021-01-03 14:25:43 +05:30
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
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,
|
2021-01-03 14:25:43 +05:30
|
|
|
// By default, sanitize is run even if there is no `html` or `template` present
|
|
|
|
// so let's optimize to only run this when necessary.
|
|
|
|
// https://github.com/twbs/bootstrap/blob/c5966de27395a407f9a3d20d0eb2ff8e8fb7b564/js/src/tooltip.js#L716
|
|
|
|
sanitize: parseBoolean(el.dataset.html) || Boolean(el.dataset.template),
|
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
|
|
|
},
|
|
|
|
};
|