| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
function LinkTextField() { |
| 7 |
var input = new OO.ui.TextInputWidget( { |
| 8 |
placeholder: mw.msg( 'wikieditor-toolbar-tool-link-int-text-tooltip' ) |
| 9 |
} ); |
| 10 |
|
| 11 |
input.connect( this, { |
| 12 |
change: 'onInputChange' |
| 13 |
} ); |
| 14 |
|
| 15 |
var config = { |
| 16 |
align: 'top', |
| 17 |
label: mw.msg( 'wikieditor-toolbar-tool-link-int-text' ), |
| 18 |
classes: [ 'mw-wikiEditor-InsertLink-LinkTextField' ] |
| 19 |
}; |
| 20 |
LinkTextField.super.call( this, input, config ); |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
this.touched = false; |
| 26 |
} |
| 27 |
|
| 28 |
OO.inheritClass( LinkTextField, OO.ui.FieldLayout ); |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
LinkTextField.prototype.setValueIfUntouched = function ( val ) { |
| 36 |
if ( !this.touched ) { |
| 37 |
this.getField().setValue( val ); |
| 38 |
} |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
LinkTextField.prototype.setTouched = function ( touched ) { |
| 45 |
this.touched = touched; |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
LinkTextField.prototype.onInputChange = function () { |
| 53 |
if ( $.contains( this.$element[ 0 ], document.activeElement ) ) { |
| 54 |
this.touched = true; |
| 55 |
} |
| 56 |
}; |
| 57 |
|
| 58 |
module.exports = LinkTextField; |