X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fui%2Fmw.rcfilters.ui.FormWrapperWidget.js;h=ee8e0bc1b9c4710edf4f8c36ffbe073b8b7e47fa;hb=1d7a1bf8bddf0908e4f572c82268733f63126a13;hp=dbee65c776882386033db725fbb11fcea757a7eb;hpb=9fde467caca76dbefb984f23736904cf8f2bcdb8;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js index dbee65c776..cfcdf353a9 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js @@ -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' ); }; /** @@ -99,27 +96,28 @@ * * @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(); }; /** * 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' ); - - this.$element.find( '.rcshowhideoption[data-feature-in-structured-ui=1]' ).each( function () { + this.$element.find( '.clshowhideoption[data-feature-in-structured-ui=1]' ).each( function () { // HACK: Remove the text node after the span. // If there isn't one, we're at the end, so remove the text node before the span. // This would be unnecessary if we added separators with CSS. @@ -133,13 +131,41 @@ } ); // Hide namespaces and tags - if ( mw.config.get( 'wgStructuredChangeFiltersEnableExperimentalViews' ) ) { - $namespaceSelect.closest( 'tr' ).detach(); - this.$element.find( '.mw-tagfilter-label' ).closest( 'tr' ).detach(); - } + this.$element.find( '.namespaceForm' ).detach(); + this.$element.find( '.mw-tagfilter-label' ).closest( 'tr' ).detach(); + + // misc: limit, days, watchlist info msg + this.$element.find( '.rclinks, .cldays, .wlinfo' ).detach(); if ( !this.$element.find( '.mw-recentchanges-table tr' ).length ) { + this.$element.find( '.mw-recentchanges-table' ).detach(); this.$element.find( 'hr' ).detach(); } + + // Get rid of all
s, which are inside rcshowhide + // If we still have content in rcshowhide, the
s are + // gone. Instead, the CSS now has a rule to mark all s + // inside .rcshowhide with display:block; to simulate newlines + // where they're actually needed. + this.$element.find( 'br' ).detach(); + if ( !this.$element.find( '.rcshowhide' ).contents().length ) { + this.$element.find( '.rcshowhide' ).detach(); + } + + if ( this.$element.find( '.cloption' ).text().trim() === '' ) { + this.$element.find( '.cloption-submit' ).detach(); + } + + this.$element.find( + '.rclistfrom, .rcnotefrom, .rcoptions-listfromreset' + ).detach(); + + // Get rid of the legend + this.$element.find( 'legend' ).detach(); + + // Check if the element is essentially empty, and detach it if it is + if ( !this.$element.text().trim().length ) { + this.$element.detach(); + } }; }( mediaWiki ) );