Debian Codegraph @

extensions/WikiEditor/modules/insertlink/LinkTypeField.js

raw symbols SCIP
1 /**
2 * @class
3 * @extends OO.ui.FieldLayout
4 * @mixes OO.EventEmitter
5 * @constructor
6 */
7 function LinkTypeField() {
8 // Mixin constructor
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 * Select the 'external link' radio.
43 *
44 * @param {boolean} isExternal
45 */
46 LinkTypeField.prototype.setIsExternal = function ( isExternal ) {
47 this.getField().selectItem( isExternal ? this.radioExt : this.radioInt );
48 };
49
50 /**
51 * Is the 'internal link' radio currently selected?
52 *
53 * @return {boolean}
54 */
55 LinkTypeField.prototype.isInternal = function () {
56 return this.radioInt.isSelected();
57 };
58
59 /**
60 * Emit a 'change' event when the radio selection changes.
61 *
62 * @private
63 */
64 LinkTypeField.prototype.onRadioChoose = function () {
65 this.emit( 'change', this.radioExt.isSelected() );
66 };
67
68 module.exports = LinkTypeField;