| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
ve.ui.MWTransclusionOutlineToggleUnusedWidget = function VeUiMWTransclusionOutlineToggleUnusedWidget() { |
| 11 |
|
| 12 |
ve.ui.MWTransclusionOutlineToggleUnusedWidget.super.call( this, { |
| 13 |
label: ve.msg( 'visualeditor-dialog-transclusion-filter-hide-unused' ), |
| 14 |
flags: [ 'progressive' ], |
| 15 |
framed: false |
| 16 |
} ); |
| 17 |
|
| 18 |
|
| 19 |
this.connect( this, { |
| 20 |
toggle: 'onToggle', |
| 21 |
click: 'onClick' |
| 22 |
} ); |
| 23 |
|
| 24 |
|
| 25 |
this.$element.addClass( 've-ui-mwTransclusionOutlineToggleUnusedWidget' ); |
| 26 |
this.showUnusedFields = true; |
| 27 |
}; |
| 28 |
|
| 29 |
|
| 30 |
OO.inheritClass( ve.ui.MWTransclusionOutlineToggleUnusedWidget, OO.ui.ButtonWidget ); |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.onClick = function () { |
| 48 |
this.toggleUnusedParameters( !this.showUnusedFields, true ); |
| 49 |
}; |
| 50 |
|
| 51 |
|
| 52 |
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.setDisabled = function ( disabled ) { |
| 53 |
ve.ui.MWTransclusionOutlineToggleUnusedWidget.super.prototype.setDisabled.call( this, disabled ); |
| 54 |
this.updateState( this.showUnusedFields ); |
| 55 |
}; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.toggleUnusedParameters = function ( showUnused, fromClick ) { |
| 63 |
if ( this.updateState( showUnused ) ) { |
| 64 |
this.emit( 'toggleUnusedFields', this.showUnusedFields, fromClick ); |
| 65 |
} |
| 66 |
}; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.updateState = function ( showUnused ) { |
| 74 |
showUnused = showUnused || this.isDisabled(); |
| 75 |
if ( showUnused !== this.showUnusedFields ) { |
| 76 |
this.showUnusedFields = showUnused; |
| 77 |
this.setLabel( ve.msg( this.showUnusedFields ? |
| 78 |
'visualeditor-dialog-transclusion-filter-hide-unused' : |
| 79 |
'visualeditor-dialog-transclusion-filter-show-all' |
| 80 |
) ); |
| 81 |
return true; |
| 82 |
} |
| 83 |
return false; |
| 84 |
}; |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.onToggle = function ( visible ) { |
| 94 |
if ( visible ) { |
| 95 |
this.emit( 'toggleUnusedFields', this.showUnusedFields ); |
| 96 |
} |
| 97 |
}; |