|
function MdTooltipDirective(t,e,i,o,n,r,a,c,l,u){function s(a,l,s){function v(){a.delay=a.delay||h}function b(){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 g(t){t?E():q()}function $(){if(l[0]&&"MutationObserver"in e){var t=new MutationObserver(function(t){t.forEach(function(t){"md-visible"===t.attributeName&&(a.visibleWatcher||(a.visibleWatcher=a.$watch("visible",g))),"md-direction"===t.attributeName&&O(a.direction)})});t.observe(l[0],{attributes:!0}),s.hasOwnProperty("mdVisible")&&(a.visibleWatcher=a.$watch("visible",g))}else a.visibleWatcher=a.$watch("visible",g),a.$watch("direction",O);var i=function(){a.$destroy()};l.one("$destroy",i),W.one("$destroy",i),a.$on("$destroy",function(){M(!1),l.remove(),t&&t.disconnect()}),l.text().indexOf(u.startSymbol())>-1&&a.$watch(function(){return l.text().trim()},w)}function w(t){if((t||!W.attr("aria-label"))&&!W.text().trim()){var e=t||l.text().trim(),i=u(e)(W.scope());W.attr("aria-label",i)}}function y(){l.detach(),l.attr("role","tooltip")}function x(){function i(){M(!1)}var r=!1;if(W[0]&&"MutationObserver"in e){var c=new MutationObserver(function(t){t.some(function(t){return"disabled"===t.attributeName&&W[0].disabled})&&n.nextTick(function(){M(!1)})});c.observe(W[0],{attributes:!0})}var l=function(){u=document.activeElement===W[0]},u=!1;angular.element(e).on("blur",l).on("resize",P),document.addEventListener("scroll",i,!0),a.$on("$destroy",function(){angular.element(e).off("blur",l).off("resize",P),W.off(d,m).off(f,h).off("mousedown",p),h(),document.removeEventListener("scroll",i,!0),c&&c.disconnect()});var m=function(t){"focus"===t.type&&u?u=!1:a.visible||(W.on(f,h),M(!0),"touchstart"===t.type&&W.one("touchend",function(){n.nextTick(function(){o.one("touchend",h)},!1)}))},h=function(){var e=a.hasOwnProperty("autohide")?a.autohide:s.hasOwnProperty("mdAutohide");(e||r||o[0].activeElement!==W[0])&&(k&&(t.cancel(k),M.queued=!1,k=null),W.off(f,h),W.triggerHandler("blur"),M(!1)),r=!1},p=function(){r=!0};W.on("mousedown",p),W.on(d,m)}function M(e){M.queued&&M.value===!!e||!M.queued&&a.visible===!!e||(M.value=!!e,M.queued||(e?(M.queued=!0,k=t(function(){a.visible=M.value,M.queued=!1,k=null,a.visibleWatcher||g(a.visible)},a.delay)):n.nextTick(function(){a.visible=!1,a.visibleWatcher||g(!1)})))}function E(){if(l[0].textContent.trim()){if(l.css({top:0,left:0}),D.append(l),n.hasComputedStyle(l,"display","none"))return a.visible=!1,void l.detach();O(),c.addClass(C,m).then(function(){l.addClass(m)})}}function q(){c.removeClass(C,m).then(function(){l.removeClass(m),a.visible||l.detach()})}function O(){a.visible&&(b(),T())}function T(){function t(t){var e={left:t.left,top:t.top};return e.left=Math.min(e.left,D.prop("scrollWidth")-i.width-p),e.left=Math.max(e.left,p),e.top=Math.min(e.top,D.prop("scrollHeight")-i.height-p),e.top=Math.max(e.top,p),e}function e(t){return"left"===t?{left:o.left-i.width-p,top:o.top+o.height/2-i.height/2}:"right"===t?{left:o.left+o.width+p,top:o.top+o.height/2-i.height/2}:"top"===t?{left:o.left+o.width/2-i.width/2,top:o.top-i.height-p}:{left:o.left+o.width/2-i.width/2,top:o.top+o.height+p}}var i=n.offsetRect(l,D),o=n.offsetRect(W,D),r=e(a.direction),c=l.prop("offsetParent");a.direction?r=t(r):c&&r.top>c.scrollHeight-i.height-p&&(r=t(e("top"))),l.css({left:r.left+"px",top:r.top+"px"})}r(l);var W=n.getParentWithPointerEvents(l),C=angular.element(l[0].getElementsByClassName("md-content")[0]),D=angular.element(document.body),k=null,P=i.throttle(function(){O()});c.pin&&c.pin(l,W),v(),y(),x(),b(),$(),w()}var d="focus touchstart mouseenter",f="blur touchcancel mouseleave",m="md-show",h=0,p=8;return{restrict:"E",transclude:!0,priority:210,template:'<div class="md-content _md" ng-transclude></div>',scope:{delay:"=?mdDelay",visible:"=?mdVisible",autohide:"=?mdAutohide",direction:"@?mdDirection"},compile:function(t,e){return e.mdDirection||e.$set("mdDirection","bottom"),s}}}goog.provide("ngmaterial.components.tooltip"),goog.require("ngmaterial.core"),MdTooltipDirective.$inject=["$timeout","$window","$$rAF","$document","$mdUtil","$mdTheming","$rootElement","$animate","$q","$interpolate"],angular.module("material.components.tooltip",["material.core"]).directive("mdTooltip",MdTooltipDirective),ngmaterial.components.tooltip=angular.module("material.components.tooltip");
|