jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/398889 )
Change subject: Toggle the Beta toggle when user clicks on label
......................................................................
Toggle the Beta toggle when user clicks on label
The beta checkbox is generated by PHP and then it's
"infused" via Javascript which lacks some fuctionalities.
To make it working we had to listen on toggle switch and
manually update the checkbox.
What we also have to do is
to listen on checkbox changes (triggered by clicking on the
label) and update the toggle plus submit the form. This task
does that.
Bug: T169807
Change-Id: I738d2dfb37608218c841a5d2014734faf5e16cae
---
M includes/specials/SpecialMobileOptions.php
M resources/mobile.special.mobileoptions.scripts/mobileoptions.js
2 files changed, 28 insertions(+), 21 deletions(-)
Approvals:
Bmansurov: Looks good to me, but someone else must approve
jenkins-bot: Verified
Jdlrobson: Looks good to me, approved
diff --git a/includes/specials/SpecialMobileOptions.php
b/includes/specials/SpecialMobileOptions.php
index 4401371..ea5d4be 100644
--- a/includes/specials/SpecialMobileOptions.php
+++ b/includes/specials/SpecialMobileOptions.php
@@ -95,29 +95,30 @@
// beta settings
if ( $this->getMFConfig()->get( 'MFEnableBeta' ) ) {
+ $input = new OOUI\CheckboxInputWidget( [
+ 'name' => 'enableBeta',
+ 'infusable' => true,
+ 'selected' => $context->isBetaGroupMember(),
+ 'id' => 'enable-beta-toggle',
+ 'value' => '1',
+ ] );
$fields[] = new OOUI\FieldLayout(
- new OOUI\CheckboxInputWidget( [
- 'name' => 'enableBeta',
- 'infusable' => true,
- 'selected' =>
$context->isBetaGroupMember(),
- 'id' => 'enable-beta-toggle',
- 'value' => '1',
- ] ),
+ $input,
[
- 'label' => new OOUI\LabelWidget( [
- 'label' => new OOUI\HtmlSnippet(
- Html::openElement(
'div' ) .
- Html::element(
'strong', [],
- $this->msg(
'mobile-frontend-settings-beta' )->parse() ) .
- Html::element( 'div', [
'class' => 'option-description' ],
- $this->msg(
'mobile-frontend-opt-in-explain' )->parse()
- ) .
- Html::closeElement(
'div' )
- )
- ] ),
- 'id' => 'beta-field',
- ]
- );
+ 'label' => new OOUI\LabelWidget( [
+ 'input' => $input,
+ 'label' => new OOUI\HtmlSnippet(
+ Html::openElement( 'div' ) .
+ Html::element( 'strong', [],
+ $this->msg(
'mobile-frontend-settings-beta' )->parse() ) .
+ Html::element( 'div', [ 'class'
=> 'option-description' ],
+ $this->msg(
'mobile-frontend-opt-in-explain' )->parse()
+ ) .
+ Html::closeElement( 'div' )
+ )
+ ] ),
+ 'id' => 'beta-field',
+ ] );
}
$fields[] = new OOUI\ButtonInputWidget( [
diff --git a/resources/mobile.special.mobileoptions.scripts/mobileoptions.js
b/resources/mobile.special.mobileoptions.scripts/mobileoptions.js
index 32efb16..8171650 100644
--- a/resources/mobile.special.mobileoptions.scripts/mobileoptions.js
+++ b/resources/mobile.special.mobileoptions.scripts/mobileoptions.js
@@ -145,6 +145,12 @@
// new toggle switch has been added.
$checkbox.hide();
+ // listening on checkbox change is required to make the
clicking on label working. Otherwise
+ // clicking on label changes the checkbox "checked" state but
it's not reflected in the toggle switch
+ $checkbox.on( 'change', function () {
+ toggleSwitch.setValue( enableToggle.isSelected() );
+ } );
+
toggleSwitch.on( 'change', function ( value ) {
$checkbox.find( 'input' )
.prop( 'checked', value );
--
To view, visit https://gerrit.wikimedia.org/r/398889
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I738d2dfb37608218c841a5d2014734faf5e16cae
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: specialpages
Gerrit-Owner: Pmiazga <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Pmiazga <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits