Modul:Ambox Bootstrap
| This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
| This module depends on the following other modules: |
This module implements the bootstap components version of template {{Ambox}}.
Usage
{{#invoke:Ambox Bootstrap|main}}
local p = {}
local amboxConfig = mw.loadData('Module:Message box/configuration').ambox.types
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local colors = {
speedy = 'danger',
delete = 'danger',
content = 'warning',
style = 'success',
move = 'info',
protection = 'default',
default = 'primary',
}
local getColor = function(type)
return colors[type] or colors.default
end
function p.main(frame)
assert(mw.bootstrap, 'Extension:BootstrapComponents must be installed for [[Module:Ambox Bootstrap]] to work!')
local args = getArgs(frame)
if not args.type or not amboxConfig[args.type] then
args.type = 'notice'
end
local content = mw.html.create('table')
content:addClass('metadata plainlinks')
:tag('tr')
:tag('td')
:addClass('mbox-image')
:tag('div')
:css( 'width', '52px' )
:wikitext('[[File:' .. amboxConfig[args.type].image .. '|'
.. (yesno(args.small) and '20x20px' or '40x40px' ) .. '|alt=|link=]]')
:done()
:done()
:tag('td')
:addClass('mbox-text')
:tag('span')
:addClass('mbox-text-span')
:wikitext(args.text or '')
:tag('span')
:addClass('hide-when-compact')
:done()
:tag('span')
:addClass('hide-when-compact')
:done()
:allDone()
if args.type == 'speedy' then
args.style = args.style and args.style .. ';' or ''
args.style = args.style .. 'border: 3px solid darkred'
end
return mw.bootstrap.parse('alert', tostring(content), {color = getColor(args.type), class=args.class, style=args.style, id = args.id})
end
return p