| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWidget( part, config ) { |
| 25 |
this.part = part; |
| 26 |
|
| 27 |
|
| 28 |
ve.ui.MWTransclusionOutlinePartWidget.super.call( this, ve.extendObject( config, { |
| 29 |
classes: [ 've-ui-mwTransclusionOutlinePartWidget' ], |
| 30 |
data: part.getId() |
| 31 |
} ) ); |
| 32 |
|
| 33 |
this.header = new ve.ui.MWTransclusionOutlineButtonWidget( config ) |
| 34 |
.connect( this, { |
| 35 |
keyPressed: 'onHeaderKeyPressed', |
| 36 |
`. |
| 37 |
click: [ 'emit', 'transclusionOutlineItemSelected', part.getId() ] |
| 38 |
} ); |
| 39 |
|
| 40 |
if ( config.ariaDescriptionUnselected ) { |
| 41 |
this.$ariaDescriptionUnselected = $( '<span>' ) |
| 42 |
.text( config.ariaDescriptionUnselected ) |
| 43 |
.addClass( 've-ui-mwTransclusionOutline-ariaHidden' ); |
| 44 |
|
| 45 |
this.$ariaDescriptionSelected = $( '<span>' ) |
| 46 |
.text( config.ariaDescriptionSelected ) |
| 47 |
.addClass( 've-ui-mwTransclusionOutline-ariaHidden' ); |
| 48 |
|
| 49 |
this.$ariaDescriptionSelectedSingle = $( '<span>' ) |
| 50 |
.text( config.ariaDescriptionSelectedSingle ) |
| 51 |
.addClass( 've-ui-mwTransclusionOutline-ariaHidden' ); |
| 52 |
|
| 53 |
this.header |
| 54 |
.setAriaDescribedBy( this.$ariaDescriptionUnselected ) |
| 55 |
.$element.prepend( |
| 56 |
this.$ariaDescriptionUnselected, |
| 57 |
this.$ariaDescriptionSelected, |
| 58 |
this.$ariaDescriptionSelectedSingle |
| 59 |
); |
| 60 |
} |
| 61 |
|
| 62 |
this.transclusionModel = this.part.getTransclusion().connect( this, { |
| 63 |
replace: 'updateButtonAriaDescription' |
| 64 |
} ); |
| 65 |
|
| 66 |
this.$element.append( this.header.$element ); |
| 67 |
}; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
OO.inheritClass( ve.ui.MWTransclusionOutlinePartWidget, OO.ui.Widget ); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
ve.ui.MWTransclusionOutlinePartWidget.prototype.onHeaderKeyPressed = function ( key ) { |
| 102 |
if ( key === OO.ui.Keys.SPACE ) { |
| 103 |
this.emit( 'transclusionPartSoftSelected', this.getData() ); |
| 104 |
} |
| 105 |
}; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
ve.ui.MWTransclusionOutlinePartWidget.prototype.isSelected = function () { |
| 113 |
return this.header.isSelected(); |
| 114 |
}; |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
ve.ui.MWTransclusionOutlinePartWidget.prototype.setSelected = function ( state ) { |
| 122 |
if ( state !== this.isSelected() ) { |
| 123 |
this.updateButtonAriaDescription( state ); |
| 124 |
this.header |
| 125 |
.setSelected( state ) |
| 126 |
.setFlags( { progressive: state } ); |
| 127 |
} |
| 128 |
}; |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
ve.ui.MWTransclusionOutlinePartWidget.prototype.updateButtonAriaDescription = function ( state ) { |
| 135 |
this.header.setAriaDescribedBy( !state ? this.$ariaDescriptionUnselected : |
| 136 |
( this.transclusionModel.isSingleTemplate() ? this.$ariaDescriptionSelectedSingle : this.$ariaDescriptionSelected ) |
| 137 |
); |
| 138 |
}; |