Merge "Skin: Make skins aware of their registered skin name"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.FilterMenuHeaderWidget.js
index eeb5ddc..dceb132 100644 (file)
                } );
                this.backButton.toggle( this.model.getCurrentView() !== 'default' );
 
+               // Help icon for Tagged edits
+               this.helpIcon = new OO.ui.ButtonWidget( {
+                       icon: 'help',
+                       framed: false,
+                       title: mw.msg( 'rcfilters-view-tags-help-icon-tooltip' ),
+                       classes: [ 'mw-rcfilters-ui-filterMenuHeaderWidget-helpIcon' ],
+                       href: mw.util.getUrl( 'Special:Tags' ),
+                       target: '_blank'
+               } );
+               this.helpIcon.toggle( this.model.getCurrentView() === 'tags' );
+
                // Highlight button
                this.highlightButton = new OO.ui.ToggleButtonWidget( {
                        icon: 'highlight',
@@ -48,7 +59,6 @@
                        classes: [ 'mw-rcfilters-ui-filterMenuHeaderWidget-invertNamespacesButton' ]
                } );
                this.invertNamespacesButton.toggle( this.model.getCurrentView() === 'namespaces' );
-               this.updateInvertButton( this.model.areNamespacesInverted() );
 
                // Events
                this.backButton.connect( this, { click: 'onBackButtonClick' } );
@@ -58,8 +68,8 @@
                        .connect( this, { click: 'onInvertNamespacesButtonClick' } );
                this.model.connect( this, {
                        highlightChange: 'onModelHighlightChange',
-                       invertChange: 'onModelInvertChange',
-                       update: 'onModelUpdate'
+                       update: 'onModelUpdate',
+                       initialize: 'onModelInitialize'
                } );
 
                // Initialize
@@ -80,7 +90,7 @@
                                                                $( '<div>' )
                                                                        .addClass( 'mw-rcfilters-ui-cell' )
                                                                        .addClass( 'mw-rcfilters-ui-filterMenuHeaderWidget-header-title' )
-                                                                       .append( this.$label ),
+                                                                       .append( this.$label, this.helpIcon.$element ),
                                                                $( '<div>' )
                                                                        .addClass( 'mw-rcfilters-ui-cell' )
                                                                        .addClass( 'mw-rcfilters-ui-filterMenuHeaderWidget-header-invert' )
 
        /* Methods */
 
+       /**
+        * Respond to model initialization event
+        *
+        * Note: need to wait for initialization before getting the invertModel
+        * and registering its update event. Creating all the models before the UI
+        * would help with that.
+        */
+       mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.onModelInitialize = function () {
+               this.invertModel = this.model.getInvertModel();
+               this.updateInvertButton();
+               this.invertModel.connect( this, { update: 'updateInvertButton' } );
+       };
+
        /**
         * Respond to model update event
         */
 
                this.invertNamespacesButton.toggle( currentView === 'namespaces' );
                this.backButton.toggle( currentView !== 'default' );
+               this.helpIcon.toggle( currentView === 'tags' );
        };
 
        /**
                this.highlightButton.setActive( highlightEnabled );
        };
 
-       /**
-        * Respond to model invert change event
-        *
-        * @param {boolean} isInverted Namespaces selection is inverted
-        */
-       mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.onModelInvertChange = function ( isInverted ) {
-               this.updateInvertButton( isInverted );
-       };
-
        /**
         * Update the state of the invert button
-        *
-        * @param {boolean} isInverted Namespaces selection is inverted
         */
-       mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.updateInvertButton = function ( isInverted ) {
-               this.invertNamespacesButton.setActive( isInverted );
+       mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.updateInvertButton = function () {
+               this.invertNamespacesButton.setActive( this.invertModel.isSelected() );
                this.invertNamespacesButton.setLabel(
-                       isInverted ?
+                       this.invertModel.isSelected() ?
                                mw.msg( 'rcfilters-exclude-button-on' ) :
                                mw.msg( 'rcfilters-exclude-button-off' )
                );