X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fdm%2Fmw.rcfilters.dm.ItemModel.js;h=44b6c8cff569530177186bb53c459043c3081947;hb=fdd862b6f04b1847379261fe448db662a91a00a0;hp=4a8869a17d9396a69fea11d201a15d54afa9d86d;hpb=4fffb933707fa4565978d24e1744ec5947e8ffde;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ItemModel.js b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ItemModel.js index 4a8869a17d..44b6c8cff5 100644 --- a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ItemModel.js +++ b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ItemModel.js @@ -41,7 +41,6 @@ // Highlight this.cssClass = config.cssClass; this.highlightColor = config.defaultHighlightColor; - this.highlightEnabled = !!config.defaultHighlightColor; }; /* Initialization */ @@ -80,29 +79,24 @@ }; /** - * 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; }; /** @@ -181,6 +175,10 @@ * @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' ); @@ -222,36 +220,6 @@ 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 * @@ -267,6 +235,6 @@ * @return {boolean} */ mw.rcfilters.dm.ItemModel.prototype.isHighlighted = function () { - return this.isHighlightEnabled() && !!this.getHighlightColor(); + return !!this.getHighlightColor(); }; }( mediaWiki ) );