blob: f6910676f87f1c4d35a72ddd00a0e880cd5cec38 [file] [log] [blame]
/*!
* Angular Material Design
* https://github.com/angular/material
* @license MIT
* v1.0.0-master-19c11fd
*/
!function(t,e,o){"use strict";function n(t,o,n,i,r,c,a,l,u){function d(a,d,h){function m(){e.isDefined(h.mdDelay)||(a.delay=s)}function p(){var t="center top";switch(a.direction){case"left":t="right center";break;case"right":t="left center";break;case"top":t="center bottom";break;case"bottom":t="center top"}C.css("transform-origin",t)}function v(){a.$on("$destroy",function(){a.visible=!1,d.remove(),e.element(o).off("resize",q)}),a.$watch("visible",function(t){t?y():E()}),a.$watch("direction",x)}function b(){k.attr("aria-label")||k.text().trim()||k.attr("aria-label",d.text().trim())}function w(){d.detach(),d.attr("role","tooltip")}function g(){function t(){$(!1)}var n=!1,r=e.element(o);if(k[0]&&"MutationObserver"in o){var c=new MutationObserver(function(t){t.forEach(function(t){"disabled"===t.attributeName&&k[0].disabled&&($(!1),a.$digest())})});c.observe(k[0],{attributes:!0})}var l=function(){u=document.activeElement===k[0]},u=!1;r.on("blur",l),r.on("resize",q),document.addEventListener("scroll",t,!0),a.$on("$destroy",function(){r.off("blur",l),r.off("resize",q),document.removeEventListener("scroll",t,!0),c&&c.disconnect()});var d=function(t){return"focus"===t.type&&u?void(u=!1):(k.on("blur mouseleave touchend touchcancel",s),void $(!0))},s=function(){var t=a.hasOwnProperty("autohide")?a.autohide:h.hasOwnProperty("mdAutohide");(t||n||i[0].activeElement!==k[0])&&(k.off("blur mouseleave touchend touchcancel",s),k.triggerHandler("blur"),$(!1)),n=!1};k.on("mousedown",function(){n=!0}),k.on("focus mouseenter touchstart",d)}function $(e){$.value=!!e,$.queued||(e?($.queued=!0,t(function(){a.visible=$.value,$.queued=!1},a.delay)):r.nextTick(function(){a.visible=!1}))}function y(){return P.append(d),r.hasComputedStyle(d,"display","none")?(a.visible=!1,void d.detach()):(x(),void e.forEach([d,C],function(t){l.addClass(t,"md-show")}))}function E(){var t=[];e.forEach([d,C],function(e){e.parent()&&e.hasClass("md-show")&&t.push(l.removeClass(e,"md-show"))}),u.all(t).then(function(){a.visible||d.detach()})}function x(){a.visible&&(p(),M())}function M(){function t(t){var e={left:t.left,top:t.top};return e.left=Math.min(e.left,P.prop("scrollWidth")-o.width-f),e.left=Math.max(e.left,f),e.top=Math.min(e.top,P.prop("scrollHeight")-o.height-f),e.top=Math.max(e.top,f),e}function e(t){return"left"===t?{left:n.left-o.width-f,top:n.top+n.height/2-o.height/2}:"right"===t?{left:n.left+n.width+f,top:n.top+n.height/2-o.height/2}:"top"===t?{left:n.left+n.width/2-o.width/2,top:n.top-o.height-f}:{left:n.left+n.width/2-o.width/2,top:n.top+n.height+f}}var o=r.offsetRect(d,P),n=r.offsetRect(k,P),i=e(a.direction),c=d.prop("offsetParent");a.direction?i=t(i):c&&i.top>c.scrollHeight-o.height-f&&(i=t(e("top"))),d.css({left:i.left+"px",top:i.top+"px"})}c(d);var k=r.getParentWithPointerEvents(d),C=e.element(d[0].getElementsByClassName("md-content")[0]),P=e.element(document.body),q=n.throttle(function(){x()});l.pin&&l.pin(d,k),m(),w(),g(),p(),v(),b()}var s=0,f=8;return{restrict:"E",transclude:!0,priority:210,template:'<div class="md-content" ng-transclude></div>',scope:{delay:"=?mdDelay",visible:"=?mdVisible",autohide:"=?mdAutohide",direction:"@?mdDirection"},link:d}}e.module("material.components.tooltip",["material.core"]).directive("mdTooltip",n),n.$inject=["$timeout","$window","$$rAF","$document","$mdUtil","$mdTheming","$rootElement","$animate","$q"]}(window,window.angular);