w/extensions/MobileFrontend/resources/mobile.special.mobileoptions.scripts/mobileoptions.js
/**
	 * Add features, that depends on localStorage, such as "exapnd all sections" or "fontchanger".
	 * The checkbox is used for turning on/off expansion of all sections on page load.
	 * @method
	 * @ignore
	 */
Add features, that depends on localStorage, such as "exapnd all sections" or "fontchanger".
The checkbox is used for turning on/off expansion of all sections on page load.
@method
@ignore
Add features that depends on localStorage such as " exapnd all sections " or " fontchanger " . The checkbox is used for turning on / off expansion of all sections on page load . @method @ignore
function initLocalStorageElements() {
		var toggleSwitch,
			enableToggle = OO.ui.infuse( $( '#enable-beta-toggle' ) ),
			$checkbox = enableToggle.$element,
			$form = $( '#mobile-options' );
		toggleSwitch = new OO.ui.ToggleSwitchWidget( {
			value: enableToggle.isSelected()
		} );
		toggleSwitch.$element.insertAfter( $checkbox );
		$checkbox.hide();
		$checkbox.on( 'change', function () {
			$checkbox.attr( 'disabled', true );
			toggleSwitch.setValue( enableToggle.isSelected() );
		} );
		toggleSwitch.on( 'change', function ( value ) {
			toggleSwitch.setValue = function () {};
			$checkbox.find( 'input' )
				.prop( 'checked', value );
			notify( true );
			setTimeout( function () {
				$form.submit();
			}, 250 );
		} );
		if ( mw.config.get( 'wgMFExpandAllSectionsUserOption' ) &&
			!browser.isWideScreen()
		) {
			addExpandAllSectionsToForm( $form );
		}
		if ( mw.config.get( 'wgMFEnableFontChanger' ) ) {
			addFontChangerToForm( $form );
		}
	}
function initLocalStorageElements ( ) { var toggleSwitch , enableToggle = OO . ui . infuse ( $ ( '#enable-beta-toggle' ) ) , $checkbox = enableToggle . $element , $form = $ ( '#mobile-options' ) ; toggleSwitch = new OO . ui . ToggleSwitchWidget ( { value : enableToggle . isSelected ( ) } ) ; toggleSwitch . $element . insertAfter ( $checkbox ) ; $checkbox . hide ( ) ; $checkbox . on ( 'change' , function ( ) { $checkbox . attr ( 'disabled' , true ) ; toggleSwitch . setValue ( enableToggle . isSelected ( ) ) ; } ) ; toggleSwitch . on ( 'change' , function ( value ) { toggleSwitch . setValue = function ( ) { } ; $checkbox . find ( 'input' ) . prop ( 'checked' , value ) ; notify ( true ) ; setTimeout ( function ( ) { $form . submit ( ) ; } , 250 ) ; } ) ; if ( mw . config . get ( 'wgMFExpandAllSectionsUserOption' ) && ! browser . isWideScreen ( ) ) { addExpandAllSectionsToForm ( $form ) ; } if ( mw . config . get ( 'wgMFEnableFontChanger' ) ) { addFontChangerToForm ( $form ) ; } }
Add features, that depends on localStorage, such as "exapnd all sections" or "fontchanger".
Add features that depends on localStorage such as " exapnd all sections " or " fontchanger " .
// Strangely the ToggleSwitchWidget does not behave as an input so any change // to it is not reflected in the form. (see T182466) // Ideally we'd replaceWith here and not have to hide the original element. // although the checkbox is hidden already, that is done via visibility // as a result, it still takes up space. We don't want it to any more now that the // new toggle switch has been added. // 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 // disable checkbox as submit is delayed by 0.25s // ugly hack, we're delaying submit form by 0.25s and we want to disable registering clicks // we want to disable the toggleSwitch but we cannot use setDisabled(true) as it makes button gray // On some Android devices animation gets stuck in the middle as browser starts submitting the form. // Let's call submit on the form after toggle button transition is done (0.25s, defined in OOUI) // Don't show this option on large screens since it's only honored for small screens. This // logic should be kept in sync with Toggle._enable().