From fd8a4c707a9c053ccf20ba0594cfc9c11354a374 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 18 Apr 2018 03:14:30 +0100 Subject: [PATCH] installer: Clean up ext-dependency jQuery code Follows-up c8833d8e8ecc. * Select the input elements by class to avoid accidentally trigging on unrelated elements elsewhere on the page in the future, given the generic selector. * Use on('change') instead of deprecated change() alias. * Set properties directly instead of via prop() indirection. * Get attribute directly instead of via data() indirection. Change-Id: I5158aa26b5fd7327d6795f0a31bbffbe99043fbf --- includes/installer/WebInstallerOptions.php | 5 ++++- mw-config/config.js | 19 ++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/includes/installer/WebInstallerOptions.php b/includes/installer/WebInstallerOptions.php index 2027c978af..d798ea1e1a 100644 --- a/includes/installer/WebInstallerOptions.php +++ b/includes/installer/WebInstallerOptions.php @@ -175,7 +175,10 @@ class WebInstallerOptions extends WebInstallerPage { if ( isset( $info['url'] ) ) { $urlText = ' ' . Html::element( 'a', [ 'href' => $info['url'] ], '(more information)' ); } - $attribs = [ 'data-name' => $ext ]; + $attribs = [ + 'data-name' => $ext, + 'class' => 'config-ext-input' + ]; $labelAttribs = []; $fullDepList = []; if ( isset( $info['requires']['extensions'] ) ) { diff --git a/mw-config/config.js b/mw-config/config.js index ab57b7b859..bb62067e2e 100644 --- a/mw-config/config.js +++ b/mw-config/config.js @@ -87,7 +87,7 @@ } ); // Synchronize radio button label for sitename with textbox - $label = $( 'label[for=config__NamespaceType_site-name]' ); + $label = $( 'label[for="config__NamespaceType_site-name"]' ); labelText = $label.text(); $label.text( labelText.replace( '$1', '' ) ); $( '#config_wgSitename' ).on( 'keyup change', syncText ).each( syncText ); @@ -132,19 +132,16 @@ // Disable checkboxes if the extension has dependencies $( '.mw-ext-with-dependencies input' ).prop( 'disabled', true ); - $( 'input[data-name]' ).change( function () { + $( '.config-ext-input[data-name]' ).on( 'change', function () { $( '.mw-ext-with-dependencies input' ).each( function () { - var $this = $( this ), - name = $this.data( 'name' ); + var name = this.getAttribute( 'data-name' ); if ( areReqsSatisfied( name ) ) { - // Un-disable it! - $this.prop( 'disabled', false ); + // Re-enable it! + this.disabled = false; } else { - // Disable the checkbox, and uncheck it if it is checked - $this.prop( 'disabled', true ); - if ( $this.prop( 'checked' ) ) { - $this.prop( 'checked', false ); - } + // Uncheck and disable the checkbox + this.checked = false; + this.disabled = true; } } ); } ); -- 2.20.1