441
edits
(add class using template name, code requested by User:SD0001) |
m (5 revisions imported from wikipedia:Module:Message_box: see Topic:Vtixlm0q28eo6jtf) |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 12: | Line 12: | ||
-- Define constants | -- Define constants | ||
local CONFIG_MODULE = 'Module:Message box/configuration' | local CONFIG_MODULE = 'Module:Message box/configuration' | ||
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} | |||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
Line 74: | Line 75: | ||
local ns = obj.title.namespace | local ns = obj.title.namespace | ||
-- boxType is "mbox" or invalid input | -- boxType is "mbox" or invalid input | ||
if ns == 0 then | if args.demospace and args.demospace ~= '' then | ||
-- implement demospace parameter of mbox | |||
local demospace = string.lower(args.demospace) | |||
if DEMOSPACES[demospace] then | |||
-- use template from DEMOSPACES | |||
obj.cfg = cfg[DEMOSPACES[demospace]] | |||
elseif string.find( demospace, 'talk' ) then | |||
-- demo as a talk page | |||
obj.cfg = cfg.tmbox | |||
else | |||
-- default to ombox | |||
obj.cfg = cfg.ombox | |||
end | |||
elseif ns == 0 then | |||
obj.cfg = cfg.ambox -- main namespace | obj.cfg = cfg.ambox -- main namespace | ||
elseif ns == 6 then | elseif ns == 6 then | ||
Line 254: | Line 268: | ||
end | end | ||
if talkTitle and talkTitle.exists then | if talkTitle and talkTitle.exists then | ||
local talkText | |||
if self.isSmall then | |||
local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk) | |||
talkText = string.format('([[%s|talk]])', talkLink) | |||
else | |||
talkText = 'Relevant discussion may be found on' | |||
if talkArgIsTalkPage then | |||
talkText = string.format( | |||
'%s [[%s|%s]].', | |||
talkText, | |||
talk, | |||
talkTitle.prefixedText | |||
) | |||
else | |||
talkText = string.format( | |||
'%s the [[%s#%s|talk page]].', | |||
talkText, | |||
talkTitle.prefixedText, | |||
talk | |||
) | |||
end | |||
end | |||
self.talk = talkText | self.talk = talkText | ||
end | end | ||
Line 510: | Line 530: | ||
:addClass('mbox-text-span') | :addClass('mbox-text-span') | ||
:wikitext(self.issue or nil) | :wikitext(self.issue or nil) | ||
if (self.talk or self.fix) | if (self.talk or self.fix) then | ||
textCellDiv:tag('span') | textCellDiv:tag('span') | ||
:addClass('hide-when-compact') | :addClass('hide-when-compact') |