@@ -32,9 +32,13 @@ import {FocusableOption} from '../core/a11y/focus-key-manager';
32
32
import { CanDisable , mixinDisabled } from '../core/common-behaviors/disabled' ;
33
33
import { RxChain , switchMap , startWith } from '../core/rxjs/index' ;
34
34
import { merge } from 'rxjs/observable/merge' ;
35
+ import { CanDisableRipple , mixinDisableRipple } from '../core/common-behaviors/disable-ripple' ;
35
36
36
37
export class MdSelectionListBase { }
37
- export const _MdSelectionListMixinBase = mixinDisabled ( MdSelectionListBase ) ;
38
+ export const _MdSelectionListMixinBase = mixinDisableRipple ( mixinDisabled ( MdSelectionListBase ) ) ;
39
+
40
+ export class MdListOptionBase { }
41
+ export const _MdListOptionMixinBase = mixinDisableRipple ( MdListOptionBase ) ;
38
42
39
43
40
44
export interface MdSelectionListOptionEvent {
@@ -51,6 +55,7 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus';
51
55
@Component ( {
52
56
moduleId : module . id ,
53
57
selector : 'md-list-option, mat-list-option' ,
58
+ inputs : [ 'disableRipple' ] ,
54
59
host : {
55
60
'role' : 'option' ,
56
61
'class' : 'mat-list-item mat-list-option' ,
@@ -65,9 +70,10 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus';
65
70
encapsulation : ViewEncapsulation . None ,
66
71
changeDetection : ChangeDetectionStrategy . OnPush
67
72
} )
68
- export class MdListOption implements AfterContentInit , OnDestroy , FocusableOption {
73
+ export class MdListOption extends _MdListOptionMixinBase
74
+ implements AfterContentInit , OnDestroy , FocusableOption , CanDisableRipple {
75
+
69
76
private _lineSetter : MdLineSetter ;
70
- private _disableRipple : boolean = false ;
71
77
private _selected : boolean = false ;
72
78
/** Whether the checkbox is disabled. */
73
79
private _disabled : boolean = false ;
@@ -76,15 +82,6 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
76
82
/** Whether the option has focus. */
77
83
_hasFocus : boolean = false ;
78
84
79
- /**
80
- * Whether the ripple effect on click should be disabled. This applies only to list items that are
81
- * part of a selection list. The value of `disableRipple` on the `md-selection-list` overrides
82
- * this flag
83
- */
84
- @Input ( )
85
- get disableRipple ( ) { return this . _disableRipple ; }
86
- set disableRipple ( value : boolean ) { this . _disableRipple = coerceBooleanProperty ( value ) ; }
87
-
88
85
@ContentChildren ( MdLine ) _lines : QueryList < MdLine > ;
89
86
90
87
/** Whether the label should appear before or after the checkbox. Defaults to 'after' */
@@ -119,7 +116,9 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
119
116
private _element : ElementRef ,
120
117
private _changeDetector : ChangeDetectorRef ,
121
118
@Optional ( ) @Inject ( forwardRef ( ( ) => MdSelectionList ) )
122
- public selectionList : MdSelectionList ) { }
119
+ public selectionList : MdSelectionList ) {
120
+ super ( ) ;
121
+ }
123
122
124
123
ngAfterContentInit ( ) {
125
124
this . _lineSetter = new MdLineSetter ( this . _lines , this . _renderer , this . _element ) ;
@@ -146,8 +145,8 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
146
145
}
147
146
148
147
/** Whether this list item should show a ripple effect when clicked. */
149
- isRippleEnabled ( ) {
150
- return ! this . disableRipple && ! this . selectionList . disableRipple ;
148
+ _isRippleDisabled ( ) {
149
+ return this . disableRipple || this . selectionList . disableRipple ;
151
150
}
152
151
153
152
_handleClick ( ) {
@@ -175,7 +174,7 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
175
174
@Component ( {
176
175
moduleId : module . id ,
177
176
selector : 'md-selection-list, mat-selection-list' ,
178
- inputs : [ 'disabled' ] ,
177
+ inputs : [ 'disabled' , 'disableRipple' ] ,
179
178
host : {
180
179
'role' : 'listbox' ,
181
180
'[attr.tabindex]' : '_tabIndex' ,
@@ -189,8 +188,7 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
189
188
changeDetection : ChangeDetectionStrategy . OnPush
190
189
} )
191
190
export class MdSelectionList extends _MdSelectionListMixinBase
192
- implements FocusableOption , CanDisable , AfterContentInit , OnDestroy {
193
- private _disableRipple : boolean = false ;
191
+ implements FocusableOption , CanDisable , CanDisableRipple , AfterContentInit , OnDestroy {
194
192
195
193
/** Tab index for the selection-list. */
196
194
_tabIndex = 0 ;
@@ -210,14 +208,6 @@ export class MdSelectionList extends _MdSelectionListMixinBase
210
208
/** options which are selected. */
211
209
selectedOptions : SelectionModel < MdListOption > = new SelectionModel < MdListOption > ( true ) ;
212
210
213
- /**
214
- * Whether the ripple effect should be disabled on the list-items or not.
215
- * This flag only has an effect for `mat-selection-list` components.
216
- */
217
- @Input ( )
218
- get disableRipple ( ) { return this . _disableRipple ; }
219
- set disableRipple ( value : boolean ) { this . _disableRipple = coerceBooleanProperty ( value ) ; }
220
-
221
211
constructor ( private _element : ElementRef ) {
222
212
super ( ) ;
223
213
}
0 commit comments