mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-18 03:31:34 +00:00
5593b23aa8
Replace all occurrences of `M.require( 'mobile.startup/pathToModule' )` with `M.require( 'mobile.startup' ).pathToModule`. Where multiple requires existed, add an intermediate variable, `var mobile = M.require( 'mobile.startup' )`, and dot off that. This changes improves the consistency of MinervaNeue which currently contains a mix of require styles and eliminates any deprecated requires. Bug: T208915 Change-Id: If14f280672d914d07275197100b12421bb217b67
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
/*
|
|
* Warn people if they're trying to switch to desktop but have cookies disabled.
|
|
*/
|
|
|
|
( function ( M ) {
|
|
|
|
var popup = M.require( 'mobile.startup' ).toast;
|
|
|
|
/**
|
|
* Checks whether cookies are enabled
|
|
* @method
|
|
* @ignore
|
|
* @return {boolean} Whether cookies are enabled
|
|
*/
|
|
function cookiesEnabled() {
|
|
// If session cookie already set, return true
|
|
if ( $.cookie( 'mf_testcookie' ) === 'test_value' ) {
|
|
return true;
|
|
// Otherwise try to set mf_testcookie and return true if it was set
|
|
} else {
|
|
$.cookie( 'mf_testcookie', 'test_value', {
|
|
path: '/'
|
|
} );
|
|
return $.cookie( 'mf_testcookie' ) === 'test_value';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* An event handler for the toggle to desktop link.
|
|
* If cookies are enabled it will redirect you to desktop site as described in
|
|
* the link href associated with the handler.
|
|
* If cookies are not enabled, show a toast and die.
|
|
* @method
|
|
* @ignore
|
|
* @return {boolean|undefined}
|
|
*/
|
|
function desktopViewClick() {
|
|
if ( !cookiesEnabled() ) {
|
|
popup.show(
|
|
mw.msg( 'mobile-frontend-cookies-required' ),
|
|
'error'
|
|
);
|
|
// Prevent default action
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// eslint-disable-next-line jquery/no-global-selector
|
|
$( '#mw-mf-display-toggle' ).on( 'click', desktopViewClick );
|
|
|
|
}( mw.mobileFrontend ) );
|