2018-12-06 17:42:31 +00:00
|
|
|
( function () {
|
2018-04-11 02:25:55 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-12-06 17:27:46 +00:00
|
|
|
function invertSelections() {
|
|
|
|
var form = document.getElementById( 'choose_pages' ),
|
|
|
|
numElements = form.elements.length,
|
|
|
|
i,
|
|
|
|
curElement;
|
2018-04-11 02:25:55 +00:00
|
|
|
|
2018-12-06 17:27:46 +00:00
|
|
|
for ( i = 0; i < numElements; i++ ) {
|
|
|
|
curElement = form.elements[ i ];
|
2018-04-11 02:25:55 +00:00
|
|
|
|
2018-12-06 17:27:46 +00:00
|
|
|
if ( curElement.type === 'checkbox' && curElement.id !== 'create-redirect' &&
|
2023-08-08 15:39:55 +00:00
|
|
|
curElement.id !== 'watch-pages' && curElement.id !== 'botEdit' ) {
|
2021-07-03 06:30:07 +00:00
|
|
|
curElement.checked = !curElement.checked;
|
2018-12-06 17:27:46 +00:00
|
|
|
}
|
2018-04-11 02:25:55 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-26 14:57:24 +00:00
|
|
|
|
|
|
|
$( function () {
|
SpecialReplaceText: Migrate deprecated Xml usage to Html class
```
Xml::textarea( $name, $content, $cols = 40, $rows = 5, $attribs );
Xml::input( $name, $size = false, $value = false, $attribs );
Xml::checkLabel( $label, $name, $id, $checked = false, $attribs );
```
For examples of trouble with Xml::checkLabel, see also I61c8f67127 in
CentralAuth and I33bf6ab5e0 in MediaWiki core. For improved clarify,
I'm replacing most of these with Html::element().
While at it, I'm also migrating `<input id=…><label for=…>…</label>`
to the simpler `<label><input>…</label>` form where this is easy to
do.
ext.ReplaceTextStyles.less has styles for label/input inside
`.ext-replacetext-search-togglebox`, which this patch leaves unchanged.
ext.ReplaceText.js refers to the IDs of namespace checkboxes,
which this change keeps in-tact. In the future, the namespace
checkbox HTML could be simplified further if the JS code selects by
`name` instead of `id`.
Test Plan:
* Given `wfLoadExtension('ReplaceText');` in LocalSettings.php,
and a Main_Page containing the word "installed".
* View Special:ReplaceText, verify it renders without errors,
and each label is click-associated with its checkbox.
* Find "Main", Replace "Minor",
tick "(Main)" namespace, tick "Replace text in page titles".
* Continue
* Verify the checkboxes under "For moved pages:" are also
associated with their labels.
Change-Id: I2060961115b7af23dcf086ed03bfa3f159f5302c
2024-03-27 02:17:49 +00:00
|
|
|
var $checkboxes = $( '#powersearch input[id^="mw-search-ns"]' );
|
2018-12-22 18:21:47 +00:00
|
|
|
|
2018-12-23 16:50:58 +00:00
|
|
|
$( '.ext-replacetext-invert' ).on( 'click', invertSelections );
|
2018-12-22 18:21:47 +00:00
|
|
|
|
2018-12-23 14:40:55 +00:00
|
|
|
// Attach handler for check all/none buttons
|
|
|
|
$( '#mw-search-toggleall' ).on( 'click', function () {
|
|
|
|
$checkboxes.prop( 'checked', true );
|
|
|
|
} );
|
|
|
|
$( '#mw-search-togglenone' ).on( 'click', function () {
|
|
|
|
$checkboxes.prop( 'checked', false );
|
|
|
|
} );
|
2018-04-26 14:57:24 +00:00
|
|
|
} );
|
2018-12-06 17:42:31 +00:00
|
|
|
}() );
|