Commit 27be863f authored by Jean du Plessis's avatar Jean du Plessis Committed by Enrique Alcántara

Replace all jQuery tooltip API calls

In copy_to_clipboard.js replace the old tooltip
calls with the tooltips facade API.
parent a355b01a
import $ from 'jquery'; import $ from 'jquery';
import Clipboard from 'clipboard'; import Clipboard from 'clipboard';
import { sprintf, __ } from '~/locale'; import { sprintf, __ } from '~/locale';
import { fixTitle, show } from '~/tooltips';
function showTooltip(target, title) { function showTooltip(target, title) {
const $target = $(target); const { originalTitle } = target.dataset;
const originalTitle = $target.data('originalTitle'); const hideTooltip = () => {
target.removeEventListener('mouseout', hideTooltip);
setTimeout(() => {
target.setAttribute('title', originalTitle);
fixTitle(target);
}, 300);
};
if (!$target.data('hideTooltip')) { target.setAttribute('title', title);
$target
.attr('title', title) fixTitle(target);
.tooltip('_fixTitle') show(target);
.tooltip('show')
.attr('title', originalTitle) target.addEventListener('mouseout', hideTooltip);
.tooltip('_fixTitle');
}
} }
function genericSuccess(e) { function genericSuccess(e) {
......
import Vue from 'vue'; import Vue from 'vue';
import jQuery from 'jquery'; import jQuery from 'jquery';
import { toArray, isFunction } from 'lodash'; import { toArray, isFunction, isElement } from 'lodash';
import Tooltips from './components/tooltips.vue'; import Tooltips from './components/tooltips.vue';
let app; let app;
...@@ -54,7 +54,11 @@ const handleTooltipEvent = (rootTarget, e, selector, config = {}) => { ...@@ -54,7 +54,11 @@ const handleTooltipEvent = (rootTarget, e, selector, config = {}) => {
} }
}; };
const applyToElements = (elements, handler) => toArray(elements).forEach(handler); const applyToElements = (elements, handler) => {
const iterable = isElement(elements) ? [elements] : toArray(elements);
toArray(iterable).forEach(handler);
};
const invokeBootstrapApi = (elements, method) => { const invokeBootstrapApi = (elements, method) => {
if (isFunction(elements.tooltip)) { if (isFunction(elements.tooltip)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment