You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6 lines
4.5 KiB

7 years ago
  1. /*!
  2. * Angular Material Design
  3. * https://github.com/angular/material
  4. * @license MIT
  5. * v1.1.2-master-a9ba340
  6. */
  7. function MdTooltipDirective(e,t,i,n,o,r,l,a){function d(d,h,v){function b(){d.mdZIndex=d.mdZIndex||u,d.mdDelay=d.mdDelay||m,p[d.mdDirection]||(d.mdDirection=f)}function g(e){if(e||!R.attr("aria-label")){var t=e||o(h.text().trim())(d.$parent);R.attr("aria-label",t)}}function y(){b(),A&&A.panelEl&&A.panelEl.removeClass(D),D="md-origin-"+d.mdDirection,O=p[d.mdDirection],V=l.newPanelPosition().relativeTo(R).addPanelPosition(O.x,O.y),A&&A.panelEl&&(A.panelEl.addClass(D),A.updatePosition(V))}function E(){function i(e){return e.some(function(e){return"disabled"===e.attributeName&&R[0].disabled}),!1}function o(){w(!1)}function l(){N=document.activeElement===R[0]}function u(e){"focus"===e.type&&N?N=!1:d.mdVisible||(R.on(s,m),w(!0),"touchstart"===e.type&&R.one("touchend",function(){r.nextTick(function(){n.one("touchend",m)},!1)}))}function m(){C=d.hasOwnProperty("mdAutohide")?d.mdAutohide:v.hasOwnProperty("mdAutohide"),(C||W||n[0].activeElement!==R[0])&&(M&&(e.cancel(M),w.queued=!1,M=null),R.off(s,m),R.triggerHandler("blur"),w(!1)),W=!1}function f(){W=!0}function p(){a.deregister("scroll",o,!0),a.deregister("blur",l),a.deregister("resize",q),R.off(c,u).off(s,m).off("mousedown",f),m(),h&&h.disconnect()}if(R[0]&&"MutationObserver"in t){var h=new MutationObserver(function(e){i(e)&&r.nextTick(function(){w(!1)})});h.observe(R[0],{attributes:!0})}N=!1,a.register("scroll",o,!0),a.register("blur",l),a.register("resize",q),d.$on("$destroy",p),R.on("mousedown",f),R.on(c,u)}function x(){function e(){d.$destroy()}if(h[0]&&"MutationObserver"in t){var i=new MutationObserver(function(e){e.forEach(function(e){"md-visible"!==e.attributeName||d.visibleWatcher||(d.visibleWatcher=d.$watch("mdVisible",$))})});i.observe(h[0],{attributes:!0}),v.hasOwnProperty("mdVisible")&&(d.visibleWatcher=d.$watch("mdVisible",$))}else d.visibleWatcher=d.$watch("mdVisible",$);d.$watch("mdDirection",y),h.one("$destroy",e),R.one("$destroy",e),d.$on("$destroy",function(){w(!1),A&&A.destroy(),i&&i.disconnect(),h.remove()}),h.text().indexOf(o.startSymbol())>-1&&d.$watch(function(){return h.text().trim()},g)}function w(t){w.queued&&w.value===!!t||!w.queued&&d.mdVisible===!!t||(w.value=!!t,w.queued||(t?(w.queued=!0,M=e(function(){d.mdVisible=w.value,w.queued=!1,M=null,d.visibleWatcher||$(d.mdVisible)},d.mdDelay)):r.nextTick(function(){d.mdVisible=!1,d.visibleWatcher||$(!1)})))}function $(e){e?T():P()}function T(){if(!h[0].textContent.trim())throw new Error("Text for the tooltip has not been provided. Please include text within the mdTooltip element.");if(!A){var e="tooltip-"+r.nextUid(),t=angular.element(document.body),i=l.newPanelAnimation().openFrom(R).closeTo(R).withAnimation({open:"md-show",close:"md-hide"}),n={id:e,attachTo:t,contentElement:h,propagateContainerEvents:!0,panelClass:"md-tooltip "+D,animation:i,position:V,zIndex:d.mdZIndex,focusOnOpen:!1};A=l.create(n)}A.open().then(function(){A.panelEl.attr("role","tooltip")})}function P(){A&&A.close()}var D,O,V,A,C,M,R=r.getParentWithPointerEvents(h),q=i.throttle(y),W=!1,N=null;b(),g(),h.detach(),y(),E(),x()}var c="focus touchstart mouseenter",s="blur touchcancel mouseleave",u=100,m=0,f="bottom",p={top:{x:l.xPosition.CENTER,y:l.yPosition.ABOVE},right:{x:l.xPosition.OFFSET_END,y:l.yPosition.CENTER},bottom:{x:l.xPosition.CENTER,y:l.yPosition.BELOW},left:{x:l.xPosition.OFFSET_START,y:l.yPosition.CENTER}};return{restrict:"E",priority:210,scope:{mdZIndex:"=?mdZIndex",mdDelay:"=?mdDelay",mdVisible:"=?mdVisible",mdAutohide:"=?mdAutohide",mdDirection:"@?mdDirection"},link:d}}function MdTooltipRegistry(){function e(e){n[e.type]&&n[e.type].forEach(function(t){t.call(this,e)},this)}function t(t,i,r){var l=n[t]=n[t]||[];l.length||(r?window.addEventListener(t,e,!0):o.on(t,e)),l.indexOf(i)===-1&&l.push(i)}function i(t,i,r){var l=n[t],a=l?l.indexOf(i):-1;a>-1&&(l.splice(a,1),0===l.length&&(r?window.removeEventListener(t,e,!0):o.off(t,e)))}var n={},o=angular.element(window);return{register:t,deregister:i}}goog.provide("ngmaterial.components.tooltip"),goog.require("ngmaterial.components.panel"),goog.require("ngmaterial.core"),MdTooltipDirective.$inject=["$timeout","$window","$$rAF","$document","$interpolate","$mdUtil","$mdPanel","$$mdTooltipRegistry"],angular.module("material.components.tooltip",["material.core","material.components.panel"]).directive("mdTooltip",MdTooltipDirective).service("$$mdTooltipRegistry",MdTooltipRegistry),ngmaterial.components.tooltip=angular.module("material.components.tooltip");