|
|
Line 61: |
Line 61: |
| :addClass( 'edit plainlinks' ) | | :addClass( 'edit plainlinks' ) |
| :wikitext( '[' .. tostring( mw.uri.fullUrl( self.args.edit, { action = 'edit' } ) ) .. ' [edit]]' ) | | :wikitext( '[' .. tostring( mw.uri.fullUrl( self.args.edit, { action = 'edit' } ) ) .. ' [edit]]' ) |
| -- :tag( 'a' )
| |
| -- :attr( 'href', tostring( mw.uri.fullUrl( self.args.edit, { action = 'edit' } ) ) )
| |
| -- :wikitext( '[edit]' )
| |
| end | | end |
|
| |
|
Line 99: |
Line 96: |
| end | | end |
|
| |
|
| local p, mt = Box, {} | | local p, mt = {}, {} |
| | |
| | p.Box = Box |
|
| |
|
| function p._main( boxType, args ) | | function p._main( boxType, args ) |
| local box = Box.new( boxType, args ) | | local box = Box.new( boxType, args ) |
| return box:render() | | return box:render() |
| end
| |
|
| |
| -- TODO deprecated, use p._main instead
| |
| function p._light( args )
| |
| return p._box( false, args )
| |
| end
| |
|
| |
| -- TODO deprecated, use p._main instead
| |
| function p._dark( args )
| |
| return p._box( true, args )
| |
| end
| |
|
| |
| -- TODO deprecated
| |
| function p._box( dark, args )
| |
| local box = mw.html.create( 'div' )
| |
| :addClass( dark and 'darkbox' or 'box' )
| |
| :addClass( args.class )
| |
|
| |
| -- box styles
| |
| if args.align == 'right' or args.align == 'left' or args.align == 'center' then box:addClass( args.align ) end
| |
| if args.width then box:css( 'width', args.width ) end
| |
|
| |
| -- title, with edit and toggle links if supplied
| |
| if args.title then
| |
| local title = box:tag( 'div' )
| |
| :addClass( 'title' )
| |
| :css( 'text-align', args.titlealign or 'center' )
| |
| :wikitext( args.title )
| |
|
| |
| if args.edit then
| |
| title:tag( 'span' )
| |
| :addClass( 'edit plainlinks' )
| |
| :wikitext( '[' .. tostring( mw.uri.fullUrl( args.edit, { action = 'edit' } ) ) .. ' [edit{{)!}}]' )
| |
| end
| |
|
| |
| if args.hide then
| |
| title:wikitext( mw.getCurrentFrame():expandTemplate{ title = 'Toggler', args = { default = args.hide } } )
| |
| end
| |
| end
| |
|
| |
| -- content, add toggle classes if necessary
| |
| local content = box:tag( 'div' )
| |
| :addClass( args.hide and '_toggle_init' .. args.hide .. ' _toggle' )
| |
|
| |
| return box, content
| |
| end | | end |
|
| |
|