Module:Side box: Difference between revisions
Content deleted Content added
Johnrdorazio (talk | contribs) m 1 revision imported |
we cookin with plainlist templatestyles now |
||
Line 1:
local yesno = require('Module:Yesno')
local p = {}
local function
local origArgs = frame:getParent().args▼
local args = {}▼
for k, v in pairs(origArgs) do▼
v = v:match('%s*(.-)%s*$')▼
if v ~= '' then▼
args[k] = v▼
end▼
end▼
return p._main(args)▼
end▼
function p._main(args)▼
local data = p.makeData(args)▼
return p.renderSidebox(data)▼
end▼
function p.makeData(args)▼
local data = {}
Line 31 ⟶ 11:
end
if args.position and args.position:lower() == 'left' then
table.insert(data.classes, '
else
table.insert(data.classes, '
end
if args.collapsible then
table.insert(data.classes, 'mw-collapsible')
if args.collapsible == "collapsed" then
table.insert(data.classes, 'mw-collapsed')
▲ end
data.collapsible = true
▲ end
table.insert(data.classes, args.class)
Line 40 ⟶ 29:
if args.image and args.image ~= 'none' then
data.image = args.image
end
-- we have to check to see if a downstream use has plainlist like
-- Template:Sister_project. also it's the default. wikitext is :(
if args.textclass == 'plainlist' or not args.textclass then
data.textclass = 'plainlist'
data.plainlist_templatestyles = 'Plainlist/styles.css'
else▼
data.textclass = args.textclass
end
-- Copy over data that does not need adjusting
local argsToCopy = {
--
'
'labelledby',
-- Styles
'style',
'textstyle',
'templatestyles',
-- Above row
Line 69:
end
local function
-- Renders the sidebox HTML.
-- Table root
local root = mw.html.create('
root:attr('role',
:attr('aria-labelledby', data.labelledby)
:addClass('side-box')
for i, class in ipairs(data.classes or {}) do
root:addClass(class)
end
if data.style then
root:cssText(data.style)
end
local frame = mw.getCurrentFrame()
if data.plainlist_templatestyles then
root:wikitext(frame:extensionTag{
name = 'templatestyles', args = { src = data.plainlist_templatestyles }
})
end
-- The "above" row
if data.above then
local
above:addClass('side-box-abovebelow')
:newline()▼
:
if data.textstyle then
end
if data.abovestyle then
end
▲ :newline()
end
-- The body row
local
body:addClass('side-box-flex')
:addClass(data.collapsible and 'mw-collapsible-content')
:newline()
if data.image then
:addClass('
:wikitext(data.image)
▲ else
end
local
if data.textstyle then
end
if data.imageright then
:addClass('
:wikitext(data.imageright)
end
Line 124 ⟶ 130:
-- The below row
if data.below then
local
below
:addClass('side-box-abovebelow')
:
if data.textstyle then
end
end
root:newline()
local templatestyles = ''
return tostring(root)▼
if data.templatestyles then
templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = data.templatestyles }
}
end
return frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Side box/styles.css' }
▲end
▲function p._main(args)
▲end
▲ local origArgs = frame:getParent().args
▲ local args = {}
▲ for k, v in pairs(origArgs) do
▲ v = v:match('%s*(.-)%s*$')
▲ if v ~= '' then
▲ args[k] = v
end
end
▲ return p._main(args)
end
|