User:Monster Domosed/common.js: Difference between revisionsGive feedback
Scrapped HeroIcon hovers for now, added support for AbilityIcon for tooltips? |
trying to make MediaWiki:Gadget-ability-upgrades work inside ability tooltip |
||
| Line 384: | Line 384: | ||
tt.css( { top: top, left: left } ); | tt.css( { top: top, left: left } ); | ||
} | |||
/* ─── Initialize ability upgrade gadget for tooltip content ─── */ | |||
function initAbilityUpgrades( $container ) { | |||
// Check if the gadget exists | |||
if ( !window.abilityUpgradeGadget ) { | |||
return; | |||
} | |||
var abilityCards = $container.find( '.ability-card' ); | |||
if ( !abilityCards.length ) { | |||
return; | |||
} | |||
// Re-run the gadget's initialization for new ability cards | |||
abilityCards.each( function () { | |||
var container = this; | |||
// Add hover listeners | |||
$( container ).find( '.ability-upgrade' ).each( function () { | |||
var el = this; | |||
$( el ).off( 'mouseenter.abilityUpgrade mouseleave.abilityUpgrade' ); | |||
$( el ).on( 'mouseenter.abilityUpgrade', function () { | |||
window.abilityUpgradeGadget.onHover( container, el ); | |||
} ); | |||
$( el ).on( 'mouseleave.abilityUpgrade', function () { | |||
window.abilityUpgradeGadget.onUnhover( container ); | |||
} ); | |||
} ); | |||
} ); | |||
} | } | ||
| Line 400: | Line 430: | ||
tt.html( tooltipCache[ cacheKey ] ).show(); | tt.html( tooltipCache[ cacheKey ] ).show(); | ||
positionTooltip( anchor ); | positionTooltip( anchor ); | ||
// Re-initialize ability upgrades for cached content | |||
if ( type === 'ability' ) { | |||
initAbilityUpgrades( tt ); | |||
} | |||
return; | return; | ||
} | } | ||
| Line 436: | Line 471: | ||
tt.html( html ).show(); | tt.html( html ).show(); | ||
positionTooltip( anchor ); | positionTooltip( anchor ); | ||
// Initialize ability upgrades for new content | |||
if ( type === 'ability' ) { | |||
initAbilityUpgrades( tt ); | |||
} | |||
} | } | ||
} ).catch( function () { | } ).catch( function () { | ||