-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtooltip.min.js
1 lines (1 loc) · 1.46 KB
/
tooltip.min.js
1
var Tooltip=function(){"use strict";function s(e){if(!a(e)){for(var t in i){if(!a(e[t]))i[t]=e[t]}}return i}function o(e){if(typeof document.getElementsByClassName==="function"){return document.getElementsByClassName(e)}else{return u(e)}}function u(t){var n=e.getElementsByTagName("*"),r=n.length,i=undefined,s=[],o=0,u;for(;o<r;o++){u=n[o];if(!a(u))break;i=u.getAttribute("class");if(i!==null&&i.indexOf(t)!==-1){s.push(u)}}return s}function a(e){return!!(typeof e==="undefined")}var e=document.getElementsByTagName("body")[0],t=undefined,n=undefined,r="tooltip-container",i={opacity:"1",hideOnMouseOut:true};return function(){function f(t){if(o(r).length>0)l();var i=t.target,s=i.getAttribute("data-tt-type"),u=document.createDocumentFragment(),a=document.createElement("div"),f=t.pageX,c=t.pageY,h;u.appendChild(a);a.className=r;a.style.cssText="left:"+f+"px;top:"+c+"px;";if(s==="element"){h=i.parentNode.nextElementSibling.innerHTML;a.innerHTML=h}else{h=i.getAttribute("title");a.innerHTML=h}if(n.hideOnMouseOut){this.addEventListener("mouseout",l)}else{var p=document.createElement("a");p.innerText="x";p.className="hideTooltip";p.addEventListener("click",l);a.appendChild(p)}e.appendChild(u);i.setAttribute("data-status","active")}function l(t){if(!a(t)&&t.type==="click")t.preventDefault();var n=o(r),i=n.length,s=0;for(;s<i;++s){e.removeChild(n[s])}}var u=function(r){var i=0,u,a;n=s(r);t=o("tooltip");a=t.length;for(;i<a;++i){u=t[i];u.addEventListener("mouseover",f)}};return{init:u}}}();