mediawiki-extensions-Replac.../resources/ext.ReplaceText.js
Fomafix a316c0f08f Avoid using core module 'mediawiki.special.search'
The core module 'mediawiki.special.search' contains more functions
which are not needed here and which causes an error message in the
JavaScript console. (T211384)

This change copies the used part of module 'mediawiki.special.search'
to the local module 'ext.ReplaceText'.

The CSS file for the style module 'ext.ReplaceTextStyles' is renamed
from ext.ReplaceText.css to ext.ReplaceTextStyles.css to make
ext.ReplaceText.css free for the CSS part of module 'ext.ReplaceText'.

Bug: T211384
Change-Id: I41225ccdf8a95a7c501fb6eea99abbd08353f4ea
2018-12-22 20:32:33 +01:00

48 lines
1.3 KiB
JavaScript

( function () {
'use strict';
function invertSelections() {
var form = document.getElementById( 'choose_pages' ),
numElements = form.elements.length,
i,
curElement;
for ( i = 0; i < numElements; i++ ) {
curElement = form.elements[ i ];
if ( curElement.type === 'checkbox' && curElement.id !== 'create-redirect' &&
curElement.id !== 'watch-pages' && curElement.id !== 'doAnnounce' ) {
form.elements[ i ].checked = form.elements[ i ].checked !== true;
}
}
}
$( function () {
var $checkboxes = $( '#powersearch input[id^=mw-search-ns]' );
$( '#replacetext-invert' )
.on( 'click', invertSelections )
.prop( 'disabled', false );
// Create check all/none button
$( '#mw-search-togglebox' ).append(
$( '<label>' )
.text( mw.msg( 'powersearch-togglelabel' ) )
).append(
$( '<input>' ).attr( 'type', 'button' )
.attr( 'id', 'mw-search-toggleall' )
.prop( 'value', mw.msg( 'powersearch-toggleall' ) )
.click( function () {
$checkboxes.prop( 'checked', true );
} )
).append(
$( '<input>' ).attr( 'type', 'button' )
.attr( 'id', 'mw-search-togglenone' )
.prop( 'value', mw.msg( 'powersearch-togglenone' ) )
.click( function () {
$checkboxes.prop( 'checked', false );
} )
);
} );
}() );