1/** 2 * Tippy.js bridge for Tooltipy. 3 * Keeps legacy CSS classes on keyword markup while Tippy handles positioning. 4 */ 5(function (window, $) { 6 'use strict'; 7 8 var instances = []; 9 10 function mapPlacement(position) { 11 switch (position) { 12 case 'top': 13 case 'bottom': 14 case 'left': 15 case 'right': 16 return position; 17 default: 18 return 'bottom'; 19 } 20 } 21 22 /** 23 * Build tippy content from the AJAX/source blocks. 24 * Do NOT wrap with .bluet_block_to_show â that class is display:none in legacy CSS. 25 */ 26 function getContentForKeyword(id) { 27 var $source = $('#tooltip_blocks_to_show').children('[data-tooltip="' + id + '"]').first(); 28 if (!$source.length) { 29 $source = $('#tooltip_blocks_to_show').children('#loading_tooltip, [data-tooltip="0"]').first(); 30 } 31 if (!$source.length) { 32 return ''; 33 } 34 35 var $container = $source.find('.bluet_block_container').first(); 36 if ($container.length) { 37 return $container.clone(true, true).get(0); 38 } 39 40 // Fallback: clone inner HTML without the hidden wrapper class. 41 var $clone = $source.clone(true, true); 42 $clone.removeClass('bluet_block_to_show').css({ 43 display: 'block', 44 opacity: '1', 45 position: 'relative', 46 visibility: 'visible', 47 }); 48 return $clone.get(0); 49 } 50 51 function destroyInstances() { 52 instances.forEach(function (inst) { 53 if (inst && typeof inst.destroy === 'function') { 54 inst.destroy(); 55 } 56 }); 57 instances = []; 58 } 59 60 /** 61 * @param {string} selector Keyword selector (e.g. ".bluet_tooltip, .bluet_img_tooltip") 62 * @param {string} position top|bottom|left|right 63 */ 64 window.tooltipyInitTippy = function (selector, position) { 65 if (typeof tippy !== 'function' || typeof window.Popper === 'undefined') { 66 return; 67 } 68 69 destroyInstances(); 70 71 var placement = mapPlacement(position || (window.tooltipyTippy && window.tooltipyTippy.placement) || 'bottom'); 72 var isMobile = window.matchMedia && window.matchMedia('(max-width: 400px)').matches; 73 var trigger = isMobile ? 'click' : 'mouseenter focus'; 74 75 var elements = document.querySelectorAll(selector); 76 if (!elements.length) { 77 return; 78 } 79 80 var created = tippy(elements, { 81 allowHTML: true, 82 interactive: true, 83 appendTo: function () { 84 return document.body; 85 }, 86 placement: placement, 87 trigger: trigger, 88 theme: 'tooltipy', 89 animation: 'fade', 90 maxWidth: 400, 91 zIndex: 999999, 92 content: function (reference) { 93 var id = reference.getAttribute('data-tooltip'); 94 return getContentForKeyword(id) || 'â¦'; 95 }, 96 onShow: function (instance) { 97 if (window.currentHoveredKeyword !== 'done') { 98 window.currentHoveredKeyword = $(instance.reference); 99 } 100 101 // Refresh content each show (AJAX may have filled blocks after first init). 102 var id = instance.reference.getAttribute('data-tooltip'); 103 var fresh = getContentForKeyword(id); 104 if (fresh) { 105 instance.setContent(fresh); 106 } 107 108 var box = instance.popper && instance.popper.querySelector('.tippy-content'); 109 if (box) { 110 // Keep tooltipy-pop for styling hooks â never bluet_block_to_show (display:none). 111 box.classList.add('tooltipy-pop'); 112 box.classList.remove('bluet_block_to_show'); 113 } 114 }, 115 onHide: function (instance) { 116 var iframe = instance.popper && instance.popper.querySelector('iframe'); 117 if (iframe && typeof window.callPlayer === 'function') { 118 var wrap = iframe.parentElement; 119 if (wrap && wrap.id) { 120 try { 121 window.callPlayer(wrap.id, 'pauseVideo'); 122 } catch (e) { 123 /* ignore */ 124 } 125 } 126 } 127 }, 128 }); 129 130 instances = Array.isArray(created) ? created : [created]; 131 }; 132 133 // Backward-compatible aliases used by inline matcher scripts. 134 window.bluet_placeTooltips = function (inlineClass, position) { 135 window.tooltipyInitTippy(inlineClass, position); 136 }; 137 138 window.moveTooltipElementsTop = function () { 139 // Tippy clones content from #tooltip_blocks_to_show; keep the container in place. 140 }; 141 142 $(document).on('keywordsLoaded', function () { 143 var pos = (window.tooltipyTippy && window.tooltipyTippy.placement) || 'bottom'; 144 window.tooltipyInitTippy('.bluet_tooltip, .bluet_img_tooltip', pos); 145 }); 146})(window, jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.