编辑“︁模块:Message box”︁
跳转到导航
跳转到搜索
该编辑可以被撤销。 请检查下面的对比以核实您想要撤销的内容,然后发布下面的更改以完成撤销。
最后版本 | 您的文本 | ||
第62行: | 第62行: | ||
table.sort(nums) | table.sort(nums) | ||
return nums | return nums | ||
end | |||
local function insertStyle(cfg) | |||
-- Create the templatestyles tag. | |||
local frame = mw.getCurrentFrame() | |||
return frame:extensionTag{ | |||
name = 'templatestyles', | |||
args = { src = cfgTables['@global'].templatestyles }, | |||
} .. frame:extensionTag{ | |||
name = 'templatestyles', | |||
args = { src = cfg.templatestyles }, | |||
} | |||
end | end | ||
第160行: | 第174行: | ||
error(format('無效的訊息框類型「%s」;有效的類型為%s', tostring(boxType), mw.text.listToText(boxTypes)), 2) | error(format('無效的訊息框類型「%s」;有效的類型為%s', tostring(boxType), mw.text.listToText(boxTypes)), 2) | ||
end | end | ||
self.cfg = cfg | |||
return cfg | return cfg | ||
end | end | ||
function box:removeBlankArgs( | function box:removeBlankArgs(args) | ||
-- Only allow blank arguments for the parameter names listed in cfg.allowBlankParams. | -- Only allow blank arguments for the parameter names listed in cfg.allowBlankParams. | ||
local newArgs = {} | local newArgs = {} | ||
第171行: | 第186行: | ||
end | end | ||
end | end | ||
for i, param in ipairs(cfg.allowBlankParams or {}) do | for i, param in ipairs(self.cfg.allowBlankParams or {}) do | ||
newArgs[param] = args[param] | newArgs[param] = args[param] | ||
end | end | ||
第177行: | 第192行: | ||
end | end | ||
function box:setBoxParameters( | function box:setBoxParameters(args) | ||
local cfg = self.cfg | |||
-- Get type data. | -- Get type data. | ||
self.type = args.type | self.type = args.type | ||
第285行: | 第302行: | ||
local talkText = '相關討論可見於' | local talkText = '相關討論可見於' | ||
if talkArgIsTalkPage then | if talkArgIsTalkPage then | ||
talkText = format('%s[[%s|%s]] | talkText = format('%s[[%s|%s]].', talkText, talk, talkTitle.prefixedText) | ||
else | else | ||
talkText = format('%s[[%s#%s|討論頁]] | talkText = format('%s[[%s#%s|討論頁]].', talkText, talkTitle.prefixedText, talk) | ||
end | end | ||
self.talk = talkText | self.talk = talkText | ||
第516行: | 第533行: | ||
)) | )) | ||
end | end | ||
root:wikitext(insertStyle(self.cfg)) | |||
-- Create the box table. | -- Create the box table. | ||
第558行: | 第577行: | ||
textCell | textCell | ||
:cssText(self.textstyle) | :cssText(self.textstyle) | ||
local textCellSpan = textCell:tag(' | local textCellSpan = textCell:tag('div') | ||
textCellSpan | textCellSpan | ||
:addClass('mbox-text-span') | :addClass('mbox-text-span') | ||
第627行: | 第646行: | ||
local outputBox = box.new() | local outputBox = box.new() | ||
outputBox:setTitle(args) | outputBox:setTitle(args) | ||
outputBox:getConfig(boxType) | |||
args = outputBox:removeBlankArgs( | args = outputBox:removeBlankArgs(args) | ||
outputBox:setBoxParameters( | outputBox:setBoxParameters(args) | ||
return outputBox:export() | return outputBox:export() | ||
end | end | ||
第638行: | 第657行: | ||
return main(boxType, args) | return main(boxType, args) | ||
end | end | ||
end | |||
local function insertStyleWikitext(frame) | |||
local args = getArgs(frame, {trim = false, removeBlanks = false}) | |||
local boxType = args[1] or 'mbox' | |||
-- // ---- // -- | |||
local outputBox = box.new() | |||
outputBox:setTitle(args) | |||
local cfg = outputBox:getConfig(boxType) | |||
return insertStyle(cfg) | |||
end | end | ||
local p = { | local p = { | ||
main = main, | main = main, | ||
mbox = makeWrapper('mbox') | mbox = makeWrapper('mbox'), | ||
insertStyle = insertStyleWikitext | |||
} | } | ||
for boxType in pairs(cfgTables) do | for boxType in pairs(cfgTables) do | ||
p[boxType] = makeWrapper(boxType) | if boxType:sub(1, 1) ~= '@' then | ||
p[boxType] = makeWrapper(boxType) | |||
end | |||
end | end | ||
return p | return p |