Template:Dialog/textarea/doc
This is a documentation subpage for Template:Dialog/textarea It may contain usage information, categories and other content that is not part of the original template page. |
This is a dialog formatting template. It is meant for use on interactive dialog pages, and may involve interactions between wiki markup, HTML, and JavaScript. Please carefully test any edits before making them. |
This template sets up a multi-line text dialog box.
Usage
editParameters:
- id — required — A unique name for the field; stick to letters and hyphens.
- cols — optional — The intended width of the text box, in characters.
- rows — optional — The intended number of lines of the text box.
- unnamed parameter — optional — The initial content of the text box. To specify a multi-line value, use double-spacing between lines. This means of initializing the content is recommended only for fixed text; for arbitrary data, use {{dialog/init}}.
The textarea can also be made invisible by specifying non-blank parameter hidden.
Internals
editBehind 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-textarea
, 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 textarea 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-textarea
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
edit