Module:NavboxMobile/doc

This module implements the Navbox template for mobile. This mobile version differs from the desktop version as follows:


 * The table does not collapse.
 * The list cells, e.g. group1, list1, each display across the width of the screen
 * Images are not displayed, as it increases the complexity of the layout while reducing the area needed for content.

Overview
This approach works by utilizing CSS class rules. See: Topic on Extension talk:MobileFrontend

An "onlymobile" class in MediaWiki:Common.css will not display classes intended for mobile devices.

A "nomobile" class in MediaWiki:Mobile.css will not display classes intended for desktop devices.

Use these classes together inside the same template. The template will be rendered twice, but only display once depending on the view (desktop or mobile).

Module description
The module was copied from Module:Navbox and modified as follows:


 * All instances of "navbox-" were replaced with "navboxMobile-" to provide unique CSS identifiers that are independent of navbox.
 * All statements which processed images were removed. The statements remain as comments to show what was changed.

In function renderListRow, the cell pair of (groupCell, listCell) appearing as a single row is broken into separate rows by adding local row = addTableRow(tbl) just before listCell.

Adding this row and removing the images are the only functional changes made to the existing navbox template. Except for removal of the images, the parameters used in the current navbox are supported.

MediaWiki:Common.css
In MediaWiki:Common.css, add: /* Only for mobile devices */ .onlymobile { display:none; }

MediaWiki:Mobile.css
In MediaWiki:Mobile.css, add: /* Only for desktop devices */ .nomobile { display:none; }

MobileFrontend processes MediaWiki:Mobile.css. To provide an independent class that is not affected by the navbox rules, copy all of the navbox and hlist CSS styles from MediaWiki:Common.css to MediaWiki:Mobile.css.

Replace all "navbox-" with "navboxMobile-". For example, "navbox-title" becomes "navboxMobile-title". This will match the CSS properties in Module:NavboxMobile.

Template:Navbox
Modify Template:Navbox to call both the desktop and mobile Lua modules as follows:

This will render both the desktop (navbox) and mobile (navboxMobile) versions. When displaying from a desktop view, MediaWiki:Common.css will not display the mobile template. When displaying from a mobile, only the mobile template will be displayed.

Constraints and limitations
This template was developed with MediaWiki 1.27.4 (Long Term Support) and MobileFrontEnd 1.0.0 (29 June 2016). No testing was performed with other versions.

The navbox class is explicitly disabled in /extensions/MobileFrontend/resources/skins.minerva.content.styles/hacks.less. Attempts to override navbox using $wgMFRemovableClasses do not display as intended when the navbox class is enabled.

Example
The following example is intended to be visible in desktop view. The layout can be seen, but the colors and text alignment are incorrect because the CSS properties are not defined in desktop view.

The template will appear as intended in mobile view.

This example also shows how to supply template parameters directly to the Lua module.