| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
ve.ui.MWTransclusionOutlineParameterWidget = function VeUiMWTransclusionOutlineParameterWidget( config ) { |
| 18 |
this.checkbox = new OO.ui.CheckboxInputWidget( { |
| 19 |
title: config.required ? |
| 20 |
ve.msg( 'visualeditor-dialog-transclusion-required-parameter' ) : |
| 21 |
null, |
| 22 |
disabled: config.required, |
| 23 |
selected: config.selected || config.required, |
| 24 |
|
| 25 |
tabIndex: -1 |
| 26 |
} ) |
| 27 |
.connect( this, { |
| 28 |
|
| 29 |
change: [ 'emit', 'change' ] |
| 30 |
} ); |
| 31 |
this.checkbox.$input.on( { |
| 32 |
mousedown: this.onMouseDown.bind( this ) |
| 33 |
} ); |
| 34 |
|
| 35 |
|
| 36 |
ve.ui.MWTransclusionOutlineParameterWidget.super.call( this, ve.extendObject( config, { |
| 37 |
classes: [ 've-ui-mwTransclusionOutlineParameterWidget' ], |
| 38 |
$label: $( '<label>' ) |
| 39 |
} ) ); |
| 40 |
|
| 41 |
this.toggleHasValue( config.hasValue ); |
| 42 |
|
| 43 |
|
| 44 |
this.$element |
| 45 |
.append( this.checkbox.$element, this.$label ); |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
OO.inheritClass( ve.ui.MWTransclusionOutlineParameterWidget, OO.ui.OptionWidget ); |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
ve.ui.MWTransclusionOutlineParameterWidget.prototype.onMouseDown = function ( e ) { |
| 59 |
|
| 60 |
e.stopPropagation(); |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
ve.ui.MWTransclusionOutlineParameterWidget.prototype.setSelected = function ( state ) { |
| 67 |
|
| 68 |
state = state || this.checkbox.isDisabled(); |
| 69 |
|
| 70 |
this.checkbox.setSelected( state, true ); |
| 71 |
return ve.ui.MWTransclusionOutlineParameterWidget.super.prototype.setSelected.call( this, state ); |
| 72 |
}; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
ve.ui.MWTransclusionOutlineParameterWidget.prototype.toggleActivePageIndicator = function ( state ) { |
| 78 |
this.$element.toggleClass( 've-ui-mwTransclusionOutlineParameterWidget-activePage', state ); |
| 79 |
}; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
ve.ui.MWTransclusionOutlineParameterWidget.prototype.toggleHasValue = function ( hasValue ) { |
| 85 |
this.$element.toggleClass( 've-ui-mwTransclusionOutlineParameterWidget-hasValue', hasValue ); |
| 86 |
}; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
ve.ui.MWTransclusionOutlineParameterWidget.prototype.ensureVisibility = function ( paddingTop ) { |
| 94 |
|
| 95 |
this.scrollElementIntoView( { animate: false, padding: { top: paddingTop } } ); |
| 96 |
}; |