| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
ve.ui.MWAriaDescribe = function VeUiMWAriaDescribe( config ) { |
| 14 |
this.$describedElement = config.$describedElement || this.$element; |
| 15 |
|
| 16 |
if ( config.$ariaDescribedBy ) { |
| 17 |
this.setAriaDescribedBy( config.$ariaDescribedBy ); |
| 18 |
} |
| 19 |
|
| 20 |
if ( config.ariaLabel ) { |
| 21 |
this.setAriaLabel( config.ariaLabel ); |
| 22 |
} |
| 23 |
}; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
OO.initClass( ve.ui.MWAriaDescribe ); |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
ve.ui.MWAriaDescribe.prototype.setAriaDescribedBy = function ( $description ) { |
| 35 |
if ( !$description ) { |
| 36 |
this.$describedElement.removeAttr( 'aria-describedby' ); |
| 37 |
return this; |
| 38 |
} |
| 39 |
|
| 40 |
if ( !$description.attr( 'id' ) ) { |
| 41 |
$description.attr( 'id', OO.ui.generateElementId() ); |
| 42 |
} |
| 43 |
this.$describedElement.attr( 'aria-describedby', $description.attr( 'id' ) ); |
| 44 |
return this; |
| 45 |
}; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
ve.ui.MWAriaDescribe.prototype.setAriaLabel = function ( label ) { |
| 53 |
this.$describedElement.attr( 'aria-label', label ); |
| 54 |
return this; |
| 55 |
}; |