Template:Dialog/text

From Wikinews, the free news source you can write!
Jump to navigation Jump to search
[edit] Template-info.svg Template documentation

This template sets up a text dialog box.

Usage

Parameters:

  • id — required — A unique name for the field; stick to letters and hyphens.
  • size — optional — The intended width of the text box, in characters.
  • unnamed parameter — optional — The initial content of the text box.

Internals

Behind the (hopefully) seamless interface this template presents to users, there is a good deal of esoteric working around quirks of the wiki software.

The template tries to set up an html span element with class wikidialog-text, id wikidialog-id, and content the specified initial value. Ideally, the dialog gadget looks for span elements with this class, and replaces each with a text box with the given initial content. However, when the specified content has multiple paragraphs in wiki markup, the wiki software generates multiple consecutive span elements, one for each paragraph, all with the same id. This multiplicity of elements could be avoided by using a div element instead of a span element, but as of this writing, the wiki software doesn't support embedding a div element on a single line, which we may want to do with small text boxes; hence the use of span elements. The show module compensates by checking for multiple consecutive span elements with class wikidialog-text and the same id, and if it finds them, it concatenates their contents into the first, and removes the later ones. To keep the show module from mistakenly merging elements from separate specifications with the same id (which can happen since the wiki software does not support gensyms), the template also sets up a trailing hidden element of the same class and different id, so that multiple elements from separate specifications always alternate with elements with different ids.

See also


Template:Dialog/safe