// Highlight
this.cssClass = config.cssClass;
this.highlightColor = config.defaultHighlightColor;
- this.highlightEnabled = !!config.defaultHighlightColor;
};
/* Initialization */
};
/**
- * Get a prefixed label
+ * Get the message key to use to wrap the label. This message takes the label as a parameter.
*
- * @param {boolean} inverted This item should be considered inverted
- * @return {string} Prefixed label
+ * @param {boolean} inverted Whether this item should be considered inverted
+ * @return {string|null} Message key, or null if no message
*/
- mw.rcfilters.dm.ItemModel.prototype.getPrefixedLabel = function ( inverted ) {
+ mw.rcfilters.dm.ItemModel.prototype.getLabelMessageKey = function ( inverted ) {
if ( this.labelPrefixKey ) {
if ( typeof this.labelPrefixKey === 'string' ) {
- return mw.message( this.labelPrefixKey, this.getLabel() ).parse();
- } else {
- return mw.message(
- this.labelPrefixKey[
- // Only use inverted-prefix if the item is selected
- // Highlight-only an inverted item makes no sense
- inverted && this.isSelected() ?
- 'inverted' : 'default'
- ],
- this.getLabel()
- ).parse();
+ return this.labelPrefixKey;
}
- } else {
- return this.getLabel();
+ return this.labelPrefixKey[
+ // Only use inverted-prefix if the item is selected
+ // Highlight-only an inverted item makes no sense
+ inverted && this.isSelected() ?
+ 'inverted' : 'default'
+ ];
}
+ return null;
};
/**
* @param {string|null} highlightColor
*/
mw.rcfilters.dm.ItemModel.prototype.setHighlightColor = function ( highlightColor ) {
+ if ( !this.isHighlightSupported() ) {
+ return;
+ }
+
if ( this.highlightColor !== highlightColor ) {
this.highlightColor = highlightColor;
this.emit( 'update' );
return this.identifiers;
};
- /**
- * Toggle the highlight feature on and off for this filter.
- * It only works if highlight is supported for this filter.
- *
- * @param {boolean} enable Highlight should be enabled
- */
- mw.rcfilters.dm.ItemModel.prototype.toggleHighlight = function ( enable ) {
- enable = enable === undefined ? !this.highlightEnabled : enable;
-
- if ( !this.isHighlightSupported() ) {
- return;
- }
-
- if ( enable === this.highlightEnabled ) {
- return;
- }
-
- this.highlightEnabled = enable;
- this.emit( 'update' );
- };
-
- /**
- * Check if the highlight feature is currently enabled for this filter
- *
- * @return {boolean}
- */
- mw.rcfilters.dm.ItemModel.prototype.isHighlightEnabled = function () {
- return !!this.highlightEnabled;
- };
-
/**
* Check if the highlight feature is supported for this filter
*
* @return {boolean}
*/
mw.rcfilters.dm.ItemModel.prototype.isHighlighted = function () {
- return this.isHighlightEnabled() && !!this.getHighlightColor();
+ return !!this.getHighlightColor();
};
}( mediaWiki ) );