From 899c856b84e877902a4f8d974023f1372943530e Mon Sep 17 00:00:00 2001 From: loviuz Date: Thu, 9 Jan 2020 19:09:49 +0100 Subject: [PATCH] Migliorato caricamento tooltip calendario --- modules/dashboard/edit.php | 60 +++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/modules/dashboard/edit.php b/modules/dashboard/edit.php index 6d63584cd..40e909c5c 100644 --- a/modules/dashboard/edit.php +++ b/modules/dashboard/edit.php @@ -680,46 +680,40 @@ if (Modules::getPermission('Interventi') == 'rw') { ?> eventAfterRender: function(event, element) { element.find('.fc-title').html(event.title); - element.data('idintervento', event.idintervento); - element.mouseover( function(){ - if( !element.hasClass('tooltipstered') ){ - $(this).data('idintervento', event.idintervento ); + element.tooltipster({ + content: '', + animation: 'grow', + contentAsHTML: true, + hideOnClick: true, + speed: 200, + delay: 300, + maxWidth: 400, + theme: 'tooltipster-shadow', + touchDevices: true, + trigger: 'hover', + position: 'left', + functionBefore: function(instance, helper) { + var $origin = $(helper.origin); + + // we set a variable so the data is only loaded once via Ajax, not every time the tooltip opens + if ($origin.data('loaded') !== true) { - $.get(globals.rootdir + "/modules/dashboard/actions.php?op=get_more_info&id="+$(this).data('idintervento'), function(data,response){ - if( response=="success" ){ - data = $.trim(data); - if( data!="ok" ){ - element.tooltipster({ - content: data, - animation: 'grow', - contentAsHTML: true, - hideOnClick: true, - onlyOne: true, - speed: 200, - delay: 100, - maxWidth: 400, - theme: 'tooltipster-shadow', - touchDevices: true, - trigger: 'hover', - position: 'left' - }); + $.get(globals.rootdir + "/modules/dashboard/actions.php?op=get_more_info&id="+event.idintervento, function(data) { - $('.tooltipstered').tooltipster('hide'); - element.tooltipster('show'); - } - else{ - return false; - } + // call the 'content' method to update the content of our tooltip with the returned data. + // note: this content update will trigger an update animation (see the updateAnimation option) + instance.content(data); - $('#calendar').fullCalendar('option', 'contentHeight', 'auto'); - } - }); - } - }); + // to remember that the data has been loaded + $origin.data('loaded', true); + }); + } + } + });