モジュール:Mbox

*このモジュールについての説明文ページを モジュール:Mbox/doc に作成できます*

```
-- This Module is used for making templates based in the Lua language.
-- See more details about Lua in [[Help:Lua]].
-- The Fandom Developer's Wiki hosts Global Lua Modules that can be imported and locally overridden.
-- The next line imports the Mbox module from the [[w:c:dev:Global Lua Modules]].
local Mbox = require('Dev:Mbox')
-- See more details about this module at [[w:c:dev:Global\_Lua\_Modules/Mbox]]

-- The imported Module is overwritten locally to include default styling.
-- For a more flexible Mbox experience, delete the function below and import
-- https://dev.fandom.com/wiki/MediaWiki:Global\_Lua\_Modules/Mbox.css
-- or paste (and modify as you like) its contents in your wiki's
-- [[MediaWiki:Wikia.css]] (see [[Help:Including\_additional\_CSS\_and\_JS]])
-- or look at https://dev.fandom.com/wiki/Global\_Lua\_Modules/Mbox
-- for more customization inspiration

--
-- 簡易版設定ここから (不要な場合は削除してください)
-- BEGIN DELETION HERE
--

local getArgs = require('Dev:Arguments').getArgs
local localCSS = mw.loadData('Module:Mbox/data').localStyle

function Mbox.main(frame)
 local args = getArgs(frame)

 -- styles
 local styles = {}
 if args.bordercolor then
 styles['border-left-color'] = args.bordercolor
 elseif args.type then
 styles['border-left-color'] = 'var(--type-' .. args.type .. ')'
 end

 if args.bgcolor then
 styles['background-color'] = args.bgcolor
 end

 -- images
 local image = args.image or ''
 local imagewidth = args.imagewidth or '80px'
 local imagelink = ''
 if args.imagelink then
 imagelink = '|link=' .. args.imagelink
 end

 local imagewikitext = '[['..'File:' .. image .. '|' .. imagewidth .. imagelink .. ']]'

 -- id for closure
 local id = args.id or 'mbox'

 local container = mw.html.create('div')
 :addClass('mbox')
 :addClass(args.class)
 :css(styles)
 :css(localCSS['mbox'])
 :cssText(args.style)

 local content = container:tag('div')
 :addClass('mbox\_\_content')
 :css(localCSS['mbox\_\_content'])

 if args.image then
 local image = content:tag('div')
 :addClass('mbox\_\_content\_\_image')
 :addClass('mw-collapsible')
 :attr('id', 'mw-customcollapsible-' .. id)
 :css(localCSS['mbox\_\_content\_\_image'])
 :wikitext(imagewikitext)
 if args.collapsed then
 image:addClass('mw-collapsed')
 end
 end

 local contentwrapper = content:tag('div')
 :addClass('mbox\_\_content\_\_wrapper')
 :css(localCSS['mbox\_\_content\_\_wrapper'])

 if args.header then
 contentwrapper:tag('div')
 :addClass('mbox\_\_content\_\_header')
 :css(localCSS['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)
 :css(localCSS['mbox\_\_content\_\_text'])
 :wikitext(args.text)
 if args.collapsed then
 text:addClass('mw-collapsed')
 end

 if args.comment then
 text:tag('div')
 :addClass('mbox\_\_content\_\_text\_\_comment')
 :css(localCSS['mbox\_\_content\_\_text\_\_comment'])
 :wikitext(args.comment)
 end
 end

 contentwrapper:tag('span')
 :addClass('mbox\_\_close')
 :addClass('mw-customtoggle-' .. id)
 :css(localCSS['mbox\_\_close'])
 :attr('title', 'Dismiss')

 if args.aside then
 local aside = content:tag('div')
 :addClass('mbox\_\_content\_\_aside')
 :addClass('mw-collapsible')
 :attr('id', 'mw-customcollapsible-' .. id)
 :css(localCSS['mbox\_\_content\_\_aside'])
 :wikitext(args.aside)
 if args.collapsed then
 aside:addClass('mw-collapsed')
 end
 end

 return container
end

--
-- 簡易版設定ここまで
-- END DELETION HERE
--

-- The last line produces the output for the template
return Mbox

```