filtersWidget = new mw.rcfilters.ui.FilterWrapperWidget(
controller, filtersModel, { $overlay: $overlay } );
+ // TODO: The changesListWrapperWidget should be able to initialize
+ // after the model is ready.
// eslint-disable-next-line no-new
new mw.rcfilters.ui.ChangesListWrapperWidget(
filtersModel, changesListModel, $( '.mw-changeslist, .mw-changeslist-empty' ) );
- // eslint-disable-next-line no-new
- new mw.rcfilters.ui.FormWrapperWidget(
- changesListModel, controller, $( 'fieldset.rcoptions' ) );
-
controller.initialize( {
registration: {
title: mw.msg( 'rcfilters-filtergroup-registration' ),
}
} );
+ // eslint-disable-next-line no-new
+ new mw.rcfilters.ui.FormWrapperWidget(
+ filtersModel, changesListModel, controller, $( 'fieldset.rcoptions' ) );
+
$( '.rcfilters-container' ).append( filtersWidget.$element );
$( 'body' ).append( $overlay );
- // HACK: Remove old-style filter links for filters handled by the widget
- // Ideally the widget would handle all filters and we'd just remove .rcshowhide entirely
- $( '.rcshowhide' ).children().each( function () {
- // HACK: Interpret the class name to get the filter name
- // This should really be set as a data attribute
- var i,
- name = null,
- // Some of the older browsers we support don't have .classList,
- // so we have to interpret the class attribute manually.
- classes = this.getAttribute( 'class' ).split( ' ' );
- for ( i = 0; i < classes.length; i++ ) {
- if ( classes[ i ].substr( 0, 'rcshow'.length ) === 'rcshow' ) {
- name = classes[ i ].substr( 'rcshow'.length );
- break;
- }
- }
- if ( name === null ) {
- return;
- }
- if ( name === 'hidemine' ) {
- // HACK: the span for hidemyself is called hidemine
- name = 'hidemyself';
- }
- // This span corresponds to a filter that's in our model, so remove it
- if ( filtersModel.getItemByName( name ) ) {
- // 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.
- if ( this.nextSibling && this.nextSibling.nodeType === Node.TEXT_NODE ) {
- this.parentNode.removeChild( this.nextSibling );
- } else if ( this.previousSibling && this.previousSibling.nodeType === Node.TEXT_NODE ) {
- this.parentNode.removeChild( this.previousSibling );
- }
- // Remove the span itself
- this.parentNode.removeChild( this );
- }
- } );
+ // Set as ready
+ $( '.rcfilters-head' ).addClass( 'mw-rcfilters-ui-ready' );
window.addEventListener( 'popstate', function () {
+ controller.updateStateBasedOnUrl();
controller.updateChangesList();
} );
+
+ $( 'a.mw-helplink' ).attr(
+ 'href',
+ 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:New_filters_for_edit_review'
+ );
+
+ controller.replaceUrl();
}
};