| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
function LinkTypeField() { |
| 8 |
|
| 9 |
OO.EventEmitter.call( this ); |
| 10 |
|
| 11 |
this.radioInt = new OO.ui.RadioOptionWidget( { |
| 12 |
label: mw.msg( 'wikieditor-toolbar-tool-link-int' ) |
| 13 |
} ); |
| 14 |
this.radioExt = new OO.ui.RadioOptionWidget( { |
| 15 |
label: mw.msg( 'wikieditor-toolbar-tool-link-ext' ) |
| 16 |
} ); |
| 17 |
var radioSelect = new OO.ui.RadioSelectWidget( { |
| 18 |
items: [ |
| 19 |
this.radioInt, |
| 20 |
this.radioExt |
| 21 |
] |
| 22 |
} ); |
| 23 |
radioSelect.connect( this, { |
| 24 |
choose: this.onRadioChoose |
| 25 |
} ); |
| 26 |
|
| 27 |
var config = { |
| 28 |
align: 'top', |
| 29 |
classes: [ 'mw-wikiEditor-InsertLink-LinkTypeField' ] |
| 30 |
}; |
| 31 |
LinkTypeField.super.call( this, radioSelect, config ); |
| 32 |
} |
| 33 |
|
| 34 |
OO.inheritClass( LinkTypeField, OO.ui.FieldLayout ); |
| 35 |
OO.mixinClass( LinkTypeField, OO.EventEmitter ); |
| 36 |
|
| 37 |
LinkTypeField.static.LINK_MODE_INTERNAL = 'internal'; |
| 38 |
|
| 39 |
LinkTypeField.static.LINK_MODE_EXTERNAL = 'external'; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
LinkTypeField.prototype.setIsExternal = function ( isExternal ) { |
| 47 |
this.getField().selectItem( isExternal ? this.radioExt : this.radioInt ); |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
LinkTypeField.prototype.isInternal = function () { |
| 56 |
return this.radioInt.isSelected(); |
| 57 |
}; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
LinkTypeField.prototype.onRadioChoose = function () { |
| 65 |
this.emit( 'change', this.radioExt.isSelected() ); |
| 66 |
}; |
| 67 |
|
| 68 |
module.exports = LinkTypeField; |