Merge "Show redirect fragments on Special:BrokenRedirects"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.FormWrapperWidget.js
index dbee65c..82992fb 100644 (file)
@@ -19,8 +19,6 @@
                mw.rcfilters.ui.FormWrapperWidget.parent.call( this, $.extend( {}, config, {
                        $element: $formRoot
                } ) );
-               // Mixin constructors
-               OO.ui.mixin.PendingElement.call( this, config );
 
                this.changeListModel = changeListModel;
                this.filtersModel = filtersModel;
@@ -48,7 +46,6 @@
        /* Initialization */
 
        OO.inheritClass( mw.rcfilters.ui.FormWrapperWidget, OO.ui.Widget );
-       OO.mixinClass( mw.rcfilters.ui.FormWrapperWidget, OO.ui.mixin.PendingElement );
 
        /**
         * Respond to link click
@@ -89,8 +86,8 @@
         * Respond to model invalidate
         */
        mw.rcfilters.ui.FormWrapperWidget.prototype.onChangesModelInvalidate = function () {
-               this.pushPending();
                this.$submitButton.prop( 'disabled', true );
+               this.$element.removeClass( 'mw-rcfilters-ui-ready' );
        };
 
        /**
         *
         * @param {jQuery|string} $changesList Updated changes list
         * @param {jQuery} $fieldset Updated fieldset
+        * @param {boolean} isInitialDOM Whether $changesListContent is the existing (already attached) DOM
         */
-       mw.rcfilters.ui.FormWrapperWidget.prototype.onChangesModelUpdate = function ( $changesList, $fieldset ) {
+       mw.rcfilters.ui.FormWrapperWidget.prototype.onChangesModelUpdate = function ( $changesList, $fieldset, isInitialDOM ) {
                this.$submitButton.prop( 'disabled', false );
+               this.$element.removeClass( 'mw-rcfilters-ui-ready' );
 
                // Replace the entire fieldset
                this.$element.empty().append( $fieldset.contents() );
-               // Make sure enhanced RC re-initializes correctly
-               mw.hook( 'wikipage.content' ).fire( this.$element );
 
-               this.cleanUpFieldset();
+               if ( !isInitialDOM ) {
+                       // Make sure enhanced RC re-initializes correctly
+                       mw.hook( 'wikipage.content' ).fire( this.$element );
+               }
 
-               this.popPending();
+               this.cleanUpFieldset();
        };
 
        /**
                } );
 
                // Hide namespaces and tags
-               if ( mw.config.get( 'wgStructuredChangeFiltersEnableExperimentalViews' ) ) {
-                       $namespaceSelect.closest( 'tr' ).detach();
-                       this.$element.find( '.mw-tagfilter-label' ).closest( 'tr' ).detach();
-               }
+               $namespaceSelect.closest( 'tr' ).detach();
+               this.$element.find( '.mw-tagfilter-label' ).closest( 'tr' ).detach();
+
+               // Hide limit and days
+               this.$element.find( '.rclinks' ).detach();
 
                if ( !this.$element.find( '.mw-recentchanges-table tr' ).length ) {
+                       this.$element.find( '.mw-recentchanges-table' ).detach();
                        this.$element.find( 'hr' ).detach();
                }
+
+               if ( !this.$element.find( '.rcshowhide' ).contents().length ) {
+                       this.$element.find( '.rcshowhide' ).detach();
+                       // If we're hiding rcshowhide, the '<br>'s are around it,
+                       // there's no need for them either.
+                       this.$element.find( 'br' ).detach();
+               }
+
+               if ( mw.rcfilters.featureFlags.liveUpdate ) {
+                       this.$element.find(
+                               'legend, .rclistfrom, .rcnotefrom, .rcoptions-listfromreset'
+                       ).detach();
+               }
+
+               if ( this.$element.text().trim() === '' ) {
+                       this.$element.detach();
+               }
        };
 }( mediaWiki ) );