@@ -33,6 +33,7 @@ import {Platform} from '../core/platform/index';
33
33
import 'rxjs/add/operator/first' ;
34
34
import { ScrollDispatcher } from '../core/overlay/scroll/scroll-dispatcher' ;
35
35
import { Subscription } from 'rxjs/Subscription' ;
36
+ import { coerceBooleanProperty } from '../core/coercion/boolean-property' ;
36
37
37
38
export type TooltipPosition = 'left' | 'right' | 'above' | 'below' | 'before' | 'after' ;
38
39
@@ -62,6 +63,7 @@ export class MdTooltip implements OnInit, OnDestroy {
62
63
scrollSubscription : Subscription ;
63
64
64
65
private _position : TooltipPosition = 'below' ;
66
+ private _disabled : boolean = false ;
65
67
66
68
/** Allows the user to define the position of the tooltip relative to the parent element */
67
69
@Input ( 'mdTooltipPosition' )
@@ -78,6 +80,18 @@ export class MdTooltip implements OnInit, OnDestroy {
78
80
}
79
81
}
80
82
83
+ /** Disables the display of the tooltip. */
84
+ @Input ( 'mdTooltipDisabled' )
85
+ get disabled ( ) : boolean { return this . _disabled ; }
86
+ set disabled ( value ) {
87
+ this . _disabled = coerceBooleanProperty ( value ) ;
88
+
89
+ // If tooltip is disabled, hide immediately.
90
+ if ( this . _disabled ) {
91
+ this . hide ( 0 ) ;
92
+ }
93
+ }
94
+
81
95
/** @deprecated */
82
96
@Input ( 'tooltip-position' )
83
97
get _positionDeprecated ( ) : TooltipPosition { return this . _position ; }
@@ -115,6 +129,11 @@ export class MdTooltip implements OnInit, OnDestroy {
115
129
get _matPosition ( ) { return this . position ; }
116
130
set _matPosition ( v ) { this . position = v ; }
117
131
132
+ // Properties with `mat-` prefix for noconflict mode.
133
+ @Input ( 'matTooltipDisabled' )
134
+ get _matDisabled ( ) { return this . disabled ; }
135
+ set _matDisabled ( v ) { this . disabled = v ; }
136
+
118
137
// Properties with `mat-` prefix for noconflict mode.
119
138
@Input ( 'matTooltipHideDelay' )
120
139
get _matHideDelay ( ) { return this . hideDelay ; }
@@ -168,7 +187,7 @@ export class MdTooltip implements OnInit, OnDestroy {
168
187
169
188
/** Shows the tooltip after the delay in ms, defaults to tooltip-delay-show or 0ms if no input */
170
189
show ( delay : number = this . showDelay ) : void {
171
- if ( ! this . _message || ! this . _message . trim ( ) ) { return ; }
190
+ if ( this . disabled || ! this . _message || ! this . _message . trim ( ) ) { return ; }
172
191
173
192
if ( ! this . _tooltipInstance ) {
174
193
this . _createTooltip ( ) ;
@@ -192,7 +211,7 @@ export class MdTooltip implements OnInit, OnDestroy {
192
211
193
212
/** Returns true if the tooltip is currently visible to the user */
194
213
_isTooltipVisible ( ) : boolean {
195
- return this . _tooltipInstance && this . _tooltipInstance . isVisible ( ) ;
214
+ return ! ! this . _tooltipInstance && this . _tooltipInstance . isVisible ( ) ;
196
215
}
197
216
198
217
/** Create the tooltip to display */
0 commit comments