Fandom Developers Wiki
Advertisement

MobileSpoiler helps creating a template for hiding a spoiler, in a way that looks nice on both desktop and mobile.

Explanation

Custom JS is currently not enabled for mobile, therefore may not suffice for hiding spoilers (although, custom CSS is now available for mobile too and might be a simpler alternative). One way that works on FandomMobile is putting the spoiler inside a collapsible.

Normal collapsibles appear as a separate block with an Expand/Collapse button on the right. If you are fine with that, you don't need this module, just use the collapsible directly. The text "Expand"/"Collapse" can be customized — see on the help page linked above.

However, if you want the collapsible to appear inline within a paragraph, a custom collapsible is needed. This by itself still does not require a module, but if you have more than one spoiler section on a page and you want to use multiple custom collaspibles, you will have to somehow make sure that each of them gets it's own unique identifier. The module automates this process while also handling the clickable text "Show Spoiler" and "Hide Spoiler".

Installation

Customizing the toggles text

The text of the toggles [Show Spoiler] and [Hide Spoiler] is automatically localized for the wiki's language, giving that there is an available translation on Module:MobileSpoiler/i18n.

In addition, the second and third parameters can be used for a custom text — see an example below.

Examples

Show in mobile skin Show in desktop skin

Simple

Fandom was previously called {{spoiler|Wikia}}.
Results in

Fandom was previously called [Hide Spoiler] Wikia[Show Spoiler].

With show/hide buttons customized

Fandom was previously called {{spoiler|Wikia|(<u>Reveal</u>)|(<u>Unreveal</u>)}}.
Results in

Fandom was previously called (Unreveal) Wikia(Reveal).

Notes

  • Template type — Make sure to not set the template type to a type that is hidden or altered on mobile, such as the "Notice" type. Choosing the "Design" type is a safe option.
  • Preview mode — Depending on the editor, custom collapsibles may not work on preview mode (specifically, using the option "Show previews without reloading the page.") However, they do work when saving the page.
Text above can be found here (edit)
Advertisement