X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fui%2Fmw.rcfilters.ui.FormWrapperWidget.js;h=d17fffffe68cc4a2e6d3067227ecf24d2ff7d8ab;hb=93ba0cc7354e24dc9a9e470eb5628d8b41864024;hp=e914bbe7d949c3796dd94bc319e483b96ffbdc82;hpb=c584722cc2e3d33edae58d46c2149063b3fc6d72;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 e914bbe7d9..d17fffffe6 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js @@ -101,6 +101,8 @@ // 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(); @@ -111,45 +113,42 @@ * Clean up the old-style show/hide that we have implemented in the filter list */ mw.rcfilters.ui.FormWrapperWidget.prototype.cleanUpFieldset = function () { - var widget = this; - - // 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 - this.$element.find( '.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'; + var $namespaceSelect = this.$element.find( '#namespace' ), + $namespaceCheckboxes = this.$element.find( '#nsassociated, #nsinvert' ), + collapseCookieName = 'changeslist-state'; + + this.$element.find( '.rcshowhideoption[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. + 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 ); + } ); - // This span corresponds to a filter that's in our model, so remove it - if ( widget.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 ); - } + // 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' ); + } ); + }; }( mediaWiki ) );