Checkout style
[wolnelektury.git] / src / wolnelektury / static / js / contrib / tlite.min.js
1 function tlite(t){document.addEventListener("mouseover",function(e){var i=e.target,n=t(i);n||(i=i.parentElement,n=i&&t(i)),n&&tlite.show(i,n,!0)})}tlite.show=function(t,e,i){function n(t,e){function n(){u=t.title||t.getAttribute(l)||u,t.title="",t.setAttribute(l,""),u&&!a&&(a=setTimeout(d,i?150:1))}function r(){tlite.hide(t,!0)}function s(e){i===e&&(a=clearTimeout(a),f&&t.removeChild(f),f=void 0)}function d(){f||(f=o(t,u,e))}var f,a,u;return t.addEventListener("mousedown",r),t.addEventListener("mouseleave",r),t.tooltip={show:n,hide:s}}function o(t,e,i){function n(){o.className="tlite tlite-"+r+s;var e=10,i=t.offsetTop,n=t.offsetLeft;o.offsetParent===t&&(i=n=0);var l=t.offsetWidth,d=t.offsetHeight,f=o.offsetHeight,a=o.offsetWidth,u=n+l/2;o.style.top=("s"===r?i-f-e:"n"===r?i+d+e:i+d/2-f/2)+"px",o.style.left=("w"===s?n:"e"===s?n+l-a:"w"===r?n+l+e:"e"===r?n-a-e:u-a/2)+"px"}var o=document.createElement("span"),l=i.grav||t.getAttribute("data-tlite")||"n";o.innerHTML=e,t.appendChild(o);var r=l[0]||"",s=l[1]||"";n();var d=o.getBoundingClientRect();return"s"===r&&d.top<0?(r="n",n()):"n"===r&&d.bottom>window.innerHeight?(r="s",n()):"e"===r&&d.left<0?(r="w",n()):"w"===r&&d.right>window.innerWidth&&(r="e",n()),o.className+=" tlite-visible",o}var l="data-tlite";e=e||{},(t.tooltip||n(t,e)).show()},tlite.hide=function(t,e){t.tooltip&&t.tooltip.hide(e)},"undefined"!=typeof module&&module.exports&&(module.exports=tlite);