Socket
Socket
Sign inDemoInstall

cp-tooltip

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cp-tooltip - npm Package Compare versions

Comparing version 1.2.0 to 1.2.4

9

build/cp-tooltip.js

@@ -6,4 +6,9 @@ /*!

* license: MIT
* version: 1.2.0
* version: 1.2.3
*/
!function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";var o=(n(1),n(2));o.module("cp-tooltip",[]),n(3),n(4)},function(t,e,n){t.exports=$},function(t,e,n){t.exports=angular},function(t,e,n){"use strict";angular.module("cp-tooltip").directive("cpTooltip",function(){var t=0,e=1e3;return{restrict:"A",link:function(n,o,r){function i(t){l=!0;var e=o[0].getBoundingClientRect(),n=$(document).scrollTop();c=$('\n <span class="cp-tooltip" style="left:'+t.clientX+"px; top:"+(n+e.top+e.height+4)+'px;">'+r.cpTooltip+"</span>\n ").hide(),$("body").append(c);var i=c.width(),s=c.height(),a=$(document).width(),u=e.left,p=n+e.top+e.height+4;u+i+10>a&&(u-=i+15),p+s>window.innerHeight&&(p-=s+40),c.css({left:u,top:p}).show()}function s(){l=!1,c&&c.remove()}var a,u,c,p=++t,l=!1,f=r.cpTooltipInstant||""==r.cpTooltipInstant;o.on("mouseenter.cptooltip"+p,function(t){a&&clearTimeout(a),u&&clearTimeout(u),a=setTimeout(function(){l||i(t)},f?100:e)}),o.on("mouseleave.cptooltip"+p,function(){u&&clearTimeout(u),u=setTimeout(function(){clearTimeout(a),s()},f?100:500)}),n.$on("$destroy",function(){s(),clearTimeout(a),clearTimeout(u),o.off("mouseenter.cptooltip"+p),o.off("mouseleave.cptooltip"+p)})}}})},function(t,e,n){var o=n(5);"string"==typeof o&&(o=[[t.id,o,""]]);n(6)(o,{})},function(t,e,n){e=t.exports=n(7)(),e.push([t.id,".cp-tooltip{background-color:#777;font-size:12px;padding:4px 8px;position:absolute;color:#fff;border-radius:2px;box-shadow:0 1px 4px 0 rgba(0,0,0,.26);z-index:100000}",""])},function(t,e,n){function o(t,e){for(var n=0;n<t.length;n++){var o=t[n],r=p[o.id];if(r){r.refs++;for(var i=0;i<r.parts.length;i++)r.parts[i](o.parts[i]);for(;i<o.parts.length;i++)r.parts.push(s(o.parts[i],e))}else{for(var a=[],i=0;i<o.parts.length;i++)a.push(s(o.parts[i],e));p[o.id]={id:o.id,refs:1,parts:a}}}}function r(t){for(var e=[],n={},o=0;o<t.length;o++){var r=t[o],i=r[0],s=r[1],a=r[2],u=r[3],c={css:s,media:a,sourceMap:u};n[i]?n[i].parts.push(c):e.push(n[i]={id:i,parts:[c]})}return e}function i(){var t=document.createElement("style"),e=d();return t.type="text/css",e.appendChild(t),t}function s(t,e){var n,o,r;if(e.singleton){var s=v++;n=h||(h=i()),o=u.bind(null,n,s,!1),r=u.bind(null,n,s,!0)}else n=i(),o=c.bind(null,n),r=function(){n.parentNode.removeChild(n)};return o(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;o(t=e)}else r()}}function a(t,e,n){var o=["/** >>"+e+" **/","/** "+e+"<< **/"],r=t.lastIndexOf(o[0]),i=n?o[0]+n+o[1]:"";if(t.lastIndexOf(o[0])>=0){var s=t.lastIndexOf(o[1])+o[1].length;return t.slice(0,r)+i+t.slice(s)}return t+i}function u(t,e,n,o){var r=n?"":o.css;if(t.styleSheet)t.styleSheet.cssText=a(t.styleSheet.cssText,e,r);else{var i=document.createTextNode(r),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(i,s[e]):t.appendChild(i)}}function c(t,e){var n=e.css,o=e.media,r=e.sourceMap;if(r&&"function"==typeof btoa)try{n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(JSON.stringify(r))+" */",n='@import url("data:text/css;base64,'+btoa(n)+'")'}catch(i){}if(o&&t.setAttribute("media",o),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}var p={},l=function(t){var e;return function(){return"undefined"==typeof e&&(e=t.apply(this,arguments)),e}},f=l(function(){return/msie 9\b/.test(window.navigator.userAgent.toLowerCase())}),d=l(function(){return document.head||document.getElementsByTagName("head")[0]}),h=null,v=0;t.exports=function(t,e){e=e||{},"undefined"==typeof e.singleton&&(e.singleton=f());var n=r(t);return o(n,e),function(t){for(var i=[],s=0;s<n.length;s++){var a=n[s],u=p[a.id];u.refs--,i.push(u)}if(t){var c=r(t);o(c,e)}for(var s=0;s<i.length;s++){var u=i[s];if(0===u.refs){for(var l=0;l<u.parts.length;l++)u.parts[l]();delete p[u.id]}}}}},function(t,e,n){t.exports=function(){var t=[];return t.toString=function(){for(var t=[],e=0;e<this.length;e++){var n=this[e];t.push(n[2]?"@media "+n[2]+"{"+n[1]+"}":n[1])}return t.join("")},t}}]);
!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";var r=(n(1),n(2));n(3);r.module("cp-tooltip",["ngSanitize"]),n(5),n(6)},function(e,t){e.exports=$},function(e,t){e.exports=angular},function(e,t,n){n(4),e.exports="ngSanitize"},function(e,t){/**
* @license AngularJS v1.5.3
* (c) 2010-2016 Google, Inc. http://angularjs.org
* License: MIT
*/
!function(e,t,n){"use strict";function r(){var e=!1;this.$get=["$$sanitizeUri",function(n){return e&&t.extend(T,k),function(e){var t=[];return a(e,c(t,function(e,t){return!/^unsafe:/.test(n(e,t))})),t.join("")}}],this.enableSvg=function(n){return t.isDefined(n)?(e=n,this):e}}function i(e){var n=[],r=c(n,t.noop);return r.chars(e),n.join("")}function o(e,n){var r,i={},o=e.split(",");for(r=0;r<o.length;r++)i[n?t.lowercase(o[r]):o[r]]=!0;return i}function a(e,t){null===e||e===n?e="":"string"!=typeof e&&(e=""+e),p.innerHTML=e;var r=5;do{if(0===r)throw f("uinput","Failed to sanitize html because the input is unstable");r--,document.documentMode<=11&&u(p),e=p.innerHTML,p.innerHTML=e}while(e!==p.innerHTML);for(var i=p.firstChild;i;){switch(i.nodeType){case 1:t.start(i.nodeName.toLowerCase(),s(i.attributes));break;case 3:t.chars(i.textContent)}var o;if(!(o=i.firstChild)&&(1==i.nodeType&&t.end(i.nodeName.toLowerCase()),o=i.nextSibling,!o))for(;null==o&&(i=i.parentNode,i!==p);)o=i.nextSibling,1==i.nodeType&&t.end(i.nodeName.toLowerCase());i=o}for(;i=p.firstChild;)p.removeChild(i)}function s(e){for(var t={},n=0,r=e.length;r>n;n++){var i=e[n];t[i.name]=i.value}return t}function l(e){return e.replace(/&/g,"&amp;").replace(d,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(h,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"&lt;").replace(/>/g,"&gt;")}function c(e,n){var r=!1,i=t.bind(e,e.push);return{start:function(e,o){e=t.lowercase(e),!r&&w[e]&&(r=e),r||T[e]!==!0||(i("<"),i(e),t.forEach(o,function(r,o){var a=t.lowercase(o),s="img"===e&&"src"===a||"background"===a;z[a]!==!0||C[a]===!0&&!n(r,s)||(i(" "),i(o),i('="'),i(l(r)),i('"'))}),i(">"))},end:function(e){e=t.lowercase(e),r||T[e]!==!0||m[e]===!0||(i("</"),i(e),i(">")),e==r&&(r=!1)},chars:function(e){r||i(l(e))}}}function u(e){if(e.nodeType===Node.ELEMENT_NODE)for(var t=e.attributes,n=0,r=t.length;r>n;n++){var i=t[n],o=i.name.toLowerCase();"xmlns:ns1"!==o&&0!==o.indexOf("ns1:")||(e.removeAttributeNode(i),n--,r--)}var a=e.firstChild;a&&u(a),a=e.nextSibling,a&&u(a)}var p,f=t.$$minErr("$sanitize"),d=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,h=/([^\#-~ |!])/g,m=o("area,br,col,hr,img,wbr"),g=o("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr"),v=o("rp,rt"),b=t.extend({},v,g),x=t.extend({},g,o("address,article,aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,section,table,ul")),y=t.extend({},v,o("a,abbr,acronym,b,bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var")),k=o("circle,defs,desc,ellipse,font-face,font-face-name,font-face-src,g,glyph,hkern,image,linearGradient,line,marker,metadata,missing-glyph,mpath,path,polygon,polyline,radialGradient,rect,stop,svg,switch,text,title,tspan"),w=o("script,style"),T=t.extend({},m,x,y,b),C=o("background,cite,href,longdesc,src,xlink:href"),L=o("abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,scope,scrolling,shape,size,span,start,summary,tabindex,target,title,type,valign,value,vspace,width"),S=o("accent-height,accumulate,additive,alphabetic,arabic-form,ascent,baseProfile,bbox,begin,by,calcMode,cap-height,class,color,color-rendering,content,cx,cy,d,dx,dy,descent,display,dur,end,fill,fill-rule,font-family,font-size,font-stretch,font-style,font-variant,font-weight,from,fx,fy,g1,g2,glyph-name,gradientUnits,hanging,height,horiz-adv-x,horiz-origin-x,ideographic,k,keyPoints,keySplines,keyTimes,lang,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mathematical,max,min,offset,opacity,orient,origin,overline-position,overline-thickness,panose-1,path,pathLength,points,preserveAspectRatio,r,refX,refY,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,rotate,rx,ry,slope,stemh,stemv,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,systemLanguage,target,text-anchor,to,transform,type,u1,u2,underline-position,underline-thickness,unicode,unicode-range,units-per-em,values,version,viewBox,visibility,width,widths,x,x-height,x1,x2,xlink:actuate,xlink:arcrole,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,xml:space,xmlns,xmlns:xlink,y,y1,y2,zoomAndPan",!0),z=t.extend({},C,S,L);!function(e){var t;if(!e.document||!e.document.implementation)throw f("noinert","Can't create an inert html document");t=e.document.implementation.createHTMLDocument("inert");var n=t.documentElement||t.getDocumentElement(),r=n.getElementsByTagName("body");if(1===r.length)p=r[0];else{var i=t.createElement("html");p=t.createElement("body"),i.appendChild(p),t.appendChild(i)}}(e),t.module("ngSanitize",[]).provider("$sanitize",r),t.module("ngSanitize").filter("linky",["$sanitize",function(e){var n=/((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"\u201d\u2019]/i,r=/^mailto:/i,o=t.$$minErr("linky"),a=t.isString;return function(s,l,c){function u(e){e&&g.push(i(e))}function p(e,n){var r;if(g.push("<a "),t.isFunction(c)&&(c=c(e)),t.isObject(c))for(r in c)g.push(r+'="'+c[r]+'" ');else c={};!t.isDefined(l)||"target"in c||g.push('target="',l,'" '),g.push('href="',e.replace(/"/g,"&quot;"),'">'),u(n),g.push("</a>")}if(null==s||""===s)return s;if(!a(s))throw o("notstring","Expected string but received: {0}",s);for(var f,d,h,m=s,g=[];f=m.match(n);)d=f[0],f[2]||f[4]||(d=(f[3]?"http://":"mailto:")+d),h=f.index,u(m.substr(0,h)),p(d,f[0].replace(r,"")),m=m.substring(h+f[0].length);return u(m),e(g.join(""))}}])}(window,window.angular)},function(e,t){"use strict";angular.module("cp-tooltip").directive("cpTooltip",["$sanitize",function(e){var t=0,n=1e3;return{restrict:"A",link:function(r,i,o){function a(t){d=!0;var n=i[0].getBoundingClientRect(),r=$(document).scrollTop();p=$('\n <span class="cp-tooltip" style="left:'+t.clientX+"px; top:"+(r+n.top+n.height+4)+'px;">'+e(o.cpTooltip)+"</span>\n ").hide(),$("body").append(p),p.on("mouseenter.cptooltip"+f,function(e){m&&u&&clearTimeout(u)}),p.on("mouseleave.cptooltip"+f,s);var a=p.width(),l=p.height(),c=$(document).width(),h=n.left,g=r+n.top+n.height+4;h+a+10>c&&(h-=a+15),g+l>window.innerHeight&&(g-=l+40),p.css({left:h,top:g}).show()}function s(){u&&clearTimeout(u),u=setTimeout(function(){clearTimeout(c),l()},h?100:500)}function l(){d=!1,p&&p.remove()}var c,u,p,f=++t,d=!1,h=o.cpTooltipInstant||""==o.cpTooltipInstant,m=o.cpTooltipAllowInteraction||""==o.cpTooltipAllowInteraction;i.on("mouseenter.cptooltip"+f,function(e){c&&clearTimeout(c),u&&clearTimeout(u),c=setTimeout(function(){d||a(e)},h?100:n)}),i.on("mouseleave.cptooltip"+f,s),r.$on("$destroy",function(){l(),clearTimeout(c),clearTimeout(u),i.off("mouseenter.cptooltip"+f),i.off("mouseleave.cptooltip"+f)})}}}])},function(e,t,n){var r=n(7);"string"==typeof r&&(r=[[e.id,r,""]]);n(9)(r,{});r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(8)(),t.push([e.id,".cp-tooltip{background-color:#777;font-size:12px;padding:4px 8px;position:absolute;color:#fff;border-radius:2px;box-shadow:0 1px 4px 0 rgba(0,0,0,.26);z-index:100000}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t];n[2]?e.push("@media "+n[2]+"{"+n[1]+"}"):e.push(n[1])}return e.join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var r={},i=0;i<this.length;i++){var o=this[i][0];"number"==typeof o&&(r[o]=!0)}for(i=0;i<t.length;i++){var a=t[i];"number"==typeof a[0]&&r[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="("+a[2]+") and ("+n+")"),e.push(a))}},e}},function(e,t,n){function r(e,t){for(var n=0;n<e.length;n++){var r=e[n],i=d[r.id];if(i){i.refs++;for(var o=0;o<i.parts.length;o++)i.parts[o](r.parts[o]);for(;o<r.parts.length;o++)i.parts.push(c(r.parts[o],t))}else{for(var a=[],o=0;o<r.parts.length;o++)a.push(c(r.parts[o],t));d[r.id]={id:r.id,refs:1,parts:a}}}}function i(e){for(var t=[],n={},r=0;r<e.length;r++){var i=e[r],o=i[0],a=i[1],s=i[2],l=i[3],c={css:a,media:s,sourceMap:l};n[o]?n[o].parts.push(c):t.push(n[o]={id:o,parts:[c]})}return t}function o(e,t){var n=g(),r=x[x.length-1];if("top"===e.insertAt)r?r.nextSibling?n.insertBefore(t,r.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),x.push(t);else{if("bottom"!==e.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");n.appendChild(t)}}function a(e){e.parentNode.removeChild(e);var t=x.indexOf(e);t>=0&&x.splice(t,1)}function s(e){var t=document.createElement("style");return t.type="text/css",o(e,t),t}function l(e){var t=document.createElement("link");return t.rel="stylesheet",o(e,t),t}function c(e,t){var n,r,i;if(t.singleton){var o=b++;n=v||(v=s(t)),r=u.bind(null,n,o,!1),i=u.bind(null,n,o,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=l(t),r=f.bind(null,n),i=function(){a(n),n.href&&URL.revokeObjectURL(n.href)}):(n=s(t),r=p.bind(null,n),i=function(){a(n)});return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else i()}}function u(e,t,n,r){var i=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=y(t,i);else{var o=document.createTextNode(i),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(o,a[t]):e.appendChild(o)}}function p(e,t){var n=t.css,r=t.media;t.sourceMap;if(r&&e.setAttribute("media",r),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function f(e,t){var n=t.css,r=(t.media,t.sourceMap);r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var i=new Blob([n],{type:"text/css"}),o=e.href;e.href=URL.createObjectURL(i),o&&URL.revokeObjectURL(o)}var d={},h=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},m=h(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),g=h(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,b=0,x=[];e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=m()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var n=i(e);return r(n,t),function(e){for(var o=[],a=0;a<n.length;a++){var s=n[a],l=d[s.id];l.refs--,o.push(l)}if(e){var c=i(e);r(c,t)}for(var a=0;a<o.length;a++){var l=o[a];if(0===l.refs){for(var u=0;u<l.parts.length;u++)l.parts[u]();delete d[l.id]}}}};var y=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()}]);
{
"name": "cp-tooltip",
"version": "1.2.0",
"version": "1.2.4",
"description": "Component Description",

@@ -21,24 +21,25 @@ "main": "build/cp-tooltip.js",

"devDependencies": {
"autoprefixer-loader": "^1.2.0",
"angular-mocks": "1.5.5",
"autoprefixer-loader": "^3.2.0",
"babel-core": "^4.7.13",
"babel-loader": "^4.2.0",
"css-loader": "^0.9.1",
"jasmine-core": "^2.1.3",
"karma": "^0.12.31",
"karma-chrome-launcher": "^0.1.7",
"karma-jasmine": "^0.3.4",
"css-loader": "^0.23.1",
"jasmine-core": "^2.4.1",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-jasmine": "^0.3.8",
"karma-phantomjs-launcher": "^0.1.4",
"ngmin": "^0.5.0",
"ngmin-webpack-plugin": "^0.1.3",
"style-loader": "^0.8.3",
"webpack": "^1.4.15",
"angular-mocks": "^1.3.15"
"style-loader": "^0.13.1",
"webpack": "^1.13.0"
},
"dependencies": {
"angular": ">=1.3.0",
"angular-sanitize": "^1.5.5",
"jquery": ">=2.0.0"
},
"optionalDependencies": {
"canopy-styleguide": "1.1.0"
}
"optionalDependencies": {
"canopy-styleguide": "latest"
}
}

@@ -7,3 +7,3 @@ # cp-tooltip

- jQuery
## Installation

@@ -19,9 +19,14 @@ 1. Install through npm `npm install --save cp-tooltip`

```html
<input type="text" cp-tooltip="Hey this is the messag"/>
<input type="text" cp-tooltip="Hey this is the message"/>
```
If you'd like the tooltip instantly render, include the `cp-tooltip-instant` attribute:
```html
<input type="text" cp-tooltip="Hey this is the messag" cp-tooltip-instant/>
<input type="text" cp-tooltip="Hey this is the message" cp-tooltip-instant/>
```
If you want the tooltip to stay visible while the user interacts with the tooltip itself, include the `cp-tooltip-allow-interaction` attribute. This is useful when you want to allow the user to highlight and copy the contents of the tooltip.
```html
<input type="text" cp-tooltip="Hey this is the message" cp-tooltip-allow-interaction/>
```
## Demo
http://canopytax.github.io/cp-tooltip/
var jquery = require('jquery');
var angular = require('angular');
angular.module('cp-tooltip', []);
var angularSanitize = require('angular-sanitize');
angular.module('cp-tooltip', ['ngSanitize']);
require('./tooltip.js');
require('./tooltip.css');
angular.module('cp-tooltip')
.directive('cpTooltip', function() {
.directive('cpTooltip', ['$sanitize', function($sanitize) {
var idCounter = 0;

@@ -13,2 +13,3 @@ var TIMEOUT = 1000;

var instant = attr.cpTooltipInstant || attr.cpTooltipInstant == "";
var allowInteraction = attr.cpTooltipAllowInteraction || attr.cpTooltipAllowInteraction == "";

@@ -26,9 +27,3 @@ /** Setup main hover event for the tooltip **/

el.on('mouseleave.cptooltip'+id, function() {
if(timeout2) clearTimeout(timeout2);
timeout2 = setTimeout(function() {
clearTimeout(timeout1);
closeTooltip();
}, instant ? 100 : 500);
});
el.on('mouseleave.cptooltip'+id, dismissTooltip);

@@ -52,7 +47,13 @@ /** Cleanup events **/

`
<span class="cp-tooltip" style="left:${e.clientX}px; top:${topScroll + rect.top + rect.height + 4}px;">${attr.cpTooltip}</span>
<span class="cp-tooltip" style="left:${e.clientX}px; top:${topScroll + rect.top + rect.height + 4}px;">${$sanitize(attr.cpTooltip)}</span>
`
).hide();
$('body').append(tooltipEl)
$('body').append(tooltipEl);
tooltipEl.on('mouseenter.cptooltip'+id, function(e) {
if(allowInteraction && timeout2) clearTimeout(timeout2);
});
tooltipEl.on('mouseleave.cptooltip'+id, dismissTooltip);
var width = tooltipEl.width();

@@ -79,2 +80,10 @@ var height = tooltipEl.height();

function dismissTooltip() {
if(timeout2) clearTimeout(timeout2);
timeout2 = setTimeout(function() {
clearTimeout(timeout1);
closeTooltip();
}, instant ? 100 : 500);
}
function closeTooltip() {

@@ -86,2 +95,2 @@ tooltipDisplayed = false;

}
});
}]);

@@ -16,3 +16,10 @@ describe('tooltip', function() {

allowInteractionElm = angular.element(
'<div>' +
'<input type="text" cp-tooltip="hello" cp-tooltip-allow-interaction>' +
'</div>'
);
$('body').append(elm);
$('body').append(allowInteractionElm);

@@ -22,2 +29,3 @@ scope = $rootScope.$new();

$compile(elm)(scope);
$compile(allowInteractionElm)(scope);
}));

@@ -29,8 +37,7 @@

elm.remove();
allowInteractionElm.remove();
});
it('Should display the tooltip when the mouse moves over', function() {
var e = $.Event('mousemove');
e.clientX = 100;
e.clientY = 200;
var e = $.Event('mouseover');

@@ -44,19 +51,4 @@ elm.find('input').trigger(e);

it('Should correctly position the tooltip', function() {
var e = $.Event('mousemove');
e.clientX = 100;
e.clientY = 200;
elm.find('input').trigger(e);
jasmine.clock().tick(1001);
var tooltip = $('.cp-tooltip');
var position = tooltip.position();
expect(position.left).toBe(100);
expect(position.top).toBe(220);
});
it('Should correctly throttle displaying the tooltip', function() {
var e = $.Event('mousemove');
e.clientX = 100;
e.clientY = 200;
var e = $.Event('mouseover');

@@ -66,18 +58,13 @@ elm.find('input').trigger(e);

e = $.Event('mousemove');
e.clientX = 100;
e.clientY = 210;
expect($('.cp-tooltip').length).toBe(0);
e = $.Event('mouseover');
elm.find('input').trigger(e);
jasmine.clock().tick(1001);
var tooltip = $('.cp-tooltip');
var position = tooltip.position();
expect(position.left).toBe(100);
expect(position.top).toBe(230);
expect($('.cp-tooltip').length).toBe(1);
});
it('Should hide the tooltip on mouseout', function() {
var e = $.Event('mousemove');
e.clientX = 100;
e.clientY = 200;
var e = $.Event('mouseover');

@@ -95,2 +82,31 @@ elm.find('input').trigger(e);

});
it('Should not hide the tooltip until clicked outside when using the cp-tooltip-allow-interaction attr', function() {
var e = $.Event('mouseover');
// Show tooltip
allowInteractionElm.find('input').trigger(e);
jasmine.clock().tick(1001);
expect($('.cp-tooltip').length).toBe(1);
// Move mouse outside of toggle element
e = $.Event('mouseout');
allowInteractionElm.find('input').trigger(e);
jasmine.clock().tick(200);
// Move mouse to tooltip element, tooltip should still be visible
e = $.Event('mouseover');
$('.cp-tooltip').trigger(e);
jasmine.clock().tick(501);
expect($('.cp-tooltip').length).toBe(1);
// Move mouse outside of tooltip element, tooltip should be dismissed
e = $.Event('mouseout');
$('.cp-tooltip').trigger(e);
jasmine.clock().tick(501);
expect($('.cp-tooltip').length).toBe(0);
});
});
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