Модул:Message box/doc

От Уикицитат

Това е страница с документация за Модул:Message box

Употреба[редактиране]

За да ползвате настоящия модул в друг Lua модул, е необходимо първо да го заредите.

local messageBox = require('Модул:Message box')

Използвайте main функцията, за да създадете съобщително каре (message box). Като самата функция приема два аргумента: първия е типа на карето (като символен низ), а втория е таблица съдържаща параметрите на карето.

local box = messageBox.main( boxType, {
    param1 = param1,
    param2 = param2,
    -- Още параметри...
})

Достъпни са седен вида кутии:

Тип на каре Шаблон Предназначение
mbox {{mbox}} При съобщителни карета с множество Именни пространства (Namespaces)
ambox {{ambox}} При съобщителни карета за статии
cmbox {{cmbox}} При съобщителни карета за категории
fmbox {{fmbox}} При съобщителни карета за горни и долни колонтитули на потребителски страници, както и за системни съобщения
imbox {{imbox}} При съобщителни карета за файлови Именни пространства (Namespaces)
tmbox {{tmbox}} При съобщителни карета за беседи
ombox {{ombox}} При съобщителни карета в други Именни пространства (Namespaces)

За повече информация отностно параметрите им се обърнете към шаблона за съответното каре.

Употреба чрез #invoke[редактиране]

Освен main функцията, настоящия модул съдържа и функции за всеки отделен вид каре. Достъпа до които става посредством следния код {{#invoke:Message box|mbox|...}}, {{#invoke:Message box|ambox|...}} и т.н. Така дадените изрази функционират при извикването им от други модули, но тъй като обработката на кода преминава първо през #invoke, то извикването им по този начин не по непродуктивно в сравнение с директното извикване на main.

Технически подробности[редактиране]

Модулът ползва един и същ базов код за всеки от шаблоните описани по-горе; разликите между всеки един от тях са конфигурирани ползвайки данните от Модул:Message box/configuration. По-долу са дадени разни конфигурационни опции заедно с тяхното значение:

  • types - a table containing data used by the type parameter of the message box. The table keys are the values that can be passed to the type parameter, and the table values are tables containing the class and the image used by that type.
  • default - the type to use if no value was passed to the type parameter, or if an invalid value was specified.
  • showInvalidTypeError - whether to show an error if the value passed to the type parameter was invalid.
  • allowBlankParams - usually blank values are stripped from parameters passed to the module. However, whitespace is preserved for the parameters included in the allowBlankParams table.
  • allowSmall - whether a small version of the message box can be produced with "small=yes".
  • smallParam - a custom name for the small parameter. For example, if set to "left" you can produce a small message box using "small=left".
  • smallClass - the class to use for small message boxes.
  • substCheck - whether to perform a subst check or not.
  • classes - an array of classes to use with the message box.
  • usePlainlinksParam - whether to allow "plainlinks=no" to turn off the plainlinks class.
  • imageEmptyCell - whether to use an empty <td>...</td> cell if there is no image set. This is used to preserve spacing for message boxes with a width of less than 100% of the screen.
  • imageEmptyCellStyle - whether empty image cells should be styled.
  • imageCheckBlank - whether "image=blank" results in no image being displayed.
  • imageSmallSize - usually, images used in small message boxes are set to 30x30px. This sets a custom size.
  • imageCellDiv - whether to enclose the image in a div enforcing a maximum image size.
  • useCollapsibleTextFields - whether to use text fields that can be collapsed, i.e. "issue", "fix", "talk", etc. Currently only used in ambox.
  • imageRightNone - whether imageright=none results in no image being displayed on the right-hand side of the message box.
  • sectionDefault - the default name for the "section" parameter. Depends on useCollapsibleTextFields.
  • allowMainspaceCategories - allow categorisation in the main namespace.
  • templateCategory - the name of a category to be placed on the template page.
  • templateCategoryRequireName - whether the name parameter is required to display the template category.
  • templateErrorCategory - the name of the error category to be used on the template page.
  • templateErrorParamsToCheck - an array of parameter names to check. If any are absent, the templateErrorCategory is applied to the template page.