4 lines
11 KiB
JavaScript
4 lines
11 KiB
JavaScript
var C=(O,q)=>()=>(q||O((q={exports:{}}).exports,q),q.exports);var w=C((A,H)=>{H.exports={options:{html:!1,placement:"top",container:"body",scrollContainer:window,template:'<div class="tooltip" data-tooltip-target="tooltip"></div>',removalDelay:200,tooltipOffset:10,windowPadding:{top:10,right:10,bottom:10,left:10}},init:function O(q){var z=this;document.documentElement.scrollTop=1,this.documentElement=document.documentElement.scrollTop===1?document.documentElement:document.body;var J=document.createElement("div");if(J.innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',this.innerHTMLBug=!J.getElementsByTagName("link").length,J=void 0,"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch)document.body.style.cursor="pointer";if(this.map={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],defaultTag:this.innerHTMLBug?[1,"X<div>","</div>"]:[0,"",""]},this.map.td=this.map.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],this.map.option=this.map.optgroup=[1,'<select multiple="multiple">',"</select>"],this.map.thead=this.map.tbody=this.map.colgroup=this.map.caption=this.map.tfoot=[1,"<table>","</table>"],this.map.text=this.map.circle=this.map.ellipse=this.map.line=this.map.path=this.map.polygon=this.map.polyline=this.map.rect=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"],q instanceof Object){for(var D in q)if(window.Object.hasOwnProperty.call(q,D)&&window.Object.hasOwnProperty.call(this.options,D))if(typeof q[D]==="object"&&!Array.isArray(q[D])){for(var F in q[D])if(window.Object.hasOwnProperty.call(q[D],F)&&window.Object.hasOwnProperty.call(this.options[D],F))this.options[D][F]=q[D][F]}else this.options[D]=q[D]}function S(I){if(!I)I=window.event;var G=I.target||I.srcElement;if(z.currentTooltip&&z.currentTooltip.getAttribute("data-autoclose")==="false")return;else if(z.currentTooltip)if(G===z.currentTooltip)return;else if(G===z.currentTrigger){z.close(z.currentTooltip);return}else{if(z.hasParent(G,z.currentTooltip))return!1;z.close(z.currentTooltip)}if(!z.hasClass(G,"tooltip-click"))return;z.open(G)}function K(I){if(!I)I=window.event;var G=I.target||I.srcElement;if(!z.hasClass(G,"tooltip-hover"))return;if(z.currentTooltip&&z.currentTooltip.getAttribute("data-autoclose")==="false")return;else if(z.currentTooltip)if(G===z.currentTooltip)return;else{if(z.hasParent(G,z.currentTooltip))return!1;z.close(z.currentTooltip)}function Q(Z){if(!Z)Z=window.event;var V=I.target||I.srcElement;if(z.hasClass(V))return;if(z.currentTooltip&&z.currentTooltip.getAttribute("data-autoclose")==="false")return;z.close(z.currentTooltip),z.removeEventListener(G,"mouseout",Q);return}z.open(G),z.addEventListener(G,"mouseout",Q);return}function U(I){if(!I)I=window.event;var G=I.target||I.srcElement;if(!z.hasClass(G,"tooltip-focus"))return;if(z.currentTooltip&&z.currentTooltip.getAttribute("data-autoclose")==="false")return;else if(z.currentTooltip)z.close(z.currentTooltip);function Q(){if(z.currentTooltip&&z.currentTooltip.getAttribute("data-autoclose")==="false")return;z.close(z.currentTooltip),z.removeEventListener(G,"blur",Q);return}z.open(G),z.addEventListener(G,"blur",Q);return}this.windowChangeHandler=function I(){if(z.currentTooltip&&z.currentTrigger)z.positionTooltip(z.currentTooltip,z.currentTrigger);return},this.addEventListener(document.body,"click",S),this.addEventListener(document.body,"mouseover",K),this.addEventListener(document.body,"focus",U,!0),this.addEventListener(window,"scroll",this.windowChangeHandler),this.addEventListener(window,"resize",this.windowChangeHandler)},open:function O(q,z){if(typeof q==="string")q=document.body.querySelector(q);if(!z)z={};var J=z.className||q.getAttribute("data-tooltip-classname"),D=z.content||q.getAttribute("data-tooltip-content"),F=z.title||q.getAttribute("data-tooltip-title"),S=z.html||q.getAttribute("data-tooltip-html"),K=z.placement||q.getAttribute("data-tooltip-placement"),U=z.container||q.getAttribute("data-tooltip-container"),I=z.container||q.getAttribute("data-tooltip-scrollContainer"),G=document.querySelector(".tooltip"),Q=this.createDOMElement(this.options.template),Z,V;if(!D)return;if(this.currentTooltip&&this.currentTooltip.getAttribute("data-autoclose")==="false")return;if(Q.appendChild(this.createDOMElement('<div class="tooltip-accent"></div>')),J)this.addClass(Q,J);if(F)Z=this.createDOMElement('<p class="tooltip-title">'+F+"</p>"),Q.appendChild(Z);if((this.options.html||S)&&D)if(this.isElement(D))V=D;else if(this.getTagName(D))V=this.createDOMElement(D);else V=this.createDOMElement('<p class="tooltip-content">'+D+"</p>");else V=this.createDOMElement('<p class="tooltip-content">'+D+"</p>");if(Q.appendChild(V),U&&U!==this.options.container){if(typeof U==="string")this.currentContainer=document.querySelector(U)}else this.currentContainer=document.querySelector(this.options.container);if(I&&I!==this.options.scrollContainer){if(typeof I==="string")this.currentScrollContainer=document.querySelector(I)}else this.currentScrollContainer=this.options.scrollContainer;if(z.autoClose===!1||q.getAttribute("data-tooltip-autoclose")==="false")Q.setAttribute("data-autoclose","false");if(G)this.currentTooltip=G.parentNode.insertBefore(Q,G);else this.currentTooltip=this.currentContainer.appendChild(Q);if(this.currentTrigger=q,this.positionTooltip(this.currentTooltip,this.currentTrigger,K),this.currentScrollContainer!==window)this.addEventListener(this.currentScrollContainer,"scroll",this.windowChangeHandler);return this.currentTooltip},close:function O(q){if(typeof q==="string")q=document.body.querySelector(q);if(this.currentScrollContainer!==window)this.removeEventListener(this.currentScrollContainer,"scroll",this.windowChangeHandler);this.removeClass(q,"visible"),this.currentTooltip=null,this.currentTrigger=null,this.currentScrollContainer=null,window.setTimeout(function z(){if(q&&q instanceof window.Element&&q.parentNode)q.parentNode.removeChild(q);else if(q=document.body.querySelector(".tooltip"),q&&q.parentNode)q.parentNode.removeChild(q)},this.options.removalDelay)},positionTooltip:function O(q,z,J){if(typeof q==="string")q=document.body.querySelector(q);if(typeof z==="string")z=document.body.querySelector(z);if(!J)J=z.getAttribute("data-tooltip-placement")||this.options.placement;var D=this,F=q.querySelector(".tooltip-accent"),S=z.getBoundingClientRect(),K=Math.floor(S.width),U=Math.floor(S.height),I=S.left,G=S.top,Q=this.options.windowPadding.top,Z=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)-this.options.windowPadding.right,V=(window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)-this.options.windowPadding.bottom,x=this.options.windowPadding.left,b,R,B,P,M,_,j,L,y,X,$,k;if(this.currentScrollContainer.getBoundingClientRect){var E=this.currentScrollContainer.getBoundingClientRect();if(E.top>=0)b=E.top+this.options.windowPadding.top;if(E.right<=Z)R=E.right-this.options.windowPadding.right;if(E.bottom<=V)B=E.bottom-this.options.windowPadding.bottom;if(E.left>=x)P=E.left+this.options.windowPadding.left}function T(){if(M=I-j/2+K/2,_=G-L-D.options.tooltipOffset,y=M+j,D.addClass(q,"tooltip-top"),!$)$=parseInt(F.offsetWidth,10);if(!k)k=parseInt(F.offsetHeight,10);if(G+U<=b){if(D.hasClass(q,"visible"))D.removeClass(q,"visible")}if(y>Z||y>R)q.style.top="auto",q.style.bottom=V+D.options.windowPadding.bottom-G+D.options.tooltipOffset+"px",q.style.right=D.options.windowPadding.right+"px",F.style.left="auto",F.style.right=K/2-$/2+(Z-I-K)+"px";else if(_<Q||_<b)return D.removeClass(q,"tooltip-top"),Y();else if(M<x||M<P)q.style.top="auto",q.style.bottom=V+D.options.windowPadding.bottom-G+D.options.tooltipOffset+"px",q.style.left=D.options.windowPadding.left+"px",F.style.right="auto",F.style.left=K/2-$/2+(I-x)+"px";else q.style.top="auto",q.style.bottom=V+D.options.windowPadding.bottom-G+D.options.tooltipOffset+"px",q.style.left=M+"px",F.style.top="",F.style.bottom="",F.style.right="",F.style.left=j/2-$/2+"px"}function N(){if(M=I+K+D.options.tooltipOffset,_=G-L/2+U/2,y=M+j,D.addClass(q,"tooltip-right"),!k)k=parseInt(F.offsetHeight,10);if(y>Z||y>R)return D.removeClass(q,"tooltip-right"),T();else q.style.top=_+"px",q.style.left=M+"px",F.style.right="",F.style.bottom="",F.style.left="",F.style.top=L/2-k/2+"px"}function Y(){if(M=I-j/2+K/2,_=G+U+D.options.tooltipOffset,y=M+j,X=_+L,D.addClass(q,"tooltip-bottom"),!$)$=parseInt(F.offsetWidth,10);if(G>=B){if(D.hasClass(q,"visible"))D.removeClass(q,"visible")}if(y>Z||y>R)q.style.top=_+"px",q.style.right=D.options.windowPadding.right+"px",F.style.left="auto",F.style.right=K/2-$/2+(Z-I-K)+"px";else if(X>V||X>B)return D.removeClass(q,"tooltip-bottom"),T();else if(M<x||M<x)q.style.top=_+"px",q.style.left=D.options.windowPadding.left+"px",F.style.right="auto",F.style.left=K/2-$/2+(I-x)+"px";else q.style.top=_+"px",q.style.bottom="auto",q.style.left=M+"px",F.style.top="",F.style.bottom="",F.style.right="",F.style.left=j/2-$/2+"px"}function W(){if(M=I-j-D.options.tooltipOffset,_=G-L/2+U/2,D.addClass(q,"tooltip-left"),!k)k=parseInt(F.offsetHeight,10);if(M<x||M<P)return D.removeClass(q,"tooltip-left"),T();else q.style.top=_+"px",q.style.left=M+"px",F.style.right="",F.style.bottom="",F.style.left="",F.style.top=L/2-k/2+"px"}if(q.style.position="fixed",j=parseInt(q.offsetWidth,10),L=parseInt(q.offsetHeight,10),$=parseInt(F.offsetWidth,10),k=parseInt(F.offsetHeight,10),D.removeClass(q,"tooltip-top"),D.removeClass(q,"tooltip-right"),D.removeClass(q,"tooltip-bottom"),D.removeClass(q,"tooltip-left"),J==="top")T();else if(J==="right")N();else if(J==="bottom")Y();else if(J==="left")W();if(!D.hasClass(q,"visible")&&(b===void 0||G+U>b&&G<B))window.setTimeout(function(){D.addClass(q,"visible")},50);else if(G+U<=b||G>=B)D.removeClass(q,"visible");return q},addEventListener:function O(q,z,J,D){if(!D)D=!1;if(q.addEventListener)return q.addEventListener(z,J,D),q;else{if(z==="focus")z="focusin";return q.attachEvent("on"+z,function(){J.call(q)}),q}},removeEventListener:function O(q,z,J,D){if(!D)D=!1;if(!q)return;if(q.removeEventListener)q.removeEventListener(z,J,D);else{if(z==="focus")z="focusin";q.detachEvent("on"+z,function(){J.call(q)})}return q},hasClass:function O(q,z){if(q.classList)return q.classList.contains(z);else return new RegExp("(^| )"+z+"( |$)","gi").test(q.className)},addClass:function O(q,z){if(q.classList)q.classList.add(z);else q.className+=" "+z;return q},removeClass:function O(q,z){if(q)if(q.classList)q.classList.remove(z);else q.className=q.className.replace(new RegExp("(^|\\b)"+z.split(" ").join("|")+"(\\b|$)","gi")," ");return q},setInnerText:function O(q,z){if(q.textContent!==void 0)q.textcontent=z;else q.innerText=z;return q},getTagName:function O(q){return/<([\w:]+)/.exec(q)},isElement:function O(q){return!!(q&&q.nodeType===1)},createDOMElement:function O(q){q=q.replace(/^\s+|\s+$/g,"");var z=this.getTagName(q)[1],J=this.map[z]||this.map.defaultTag,D=J[0],F=J[1],S=J[2],K=document.createElement("div");K.innerHTML=F+q+S;while(D--)K=K.lastChild;return K.removeChild(K.firstChild)},hasParent:function O(q,z){if(!q||!z)return!1;var J=!1;while(q.parentNode&&!J)if(q=q.parentNode,q===z)J=!0;return J}}});export default w();
|
|
|
|
//# debugId=9835718B3D42F23F64756E2164756E21
|