Module:Message box: Difference between revisions

div structure behind flag
m 1 revision imported
 
(2 intermediate revisions by 2 users not shown)
Line 166: Line 166:
)
)


-- Set the below row.
self.below = cfg.below and args.below
-- Add attributes, classes and styles.
-- Add attributes, classes and styles.
self.id = args.id
self.id = args.id
Line 174: Line 177:
if yesno(args.plainlinks) ~= false then
if yesno(args.plainlinks) ~= false then
self:addClass('plainlinks')
self:addClass('plainlinks')
end
if self.below then
self:addClass('mbox-with-below')
end
end
for _, class in ipairs(cfg.classes or {}) do
for _, class in ipairs(cfg.classes or {}) do
Line 316: Line 322:
self.text = args.text
self.text = args.text
end
end
-- Set the below row.
self.below = cfg.below and args.below


-- General image settings.
-- General image settings.
Line 509: Line 512:
if self.attrs then
if self.attrs then
mbox:attr(self.attrs)
mbox:attr(self.attrs)
end
local flex_container
if self.below then
-- we need to wrap the flex components (`image(right)` and `text`) in their
-- own container div to support the `below` parameter
flex_container = mw.html.create('div')
flex_container:addClass('mbox-flex')
else
-- the mbox itself is the parent, so we need no HTML flex_container
flex_container = mw.html.create()
end
end


-- Add the left-hand image.
-- Add the left-hand image.
if self.imageLeft then
if self.imageLeft then
local imageLeftCell = mbox:tag('div'):addClass('mbox-image')
local imageLeftCell = flex_container:tag('div'):addClass('mbox-image')
imageLeftCell
imageLeftCell
:addClass(self.imageLeftClass)
:addClass(self.imageLeftClass)
Line 520: Line 534:


-- Add the text.
-- Add the text.
local textCell = mbox:tag('div'):addClass('mbox-text')
local textCell = flex_container:tag('div'):addClass('mbox-text')
if self.useCollapsibleTextFields then
if self.useCollapsibleTextFields then
-- The message box uses advanced text parameters that allow things to be
-- The message box uses advanced text parameters that allow things to be
Line 557: Line 571:
-- Add the right-hand image.
-- Add the right-hand image.
if self.imageRight then
if self.imageRight then
local imageRightCell = mbox:tag('div'):addClass('mbox-imageright')
local imageRightCell = flex_container:tag('div'):addClass('mbox-imageright')
imageRightCell
imageRightCell
:addClass(self.imageRightClass)
:addClass(self.imageRightClass)
:wikitext(self.imageRight or nil)
:wikitext(self.imageRight or nil)
end
end
mbox:node(flex_container)


-- Add the below row.
-- Add the below row.
if self.below then
if self.below then
mbox:tag('div')
mbox:tag('div')
:addClass('mbox-text')
:addClass('mbox-text mbox-below')
:cssText(self.textstyle or nil)
:cssText(self.textstyle or nil)
:wikitext(self.below or nil)
:wikitext(self.below or nil)