!function(n){"use strict";n.module("720kb.tooltips",[]).provider("tooltipsConfig",function(){var t={scroll:!1,showTrigger:"mouseover",hideTrigger:"mouseleave",hideTarget:"element",side:"top",size:"medium","try":!0,"class":"",speed:"medium",delay:0,lazy:!0,closeButton:null};this.options=function(){return 1===arguments.length&&n.extend(t,arguments[0]),n.copy(t)};this.$get=function(){return t}}).directive("tooltips",["$window","$compile","$interpolate","$interval","$sce","tooltipsConfig",function(t,i,r,u,f,e){var c=8,l=9,a=10,v=20,o="_720kb-tooltip-",s=r.startSymbol(),h=r.endSymbol();return{restrict:"A",scope:{},link:function(r,y,p){function pt(){ei&&bt||(bt=!0,r.initTooltip(d));ui&&r.tooltipTryPosition();r.showTooltip()}function ht(){r.hideTooltip()}function wt(){r.hideTooltip();r.initTooltip(vt)}var w,rt,ut,nt,ft,et,tt,it,ct,lt,bt=!1,b=n.element(y[0]),gt=n.element(t.document.getElementsByTagName("body")[0]),ni=p.tooltipTitle||p.title||"",ti=p.tooltipScroll||e.scroll,ii=p.tooltipContent||"",ri=p.tooltipHtml||"",kt=p.tooltipShowTrigger||e.showTrigger,at=p.tooltipHideTrigger||e.hideTrigger,ot="undefined"!=typeof p.tooltipHideTarget&&null!==p.tooltipHideTarget?p.tooltipHideTarget:e.hideTarget,vt=p.tooltipSide||e.side,d=vt,st=p.tooltipSize||e.size,ui="undefined"!=typeof p.tooltipTry&&null!==p.tooltipTry?r.$eval(p.tooltipTry):e["try"],fi=p.tooltipClass||e["class"],k=(p.tooltipSpeed||e.speed).toLowerCase(),dt=p.tooltipDelay||e.delay,ei="undefined"!=typeof p.tooltipLazy&&null!==p.tooltipLazy?r.$eval(p.tooltipLazy):e.lazy,yt=p.tooltipCloseButton||e.closeButton,oi="undefined"!=typeof yt&&null!==yt,g='<div class="_720kb-tooltip '+o+st+'">';"element"!==ot&&"tooltip"!==ot&&(ot="element");oi&&(g=g+'<span class="'+o+'close-button" ng-click="hideTooltip()"> '+yt+" <\/span>");p.tooltipView&&(g=p.tooltipViewCtrl?g+'<div ng-controller="'+p.tooltipViewCtrl+'" ng-include="\''+p.tooltipView+"'\"><\/div>":g+"<div ng-include=\"'"+p.tooltipView+"'\"><\/div>");g=g+'<div class="'+o+'title"> '+s+"title"+h+"<\/div>"+s+"content"+h+' <span class="'+o+'html_content" ng-bind-html="getHtml()"><\/span> <span class="'+o+'caret"><\/span><\/div>';r.title=ni;r.content=ii;r.html=ri;r.getHtml=function(){return f.trustAsHtml(r.html)};r.parseSpeed=function(){switch(k){case"fast":k=100;break;case"medium":k=450;break;case"slow":k=800;break;default:k=Number(k)}};w=i(g)(r);w.addClass(fi);gt.append(w);r.isTooltipEmpty=function(){if(!r.title&&!r.content&&!r.html)return!0};r.initTooltip=function(n){r.isTooltipEmpty()?w.css("visibility","hidden"):(w.css("visibility","visible"),ft=b[0].offsetHeight,et=b[0].offsetWidth,rt=w[0].offsetHeight,ut=w[0].offsetWidth,r.parseSpeed(),r.tooltipPositioning(n))};r.getOffsets=function(){tt=r.getOffsetTop(b[0]);it=r.getOffsetLeft(b[0])};r.getOffsetTop=function(n){var i=n.getBoundingClientRect().top+t.scrollY;return isNaN(i)&&(i=n.getBoundingClientRect().top+t.pageYOffset),i};r.getOffsetLeft=function(n){var i=n.getBoundingClientRect().left+t.scrollX;return isNaN(i)&&(i=n.getBoundingClientRect().left+t.pageXOffset),i};r.bindShowTriggers=function(){b.bind(kt,pt)};r.bindHideTriggers=function(){"tooltip"===ot?w.bind(at,ht):b.bind(at,ht)};r.clearTriggers=function(){b.unbind(kt,pt);b.unbind(at,ht)};r.bindShowTriggers();r.showTooltip=function(){ti&&(lt=b[0].getBoundingClientRect(),ct=u(function(){var t=b[0].getBoundingClientRect();n.equals(lt,t)||r.tooltipPositioning(d);lt=t},v));w.addClass(o+"open");w.css("transition","opacity "+k+"ms linear");dt&&w.css("transition-delay",dt+"ms");r.clearTriggers();r.bindHideTriggers()};r.hideTooltip=function(){w.css("transition","opacity "+k+"ms linear, visibility 0s linear "+k+"ms");w.removeClass(o+"open");r.clearTriggers();r.bindShowTriggers();n.isDefined(r.positionInterval)&&(u.cancel(ct),ct=void 0)};r.removePosition=function(){w.removeClass(o+"left").removeClass(o+"right").removeClass(o+"top").removeClass(o+"bottom ")};r.tooltipPositioning=function(n){r.removePosition();r.getOffsets();var t,i;"small"===st?nt=c:"medium"===st?nt=l:"large"===st&&(nt=a);"left"===n&&(t=tt+ft/2-rt/2,i=it-(ut+nt),w.css("top",t+"px"),w.css("left",i+"px"),w.addClass(o+"left"));"right"===n&&(t=tt+ft/2-rt/2,i=it+et+nt,w.css("top",t+"px"),w.css("left",i+"px"),w.addClass(o+"right"));"top"===n&&(t=tt-nt-rt,i=it+et/2-ut/2,w.css("top",t+"px"),w.css("left",i+"px"),w.addClass(o+"top"));"bottom"===n&&(t=tt+ft+nt,i=it+et/2-ut/2,w.css("top",t+"px"),w.css("left",i+"px"),w.addClass(o+"bottom"))};r.tooltipTryPosition=function(){var l=w[0].offsetHeight,a=w[0].offsetWidth,f=w[0].offsetTop,e=w[0].offsetLeft,o=t.innerWidth,s=t.innerHeight,v=o-(a+e),y=s-(l+f),p=b[0].offsetHeight,k=b[0].offsetWidth,h=b[0].offsetLeft,c=b[0].offsetTop,g=o-(h+k),nt=s-(p+c),n={left:e,top:f,bottom:y,right:v},i={left:h,right:g,top:c,bottom:nt},u=Object.keys(i).reduce(function(n,t){return i[n]>i[t]?n:t}),tt=Object.keys(n).reduce(function(t,i){return n[t]<n[i]?t:i});vt!==u&&n[tt]<20&&(d=u,r.tooltipPositioning(d),r.initTooltip(u))};n.element(t).bind("resize",wt);r.$on("$destroy",function(){n.element(t).unbind("resize",wt);r.clearTriggers();w.remove()});p.tooltipTitle&&p.$observe("tooltipTitle",function(n){r.title=n;r.initTooltip(d)});p.title&&p.$observe("title",function(n){r.title=n;r.initTooltip(d)});p.tooltipContent&&p.$observe("tooltipContent",function(n){r.content=n;r.initTooltip(d)});p.tooltipHtml&&p.$observe("tooltipHtml",function(n){r.html=n;r.initTooltip(d)})}}}])}(angular)