17,230
edits
(Created page with "-- This is the base module for creating boxes with common styling. -- invoker args: -- content (or [1]) (required) -- align ('left', 'right', 'center') -- width (e.g. '2...") |
(output content so subclasses can do what they want with it. I'll need to add content support to the base Box functions later.) |
||
Line 12: | Line 12: | ||
function p.light( frame ) | function p.light( frame ) | ||
return tostring( p._light( | return tostring( p._light( frame.args ) ) | ||
end | end | ||
function p.dark( frame ) | function p.dark( frame ) | ||
return tostring( p._dark( | return tostring( p._dark( frame.args ) ) | ||
end | end | ||
function p._light( | function p._light( args ) | ||
return p._box( false | return p._box( false, args ) | ||
end | end | ||
function p._dark( | function p._dark( args ) | ||
return p._box( true | return p._box( true, args ) | ||
end | end | ||
-- Constructs the box | -- Constructs the box | ||
function p._box( dark | function p._box( dark, args ) | ||
local box = mw.html.create( 'div' ) | local box = mw.html.create( 'div' ) | ||
:addClass( dark and 'darkbox' or 'box' ) | :addClass( dark and 'darkbox' or 'box' ) | ||
Line 57: | Line 57: | ||
-- content, add toggle classes if necessary | -- content, add toggle classes if necessary | ||
box:tag( 'div' ) | local content = box:tag( 'div' ) | ||
:addClass( args.hide and '_toggle_init' .. args.hide .. ' _toggle' ) | :addClass( args.hide and '_toggle_init' .. args.hide .. ' _toggle' ) | ||
return box | return box, content | ||
end | end | ||
return p | return p |