// Collect all data from form
$( e.target ).find( 'input:not([type="hidden"],[type="submit"]), select' ).each( function () {
+ var value = '';
+
if ( !$( this ).is( ':checkbox' ) || $( this ).is( ':checked' ) ) {
- data[ $( this ).prop( 'name' ) ] = $( this ).val();
+ value = $( this ).val();
}
+
+ data[ $( this ).prop( 'name' ) ] = value;
} );
this.controller.updateChangesList( data );
*
* @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();
* Clean up the old-style show/hide that we have implemented in the filter list
*/
mw.rcfilters.ui.FormWrapperWidget.prototype.cleanUpFieldset = function () {
- var $namespaceSelect = this.$element.find( '#namespace' ),
- $namespaceCheckboxes = this.$element.find( '#nsassociated, #nsinvert' ),
- collapseCookieName = 'changeslist-state';
+ var $namespaceSelect = this.$element.find( '#namespace' );
this.$element.find( '.rcshowhideoption[data-feature-in-structured-ui=1]' ).each( function () {
// HACK: Remove the text node after the span.
this.parentNode.removeChild( this );
} );
- // Bind namespace select to change event
- // see resources/src/mediawiki.special/mediawiki.special.recentchanges.js
- $namespaceCheckboxes.prop( 'disabled', $namespaceSelect.val() === '' );
- $namespaceSelect.on( 'change', function () {
- $namespaceCheckboxes.prop( 'disabled', $( this ).val() === '' );
- } );
-
- // Collapse legend
- // see resources/src/mediawiki.special/mediawiki.special.changelist.legend.js
- this.$element.find( '.mw-changeslist-legend' )
- .makeCollapsible( {
- collapsed: mw.cookie.get( collapseCookieName ) === 'collapsed'
- } )
- .on( 'beforeExpand.mw-collapsible', function () {
- mw.cookie.set( collapseCookieName, 'expanded' );
- } )
- .on( 'beforeCollapse.mw-collapsible', function () {
- mw.cookie.set( collapseCookieName, 'collapsed' );
- } );
-
+ // Hide namespaces and tags
+ if ( mw.config.get( 'wgStructuredChangeFiltersEnableExperimentalViews' ) ) {
+ $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();
+ }
};
}( mediaWiki ) );