| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
ve.ui.MWTransclusionOutlineButtonWidget = function VeUiMWTransclusionOutlineButtonWidget( config ) { |
| 18 |
|
| 19 |
ve.ui.MWTransclusionOutlineButtonWidget.super.call( this, ve.extendObject( config, { |
| 20 |
classes: [ 've-ui-mwTransclusionOutlineButtonWidget' ] |
| 21 |
} ) ); |
| 22 |
|
| 23 |
|
| 24 |
OO.ui.mixin.ButtonElement.call( this, { |
| 25 |
|
| 26 |
$button: $( '<span>' ), |
| 27 |
framed: false |
| 28 |
} ); |
| 29 |
OO.ui.mixin.IconElement.call( this, config ); |
| 30 |
OO.ui.mixin.TabIndexedElement.call( this, ve.extendObject( { |
| 31 |
$tabIndexed: this.$button |
| 32 |
}, config ) ); |
| 33 |
ve.ui.MWAriaDescribe.call( this, { |
| 34 |
ariaLabel: config.label, |
| 35 |
$describedElement: this.$button |
| 36 |
} ); |
| 37 |
|
| 38 |
|
| 39 |
this.$button.attr( { |
| 40 |
role: 'gridcell', |
| 41 |
'aria-selected': 'false' |
| 42 |
} ); |
| 43 |
|
| 44 |
this.$element |
| 45 |
.append( this.$button.append( this.$icon, this.$label ) ); |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
OO.inheritClass( ve.ui.MWTransclusionOutlineButtonWidget, OO.ui.OptionWidget ); |
| 51 |
OO.mixinClass( ve.ui.MWTransclusionOutlineButtonWidget, OO.ui.mixin.ButtonElement ); |
| 52 |
OO.mixinClass( ve.ui.MWTransclusionOutlineButtonWidget, OO.ui.mixin.IconElement ); |
| 53 |
OO.mixinClass( ve.ui.MWTransclusionOutlineButtonWidget, OO.ui.mixin.TabIndexedElement ); |
| 54 |
OO.mixinClass( ve.ui.MWTransclusionOutlineButtonWidget, ve.ui.MWAriaDescribe ); |
| 55 |
|
| 56 |
ve.ui.MWTransclusionOutlineButtonWidget.static.highlightable = false; |
| 57 |
ve.ui.MWTransclusionOutlineButtonWidget.static.pressable = false; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
ve.ui.MWTransclusionOutlineButtonWidget.prototype.onKeyDown = function ( e ) { |
| 72 |
const isMac = ve.getSystemPlatform() === 'mac'; |
| 73 |
const withMetaKey = isMac ? e.metaKey : e.ctrlKey; |
| 74 |
|
| 75 |
if ( e.which === OO.ui.Keys.SPACE && |
| 76 |
!withMetaKey && !e.shiftKey && !e.altKey |
| 77 |
) { |
| 78 |
|
| 79 |
if ( !this.isSelected() ) { |
| 80 |
this.emit( 'keyPressed', e.which ); |
| 81 |
} |
| 82 |
|
| 83 |
e.preventDefault(); |
| 84 |
return; |
| 85 |
} |
| 86 |
|
| 87 |
return OO.ui.mixin.ButtonElement.prototype.onKeyDown.call( this, e ); |
| 88 |
}; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
ve.ui.MWTransclusionOutlineButtonWidget.prototype.setSelected = function ( state ) { |
| 94 |
if ( this.$button ) { |
| 95 |
this.$button.attr( 'aria-selected', state.toString() ); |
| 96 |
} |
| 97 |
return ve.ui.MWTransclusionOutlineButtonWidget.super.prototype.setSelected.call( this, state ); |
| 98 |
}; |