Commit dd0b300a authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '249784-replace-bs-tooltip-main-js' into 'master'

Replace jQuery tooltip api calls with tooltips facade in main.js

Closes #249784

See merge request gitlab-org/gitlab!43908
parents 8a347092 f009edbb
...@@ -39,6 +39,8 @@ import initPersistentUserCallouts from './persistent_user_callouts'; ...@@ -39,6 +39,8 @@ import initPersistentUserCallouts from './persistent_user_callouts';
import { initUserTracking, initDefaultTrackers } from './tracking'; import { initUserTracking, initDefaultTrackers } from './tracking';
import { __ } from './locale'; import { __ } from './locale';
import * as tooltips from '~/tooltips';
import 'ee_else_ce/main_ee'; import 'ee_else_ce/main_ee';
applyGitLabUIConfig(); applyGitLabUIConfig();
...@@ -77,7 +79,7 @@ document.addEventListener('beforeunload', () => { ...@@ -77,7 +79,7 @@ document.addEventListener('beforeunload', () => {
// Unbind scroll events // Unbind scroll events
$(document).off('scroll'); $(document).off('scroll');
// Close any open tooltips // Close any open tooltips
$('.has-tooltip, [data-toggle="tooltip"]').tooltip('dispose'); tooltips.dispose(document.querySelectorAll('.has-tooltip, [data-toggle="tooltip"]'));
// Close any open popover // Close any open popover
$('[data-toggle="popover"]').popover('dispose'); $('[data-toggle="popover"]').popover('dispose');
}); });
...@@ -133,8 +135,10 @@ function deferredInitialisation() { ...@@ -133,8 +135,10 @@ function deferredInitialisation() {
addSelectOnFocusBehaviour('.js-select-on-focus'); addSelectOnFocusBehaviour('.js-select-on-focus');
$('.remove-row').on('ajax:success', function removeRowAjaxSuccessCallback() { $('.remove-row').on('ajax:success', function removeRowAjaxSuccessCallback() {
tooltips.dispose(this);
// eslint-disable-next-line no-jquery/no-fade
$(this) $(this)
.tooltip('dispose')
.closest('li') .closest('li')
.fadeOut(); .fadeOut();
}); });
...@@ -154,7 +158,7 @@ function deferredInitialisation() { ...@@ -154,7 +158,7 @@ function deferredInitialisation() {
const delay = glTooltipDelay ? JSON.parse(glTooltipDelay) : 0; const delay = glTooltipDelay ? JSON.parse(glTooltipDelay) : 0;
// Initialize tooltips // Initialize tooltips
$body.tooltip({ tooltips.initTooltips({
selector: '.has-tooltip, [data-toggle="tooltip"]', selector: '.has-tooltip, [data-toggle="tooltip"]',
trigger: 'hover', trigger: 'hover',
boundary: 'viewport', boundary: 'viewport',
......
...@@ -58,6 +58,8 @@ const applyToElements = (elements, handler) => toArray(elements).forEach(handler ...@@ -58,6 +58,8 @@ const applyToElements = (elements, handler) => toArray(elements).forEach(handler
const invokeBootstrapApi = (elements, method) => { const invokeBootstrapApi = (elements, method) => {
if (isFunction(elements.tooltip)) { if (isFunction(elements.tooltip)) {
elements.tooltip(method);
} else {
jQuery(elements).tooltip(method); jQuery(elements).tooltip(method);
} }
}; };
......
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