Merge "RCFilters: Don't emit wikipage.content on first load"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 18 Jul 2017 23:18:51 +0000 (23:18 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 18 Jul 2017 23:18:51 +0000 (23:18 +0000)
resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js

index c839a13..49c0b82 100644 (file)
         *
         * @param {jQuery|string} changesListContent
         * @param {jQuery} $fieldset
+        * @param {boolean} [isInitialDOM] Using the initial (already attached) DOM elements
         */
-       mw.rcfilters.dm.ChangesListViewModel.prototype.update = function ( changesListContent, $fieldset ) {
+       mw.rcfilters.dm.ChangesListViewModel.prototype.update = function ( changesListContent, $fieldset, isInitialDOM ) {
                this.valid = true;
-               this.emit( 'update', changesListContent, $fieldset );
+               this.emit( 'update', changesListContent, $fieldset, isInitialDOM );
        };
 
 }( mediaWiki ) );
index a9283b9..5dd830b 100644 (file)
                        // so it gets processed
                        this.changesListModel.update(
                                $changesList.length ? $changesList : 'NO_RESULTS',
-                               $( 'fieldset.rcoptions' ).first()
+                               $( 'fieldset.rcoptions' ).first(),
+                               true // We're using existing DOM elements
                        );
                }
 
index 843acce..6512f04 100644 (file)
         * Respond to changes list model update
         *
         * @param {jQuery|string} $changesListContent The content of the updated changes list
+        * @param {jQuery} $fieldset The content of the updated fieldset
+        * @param {boolean} isInitialDOM Whether $changesListContent is the existing (already attached) DOM
         */
-       mw.rcfilters.ui.ChangesListWrapperWidget.prototype.onModelUpdate = function ( $changesListContent ) {
+       mw.rcfilters.ui.ChangesListWrapperWidget.prototype.onModelUpdate = function ( $changesListContent, $fieldset, isInitialDOM ) {
                var conflictItem,
                        $message = $( '<div>' )
                                .addClass( 'mw-rcfilters-ui-changesListWrapperWidget-results' ),
                        // Apply highlight
                        this.applyHighlight();
 
-                       // Make sure enhanced RC re-initializes correctly
-                       mw.hook( 'wikipage.content' ).fire( this.$element );
+                       if ( !isInitialDOM ) {
+                               // Make sure enhanced RC re-initializes correctly
+                               mw.hook( 'wikipage.content' ).fire( this.$element );
+                       }
                }
                this.popPending();
        };
index dbee65c..9c82451 100644 (file)
         *
         * @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 );
 
                // Replace the entire fieldset
                this.$element.empty().append( $fieldset.contents() );
-               // Make sure enhanced RC re-initializes correctly
-               mw.hook( 'wikipage.content' ).fire( this.$element );
+
+               if ( !isInitialDOM ) {
+                       // Make sure enhanced RC re-initializes correctly
+                       mw.hook( 'wikipage.content' ).fire( this.$element );
+               }
 
                this.cleanUpFieldset();