mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-03-04 10:11:26 +01:00
egw.tooltip: Make sure tooltip event listeners are cleaned up when the window closes
This commit is contained in:
parent
f3632670fe
commit
995be1c5d0
@ -25,17 +25,31 @@ egw.extend('tooltip', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
var tooltip_div = null;
|
||||
var current_elem = null;
|
||||
const tooltipped = [];
|
||||
_wnd.addEventListener("beforeunload", (e) =>
|
||||
{
|
||||
tooltipped.forEach(node =>
|
||||
{
|
||||
egw.tooltipUnbind(node);
|
||||
});
|
||||
tooltipped.splice(0, tooltipped.length);
|
||||
if (tooltip_div)
|
||||
{
|
||||
tooltipped.off();
|
||||
}
|
||||
})
|
||||
|
||||
var time_delta = 100;
|
||||
var show_delta = 0;
|
||||
var show_delay = 200;
|
||||
let tooltip_div = null;
|
||||
let current_elem = null;
|
||||
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
const time_delta = 100;
|
||||
let show_delta = 0;
|
||||
const show_delay = 200;
|
||||
|
||||
var optionsDefault = {
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
|
||||
const optionsDefault = {
|
||||
hideonhover: true,
|
||||
position:'right',
|
||||
open: function(){},
|
||||
@ -137,7 +151,8 @@ egw.extend('tooltip', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
||||
jQuery(_wnd.document.body).append(tooltip_div);
|
||||
|
||||
//The tooltip should automatically hide when the mouse comes over it
|
||||
tooltip_div.mouseenter(function() {
|
||||
tooltip_div.on("mouseenter.tooltip", function ()
|
||||
{
|
||||
if (_options.hideonhover) hide();
|
||||
});
|
||||
}
|
||||
@ -176,7 +191,8 @@ egw.extend('tooltip', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
||||
tooltipBind: function(_elem, _html, _isHtml, _options) {
|
||||
|
||||
var options = {...optionsDefault, ...(_options||{})};
|
||||
|
||||
const elem = _elem instanceof Node ? _elem : (typeof _elem.get == "function" ? _elem.get(0) : _elem);
|
||||
tooltipped.push(elem);
|
||||
_elem = jQuery(_elem);
|
||||
if (_html && !egwIsMobile())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user