Module:Message box/sandbox: Difference between revisions

Content deleted Content added
m sync
add collapsible spagetti code
Line 194:
-- Set text style.
self.textstyle = args.textstyle
 
-- Set header style.
-- Only for tmbox
self.headerstyle = args.headerstyle
-- Specify header text
self.headertext = args.headertext
-- Find if we are on the template page or not. This functionality is only
-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
Line 328 ⟶ 335:
self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px'
end
-- Collapsible setting for tmbox
local setCollapsible = args.collapse
if setCollapsible then
self.tableCollapseStyle = 'border-collapse:separate;'
end
 
 
-- Left image settings.
Line 489 ⟶ 503:
for i, class in ipairs(self.classes or {}) do
boxTable:addClass(class or nil)
end
if setCollapsible then
boxTable
:addClass ('mw-collapsible mw-made-collapsible')
:cssText (self.tableCollapseStyle)
:attr('cellspacing', '4')
end
boxTable
Line 497 ⟶ 517:
boxTable:attr(self.attrs)
end
 
-- Add the left-hand image.
local row = boxTable:tag('tr')
Line 518 ⟶ 538:
:addClass('mbox-empty-cell')
:cssText(self.imageEmptyCellStyle or nil)
end
 
-- Add header?
local header = row:tag('td'):addClass('mbox-text')
if self.headertext then
if setCollapsible then
-- The show button
local showButton = header:tag('span'):addClass('collapseButton'):cssText('float:left;')
local togglewhitespace = showButton:tag('span'):addClass('nowrap'):wikitext('          ')
header
:cssText(self.headerstyle or nil)
:wikitext((showButton and togglewhitespace and self.headertext) or nil)
else
header
:cssText(self.headerstyle or nil)
:wikitext(self.headertext or nil)
end
end
if self.imageLeft then
local imageLeftCell = row:tag('th'):addClass('mbox-image')
if self.imageCellDiv then
-- If we are using a div, redefine imageLeftCell so that the image
-- is inside it. Divs use style="width: 52px;", which limits the
-- image width to 52px. If any images in a div are wider than that,
-- they may overlap with the text or cause other display problems.
imageLeftCell = imageLeftCell:tag('div'):css('width', '52px')
end
end
 
Line 548 ⟶ 598:
:tag('i')
:wikitext(string.format(" (%s)", self.removalNotice))
end
if setCollapsible then
textCell:addClass('outercollapse')
end
else