Module:Mbox

-- This Module is used for making templates based in the Lua language. -- See more details about Lua in Help:Lua. -- Based on: -- https://dev.fandom.com/wiki/Module:Mbox -- Changes: -- + Support imageadjust param for center|left|right|thumb, etc -- local Mbox = {} local getArgs = require('Dev:Arguments').getArgs function Mbox.main(frame)local args = getArgs(frame) -- styleslocal styles = {}styles['border-left-color'] = args['bordercolor']styles['background-color'] = args['bgcolor'] -- imageslocal image = args.image or local imageadjust = if args.imagelink thenimageadjust = '|' .. args.imageadjustendlocal imagewidth = args.imagewidth or '80px'local imagelink = ''if args.imagelink thenimagelink = '|link=' .. args.imagelinkendlocal imagewikitext = '' -- id for closurelocal id = args.id or 'mbox'local container = mw.html.create('div'):addClass('mbox'):addClass(args['type'] and ('mbox-type-' .. args['type'])):addClass(args.class):css(styles):cssText(args.style)local content = container:tag('div'):addClass('mbox__content')if args.image thenlocal image = content:tag('div'):addClass('mbox__content__image'):addClass('mw-collapsible'):attr('id', 'mw-customcollapsible-' .. id):wikitext(imagewikitext)if args.collapsed thenimage:addClass('mw-collapsed')endendlocal contentwrapper = content:tag('div'):addClass('mbox__content__wrapper')if args.header thencontentwrapper:tag('div'):addClass('mbox__content__header'):wikitext(args.header)endif args.text thenlocal text = contentwrapper:tag('div'):addClass('mbox__content__text'):addClass('mw-collapsible'):attr('id', 'mw-customcollapsible-' .. id):wikitext(args.text)if args.collapsed thentext:addClass('mw-collapsed')endif args.comment thentext:tag('div'):addClass('mbox__content__text__comment'):wikitext(args.comment)endendcontentwrapper:tag('span'):addClass('mbox__close'):addClass('mw-customtoggle-' .. id):attr('title', 'Dismiss')if args.aside thenlocal aside = content:tag('div'):addClass('mbox__content__aside'):addClass('mw-collapsible'):attr('id', 'mw-customcollapsible-' .. id):wikitext(args.aside)if args.collapsed thenaside:addClass('mw-collapsed')endendreturn container end return Mbox