| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/lemans/components/com_community/assets/source/js/utils/ |
Upload File : |
(function( root, $, factory ) {
joms.util || (joms.util = {});
joms.util.hovercard = factory( root, $ );
})( window, joms.jQuery, function( window, $ ) {
var card,
showTimer = 0,
hideTimer = 0,
animateTimer = 0,
cache = {},
mouseOver = false,
current = 0;
var MOUSEOVER_EVENT = 'mouseover.joms-hcard',
MOUSEOUT_EVENT = 'mouseout.joms-hcard',
IMG_SELECTOR = 'img[data-author]';
function initialize() {
// Only enable on desktop browser.
if ( joms.mobile ) {
return;
}
createCard();
// Attach handler.
$( document.body )
.off( MOUSEOVER_EVENT ).off( MOUSEOUT_EVENT )
.on( MOUSEOVER_EVENT, IMG_SELECTOR, onMouseOver )
.on( MOUSEOUT_EVENT, IMG_SELECTOR, onMouseOut );
}
function onMouseOver( e ) {
var img = $( e.target ),
id = img.data('author');
// Remove title attribute to avoid redundancy.
img.removeAttr('title');
resetCard();
mouseOver = true;
current = id;
clearTimeout( hideTimer );
if ( cache[id] ) {
clearTimeout( showTimer );
showTimer = setTimeout(function() {
mouseOver && updateCard( cache[id], img );
}, 100 );
return;
}
joms.ajax({
func: 'profile,ajaxFetchCard',
data: [ id ],
callback: function( json ) {
if ( json.html ) {
cache[id] = json.html;
clearTimeout( showTimer );
mouseOver && current == id && updateCard( json.html, img );
}
}
});
}
function onMouseOut() {
mouseOver = false;
clearTimeout( showTimer );
hideTimer = setTimeout(function() {
card && resetCard();
}, 100 );
}
function createCard() {
card = $('<div>Loading...</div>');
card.css({
position: 'absolute',
zIndex: 2000,
display: 'none',
opacity:0,
transition: 'opacity 300ms, top 300ms'
});
card.appendTo( document.body );
card.on( MOUSEOVER_EVENT, function() { clearTimeout( hideTimer ); });
card.on( MOUSEOUT_EVENT, onMouseOut );
}
function resetCard() {
clearTimeout( animateTimer );
card && card.css({
display: 'none',
opacity: 0
});
}
function updateCard( html, img ) {
var doc = $( document ),
offset = img.offset(),
width = img.width(),
height = img.height(),
maxWidth = window.innerWidth,
maxHeight = window.innerHeight + doc.scrollTop(),
cardHeight = 140,
alignLeft = offset.left + 320 < maxWidth,
top = offset.top + height + 10;
card.html( html );
cardHeight = card.height();
if ( top + cardHeight > maxHeight ) {
top = offset.top - cardHeight - 4;
}
card.css({
top: top - 10,
left: alignLeft ? offset.left : '',
right: alignLeft ? '' : maxWidth - offset.left - width,
display: 'block',
opacity: 0
});
animateTimer = setTimeout(function() {
card.css({
top: top,
opacity: 1
})
}, 300)
}
// Exports.
return {
initialize: initialize
};
});