mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-18 11:35:54 +00:00
2cc9516cde
This is programmatic output from python3 scripts/migrate.py This will result in a Minerva skin dependent on MobileFrontend. Post merge we will rename message keys to have minerva- prefix Bug: T166748 Change-Id: Iff1f7e63e796cc5d4a6d2ab0370e0c33248d2fce
51 lines
1.2 KiB
JavaScript
51 lines
1.2 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;
|
|
}
|
|
}
|
|
|
|
$( '#mw-mf-display-toggle' ).on( 'click', desktopViewClick );
|
|
|
|
}( mw.mobileFrontend, jQuery ) );
|