Module:Box: Difference between revisions

Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.
119 bytes removed ,  February 8, 2017
output content so subclasses can do what they want with it. I'll need to add content support to the base Box functions later.
(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( frame.args.content or frame.args[1], frame.args ) )
     return tostring( p._light( frame.args ) )
end
end


function p.dark( frame )
function p.dark( frame )
     return tostring( p._dark( frame.args.content or frame.args[1], frame.args ) )
     return tostring( p._dark( frame.args ) )
end
end


function p._light( content, args )
function p._light( args )
     return p._box( false, content, args )
     return p._box( false, args )
end
end


function p._dark( content, args )
function p._dark( args )
     return p._box( true, content, args )
     return p._box( true, args )
end
end


-- Constructs the box
-- Constructs the box
function p._box( dark, content, args )
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' )
        :node( content )


     return box
     return box, content
end
end


return p
return p

Navigation menu