1(function($) { 2 'use strict'; 3 4 var $tooltipBox = null; 5 var hideTimeout = null; 6 var touchTimeout = null; 7 8 function createTooltipBox() { 9 if (!$tooltipBox) { 10 $tooltipBox = $('<div class="hostpn-tooltip-box"></div>'); 11 $('body').append($tooltipBox); 12 } 13 return $tooltipBox; 14 } 15 16 function positionTooltip(element) { 17 var box = createTooltipBox(); 18 var rect = element.getBoundingClientRect(); 19 var boxWidth = box.outerWidth(); 20 var boxHeight = box.outerHeight(); 21 var spaceAbove = rect.top; 22 var left = rect.left + (rect.width / 2) - (boxWidth / 2); 23 24 if (left < 4) left = 4; 25 if (left + boxWidth > window.innerWidth - 4) left = window.innerWidth - boxWidth - 4; 26 27 if (spaceAbove >= boxHeight + 10) { 28 box.removeClass('hostpn-tooltip-box--bottom'); 29 box.css({ top: rect.top - boxHeight - 8, left: left }); 30 } else { 31 box.addClass('hostpn-tooltip-box--bottom'); 32 box.css({ top: rect.bottom + 8, left: left }); 33 } 34 } 35 36 function getTooltipContent(el) { 37 var $el = $(el); 38 var contentSelector = $el.attr('data-hostpn-tooltip-content'); 39 if (contentSelector) { 40 var $source = $(contentSelector); 41 if ($source.length) return $source.html(); 42 } 43 var text = $el.attr('data-hostpn-tooltip'); 44 if (text) return $('<span>').text(text).html(); 45 return null; 46 } 47 48 function showTooltip(el) { 49 clearTimeout(hideTimeout); 50 clearTimeout(touchTimeout); 51 var content = getTooltipContent(el); 52 if (!content) return; 53 var box = createTooltipBox(); 54 box.html(content); 55 box.addClass('hostpn-tooltip-box--visible'); 56 positionTooltip(el); 57 } 58 59 function hideTooltip() { 60 clearTimeout(touchTimeout); 61 if ($tooltipBox) { 62 $tooltipBox.removeClass('hostpn-tooltip-box--visible hostpn-tooltip-box--bottom'); 63 } 64 } 65 66 window.PN_COOKIES_MANAGER_Tooltips = { 67 init: function(selector) { 68 selector = selector || '.pn-cookies-manager-tooltip'; 69 $(selector).each(function() { 70 var $el = $(this); 71 if ($el.attr('title') && !$el.attr('data-hostpn-tooltip')) { 72 $el.attr('data-hostpn-tooltip', $el.attr('title')); 73 $el.removeAttr('title'); 74 } 75 }); 76 }, 77 show: function(element) { 78 var el = element instanceof $ ? element[0] : element; 79 if (el) showTooltip(el); 80 }, 81 hide: function() { hideTooltip(); } 82 }; 83 84 $(document).on('mouseenter', '.pn-cookies-manager-tooltip', function() { 85 var $el = $(this); 86 if ($el.attr('title') && !$el.attr('data-hostpn-tooltip')) { 87 $el.attr('data-hostpn-tooltip', $el.attr('title')); 88 $el.removeAttr('title'); 89 } 90 showTooltip(this); 91 }); 92 $(document).on('mouseleave', '.pn-cookies-manager-tooltip', function() { hideTooltip(); }); 93 $(document).on('focusin', '.pn-cookies-manager-tooltip', function() { 94 var $el = $(this); 95 if ($el.attr('title') && !$el.attr('data-hostpn-tooltip')) { 96 $el.attr('data-hostpn-tooltip', $el.attr('title')); 97 $el.removeAttr('title'); 98 } 99 showTooltip(this); 100 }); 101 $(document).on('focusout', '.pn-cookies-manager-tooltip', function() { hideTooltip(); }); 102 $(document).on('touchstart', '.pn-cookies-manager-tooltip', function(e) { 103 var $el = $(this); 104 if ($el.attr('title') && !$el.attr('data-hostpn-tooltip')) { 105 $el.attr('data-hostpn-tooltip', $el.attr('title')); 106 $el.removeAttr('title'); 107 } 108 showTooltip(this); 109 touchTimeout = setTimeout(function() { hideTooltip(); }, 4000); 110 }); 111 112 $(document).ready(function() { PN_COOKIES_MANAGER_Tooltips.init(); }); 113})(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.