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) -- styles local styles = {} styles['border-left-color'] = args['bordercolor'] styles['background-color'] = args['bgcolor'] -- images local image = args.image or '' local imageadjust = '' if args.imageadjust then imageadjust = '|' .. args.imageadjust end local imagewidth = args.imagewidth or '80px' local imagelink = '' if args.imagelink then imagelink = '|link=' .. args.imagelink end local imagewikitext = '' -- id for closure local 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 then local image = content:tag('div') :addClass('mbox__content__image') :addClass('mw-collapsible') :attr('id', 'mw-customcollapsible-' .. id) :wikitext(imagewikitext) if args.collapsed then image:addClass('mw-collapsed') end end local contentwrapper = content:tag('div') :addClass('mbox__content__wrapper') if args.header then contentwrapper:tag('div') :addClass('mbox__content__header') :wikitext(args.header) end if args.text then local text = contentwrapper:tag('div') :addClass('mbox__content__text') :addClass('mw-collapsible') :attr('id', 'mw-customcollapsible-' .. id) :wikitext(args.text) if args.collapsed then text:addClass('mw-collapsed') end if args.comment then text:tag('div') :addClass('mbox__content__text__comment') :wikitext(args.comment) end end contentwrapper:tag('span') :addClass('mbox__close') :addClass('mw-customtoggle-' .. id) :attr('title', 'Dismiss') if args.aside then local aside = content:tag('div') :addClass('mbox__content__aside') :addClass('mw-collapsible') :attr('id', 'mw-customcollapsible-' .. id) :wikitext(args.aside) if args.collapsed then aside:addClass('mw-collapsed') end end return container end return Mbox