Module:Message box: Difference between revisions

Jump to navigation Jump to search
add imbox
(more abstraction for box structure and better small=yes support)
(add imbox)
Line 2:
 
local htmlBuilder = require('Module:HtmlBuilder')
local yesno = require('Module:Yesno')
 
local p = {}
Line 14 ⟶ 15:
function p.build(data, args)
-- Process config data.
local isSmall = args.small == 'yes' or args.small == true
local typeData = data.types[args.type]
local invalidType = args.type and not typeData and true or false
typeData = typeData or data.types[data.default]
 
local isSmall = (args.small == 'yes' or args.small == true) and true or false
local image, imageRight, text, imageSize
if isSmall then
Line 24 ⟶ 25:
imageRight = args.smallimageright or args.imageright
text = args.smalltext or args.text
imageSize = data.imageSizeSmall or data.imageSize or '40x40px'
else
image = args.image
imageRight = args.imageright
text = args.text
imageSize = data.imageSizeLarge or data.imageSize or '40x40px'
end
 
Line 43 ⟶ 44:
end
box
.addClass(isSmall and 'mbox-small')
.addClass(data.classPlainlinksYesno and yesno(args.plainlinks or true) and 'plainlinks')
.addClass(typeData.class)
.addClass(args.class)
Line 55 ⟶ 58:
elseif data.imageEmptyCell then
row.tag('td')
.addClass('mbox-empty-cell') -- No image. Cell with some width or padding necessary for text cell to have 100% width.
end
 
Line 65 ⟶ 68:
 
-- Add the right-hand image.
if imageRight and not (data.imageRightNone and imageRight == 'none') then
row.tag('td')
.addClass('mbox-imageright')
.wikitext(imageRight)
end
 
-- Add the below row.
if data.below and args.below then
box.tag('tr')
.tag('td')
.attr('colspan', args.imageright and '3' or '2')
.addClass('mbox-text')
.cssText(args.textstyle)
.wikitext(args.below)
end
 
Line 102 ⟶ 115:
data.default = 'system'
data.classes = { 'plainlinks', 'fmbox' }
data.imageSize = '40x40px'
data.imageEmptyCell = false
data.imageRightNone = false
return p.build(data, args)
end
Line 144 ⟶ 157:
data.imageSizeSmall = '30x30px'
data.imageEmptyCell = true
data.imageRightNone = true
return p.build(data, args)
end
 
function p._imbox(args)
local data = {}
data.types = {
speedy = {
class = 'imbox-speedy',
image = 'Imbox speedy deletion.png'
},
delete = {
class = 'imbox-delete',
image = 'Imbox deletion.png'
},
content = {
class = 'imbox-content',
image = 'Imbox content.png'
},
style = {
class = 'imbox-style',
image = 'Edit-clear.svg'
},
move = {
class = 'imbox-move',
image = 'Imbox move.png'
},
protection = {
class = 'imbox-protection',
image = 'Imbox protection.png'
},
license = {
class = 'imbox-license',
image = 'Imbox license.png'
},
featured = {
class = 'imbox-featured',
image = 'Imbox featured.png'
},
notice = {
class = 'imbox-notice',
image = 'Imbox notice.png'
}
}
data.imageSizedefault = '40x40pxnotice'
data.classes = {'imbox'}
data.classPlainlinksYesno = true
data.imageEmptyCell = true
data.below = true
return p.build(data, args)
end
Line 178 ⟶ 240:
 
p.fmbox = makeWrapper(p._fmbox)
p.imbox = makeWrapper(p._imbox)
p.ombox = makeWrapper(p._ombox)
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu