@@ -32,9 +32,13 @@ import {FocusableOption} from '../core/a11y/focus-key-manager';
3232import { CanDisable , mixinDisabled } from '../core/common-behaviors/disabled' ;
3333import { RxChain , switchMap , startWith } from '../core/rxjs/index' ;
3434import { merge } from 'rxjs/observable/merge' ;
35+ import { CanDisableRipple , mixinDisableRipple } from '../core/common-behaviors/disable-ripple' ;
3536
3637export 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 ) ;
3842
3943
4044export interface MdSelectionListOptionEvent {
@@ -51,6 +55,7 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus';
5155@Component ( {
5256 moduleId : module . id ,
5357 selector : 'md-list-option, mat-list-option' ,
58+ inputs : [ 'disableRipple' ] ,
5459 host : {
5560 'role' : 'option' ,
5661 'class' : 'mat-list-item mat-list-option' ,
@@ -65,9 +70,10 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus';
6570 encapsulation : ViewEncapsulation . None ,
6671 changeDetection : ChangeDetectionStrategy . OnPush
6772} )
68- export class MdListOption implements AfterContentInit , OnDestroy , FocusableOption {
73+ export class MdListOption extends _MdListOptionMixinBase
74+ implements AfterContentInit , OnDestroy , FocusableOption , CanDisableRipple {
75+
6976 private _lineSetter : MdLineSetter ;
70- private _disableRipple : boolean = false ;
7177 private _selected : boolean = false ;
7278 /** Whether the checkbox is disabled. */
7379 private _disabled : boolean = false ;
@@ -76,15 +82,6 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
7682 /** Whether the option has focus. */
7783 _hasFocus : boolean = false ;
7884
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-
8885 @ContentChildren ( MdLine ) _lines : QueryList < MdLine > ;
8986
9087 /** Whether the label should appear before or after the checkbox. Defaults to 'after' */
@@ -119,7 +116,9 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
119116 private _element : ElementRef ,
120117 private _changeDetector : ChangeDetectorRef ,
121118 @Optional ( ) @Inject ( forwardRef ( ( ) => MdSelectionList ) )
122- public selectionList : MdSelectionList ) { }
119+ public selectionList : MdSelectionList ) {
120+ super ( ) ;
121+ }
123122
124123 ngAfterContentInit ( ) {
125124 this . _lineSetter = new MdLineSetter ( this . _lines , this . _renderer , this . _element ) ;
@@ -146,8 +145,8 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
146145 }
147146
148147 /** 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 ;
151150 }
152151
153152 _handleClick ( ) {
@@ -175,7 +174,7 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
175174@Component ( {
176175 moduleId : module . id ,
177176 selector : 'md-selection-list, mat-selection-list' ,
178- inputs : [ 'disabled' ] ,
177+ inputs : [ 'disabled' , 'disableRipple' ] ,
179178 host : {
180179 'role' : 'listbox' ,
181180 '[attr.tabindex]' : '_tabIndex' ,
@@ -189,8 +188,7 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio
189188 changeDetection : ChangeDetectionStrategy . OnPush
190189} )
191190export class MdSelectionList extends _MdSelectionListMixinBase
192- implements FocusableOption , CanDisable , AfterContentInit , OnDestroy {
193- private _disableRipple : boolean = false ;
191+ implements FocusableOption , CanDisable , CanDisableRipple , AfterContentInit , OnDestroy {
194192
195193 /** Tab index for the selection-list. */
196194 _tabIndex = 0 ;
@@ -210,14 +208,6 @@ export class MdSelectionList extends _MdSelectionListMixinBase
210208 /** options which are selected. */
211209 selectedOptions : SelectionModel < MdListOption > = new SelectionModel < MdListOption > ( true ) ;
212210
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-
221211 constructor ( private _element : ElementRef ) {
222212 super ( ) ;
223213 }
0 commit comments