mw.rcfilters.ui.TagItemWidget.parent.call( this, $.extend( {
data: this.model.getName(),
- label: this.model.getLabel()
+ label: $( '<div>' ).html( this.model.getPrefixedLabel() ).contents()
}, config ) );
this.$overlay = config.$overlay || this.$element;
}
}, config ) );
- this.positioned = false;
this.popupTimeoutShow = null;
this.popupTimeoutHide = null;
this.$highlight = $( '<div>' )
.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.model.getLabel() ) );
+
// Events
this.model.connect( this, { update: 'onModelUpdate' } );
mw.rcfilters.ui.TagItemWidget.prototype.onModelUpdate = function () {
this.setCurrentMuteState();
+ // Update label if needed
+ this.setLabel( $( '<div>' ).html( this.model.getPrefixedLabel() ).contents() );
+
this.setHighlightColor();
};
if ( labelText ) {
this.popupLabel.setLabel( labelText );
- if ( !this.positioned ) {
- // Recalculate anchor position to be center of the capsule item
- this.popup.$anchor.css( 'margin-left', ( this.$element.width() / 2 ) );
- this.positioned = true;
- }
-
// Set timeout for the popup to show
this.popupTimeoutShow = setTimeout( function () {
this.popup.toggle( true );
return this.model.getName();
};
+ /**
+ * Get item model
+ *
+ * @return {string} Filter model
+ */
+ mw.rcfilters.ui.TagItemWidget.prototype.getModel = function () {
+ return this.model;
+ };
+
+ /**
+ * Get item view
+ *
+ * @return {string} Filter view
+ */
+ mw.rcfilters.ui.TagItemWidget.prototype.getView = function () {
+ return this.model.getGroupModel().getView();
+ };
+
/**
* Remove and destroy external elements of this widget
*/