Module:Mbox: Difference between revisions
From Polcompball Wiki
Jump to navigationJump to search
Content added Content deleted
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
-- <nowiki> |
|||
-- 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]]. |
|||
⚫ | |||
-- 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 getArgs = require('Dev:Arguments').getArgs |
||
local |
local i18n = require('Dev:I18n').loadMessages('Mbox') |
||
function Mbox.main(frame) |
function Mbox.main(frame) |
||
Line 26: | Line 9: | ||
-- styles |
-- styles |
||
local styles = {} |
local styles = {} |
||
styles['border-left-color'] = i18n:parameter('bordercolor', args) |
|||
styles['background-color'] = i18n:parameter('bgcolor', args) |
|||
⚫ | |||
styles['border-left-color'] = 'var(--type-' .. args.type .. ')' |
|||
end |
|||
-- images |
|||
local image = i18n:parameter('image', args) or '' |
|||
local imageadjust = '' |
|||
⚫ | |||
⚫ | |||
end |
end |
||
⚫ | |||
⚫ | |||
-- images |
|||
local |
local imagelinkarg = i18n:parameter('imagelink', args) |
||
if imagelinkarg then |
|||
⚫ | |||
imagelink = imagelink .. imagelinkarg |
|||
⚫ | |||
⚫ | |||
end |
end |
||
local imagewikitext = |
local imagewikitext = '[[File:' .. image .. '|' .. imagewidth .. imageadjust .. imagelink .. ']]' |
||
-- id for closure |
-- id for closure |
||
local id = |
local id = i18n:parameter('id', args) or 'mbox' |
||
local typeclass = i18n:parameter('type', args) |
|||
local container = mw.html.create('div') |
local container = mw.html.create('div') |
||
:addClass('mbox') |
:addClass('mbox') |
||
:addClass( |
:addClass(typeclass and ('mbox-type-' .. typeclass)) |
||
:addClass(i18n:parameter('class', args)) |
|||
:css(styles) |
:css(styles) |
||
: |
:cssText(i18n:parameter('style', args)) |
||
:cssText(args.style) |
|||
local content = container:tag('div') |
local content = container:tag('div') |
||
:addClass('mbox__content') |
:addClass('mbox__content') |
||
local collapsed = i18n:parameter('collapsed', args) |
|||
:css(localCSS['mbox__content']) |
|||
if |
if image ~= '' then |
||
local image = content:tag('div') |
local image = content:tag('div') |
||
:addClass('mbox__content__image') |
:addClass('mbox__content__image') |
||
:addClass('mw-collapsible') |
:addClass('mw-collapsible') |
||
:attr('id', 'mw-customcollapsible-' .. id) |
:attr('id', 'mw-customcollapsible-' .. id) |
||
:css(localCSS['mbox__content__image']) |
|||
:wikitext(imagewikitext) |
:wikitext(imagewikitext) |
||
if |
if collapsed then |
||
image:addClass('mw-collapsed') |
image:addClass('mw-collapsed') |
||
end |
end |
||
Line 74: | Line 55: | ||
local contentwrapper = content:tag('div') |
local contentwrapper = content:tag('div') |
||
:addClass('mbox__content__wrapper') |
:addClass('mbox__content__wrapper') |
||
local header = i18n:parameter('header', args) |
|||
:css(localCSS['mbox__content__wrapper']) |
|||
if |
if header then |
||
contentwrapper:tag('div') |
contentwrapper:tag('div') |
||
:addClass('mbox__content__header') |
:addClass('mbox__content__header') |
||
: |
:wikitext(header) |
||
:wikitext(args.header) |
|||
end |
end |
||
local textarg = i18n:parameter('text', args) |
|||
if textarg then |
|||
local text = contentwrapper:tag('div') |
local text = contentwrapper:tag('div') |
||
:addClass('mbox__content__text') |
:addClass('mbox__content__text') |
||
:addClass('mw-collapsible') |
:addClass('mw-collapsible') |
||
:attr('id', 'mw-customcollapsible-' .. id) |
:attr('id', 'mw-customcollapsible-' .. id) |
||
: |
:wikitext(textarg) |
||
if collapsed then |
|||
⚫ | |||
text:addClass('mw-collapsed') |
text:addClass('mw-collapsed') |
||
end |
end |
||
local comment = i18n:parameter('comment', args) |
|||
⚫ | |||
text:tag('div') |
text:tag('div') |
||
:addClass('mbox__content__text__comment') |
:addClass('mbox__content__text__comment') |
||
: |
:wikitext(comment) |
||
:wikitext(args.comment) |
|||
end |
end |
||
end |
end |
||
Line 105: | Line 85: | ||
:addClass('mbox__close') |
:addClass('mbox__close') |
||
:addClass('mw-customtoggle-' .. id) |
:addClass('mw-customtoggle-' .. id) |
||
: |
:attr('title', i18n:msg('dismiss')) |
||
:attr('title', 'Dismiss') |
|||
local asidearg = i18n:parameter('aside', args) |
|||
if asidearg then |
|||
local aside = content:tag('div') |
local aside = content:tag('div') |
||
:addClass('mbox__content__aside') |
:addClass('mbox__content__aside') |
||
:addClass('mw-collapsible') |
:addClass('mw-collapsible') |
||
:attr('id', 'mw-customcollapsible-' .. id) |
:attr('id', 'mw-customcollapsible-' .. id) |
||
: |
:wikitext(asidearg) |
||
if collapsed then |
|||
if args.collapsed then |
|||
aside:addClass('mw-collapsed') |
aside:addClass('mw-collapsed') |
||
end |
end |
||
Line 123: | Line 102: | ||
end |
end |
||
-- |
|||
-- END DELETION HERE |
|||
-- |
|||
-- The last line produces the output for the template |
|||
return Mbox |
return Mbox |