internetips
Advanced tools
Comparing version 0.1.0 to 0.2.1
@@ -86,2 +86,3 @@ window["internetips"] = | ||
exports._inspectConfig = _inspectConfig; | ||
exports._defineTestHooks = _defineTestHooks; | ||
@@ -235,2 +236,7 @@ | ||
// Null by default, these hooks can be set via injected callables that will | ||
// be invoked during relevant API calls. These should be used explicity for | ||
// testing purposes. | ||
var onShowHook, onHideHook, onDestroyHook; | ||
/** | ||
@@ -302,2 +308,7 @@ * Set configuration defaults. If the tooltip node already exists (eg. has been | ||
} | ||
// Test hook integration | ||
if (typeof onHideHook === 'function') { | ||
onHideHook(); | ||
} | ||
} | ||
@@ -314,2 +325,7 @@ | ||
containerNode = tipNode = null; | ||
// Test hook integration | ||
if (typeof onDestroyHook === 'function') { | ||
onDestroyHook(); | ||
} | ||
} | ||
@@ -400,2 +416,7 @@ | ||
isOpen = true; | ||
// Test hook integration | ||
if (typeof onShowHook === 'function') { | ||
onShowHook(containerNode.innerHTML); | ||
} | ||
} | ||
@@ -592,3 +613,11 @@ | ||
function _defineTestHooks() { | ||
var definitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
onShowHook = definitions.onShow || null; | ||
onHideHook = definitions.onHide || null; | ||
onDestroyHook = definitions.onDestroy || null; | ||
} | ||
/***/ }) | ||
/******/ ]); |
@@ -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(y)return console.warn("Disallowed: set tooltip configs after first .show().");Object.assign(F,t,{placeClass:Object.assign({},F.placeClass,t.placeClass)},{typeClass:Object.assign({},F.typeClass,t.typeClass)},{defaults:Object.assign({},F.defaults,t.defaults,{effect:F.defaults.effect,target:F.defaults.target})})}function o(t){return t&&t.content?(d(),z=Object.assign({},F.defaults,t,{classes:F.defaults.classes.concat(t.classes||[])}),y.innerHTML=z.content,h(),"solid"===z.effect?s():void l()):console.warn("Cannot .show() tooltip without `content` param.")}function r(){z=H=A=D=null,R=L=!1,V=!0,T(O),document.removeEventListener("mousemove",C),y&&(y.style.cssText=null,y.className=F.tooltipClass,y.innerHTML=null)}function a(){g(),r(),y&&y.parentNode.removeChild(y),v&&v.parentNode.removeChild(v),v=y=null}function s(){if(!z.target)return r(),console.warn("Cannot .show() tooltip when effect === `solid` without target node.");var t=z.target.getBoundingClientRect();z.offsetX+=parseInt(t.width/2)||0,z.offsetY+=parseInt(t.height/2)||0,H=t.left+t.width/2,A=t.top+t.height/2,c()}function l(){if(z.target){var t=z.target.getBoundingClientRect();H=t.left+t.width/2,A=t.top+t.height/2}L=!0,document.addEventListener("mousemove",C),c()}function c(){if(V){var t={};if(!f(t)){var e;switch(!0){case!j.withinLeftWhenVert:t.top=j.topWhenHorizontal,t.left=j.leftWhenDirRight,e="right";break;case!j.withinRightWhenVert:t.top=j.topWhenHorizontal,t.right=j.rightWhenDirLeft,e="left";break;case!j.canPlaceTop:t.left=j.leftWhenVertical,t.top=j.topWhenDirBottom,e="bottom";break;default:t.left=j.leftWhenVertical,t.bottom=j.bottomWhenDirTop,e="top"}h(F.placeClass[e])}u(t),V=!1,R=!0}L&&(O=q(c))}function f(t){var e=!1;if(!z.place)return e;switch(z.place){case"top":j.canPlaceTop&&j.withinLeftAndRightWhenVert&&(h(F.placeClass.top),t.bottom=j.bottomWhenDirTop,t.left=j.leftWhenVertical,e=!0);break;case"right":j.canPlaceRight&&(h(F.placeClass.right),t.top=j.topWhenHorizontal,t.left=j.leftWhenDirRight,e=!0);break;case"bottom":j.canPlaceBottom&&j.withinLeftAndRightWhenVert&&(h(F.placeClass.bottom),t.top=j.topWhenDirBottom,t.left=j.leftWhenVertical,e=!0);break;case"left":j.canPlaceLeft&&(h(F.placeClass.left),t.top=j.topWhenHorizontal,t.right=j.rightWhenDirLeft,e=!0)}return e}function u(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e+=n+":"+parseInt(t[n])+"px;");y.style.cssText=e}function h(t){D!==t&&(D=t,y.className=[F.tooltipClass,F.activeClass,F.typeClass[z.type],t].concat(z.classes).join(" "))}function d(){if(y)return r();v=document.querySelector("."+F.containerClass),v||(v=document.createElement("div"),v.className=F.containerClass,document.body.appendChild(v)),y=v.querySelector("."+F.tooltipClass),y||(y=document.createElement("div"),y.className=F.tooltipClass,v.appendChild(y)),k=document.body.getBoundingClientRect().width,P=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(){R===!0&&r()}function m(){k=document.body.getBoundingClientRect().width,P=window.innerHeight}function C(t){V=!0,H=t.clientX,A=t.clientY}function W(){Object.assign(F,B)}function b(){return F}Object.defineProperty(e,"__esModule",{value:!0}),e.show=o,e.hide=r,e.setConfig=i,e.destroy=a,e._restoreConfigDefaults=W,e._inspectConfig=b;var v,y,R,L,H,A,V,D,O,k,P,z,F={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}},j=Object.create({},{nodeWidth:{get:function(){return y.clientWidth}},nodeHeight:{get:function(){return y.clientHeight}},leftWhenVertical:{get:function(){return H-this.nodeWidth/2}},topWhenHorizontal:{get:function(){return A-this.nodeHeight/2}},rightWhenDirLeft:{get:function(){return k-H+z.offsetX}},leftWhenDirRight:{get:function(){return H+z.offsetX}},bottomWhenDirTop:{get:function(){return P-(A-z.offsetY)}},topWhenDirBottom:{get:function(){return A+z.offsetY}},withinLeftWhenVert:{get:function(){return this.leftWhenVertical>0}},withinRightWhenVert:{get:function(){return H+this.nodeWidth/2<k}},withinLeftAndRightWhenVert:{get:function(){return this.withinRightWhenVert&&this.withinLeftWhenVert}},canPlaceTop:{get:function(){return A-(this.nodeHeight+z.offsetY)>0}},canPlaceBottom:{get:function(){return A+this.nodeHeight+z.offsetY<P}},canPlaceLeft:{get:function(){return H-(this.nodeWidth+z.offsetX)>0&&this.topWhenHorizontal>0}},canPlaceRight:{get:function(){return H+this.nodeWidth+z.offsetX<k&&this.topWhenHorizontal>0}}}),q=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(){console.warn("tooltips require requestAnimationFrame; `float` will not work.")},T=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.msCancelAnimationFrame||function(){},B=JSON.parse(JSON.stringify(F))}]); | ||
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))}]); |
@@ -12,2 +12,3 @@ 'use strict'; | ||
exports._inspectConfig = _inspectConfig; | ||
exports._defineTestHooks = _defineTestHooks; | ||
@@ -161,2 +162,7 @@ | ||
// Null by default, these hooks can be set via injected callables that will | ||
// be invoked during relevant API calls. These should be used explicity for | ||
// testing purposes. | ||
var onShowHook, onHideHook, onDestroyHook; | ||
/** | ||
@@ -228,2 +234,7 @@ * Set configuration defaults. If the tooltip node already exists (eg. has been | ||
} | ||
// Test hook integration | ||
if (typeof onHideHook === 'function') { | ||
onHideHook(); | ||
} | ||
} | ||
@@ -240,2 +251,7 @@ | ||
containerNode = tipNode = null; | ||
// Test hook integration | ||
if (typeof onDestroyHook === 'function') { | ||
onDestroyHook(); | ||
} | ||
} | ||
@@ -326,2 +342,7 @@ | ||
isOpen = true; | ||
// Test hook integration | ||
if (typeof onShowHook === 'function') { | ||
onShowHook(containerNode.innerHTML); | ||
} | ||
} | ||
@@ -516,2 +537,10 @@ | ||
return configs; | ||
} | ||
function _defineTestHooks() { | ||
var definitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
onShowHook = definitions.onShow || null; | ||
onHideHook = definitions.onHide || null; | ||
onDestroyHook = definitions.onDestroy || null; | ||
} |
@@ -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(y)return console.warn("Disallowed: set tooltip configs after first .show().");Object.assign(F,t,{placeClass:Object.assign({},F.placeClass,t.placeClass)},{typeClass:Object.assign({},F.typeClass,t.typeClass)},{defaults:Object.assign({},F.defaults,t.defaults,{effect:F.defaults.effect,target:F.defaults.target})})}function o(t){return t&&t.content?(d(),z=Object.assign({},F.defaults,t,{classes:F.defaults.classes.concat(t.classes||[])}),y.innerHTML=z.content,h(),"solid"===z.effect?s():void l()):console.warn("Cannot .show() tooltip without `content` param.")}function r(){z=H=A=D=null,R=L=!1,V=!0,T(O),document.removeEventListener("mousemove",C),y&&(y.style.cssText=null,y.className=F.tooltipClass,y.innerHTML=null)}function a(){g(),r(),y&&y.parentNode.removeChild(y),v&&v.parentNode.removeChild(v),v=y=null}function s(){if(!z.target)return r(),console.warn("Cannot .show() tooltip when effect === `solid` without target node.");var t=z.target.getBoundingClientRect();z.offsetX+=parseInt(t.width/2)||0,z.offsetY+=parseInt(t.height/2)||0,H=t.left+t.width/2,A=t.top+t.height/2,c()}function l(){if(z.target){var t=z.target.getBoundingClientRect();H=t.left+t.width/2,A=t.top+t.height/2}L=!0,document.addEventListener("mousemove",C),c()}function c(){if(V){var t={};if(!f(t)){var e;switch(!0){case!j.withinLeftWhenVert:t.top=j.topWhenHorizontal,t.left=j.leftWhenDirRight,e="right";break;case!j.withinRightWhenVert:t.top=j.topWhenHorizontal,t.right=j.rightWhenDirLeft,e="left";break;case!j.canPlaceTop:t.left=j.leftWhenVertical,t.top=j.topWhenDirBottom,e="bottom";break;default:t.left=j.leftWhenVertical,t.bottom=j.bottomWhenDirTop,e="top"}h(F.placeClass[e])}u(t),V=!1,R=!0}L&&(O=q(c))}function f(t){var e=!1;if(!z.place)return e;switch(z.place){case"top":j.canPlaceTop&&j.withinLeftAndRightWhenVert&&(h(F.placeClass.top),t.bottom=j.bottomWhenDirTop,t.left=j.leftWhenVertical,e=!0);break;case"right":j.canPlaceRight&&(h(F.placeClass.right),t.top=j.topWhenHorizontal,t.left=j.leftWhenDirRight,e=!0);break;case"bottom":j.canPlaceBottom&&j.withinLeftAndRightWhenVert&&(h(F.placeClass.bottom),t.top=j.topWhenDirBottom,t.left=j.leftWhenVertical,e=!0);break;case"left":j.canPlaceLeft&&(h(F.placeClass.left),t.top=j.topWhenHorizontal,t.right=j.rightWhenDirLeft,e=!0)}return e}function u(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e+=n+":"+parseInt(t[n])+"px;");y.style.cssText=e}function h(t){D!==t&&(D=t,y.className=[F.tooltipClass,F.activeClass,F.typeClass[z.type],t].concat(z.classes).join(" "))}function d(){if(y)return r();v=document.querySelector("."+F.containerClass),v||(v=document.createElement("div"),v.className=F.containerClass,document.body.appendChild(v)),y=v.querySelector("."+F.tooltipClass),y||(y=document.createElement("div"),y.className=F.tooltipClass,v.appendChild(y)),k=document.body.getBoundingClientRect().width,P=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(){R===!0&&r()}function m(){k=document.body.getBoundingClientRect().width,P=window.innerHeight}function C(t){V=!0,H=t.clientX,A=t.clientY}function W(){Object.assign(F,B)}function b(){return F}Object.defineProperty(e,"__esModule",{value:!0}),e.show=o,e.hide=r,e.setConfig=i,e.destroy=a,e._restoreConfigDefaults=W,e._inspectConfig=b;var v,y,R,L,H,A,V,D,O,k,P,z,F={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}},j=Object.create({},{nodeWidth:{get:function(){return y.clientWidth}},nodeHeight:{get:function(){return y.clientHeight}},leftWhenVertical:{get:function(){return H-this.nodeWidth/2}},topWhenHorizontal:{get:function(){return A-this.nodeHeight/2}},rightWhenDirLeft:{get:function(){return k-H+z.offsetX}},leftWhenDirRight:{get:function(){return H+z.offsetX}},bottomWhenDirTop:{get:function(){return P-(A-z.offsetY)}},topWhenDirBottom:{get:function(){return A+z.offsetY}},withinLeftWhenVert:{get:function(){return this.leftWhenVertical>0}},withinRightWhenVert:{get:function(){return H+this.nodeWidth/2<k}},withinLeftAndRightWhenVert:{get:function(){return this.withinRightWhenVert&&this.withinLeftWhenVert}},canPlaceTop:{get:function(){return A-(this.nodeHeight+z.offsetY)>0}},canPlaceBottom:{get:function(){return A+this.nodeHeight+z.offsetY<P}},canPlaceLeft:{get:function(){return H-(this.nodeWidth+z.offsetX)>0&&this.topWhenHorizontal>0}},canPlaceRight:{get:function(){return H+this.nodeWidth+z.offsetX<k&&this.topWhenHorizontal>0}}}),q=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(){console.warn("tooltips require requestAnimationFrame; `float` will not work.")},T=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.msCancelAnimationFrame||function(){},B=JSON.parse(JSON.stringify(F))}]); | ||
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))}]); |
@@ -7,3 +7,4 @@ export { | ||
_restoreConfigDefaults, | ||
_inspectConfig | ||
_inspectConfig, | ||
_defineTestHooks | ||
}; | ||
@@ -29,3 +30,3 @@ | ||
// configuration | ||
// configuration | ||
const | ||
@@ -152,2 +153,6 @@ configs = { | ||
// Null by default, these hooks can be set via injected callables that will | ||
// be invoked during relevant API calls. These should be used explicity for | ||
// testing purposes. | ||
var onShowHook, onHideHook, onDestroyHook; | ||
@@ -224,2 +229,7 @@ /** | ||
} | ||
// Test hook integration | ||
if (typeof onHideHook === 'function') { | ||
onHideHook(); | ||
} | ||
} | ||
@@ -236,2 +246,7 @@ | ||
containerNode = tipNode = null; | ||
// Test hook integration | ||
if (typeof onDestroyHook === 'function') { | ||
onDestroyHook(); | ||
} | ||
} | ||
@@ -324,2 +339,7 @@ | ||
isOpen = true; | ||
// Test hook integration | ||
if (typeof onShowHook === 'function') { | ||
onShowHook(containerNode.innerHTML); | ||
} | ||
} | ||
@@ -516,1 +536,7 @@ | ||
} | ||
function _defineTestHooks(definitions = {}) { | ||
onShowHook = definitions.onShow || null; | ||
onHideHook = definitions.onHide || null; | ||
onDestroyHook = definitions.onDestroy || null; | ||
} |
{ | ||
"name": "internetips", | ||
"version": "0.1.0", | ||
"version": "0.2.1", | ||
"description": "A tooltip library without the whole kitchen sink", | ||
@@ -5,0 +5,0 @@ "main": "dist/node/index.js", |
177319
3320