12 lines
9.3 KiB
JavaScript
12 lines
9.3 KiB
JavaScript
|
/*
|
||
|
* angular-tooltips
|
||
|
* 1.2.2
|
||
|
*
|
||
|
* Angular.js tooltips module.
|
||
|
* http://720kb.github.io/angular-tooltips
|
||
|
*
|
||
|
* MIT license
|
||
|
* Tue Jun 20 2017
|
||
|
*/
|
||
|
!function(t,o){"use strict";var e="tooltips",i=function(){var t,e=[],i=0,r=function(t){t-i>=15?(e.forEach(function(t){t()}),i=t):o.console.log("Skipped!")},l=function(){o.clearTimeout(t),t=o.setTimeout(function(){o.requestAnimationFrame(r)},500)},n=function(t){t&&e.push(t)};return{add:function(t){e.length||o.addEventListener("resize",l),n(t)},remove:function(){e.length||(o.clearTimeout(t),o.removeEventListener("resize",l))}}}(),r=function(t){var o={};return t.removeAttr(e),void 0!==t.attr("tooltip-template")&&(o["tooltip-template"]=t.attr("tooltip-template"),t.removeAttr("tooltip-template")),void 0!==t.attr("tooltip-template-url")&&(o["tooltip-template-url"]=t.attr("tooltip-template-url"),t.removeAttr("tooltip-template-url")),void 0!==t.attr("tooltip-template-url-cache")&&(o["tooltip-template-url-cache"]=t.attr("tooltip-template-url-cache"),t.removeAttr("tooltip-template-url-cache")),void 0!==t.attr("tooltip-controller")&&(o["tooltip-controller"]=t.attr("tooltip-controller"),t.removeAttr("tooltip-controller")),void 0!==t.attr("tooltip-side")&&(o["tooltip-side"]=t.attr("tooltip-side"),t.removeAttr("tooltip-side")),void 0!==t.attr("tooltip-show-trigger")&&(o["tooltip-show-trigger"]=t.attr("tooltip-show-trigger"),t.removeAttr("tooltip-show-trigger")),void 0!==t.attr("tooltip-hide-trigger")&&(o["tooltip-hide-trigger"]=t.attr("tooltip-hide-trigger"),t.removeAttr("tooltip-hide-trigger")),void 0!==t.attr("tooltip-smart")&&(o["tooltip-smart"]=t.attr("tooltip-smart"),t.removeAttr("tooltip-smart")),void 0!==t.attr("tooltip-class")&&(o["tooltip-class"]=t.attr("tooltip-class"),t.removeAttr("tooltip-class")),void 0!==t.attr("tooltip-show")&&(o["tooltip-show"]=t.attr("tooltip-show"),t.removeAttr("tooltip-show")),void 0!==t.attr("tooltip-close-button")&&(o["tooltip-close-button"]=t.attr("tooltip-close-button"),t.removeAttr("tooltip-close-button")),void 0!==t.attr("tooltip-size")&&(o["tooltip-size"]=t.attr("tooltip-size"),t.removeAttr("tooltip-size")),void 0!==t.attr("tooltip-speed")&&(o["tooltip-speed"]=t.attr("tooltip-speed"),t.removeAttr("tooltip-speed")),o},l=function(t){return o.getComputedStyle?o.getComputedStyle(t,""):t.currentStyle?t.currentStyle:void 0},n=function(e){for(var i,r,l=o.document.querySelectorAll("._exradicated-tooltip"),n=0,p=l.length;n<p;n+=1)if(i=l.item(n),i&&(r=t.element(i),r.data("_tooltip-parent")&&r.data("_tooltip-parent")===e))return r},p=function(t){var o=n(t);o&&o.remove()},a=function(t){if(t){var e=t[0].getBoundingClientRect();return(e.top<0||e.top>o.document.body.offsetHeight||e.left<0||e.left>o.document.body.offsetWidth||e.bottom<0||e.bottom>o.document.body.offsetHeight||e.right<0||e.right>o.document.body.offsetWidth)&&(t.css({top:"",left:"",bottom:"",right:""}),!0)}throw new Error("You must provide a position")},s=function(t){return t.split(" ").map(function(t){return"_"+t}).join(" ")},d=["_top","_top _left","_left","_bottom _left","_bottom","_bottom _right","_right","_top _right"],c=function(t,o,e){for(var i=d.indexOf(s(e)),r=d.length,l=0;l<r&&a(t);l+=1)i+=1,i>=d.length&&(i=0),o.removeClass("_top _left _bottom _right"),o.addClass(d[i])},u=function(){var t={side:"top",showTrigger:"mouseenter",hideTrigger:"mouseleave","class":"",smart:!1,closeButton:!1,size:"",speed:"steady",tooltipTemplateUrlCache:!1,show:null};return{configure:function(o){var e,i=Object.keys(t),r=0;if(o)for(;r<i.length;r+=1)e=i[r],e&&o[e]&&(t[e]=o[e])},$get:function(){return t}}},m=["$log","$http","$compile","$timeout","$controller","$injector","tooltipsConf","$templateCache","$q",function(e,a,d,u,m,f,g,h,v){var C=function(f,C,b,y,w){if(b.tooltipTemplate&&b.tooltipTemplateUrl)throw new Error("You can not define tooltip-template and tooltip-template-url together");if(!b.tooltipTemplateUrl&&!b.tooltipTemplate&&b.tooltipController)throw new Error("You can not have a controller without a template or templateUrl defined");var _,T=s(g.side),S=g.showTrigger,$=g.hideTrigger,A=g.size,B="_"+g.speed;b.tooltipSide=b.tooltipSide||g.side,b.tooltipShowTrigger=b.tooltipShowTrigger||g.showTrigger,b.tooltipHideTrigger=b.tooltipHideTrigger||g.hideTrigg
|