Template:Ajax

From Terraria Wiki
Jump to navigation Jump to search
This template is i18n-ready, which means it is easy to localize for different languages. Please see I18n & l10n for templates to learn more.
See Template:Ajax/l10n for the localization of this template.
Template-info.svg Documentation The documentation below is transcluded from Template:Ajax/doc. (edit | history)

This template allows loading the content of another wiki page into a box when the reader clicks a link. The functionality is provided by Common.js via AJAX.

Note: AJAX may not render properly on certain mobile devices, hence it should be avoided on pages that mainly feature mobile content.

Usage

{{ ajax | <target page> | keepterraria = y/yes | width = <box width> | head = <box heading text> | headstyle = <heading styling> | nohead = y/yes | bodystyle = <box content styling> | bodyload = <box text> | nojs = <non-JavaScript text> | mainstyle = <box CSS class> }}

First unnamed parameter or target

Name of the wiki page that will be loaded when the link is clicked. This is the only parameter that is required; the rest are optional.

If this parameter is not passed as |target=... (but as the first unnamed parameter instead, i.e. just |...), then the other parameters should follow on the same line, with no line break between the wiki page name and another parameter. Otherwise, a glitch occurs and the wiki's main page may become the target instead.

keepterraria

By default, Ajax removes the CSS class terraria from all elements on the target page, resulting in e.g. tables without lines. Use this parameter to prevent that.

width

Width of the wrapper table, defaults to 100%.

head

Text in the heading of the wrapper table. The heading is blank by default but will still be shown, so that the "edit" and "show/hide" links on the right are visible.

headstyle

Custom styling for the heading of the wrapper table. CSS styles must be wrapped in style="..." and wiki table styling (e.g. align=left) is available.

nohead

Hides the heading of the wrapper table. Note that this also means that the "edit" and "show/hide" links are inaccessible.

bodystyle

Custom styling for the content of the wrapper table, both before and after the loading of the target page. CSS styles must be wrapped in style="..." and wiki table styling (e.g. align=left) is available. The default styling is align=center.

bodyload

Initial text in the wrapper table, before the target page is loaded. Wrap the text that should be displayed as the "load" link in [link]...[/link].

nojs

Text for users that have JavaScript disabled (which is of course required for AJAX operations).

mainstyle

CSS class names for the wrapper table, defaults to terraria.

Target page syntax

  • Tabular data should be wrapped in a table on the target page. Table formatting should be applied on the target page, not on the calling page.
  • You can enclose data in <span class="ajaxHide"></span> on the target page to hide it on the calling page.
  • For additional information regarding Ajax formatting, please see User:NoseOfCthulhu/Sandbox1#AJAX notes.

Examples

Examples use Template talk:Ajax/include as their target.

Without body/link text specified
[link]Click/tap here to reveal this content. (there may be a slight delay)[/link]
This table requires JavaScript to be enabled and site tooltips to be turned on to be displayed.
You can also view the data on another page.
With body/link text specified
The data for this table is not yet loaded.
[link]Click here[/link] to load data.
This table requires JavaScript to be enabled and site tooltips to be turned on to be displayed.
You can also view the data on another page.