| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
( function () { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
mw.widgets.ComplexNamespaceInputWidget = function MwWidgetsComplexNamespaceInputWidget( config ) { |
| 35 |
|
| 36 |
config = Object.assign( |
| 37 |
{ |
| 38 |
|
| 39 |
namespace: {}, |
| 40 |
invert: {}, |
| 41 |
invertLabel: {}, |
| 42 |
associated: {}, |
| 43 |
associatedLabel: {} |
| 44 |
}, |
| 45 |
config |
| 46 |
); |
| 47 |
|
| 48 |
|
| 49 |
mw.widgets.ComplexNamespaceInputWidget.super.call( this, config ); |
| 50 |
|
| 51 |
|
| 52 |
this.config = config; |
| 53 |
|
| 54 |
this.namespace = new mw.widgets.NamespaceInputWidget( config.namespace ); |
| 55 |
if ( config.associated !== null ) { |
| 56 |
this.associated = new OO.ui.CheckboxInputWidget( Object.assign( |
| 57 |
{ value: '1' }, |
| 58 |
config.associated |
| 59 |
) ); |
| 60 |
|
| 61 |
this.associatedLabel = new OO.ui.FieldLayout( |
| 62 |
this.associated, |
| 63 |
Object.assign( |
| 64 |
{ align: 'inline' }, |
| 65 |
config.associatedLabel |
| 66 |
) |
| 67 |
); |
| 68 |
} |
| 69 |
if ( config.invert !== null ) { |
| 70 |
this.invert = new OO.ui.CheckboxInputWidget( Object.assign( |
| 71 |
{ value: '1' }, |
| 72 |
config.invert |
| 73 |
) ); |
| 74 |
|
| 75 |
this.invertLabel = new OO.ui.FieldLayout( |
| 76 |
this.invert, |
| 77 |
Object.assign( |
| 78 |
{ align: 'inline' }, |
| 79 |
config.invertLabel |
| 80 |
) |
| 81 |
); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
this.namespace.connect( this, { change: 'updateCheckboxesState' } ); |
| 86 |
|
| 87 |
|
| 88 |
this.$element |
| 89 |
.addClass( 'mw-widget-complexNamespaceInputWidget' ) |
| 90 |
.append( |
| 91 |
this.namespace.$element, |
| 92 |
this.invert ? this.invertLabel.$element : '', |
| 93 |
this.associated ? this.associatedLabel.$element : '' |
| 94 |
); |
| 95 |
this.updateCheckboxesState(); |
| 96 |
}; |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
OO.inheritClass( mw.widgets.ComplexNamespaceInputWidget, OO.ui.Widget ); |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
mw.widgets.ComplexNamespaceInputWidget.prototype.updateCheckboxesState = function () { |
| 110 |
const disabled = this.namespace.getValue() === this.namespace.allValue; |
| 111 |
if ( this.invert ) { |
| 112 |
this.invert.setDisabled( disabled ); |
| 113 |
} |
| 114 |
if ( this.associated ) { |
| 115 |
this.associated.setDisabled( disabled ); |
| 116 |
} |
| 117 |
}; |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
mw.widgets.ComplexNamespaceInputWidget.prototype.setDisabled = function ( disabled ) { |
| 123 |
mw.widgets.ComplexNamespaceInputWidget.super.prototype.setDisabled.call( this, disabled ); |
| 124 |
if ( this.namespace ) { |
| 125 |
this.namespace.setDisabled( disabled ); |
| 126 |
} |
| 127 |
if ( this.invert ) { |
| 128 |
this.invert.setDisabled( disabled ); |
| 129 |
} |
| 130 |
|
| 131 |
if ( this.associated ) { |
| 132 |
this.associated.setDisabled( disabled ); |
| 133 |
} |
| 134 |
return this; |
| 135 |
}; |
| 136 |
|
| 137 |
}() ); |