7 lines
No EOL
3.2 KiB
JavaScript
7 lines
No EOL
3.2 KiB
JavaScript
/*!
|
|
* Angular Material Design
|
|
* https://github.com/angular/material
|
|
* @license MIT
|
|
* v0.10.1
|
|
*/
|
|
!function(t,e,o){"use strict";function n(t,o,n,i,l,a,r,d,h){function u(u,s,p){function m(){e.isDefined(p.mdDelay)||(u.delay=c)}function v(){u.$on("$destroy",function(){u.visible=!1,s.remove(),e.element(o).off("resize",T)}),u.$watch("visible",function(t){t?C():q()})}function w(){D.attr("aria-label")||D.text().trim()||D.attr("aria-label",s.text().trim())}function g(){s.detach(),s.attr("role","tooltip")}function b(){for(var t=s.parent();t&&$("pointer-events","none",t[0]);)t=t.parent();return t}function y(){for(var t=s.parent()[0];t&&t!==r[0]&&t!==document.body;)t=t.parentNode;return t}function $(t,n,i){t=p.$normalize(t),i=i||s[0];var l=o.getComputedStyle(i);return e.isDefined(l[t])&&l[t]==n}function M(){var t=!1,n=function(){D.on("blur mouseleave touchend touchcancel",l),x(!0)},l=function(){var e=u.hasOwnProperty("autohide")?u.autohide:p.hasOwnProperty("mdAutohide");(e||t||i[0].activeElement!==D[0])&&(D.off("blur mouseleave touchend touchcancel",l),x(!1)),t=!1};D.on("mousedown",function(){t=!0}),D.on("focus mouseenter touchstart",n),e.element(o).on("resize",T)}function x(e){x.value=!!e,x.queued||(e?(x.queued=!0,t(function(){u.visible=x.value,x.queued=!1},u.delay)):l.nextTick(function(){u.visible=!1}))}function C(){return P.append(s),$("display","none")?(u.visible=!1,void s.detach()):(E(),void e.forEach([s,k,z],function(t){d.addClass(t,"md-show")}))}function q(){h.all([d.removeClass(z,"md-show"),d.removeClass(k,"md-show"),d.removeClass(s,"md-show")]).then(function(){u.visible||s.detach()})}function E(){function t(){var t="left"===A||"right"===A?2*Math.sqrt(Math.pow(n.width,2)+Math.pow(n.height/2,2)):2*Math.sqrt(Math.pow(n.width/2,2)+Math.pow(n.height,2)),e="left"===A?{left:100,top:50}:"right"===A?{left:0,top:50}:"top"===A?{left:50,top:100}:{left:50,top:0};k.css({width:t+"px",height:t+"px",left:e.left+"%",top:e.top+"%"})}function e(t){var e={left:t.left,top:t.top};return e.left=Math.min(e.left,P.prop("scrollWidth")-n.width-f),e.left=Math.max(e.left,f),e.top=Math.min(e.top,P.prop("scrollHeight")-n.height-f),e.top=Math.max(e.top,f),e}function o(t){return"left"===t?{left:i.left-n.width-f,top:i.top+i.height/2-n.height/2}:"right"===t?{left:i.left+i.width+f,top:i.top+i.height/2-n.height/2}:"top"===t?{left:i.left+i.width/2-n.width/2,top:i.top-n.height-f}:{left:i.left+i.width/2-n.width/2,top:i.top+i.height+f}}var n=l.offsetRect(s,P),i=l.offsetRect(D,P),a=o(A);A?a=e(a):a.top>s.prop("offsetParent").scrollHeight-n.height-f&&(a=e(o("top"))),s.css({top:a.top+"px",left:a.left+"px"}),t()}a(s);var D=b(),k=e.element(s[0].getElementsByClassName("md-background")[0]),z=e.element(s[0].getElementsByClassName("md-content")[0]),A=p.mdDirection,N=y(),P=e.element(N||document.body),T=n.throttle(function(){u.visible&&E()});m(),g(),M(),v(),w()}var c=300,f=8;return{restrict:"E",transclude:!0,priority:210,template:' <div class="md-background"></div> <div class="md-content" ng-transclude></div>',scope:{visible:"=?mdVisible",delay:"=?mdDelay",autohide:"=?mdAutohide"},link:u}}e.module("material.components.tooltip",["material.core"]).directive("mdTooltip",n),n.$inject=["$timeout","$window","$$rAF","$document","$mdUtil","$mdTheming","$rootElement","$animate","$q"]}(window,window.angular); |