Module:Message box
From Chalo Chatu, Zambia online encyclopedia
Jump to navigationJump to search
-- Module:Message box/doc -- This is the documentation page for Module:Message box. -- Editors: Please do not edit the module itself here. Documentation only.
Module:Message box
This module creates standardized message boxes such as {{ambox}}, {{imbox}}, {{ombox}}, etc. It is a Lua implementation of the various "box" templates and should be used via those templates, not directly.
Usage
You normally do not call this module directly. Instead, use one of the wrapper templates:
- {{ambox}} – for article message boxes
- {{imbox}} – for file and image pages
- {{tmbox}} – for talk page message boxes
- {{ombox}} – for other namespaces
- {{cmbox}} – for category pages
Each wrapper template passes parameters to this module to generate a consistent, styled message box.
Parameters
The wrapper templates accept the following parameters:
- type
- The type of message box. Examples: speedy, delete, content, style, notice, protection.
- This controls the color and icon.
- image
- Optional custom image/icon (overrides default).
- text
- The main message text shown in the box.
- small
- If set to "yes", produces a smaller version of the box.
- style
- Additional CSS styling applied to the box.
- class
- Adds custom classes to the message box.
Example
{{ambox
| type = content
| text = This article needs additional references for verification.
}}
Produces:
This article needs additional references for verification.
See also
-- Unified Message box module for Chalo Chatu
local p = {}
-- Helper: get box style
local function makeStyle(type, inline)
local colors = {
notice = '#f9f9f9',
warning = '#fff2cc',
error = '#fdd',
info = '#eaf3ff'
}
local border = {
notice = '#aaa',
warning = '#fc3',
error = '#d33',
info = '#36c'
}
if inline then
return string.format(
"border:1px solid %s; background:%s; padding:0.5em; margin:0.5em 0;",
border[type] or '#aaa',
colors[type] or '#f9f9f9'
)
else
return string.format(
"border:2px solid %s; background:%s; padding:0.5em; margin:1em auto; width:80%%;",
border[type] or '#aaa',
colors[type] or '#f9f9f9'
)
end
end
-- Article message box
function p.ambox(frame)
local args = frame:getParent().args
local text = args['text'] or ''
local type = args['type'] or 'notice'
local style = makeStyle(type, false)
return string.format('<div style="%s">%s</div>', style, text)
end
-- Alias: mbox = ambox
p.mbox = p.ambox
-- Inline message box
function p.imbox(frame)
local args = frame:getParent().args
local text = args['text'] or ''
local type = args['type'] or 'notice'
local style = makeStyle(type, true)
return string.format('<div style="%s">%s</div>', style, text)
end
-- Alias: infobox = imbox
p.infobox = p.imbox
return p