dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "User: Remove deprecated, unused auth functions"
[lhc/web/wiklou.git]
/
resources
/
src
/
mediawiki.rcfilters
/
ui
/
mw.rcfilters.ui.TagItemWidget.js
diff --git
a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.TagItemWidget.js
b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.TagItemWidget.js
index
81889b2
..
188650a
100644
(file)
--- a/
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.TagItemWidget.js
+++ b/
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.TagItemWidget.js
@@
-8,21
+8,26
@@
*
* @constructor
* @param {mw.rcfilters.Controller} controller
*
* @constructor
* @param {mw.rcfilters.Controller} controller
- * @param {mw.rcfilters.dm.FilterItem} model Item model
+ * @param {mw.rcfilters.dm.FiltersViewModel} filtersViewModel
+ * @param {mw.rcfilters.dm.FilterItem} invertModel
+ * @param {mw.rcfilters.dm.FilterItem} itemModel Item model
* @param {Object} config Configuration object
* @cfg {jQuery} [$overlay] A jQuery object serving as overlay for popups
*/
* @param {Object} config Configuration object
* @cfg {jQuery} [$overlay] A jQuery object serving as overlay for popups
*/
- mw.rcfilters.ui.TagItemWidget = function MwRcfiltersUiTagItemWidget( controller, model, config ) {
+ mw.rcfilters.ui.TagItemWidget = function MwRcfiltersUiTagItemWidget(
+ controller, filtersViewModel, invertModel, itemModel, config
+ ) {
// Configuration initialization
config = config || {};
this.controller = controller;
// Configuration initialization
config = config || {};
this.controller = controller;
- this.model = model;
+ this.invertModel = invertModel;
+ this.filtersViewModel = filtersViewModel;
+ this.itemModel = itemModel;
this.selected = false;
mw.rcfilters.ui.TagItemWidget.parent.call( this, $.extend( {
this.selected = false;
mw.rcfilters.ui.TagItemWidget.parent.call( this, $.extend( {
- data: this.model.getName(),
- label: $( '<div>' ).html( this.model.getPrefixedLabel() ).contents()
+ data: this.itemModel.getName()
}, config ) );
this.$overlay = config.$overlay || this.$element;
}, config ) );
this.$overlay = config.$overlay || this.$element;
@@
-49,10
+54,12
@@
.addClass( 'mw-rcfilters-ui-tagItemWidget-highlight' );
// Add title attribute with the item label to 'x' button
.addClass( 'mw-rcfilters-ui-tagItemWidget-highlight' );
// Add title attribute with the item label to 'x' button
- this.closeButton.setTitle( mw.msg( 'rcfilters-tag-remove', this.
m
odel.getLabel() ) );
+ this.closeButton.setTitle( mw.msg( 'rcfilters-tag-remove', this.
itemM
odel.getLabel() ) );
// Events
// Events
- this.model.connect( this, { update: 'onModelUpdate' } );
+ this.filtersViewModel.connect( this, { highlightChange: 'updateUiBasedOnState' } );
+ this.invertModel.connect( this, { update: 'updateUiBasedOnState' } );
+ this.itemModel.connect( this, { update: 'updateUiBasedOnState' } );
// Initialization
this.$overlay.append( this.popup.$element );
// Initialization
this.$overlay.append( this.popup.$element );
@@
-63,8
+70,7
@@
.on( 'mouseenter', this.onMouseEnter.bind( this ) )
.on( 'mouseleave', this.onMouseLeave.bind( this ) );
.on( 'mouseenter', this.onMouseEnter.bind( this ) )
.on( 'mouseleave', this.onMouseLeave.bind( this ) );
- this.setCurrentMuteState();
- this.setHighlightColor();
+ this.updateUiBasedOnState();
};
/* Initialization */
};
/* Initialization */
@@
-77,17
+83,34
@@
/**
* Respond to model update event
*/
/**
* Respond to model update event
*/
- mw.rcfilters.ui.TagItemWidget.prototype.onModelUpdate = function () {
- this.setCurrentMuteState();
-
+ mw.rcfilters.ui.TagItemWidget.prototype.updateUiBasedOnState = function () {
// Update label if needed
// Update label if needed
- this.setLabel( $( '<div>' ).html( this.model.getPrefixedLabel() ).contents() );
+ var labelMsg = this.itemModel.getLabelMessageKey( this.invertModel.isSelected() );
+ if ( labelMsg ) {
+ this.setLabel( $( '<div>' ).append(
+ $( '<bdi>' ).html(
+ mw.message( labelMsg, mw.html.escape( this.itemModel.getLabel() ) ).parse()
+ )
+ ).contents() );
+ } else {
+ this.setLabel(
+ $( '<bdi>' ).append(
+ this.itemModel.getLabel()
+ )
+ );
+ }
+ this.setCurrentMuteState();
this.setHighlightColor();
};
this.setHighlightColor();
};
+ /**
+ * Set the current highlight color for this item
+ */
mw.rcfilters.ui.TagItemWidget.prototype.setHighlightColor = function () {
mw.rcfilters.ui.TagItemWidget.prototype.setHighlightColor = function () {
- var selectedColor = this.model.isHighlightEnabled() ? this.model.getHighlightColor() : null;
+ var selectedColor = this.filtersViewModel.isHighlightEnabled() && this.itemModel.isHighlighted ?
+ this.itemModel.getHighlightColor() :
+ null;
this.$highlight
.attr( 'data-color', selectedColor )
this.$highlight
.attr( 'data-color', selectedColor )
@@
-106,7
+129,7
@@
* Respond to mouse enter event
*/
mw.rcfilters.ui.TagItemWidget.prototype.onMouseEnter = function () {
* Respond to mouse enter event
*/
mw.rcfilters.ui.TagItemWidget.prototype.onMouseEnter = function () {
- var labelText = this.
m
odel.getStateMessage();
+ var labelText = this.
itemM
odel.getStateMessage();
if ( labelText ) {
this.popupLabel.setLabel( labelText );
if ( labelText ) {
this.popupLabel.setLabel( labelText );
@@
-165,7
+188,7
@@
* @return {string} Filter name
*/
mw.rcfilters.ui.TagItemWidget.prototype.getName = function () {
* @return {string} Filter name
*/
mw.rcfilters.ui.TagItemWidget.prototype.getName = function () {
- return this.
m
odel.getName();
+ return this.
itemM
odel.getName();
};
/**
};
/**
@@
-174,7
+197,7
@@
* @return {string} Filter model
*/
mw.rcfilters.ui.TagItemWidget.prototype.getModel = function () {
* @return {string} Filter model
*/
mw.rcfilters.ui.TagItemWidget.prototype.getModel = function () {
- return this.
m
odel;
+ return this.
itemM
odel;
};
/**
};
/**
@@
-183,7
+206,7
@@
* @return {string} Filter view
*/
mw.rcfilters.ui.TagItemWidget.prototype.getView = function () {
* @return {string} Filter view
*/
mw.rcfilters.ui.TagItemWidget.prototype.getView = function () {
- return this.
m
odel.getGroupModel().getView();
+ return this.
itemM
odel.getGroupModel().getView();
};
/**
};
/**
@@
-194,7
+217,7
@@
this.popup.$element.detach();
// Disconnect events
this.popup.$element.detach();
// Disconnect events
- this.
m
odel.disconnect( this );
+ this.
itemM
odel.disconnect( this );
this.closeButton.disconnect( this );
};
}( mediaWiki, jQuery ) );
this.closeButton.disconnect( this );
};
}( mediaWiki, jQuery ) );