Forum:Disabling the mobile view?

ShoutWiki — express yourself and be heard!
Jump to navigation Jump to search

Forums: Index Community help

I have custom Common.css on my wiki that works and looks better than the default mobile view (it's also responsive, but it retains the colour scheme and, importantly, doesn't get away with navboxes). Is it possible to make the desktop view the default regardless of what the user agent string says (on a per wiki basis, obviously)? --HelloAnonMyOldFriend (talk) 13:16, 21 July 2020 (UTC)

mw:Extension:MobileFrontend is installed on every wiki. I believe that the way the farm is configured, there's no way to disable it on a per-wiki basis. The most significant effect of the extension is that it switches the skin to Minerva, independent of what users have configured in their preferences or what the founder (or staff) has configured as the default skin. The query string ?mobileaction=toggle_view_mobile once switches the skin to Minerva, just like using the query string ?useskin=minerva on every view, but without having to use the query string on every view. The query string ?mobileaction=toggle_view_desktop once switches the skin to whatever is set in Preferences (or in the wiki config for anonymous users). I believe MobileFrontend loads JavaScript from MediaWiki:Mobile.js. I once suggested the following code snippet for Mobile.js to another user, but I'm not sure it worked for him.
/* Any JavaScript here is loaded instead of MediaWiki:Common.js for users using the mobile site */

/**
 * Make first mobile view switch to desktop
 * . check for localStorage capability
 * . if capable and key not found, set key and switch to desktop
 */
( function ( ) {
	'use strict';

	var
		key = 'mobileSwitch';

	if ( ( typeof Storage !== 'undefined' ) && ( localStorage[key] === null ) ) {
		localStorage[key] = '';
		location.search += ( location.search === '' ? '?' : '&' ) + 'mobileaction=toggle_view_desktop';
	}
} ( ) );
--Saftzie (talk) 20:52, 21 July 2020 (UTC)
Thank you. Unfortunately, the code doesn't seem to work. I also tried putting it in Common.js, just in case, but with no luck.
--HelloAnonMyOldFriend (talk) 21:07, 21 July 2020 (UTC)
You definitely shouldn't have it in Common.js. I don't think it'll blow anything up, but it would cause an unnecessary page reload the first time users visit your wiki. --Saftzie (talk) 21:12, 21 July 2020 (UTC)
I'm not using the code anywhere now, I only tried to see if it would possibly work in Common.js, which it has not. --HelloAnonMyOldFriend (talk) 22:07, 21 July 2020 (UTC)
What skin is your wiki using? MobileFrontend can be configured to use Vector or Timeless instead of Minerva. You'd still need to import Common.css styles to Mobile.css, though. --miki-- (talk) 21:45, 21 July 2020 (UTC)
I'm using MonoBook, which admittedly might be a slightly outdated skin.--HelloAnonMyOldFriend (talk) 22:07, 21 July 2020 (UTC)