| 1 |
const ItemMenuOptionWidget = require( './ItemMenuOptionWidget.js' ); |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
const FilterMenuOptionWidget = function MwRcfiltersUiFilterMenuOptionWidget( |
| 18 |
controller, filtersViewModel, invertModel, itemModel, highlightPopup, config |
| 19 |
) { |
| 20 |
config = config || {}; |
| 21 |
|
| 22 |
this.controller = controller; |
| 23 |
this.invertModel = invertModel; |
| 24 |
this.model = itemModel; |
| 25 |
|
| 26 |
|
| 27 |
FilterMenuOptionWidget.super.call( this, controller, filtersViewModel, this.invertModel, itemModel, highlightPopup, config ); |
| 28 |
|
| 29 |
|
| 30 |
this.model.getGroupModel().connect( this, { update: 'onGroupModelUpdate' } ); |
| 31 |
|
| 32 |
this.$element |
| 33 |
.addClass( 'mw-rcfilters-ui-filterMenuOptionWidget' ); |
| 34 |
}; |
| 35 |
|
| 36 |
|
| 37 |
OO.inheritClass( FilterMenuOptionWidget, ItemMenuOptionWidget ); |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
FilterMenuOptionWidget.static.scrollIntoViewOnSelect = false; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
FilterMenuOptionWidget.prototype.updateUiBasedOnState = function () { |
| 50 |
|
| 51 |
FilterMenuOptionWidget.super.prototype.updateUiBasedOnState.call( this ); |
| 52 |
|
| 53 |
this.setCurrentMuteState(); |
| 54 |
}; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
FilterMenuOptionWidget.prototype.onGroupModelUpdate = function () { |
| 60 |
this.setCurrentMuteState(); |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
FilterMenuOptionWidget.prototype.setCurrentMuteState = function () { |
| 67 |
if ( this.invertModel && this.invertModel.isSelected() ) { |
| 68 |
|
| 69 |
|
| 70 |
this.setFlags( { |
| 71 |
muted: this.model.isSelected() |
| 72 |
} ); |
| 73 |
} else { |
| 74 |
this.setFlags( { |
| 75 |
muted: ( |
| 76 |
this.model.isConflicted() || |
| 77 |
( |
| 78 |
|
| 79 |
this.model.getGroupModel().isActive() && |
| 80 |
|
| 81 |
!this.model.isSelected() && |
| 82 |
|
| 83 |
!this.model.isIncluded() |
| 84 |
) |
| 85 |
) |
| 86 |
} ); |
| 87 |
} |
| 88 |
}; |
| 89 |
|
| 90 |
module.exports = FilterMenuOptionWidget; |