New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

internetips

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

internetips - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

23

dist/bundled.js

@@ -295,3 +295,3 @@ window["internetips"] =

*/
function hide() {
function reset() {
activeParams = pointX = pointY = lastPlacementDirection = null;

@@ -307,3 +307,12 @@ isOpen = isFloating = false;

}
}
/**
* This is the *publicly* exposed hide function (instead of proxying the reset
* function directly as 'hide', because we want to enable the onHideHook and
* invoke it only when the public fn is invoked).
*/
function hide() {
reset();
// Test hook integration

@@ -320,3 +329,3 @@ if (typeof onHideHook === 'function') {

unbindWindowEvents();
hide();
reset();
tipNode && tipNode.parentNode.removeChild(tipNode);

@@ -344,3 +353,3 @@ containerNode && containerNode.parentNode.removeChild(containerNode);

if (!activeParams.target) {
hide();
reset();
return console.warn('Cannot .show() tooltip when effect === `solid` without target node.');

@@ -519,3 +528,3 @@ }

if (tipNode) {
return hide();
return reset();
}

@@ -541,3 +550,3 @@

bindWindowEvents();
hide();
reset();
}

@@ -550,3 +559,3 @@

* the event listeners initialized, since they do little work, then
* binding and unbinding between every show()/hide() call.
* binding and unbinding between every show()/reset() call.
* Note: this should only be called once, during the first initialization,

@@ -580,3 +589,3 @@ * but just to ensure we don't accidentally bind multiple listeners of the

if (isOpen === true) {
hide();
reset();
}

@@ -583,0 +592,0 @@ }

@@ -1,1 +0,1 @@

window.internetips=function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(R)return console.warn("Disallowed: set tooltip configs after first .show().");Object.assign(B,t,{placeClass:Object.assign({},B.placeClass,t.placeClass)},{typeClass:Object.assign({},B.typeClass,t.typeClass)},{defaults:Object.assign({},B.defaults,t.defaults,{effect:B.defaults.effect,target:B.defaults.target})})}function o(t){return t&&t.content?(d(),F=Object.assign({},B.defaults,t,{classes:B.defaults.classes.concat(t.classes||[])}),R.innerHTML=F.content,h(),"solid"===F.effect?s():void l()):console.warn("Cannot .show() tooltip without `content` param.")}function r(){F=A=D=k=null,L=H=!1,V=!0,N(O),document.removeEventListener("mousemove",C),R&&(R.style.cssText=null,R.className=B.tooltipClass,R.innerHTML=null),"function"==typeof j&&j()}function a(){g(),r(),R&&R.parentNode.removeChild(R),y&&y.parentNode.removeChild(y),y=R=null,"function"==typeof q&&q()}function s(){if(!F.target)return r(),console.warn("Cannot .show() tooltip when effect === `solid` without target node.");var t=F.target.getBoundingClientRect();F.offsetX+=parseInt(t.width/2)||0,F.offsetY+=parseInt(t.height/2)||0,A=t.left+t.width/2,D=t.top+t.height/2,c()}function l(){if(F.target){var t=F.target.getBoundingClientRect();A=t.left+t.width/2,D=t.top+t.height/2}H=!0,document.addEventListener("mousemove",C),c()}function c(){if(V){var t={};if(!f(t)){var e;switch(!0){case!x.withinLeftWhenVert:t.top=x.topWhenHorizontal,t.left=x.leftWhenDirRight,e="right";break;case!x.withinRightWhenVert:t.top=x.topWhenHorizontal,t.right=x.rightWhenDirLeft,e="left";break;case!x.canPlaceTop:t.left=x.leftWhenVertical,t.top=x.topWhenDirBottom,e="bottom";break;default:t.left=x.leftWhenVertical,t.bottom=x.bottomWhenDirTop,e="top"}h(B.placeClass[e])}u(t),V=!1,L=!0,"function"==typeof T&&T(y.innerHTML)}H&&(O=E(c))}function f(t){var e=!1;if(!F.place)return e;switch(F.place){case"top":x.canPlaceTop&&x.withinLeftAndRightWhenVert&&(h(B.placeClass.top),t.bottom=x.bottomWhenDirTop,t.left=x.leftWhenVertical,e=!0);break;case"right":x.canPlaceRight&&(h(B.placeClass.right),t.top=x.topWhenHorizontal,t.left=x.leftWhenDirRight,e=!0);break;case"bottom":x.canPlaceBottom&&x.withinLeftAndRightWhenVert&&(h(B.placeClass.bottom),t.top=x.topWhenDirBottom,t.left=x.leftWhenVertical,e=!0);break;case"left":x.canPlaceLeft&&(h(B.placeClass.left),t.top=x.topWhenHorizontal,t.right=x.rightWhenDirLeft,e=!0)}return e}function u(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e+=n+":"+parseInt(t[n])+"px;");R.style.cssText=e}function h(t){k!==t&&(k=t,R.className=[B.tooltipClass,B.activeClass,B.typeClass[F.type],t].concat(F.classes).join(" "))}function d(){if(R)return r();y=document.querySelector("."+B.containerClass),y||(y=document.createElement("div"),y.className=B.containerClass,document.body.appendChild(y)),R=y.querySelector("."+B.tooltipClass),R||(R=document.createElement("div"),R.className=B.tooltipClass,y.appendChild(R)),P=document.body.getBoundingClientRect().width,z=window.innerHeight,p(),r()}function p(){g(),window.addEventListener("scroll",w),window.addEventListener("resize",m)}function g(){window.removeEventListener("scroll",w),window.removeEventListener("resize",m)}function w(){L===!0&&r()}function m(){P=document.body.getBoundingClientRect().width,z=window.innerHeight}function C(t){V=!0,A=t.clientX,D=t.clientY}function W(){Object.assign(B,X)}function b(){return B}function v(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};T=t.onShow||null,j=t.onHide||null,q=t.onDestroy||null}Object.defineProperty(e,"__esModule",{value:!0}),e.show=o,e.hide=r,e.setConfig=i,e.destroy=a,e._restoreConfigDefaults=W,e._inspectConfig=b,e._defineTestHooks=v;var y,R,L,H,A,D,V,k,O,P,z,F,T,j,q,B={containerClass:"internetips-container",tooltipClass:"internetips",activeClass:"internetips-show",placeClass:{top:"internetips-place-top",right:"internetips-place-right",bottom:"internetips-place-bottom",left:"internetips-place-left"},typeClass:{dark:"internetips-type-dark",light:"internetips-type-light"},defaults:{effect:"float",target:null,place:null,type:"dark",classes:[],offsetX:15,offsetY:15}},x=Object.create({},{nodeWidth:{get:function(){return R.clientWidth}},nodeHeight:{get:function(){return R.clientHeight}},leftWhenVertical:{get:function(){return A-this.nodeWidth/2}},topWhenHorizontal:{get:function(){return D-this.nodeHeight/2}},rightWhenDirLeft:{get:function(){return P-A+F.offsetX}},leftWhenDirRight:{get:function(){return A+F.offsetX}},bottomWhenDirTop:{get:function(){return z-(D-F.offsetY)}},topWhenDirBottom:{get:function(){return D+F.offsetY}},withinLeftWhenVert:{get:function(){return this.leftWhenVertical>0}},withinRightWhenVert:{get:function(){return A+this.nodeWidth/2<P}},withinLeftAndRightWhenVert:{get:function(){return this.withinRightWhenVert&&this.withinLeftWhenVert}},canPlaceTop:{get:function(){return D-(this.nodeHeight+F.offsetY)>0}},canPlaceBottom:{get:function(){return D+this.nodeHeight+F.offsetY<z}},canPlaceLeft:{get:function(){return A-(this.nodeWidth+F.offsetX)>0&&this.topWhenHorizontal>0}},canPlaceRight:{get:function(){return A+this.nodeWidth+F.offsetX<P&&this.topWhenHorizontal>0}}}),E=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(){console.warn("tooltips require requestAnimationFrame; `float` will not work.")},N=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.msCancelAnimationFrame||function(){},X=JSON.parse(JSON.stringify(B))}]);
window.internetips=function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(L)return console.warn("Disallowed: set tooltip configs after first .show().");Object.assign(x,t,{placeClass:Object.assign({},x.placeClass,t.placeClass)},{typeClass:Object.assign({},x.typeClass,t.typeClass)},{defaults:Object.assign({},x.defaults,t.defaults,{effect:x.defaults.effect,target:x.defaults.target})})}function o(t){return t&&t.content?(p(),T=Object.assign({},x.defaults,t,{classes:x.defaults.classes.concat(t.classes||[])}),L.innerHTML=T.content,d(),"solid"===T.effect?l():void c()):console.warn("Cannot .show() tooltip without `content` param.")}function r(){T=D=V=O=null,H=A=!1,k=!0,X(P),document.removeEventListener("mousemove",W),L&&(L.style.cssText=null,L.className=x.tooltipClass,L.innerHTML=null)}function a(){r(),"function"==typeof q&&q()}function s(){w(),r(),L&&L.parentNode.removeChild(L),R&&R.parentNode.removeChild(R),R=L=null,"function"==typeof B&&B()}function l(){if(!T.target)return r(),console.warn("Cannot .show() tooltip when effect === `solid` without target node.");var t=T.target.getBoundingClientRect();T.offsetX+=parseInt(t.width/2)||0,T.offsetY+=parseInt(t.height/2)||0,D=t.left+t.width/2,V=t.top+t.height/2,f()}function c(){if(T.target){var t=T.target.getBoundingClientRect();D=t.left+t.width/2,V=t.top+t.height/2}A=!0,document.addEventListener("mousemove",W),f()}function f(){if(k){var t={};if(!u(t)){var e;switch(!0){case!E.withinLeftWhenVert:t.top=E.topWhenHorizontal,t.left=E.leftWhenDirRight,e="right";break;case!E.withinRightWhenVert:t.top=E.topWhenHorizontal,t.right=E.rightWhenDirLeft,e="left";break;case!E.canPlaceTop:t.left=E.leftWhenVertical,t.top=E.topWhenDirBottom,e="bottom";break;default:t.left=E.leftWhenVertical,t.bottom=E.bottomWhenDirTop,e="top"}d(x.placeClass[e])}h(t),k=!1,H=!0,"function"==typeof j&&j(R.innerHTML)}A&&(P=N(f))}function u(t){var e=!1;if(!T.place)return e;switch(T.place){case"top":E.canPlaceTop&&E.withinLeftAndRightWhenVert&&(d(x.placeClass.top),t.bottom=E.bottomWhenDirTop,t.left=E.leftWhenVertical,e=!0);break;case"right":E.canPlaceRight&&(d(x.placeClass.right),t.top=E.topWhenHorizontal,t.left=E.leftWhenDirRight,e=!0);break;case"bottom":E.canPlaceBottom&&E.withinLeftAndRightWhenVert&&(d(x.placeClass.bottom),t.top=E.topWhenDirBottom,t.left=E.leftWhenVertical,e=!0);break;case"left":E.canPlaceLeft&&(d(x.placeClass.left),t.top=E.topWhenHorizontal,t.right=E.rightWhenDirLeft,e=!0)}return e}function h(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e+=n+":"+parseInt(t[n])+"px;");L.style.cssText=e}function d(t){O!==t&&(O=t,L.className=[x.tooltipClass,x.activeClass,x.typeClass[T.type],t].concat(T.classes).join(" "))}function p(){if(L)return r();R=document.querySelector("."+x.containerClass),R||(R=document.createElement("div"),R.className=x.containerClass,document.body.appendChild(R)),L=R.querySelector("."+x.tooltipClass),L||(L=document.createElement("div"),L.className=x.tooltipClass,R.appendChild(L)),z=document.body.getBoundingClientRect().width,F=window.innerHeight,g(),r()}function g(){w(),window.addEventListener("scroll",m),window.addEventListener("resize",C)}function w(){window.removeEventListener("scroll",m),window.removeEventListener("resize",C)}function m(){H===!0&&r()}function C(){z=document.body.getBoundingClientRect().width,F=window.innerHeight}function W(t){k=!0,D=t.clientX,V=t.clientY}function b(){Object.assign(x,Y)}function v(){return x}function y(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};j=t.onShow||null,q=t.onHide||null,B=t.onDestroy||null}Object.defineProperty(e,"__esModule",{value:!0}),e.show=o,e.hide=a,e.setConfig=i,e.destroy=s,e._restoreConfigDefaults=b,e._inspectConfig=v,e._defineTestHooks=y;var R,L,H,A,D,V,k,O,P,z,F,T,j,q,B,x={containerClass:"internetips-container",tooltipClass:"internetips",activeClass:"internetips-show",placeClass:{top:"internetips-place-top",right:"internetips-place-right",bottom:"internetips-place-bottom",left:"internetips-place-left"},typeClass:{dark:"internetips-type-dark",light:"internetips-type-light"},defaults:{effect:"float",target:null,place:null,type:"dark",classes:[],offsetX:15,offsetY:15}},E=Object.create({},{nodeWidth:{get:function(){return L.clientWidth}},nodeHeight:{get:function(){return L.clientHeight}},leftWhenVertical:{get:function(){return D-this.nodeWidth/2}},topWhenHorizontal:{get:function(){return V-this.nodeHeight/2}},rightWhenDirLeft:{get:function(){return z-D+T.offsetX}},leftWhenDirRight:{get:function(){return D+T.offsetX}},bottomWhenDirTop:{get:function(){return F-(V-T.offsetY)}},topWhenDirBottom:{get:function(){return V+T.offsetY}},withinLeftWhenVert:{get:function(){return this.leftWhenVertical>0}},withinRightWhenVert:{get:function(){return D+this.nodeWidth/2<z}},withinLeftAndRightWhenVert:{get:function(){return this.withinRightWhenVert&&this.withinLeftWhenVert}},canPlaceTop:{get:function(){return V-(this.nodeHeight+T.offsetY)>0}},canPlaceBottom:{get:function(){return V+this.nodeHeight+T.offsetY<F}},canPlaceLeft:{get:function(){return D-(this.nodeWidth+T.offsetX)>0&&this.topWhenHorizontal>0}},canPlaceRight:{get:function(){return D+this.nodeWidth+T.offsetX<z&&this.topWhenHorizontal>0}}}),N=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(){console.warn("tooltips require requestAnimationFrame; `float` will not work.")},X=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.msCancelAnimationFrame||function(){},Y=JSON.parse(JSON.stringify(x))}]);

@@ -221,3 +221,3 @@ 'use strict';

*/
function hide() {
function reset() {
activeParams = pointX = pointY = lastPlacementDirection = null;

@@ -233,3 +233,12 @@ isOpen = isFloating = false;

}
}
/**
* This is the *publicly* exposed hide function (instead of proxying the reset
* function directly as 'hide', because we want to enable the onHideHook and
* invoke it only when the public fn is invoked).
*/
function hide() {
reset();
// Test hook integration

@@ -246,3 +255,3 @@ if (typeof onHideHook === 'function') {

unbindWindowEvents();
hide();
reset();
tipNode && tipNode.parentNode.removeChild(tipNode);

@@ -270,3 +279,3 @@ containerNode && containerNode.parentNode.removeChild(containerNode);

if (!activeParams.target) {
hide();
reset();
return console.warn('Cannot .show() tooltip when effect === `solid` without target node.');

@@ -445,3 +454,3 @@ }

if (tipNode) {
return hide();
return reset();
}

@@ -467,3 +476,3 @@

bindWindowEvents();
hide();
reset();
}

@@ -476,3 +485,3 @@

* the event listeners initialized, since they do little work, then
* binding and unbinding between every show()/hide() call.
* binding and unbinding between every show()/reset() call.
* Note: this should only be called once, during the first initialization,

@@ -506,3 +515,3 @@ * but just to ensure we don't accidentally bind multiple listeners of the

if (isOpen === true) {
hide();
reset();
}

@@ -509,0 +518,0 @@ }

@@ -1,1 +0,1 @@

window.internetips=function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(R)return console.warn("Disallowed: set tooltip configs after first .show().");Object.assign(B,t,{placeClass:Object.assign({},B.placeClass,t.placeClass)},{typeClass:Object.assign({},B.typeClass,t.typeClass)},{defaults:Object.assign({},B.defaults,t.defaults,{effect:B.defaults.effect,target:B.defaults.target})})}function o(t){return t&&t.content?(d(),F=Object.assign({},B.defaults,t,{classes:B.defaults.classes.concat(t.classes||[])}),R.innerHTML=F.content,h(),"solid"===F.effect?s():void l()):console.warn("Cannot .show() tooltip without `content` param.")}function r(){F=A=D=k=null,L=H=!1,V=!0,N(O),document.removeEventListener("mousemove",C),R&&(R.style.cssText=null,R.className=B.tooltipClass,R.innerHTML=null),"function"==typeof j&&j()}function a(){g(),r(),R&&R.parentNode.removeChild(R),y&&y.parentNode.removeChild(y),y=R=null,"function"==typeof q&&q()}function s(){if(!F.target)return r(),console.warn("Cannot .show() tooltip when effect === `solid` without target node.");var t=F.target.getBoundingClientRect();F.offsetX+=parseInt(t.width/2)||0,F.offsetY+=parseInt(t.height/2)||0,A=t.left+t.width/2,D=t.top+t.height/2,c()}function l(){if(F.target){var t=F.target.getBoundingClientRect();A=t.left+t.width/2,D=t.top+t.height/2}H=!0,document.addEventListener("mousemove",C),c()}function c(){if(V){var t={};if(!f(t)){var e;switch(!0){case!x.withinLeftWhenVert:t.top=x.topWhenHorizontal,t.left=x.leftWhenDirRight,e="right";break;case!x.withinRightWhenVert:t.top=x.topWhenHorizontal,t.right=x.rightWhenDirLeft,e="left";break;case!x.canPlaceTop:t.left=x.leftWhenVertical,t.top=x.topWhenDirBottom,e="bottom";break;default:t.left=x.leftWhenVertical,t.bottom=x.bottomWhenDirTop,e="top"}h(B.placeClass[e])}u(t),V=!1,L=!0,"function"==typeof T&&T(y.innerHTML)}H&&(O=E(c))}function f(t){var e=!1;if(!F.place)return e;switch(F.place){case"top":x.canPlaceTop&&x.withinLeftAndRightWhenVert&&(h(B.placeClass.top),t.bottom=x.bottomWhenDirTop,t.left=x.leftWhenVertical,e=!0);break;case"right":x.canPlaceRight&&(h(B.placeClass.right),t.top=x.topWhenHorizontal,t.left=x.leftWhenDirRight,e=!0);break;case"bottom":x.canPlaceBottom&&x.withinLeftAndRightWhenVert&&(h(B.placeClass.bottom),t.top=x.topWhenDirBottom,t.left=x.leftWhenVertical,e=!0);break;case"left":x.canPlaceLeft&&(h(B.placeClass.left),t.top=x.topWhenHorizontal,t.right=x.rightWhenDirLeft,e=!0)}return e}function u(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e+=n+":"+parseInt(t[n])+"px;");R.style.cssText=e}function h(t){k!==t&&(k=t,R.className=[B.tooltipClass,B.activeClass,B.typeClass[F.type],t].concat(F.classes).join(" "))}function d(){if(R)return r();y=document.querySelector("."+B.containerClass),y||(y=document.createElement("div"),y.className=B.containerClass,document.body.appendChild(y)),R=y.querySelector("."+B.tooltipClass),R||(R=document.createElement("div"),R.className=B.tooltipClass,y.appendChild(R)),P=document.body.getBoundingClientRect().width,z=window.innerHeight,p(),r()}function p(){g(),window.addEventListener("scroll",w),window.addEventListener("resize",m)}function g(){window.removeEventListener("scroll",w),window.removeEventListener("resize",m)}function w(){L===!0&&r()}function m(){P=document.body.getBoundingClientRect().width,z=window.innerHeight}function C(t){V=!0,A=t.clientX,D=t.clientY}function W(){Object.assign(B,X)}function b(){return B}function v(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};T=t.onShow||null,j=t.onHide||null,q=t.onDestroy||null}Object.defineProperty(e,"__esModule",{value:!0}),e.show=o,e.hide=r,e.setConfig=i,e.destroy=a,e._restoreConfigDefaults=W,e._inspectConfig=b,e._defineTestHooks=v;var y,R,L,H,A,D,V,k,O,P,z,F,T,j,q,B={containerClass:"internetips-container",tooltipClass:"internetips",activeClass:"internetips-show",placeClass:{top:"internetips-place-top",right:"internetips-place-right",bottom:"internetips-place-bottom",left:"internetips-place-left"},typeClass:{dark:"internetips-type-dark",light:"internetips-type-light"},defaults:{effect:"float",target:null,place:null,type:"dark",classes:[],offsetX:15,offsetY:15}},x=Object.create({},{nodeWidth:{get:function(){return R.clientWidth}},nodeHeight:{get:function(){return R.clientHeight}},leftWhenVertical:{get:function(){return A-this.nodeWidth/2}},topWhenHorizontal:{get:function(){return D-this.nodeHeight/2}},rightWhenDirLeft:{get:function(){return P-A+F.offsetX}},leftWhenDirRight:{get:function(){return A+F.offsetX}},bottomWhenDirTop:{get:function(){return z-(D-F.offsetY)}},topWhenDirBottom:{get:function(){return D+F.offsetY}},withinLeftWhenVert:{get:function(){return this.leftWhenVertical>0}},withinRightWhenVert:{get:function(){return A+this.nodeWidth/2<P}},withinLeftAndRightWhenVert:{get:function(){return this.withinRightWhenVert&&this.withinLeftWhenVert}},canPlaceTop:{get:function(){return D-(this.nodeHeight+F.offsetY)>0}},canPlaceBottom:{get:function(){return D+this.nodeHeight+F.offsetY<z}},canPlaceLeft:{get:function(){return A-(this.nodeWidth+F.offsetX)>0&&this.topWhenHorizontal>0}},canPlaceRight:{get:function(){return A+this.nodeWidth+F.offsetX<P&&this.topWhenHorizontal>0}}}),E=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(){console.warn("tooltips require requestAnimationFrame; `float` will not work.")},N=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.msCancelAnimationFrame||function(){},X=JSON.parse(JSON.stringify(B))}]);
window.internetips=function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(L)return console.warn("Disallowed: set tooltip configs after first .show().");Object.assign(x,t,{placeClass:Object.assign({},x.placeClass,t.placeClass)},{typeClass:Object.assign({},x.typeClass,t.typeClass)},{defaults:Object.assign({},x.defaults,t.defaults,{effect:x.defaults.effect,target:x.defaults.target})})}function o(t){return t&&t.content?(p(),T=Object.assign({},x.defaults,t,{classes:x.defaults.classes.concat(t.classes||[])}),L.innerHTML=T.content,d(),"solid"===T.effect?l():void c()):console.warn("Cannot .show() tooltip without `content` param.")}function r(){T=D=V=O=null,H=A=!1,k=!0,X(P),document.removeEventListener("mousemove",W),L&&(L.style.cssText=null,L.className=x.tooltipClass,L.innerHTML=null)}function a(){r(),"function"==typeof q&&q()}function s(){w(),r(),L&&L.parentNode.removeChild(L),R&&R.parentNode.removeChild(R),R=L=null,"function"==typeof B&&B()}function l(){if(!T.target)return r(),console.warn("Cannot .show() tooltip when effect === `solid` without target node.");var t=T.target.getBoundingClientRect();T.offsetX+=parseInt(t.width/2)||0,T.offsetY+=parseInt(t.height/2)||0,D=t.left+t.width/2,V=t.top+t.height/2,f()}function c(){if(T.target){var t=T.target.getBoundingClientRect();D=t.left+t.width/2,V=t.top+t.height/2}A=!0,document.addEventListener("mousemove",W),f()}function f(){if(k){var t={};if(!u(t)){var e;switch(!0){case!E.withinLeftWhenVert:t.top=E.topWhenHorizontal,t.left=E.leftWhenDirRight,e="right";break;case!E.withinRightWhenVert:t.top=E.topWhenHorizontal,t.right=E.rightWhenDirLeft,e="left";break;case!E.canPlaceTop:t.left=E.leftWhenVertical,t.top=E.topWhenDirBottom,e="bottom";break;default:t.left=E.leftWhenVertical,t.bottom=E.bottomWhenDirTop,e="top"}d(x.placeClass[e])}h(t),k=!1,H=!0,"function"==typeof j&&j(R.innerHTML)}A&&(P=N(f))}function u(t){var e=!1;if(!T.place)return e;switch(T.place){case"top":E.canPlaceTop&&E.withinLeftAndRightWhenVert&&(d(x.placeClass.top),t.bottom=E.bottomWhenDirTop,t.left=E.leftWhenVertical,e=!0);break;case"right":E.canPlaceRight&&(d(x.placeClass.right),t.top=E.topWhenHorizontal,t.left=E.leftWhenDirRight,e=!0);break;case"bottom":E.canPlaceBottom&&E.withinLeftAndRightWhenVert&&(d(x.placeClass.bottom),t.top=E.topWhenDirBottom,t.left=E.leftWhenVertical,e=!0);break;case"left":E.canPlaceLeft&&(d(x.placeClass.left),t.top=E.topWhenHorizontal,t.right=E.rightWhenDirLeft,e=!0)}return e}function h(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e+=n+":"+parseInt(t[n])+"px;");L.style.cssText=e}function d(t){O!==t&&(O=t,L.className=[x.tooltipClass,x.activeClass,x.typeClass[T.type],t].concat(T.classes).join(" "))}function p(){if(L)return r();R=document.querySelector("."+x.containerClass),R||(R=document.createElement("div"),R.className=x.containerClass,document.body.appendChild(R)),L=R.querySelector("."+x.tooltipClass),L||(L=document.createElement("div"),L.className=x.tooltipClass,R.appendChild(L)),z=document.body.getBoundingClientRect().width,F=window.innerHeight,g(),r()}function g(){w(),window.addEventListener("scroll",m),window.addEventListener("resize",C)}function w(){window.removeEventListener("scroll",m),window.removeEventListener("resize",C)}function m(){H===!0&&r()}function C(){z=document.body.getBoundingClientRect().width,F=window.innerHeight}function W(t){k=!0,D=t.clientX,V=t.clientY}function b(){Object.assign(x,Y)}function v(){return x}function y(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};j=t.onShow||null,q=t.onHide||null,B=t.onDestroy||null}Object.defineProperty(e,"__esModule",{value:!0}),e.show=o,e.hide=a,e.setConfig=i,e.destroy=s,e._restoreConfigDefaults=b,e._inspectConfig=v,e._defineTestHooks=y;var R,L,H,A,D,V,k,O,P,z,F,T,j,q,B,x={containerClass:"internetips-container",tooltipClass:"internetips",activeClass:"internetips-show",placeClass:{top:"internetips-place-top",right:"internetips-place-right",bottom:"internetips-place-bottom",left:"internetips-place-left"},typeClass:{dark:"internetips-type-dark",light:"internetips-type-light"},defaults:{effect:"float",target:null,place:null,type:"dark",classes:[],offsetX:15,offsetY:15}},E=Object.create({},{nodeWidth:{get:function(){return L.clientWidth}},nodeHeight:{get:function(){return L.clientHeight}},leftWhenVertical:{get:function(){return D-this.nodeWidth/2}},topWhenHorizontal:{get:function(){return V-this.nodeHeight/2}},rightWhenDirLeft:{get:function(){return z-D+T.offsetX}},leftWhenDirRight:{get:function(){return D+T.offsetX}},bottomWhenDirTop:{get:function(){return F-(V-T.offsetY)}},topWhenDirBottom:{get:function(){return V+T.offsetY}},withinLeftWhenVert:{get:function(){return this.leftWhenVertical>0}},withinRightWhenVert:{get:function(){return D+this.nodeWidth/2<z}},withinLeftAndRightWhenVert:{get:function(){return this.withinRightWhenVert&&this.withinLeftWhenVert}},canPlaceTop:{get:function(){return V-(this.nodeHeight+T.offsetY)>0}},canPlaceBottom:{get:function(){return V+this.nodeHeight+T.offsetY<F}},canPlaceLeft:{get:function(){return D-(this.nodeWidth+T.offsetX)>0&&this.topWhenHorizontal>0}},canPlaceRight:{get:function(){return D+this.nodeWidth+T.offsetX<z&&this.topWhenHorizontal>0}}}),N=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(){console.warn("tooltips require requestAnimationFrame; `float` will not work.")},X=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.msCancelAnimationFrame||function(){},Y=JSON.parse(JSON.stringify(x))}]);

@@ -215,3 +215,3 @@ export {

*/
function hide() {
function reset() {
activeParams = pointX = pointY = lastPlacementDirection = null;

@@ -227,3 +227,12 @@ isOpen = isFloating = false;

}
}
/**
* This is the *publicly* exposed hide function (instead of proxying the reset
* function directly as 'hide', because we want to enable the onHideHook and
* invoke it only when the public fn is invoked).
*/
function hide() {
reset();
// Test hook integration

@@ -240,3 +249,3 @@ if (typeof onHideHook === 'function') {

unbindWindowEvents();
hide();
reset();
tipNode && tipNode.parentNode.removeChild(tipNode);

@@ -264,3 +273,3 @@ containerNode && containerNode.parentNode.removeChild(containerNode);

if (!activeParams.target) {
hide();
reset();
return console.warn(

@@ -445,3 +454,3 @@ 'Cannot .show() tooltip when effect === `solid` without target node.'

function ensureInitializedAndReady() {
if (tipNode) { return hide(); }
if (tipNode) { return reset(); }

@@ -466,3 +475,3 @@ containerNode = document.querySelector(`.${configs.containerClass}`);

bindWindowEvents();
hide();
reset();
}

@@ -475,3 +484,3 @@

* the event listeners initialized, since they do little work, then
* binding and unbinding between every show()/hide() call.
* binding and unbinding between every show()/reset() call.
* Note: this should only be called once, during the first initialization,

@@ -504,3 +513,3 @@ * but just to ensure we don't accidentally bind multiple listeners of the

function trackWindowScroll() {
if (isOpen === true) { hide(); }
if (isOpen === true) { reset(); }
}

@@ -507,0 +516,0 @@

{
"name": "internetips",
"version": "0.2.1",
"version": "0.2.2",
"description": "A tooltip library without the whole kitchen sink",

@@ -5,0 +5,0 @@ "main": "dist/node/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc