| Line 13: |
Line 13: |
| | 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'} | | local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'} |
| | + | local TEMPLATE_STYLES = 'Module:Message box/%s.css' |
| | | | |
| | -------------------------------------------------------------------------------- | | -------------------------------------------------------------------------------- |
| Line 66: |
Line 67: |
| | args = args or {} | | args = args or {} |
| | local obj = {} | | local obj = {} |
| | + | |
| | + | obj.boxType = boxType |
| | | | |
| | -- Set the title object and the namespace. | | -- Set the title object and the namespace. |
| Line 81: |
Line 84: |
| | -- use template from DEMOSPACES | | -- use template from DEMOSPACES |
| | obj.cfg = cfg[DEMOSPACES[demospace]] | | obj.cfg = cfg[DEMOSPACES[demospace]] |
| | + | obj.boxType = DEMOSPACES[demospace] |
| | elseif string.find( demospace, 'talk' ) then | | elseif string.find( demospace, 'talk' ) then |
| | -- demo as a talk page | | -- demo as a talk page |
| | obj.cfg = cfg.tmbox | | obj.cfg = cfg.tmbox |
| | + | obj.boxType = 'tmbox' |
| | else | | else |
| | -- default to ombox | | -- default to ombox |
| | obj.cfg = cfg.ombox | | obj.cfg = cfg.ombox |
| | + | obj.boxType = 'ombox' |
| | end | | end |
| | elseif ns == 0 then | | elseif ns == 0 then |
| | obj.cfg = cfg.ambox -- main namespace | | obj.cfg = cfg.ambox -- main namespace |
| | + | obj.boxType = 'ambox' |
| | elseif ns == 6 then | | elseif ns == 6 then |
| | obj.cfg = cfg.imbox -- file namespace | | obj.cfg = cfg.imbox -- file namespace |
| | + | obj.boxType = 'imbox' |
| | elseif ns == 14 then | | elseif ns == 14 then |
| | obj.cfg = cfg.cmbox -- category namespace | | obj.cfg = cfg.cmbox -- category namespace |
| | + | obj.boxType = 'cmbox' |
| | else | | else |
| | local nsTable = mw.site.namespaces[ns] | | local nsTable = mw.site.namespaces[ns] |
| | if nsTable and nsTable.isTalk then | | if nsTable and nsTable.isTalk then |
| | obj.cfg = cfg.tmbox -- any talk namespace | | obj.cfg = cfg.tmbox -- any talk namespace |
| | + | obj.boxType = 'tmbox' |
| | else | | else |
| | obj.cfg = cfg.ombox -- other namespaces or invalid input | | obj.cfg = cfg.ombox -- other namespaces or invalid input |
| | + | obj.boxType = 'ombox' |
| | end | | end |
| | end | | end |
| Line 268: |
Line 279: |
| | end | | end |
| | if talkTitle and talkTitle.exists then | | if talkTitle and talkTitle.exists then |
| − | local talkText
| + | local talkText = 'Relevant discussion may be found on' |
| − | if self.isSmall then
| + | if talkArgIsTalkPage then |
| − | local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. '#' .. talk)
| + | talkText = string.format( |
| − | talkText = string.format('([[%s|talk]])', talkLink)
| + | '%s [[%s|%s]].', |
| − | else
| + | talkText, |
| − | talkText = 'Relevant discussion may be found on'
| + | talk, |
| − | if talkArgIsTalkPage then
| + | talkTitle.prefixedText |
| − | talkText = string.format(
| + | ) |
| − | '%s [[%s|%s]].',
| + | else |
| − | talkText,
| + | talkText = string.format( |
| − | talk,
| + | '%s the [[%s#%s|talk page]].', |
| − | talkTitle.prefixedText
| + | talkText, |
| − | )
| + | talkTitle.prefixedText, |
| − | else
| + | talk |
| − | talkText = string.format(
| + | ) |
| − | '%s the [[%s#%s|talk page]].',
| + | end |
| − | talkText,
| |
| − | talkTitle.prefixedText,
| |
| − | talk
| |
| − | )
| |
| − | end
| |
| − | end
| |
| | self.talk = talkText | | self.talk = talkText |
| | end | | end |
| Line 303: |
Line 308: |
| | end | | end |
| | if date then | | if date then |
| − | self.date = string.format(" <span class='date-container'>''(<span class='date'>%s</span>)''</span>", date) | + | self.date = string.format(" <small class='date-container'>''(<span class='date'>%s</span>)''</small>", date) |
| | end | | end |
| | self.info = args.info | | self.info = args.info |
| Line 326: |
Line 331: |
| | self.imageEmptyCell = cfg.imageEmptyCell | | self.imageEmptyCell = cfg.imageEmptyCell |
| | if cfg.imageEmptyCellStyle then | | if cfg.imageEmptyCellStyle then |
| − | self.imageEmptyCellStyle = 'border:none;padding:0;width:1px' | + | self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px' |
| | end | | end |
| | | | |
| Line 483: |
Line 488: |
| | )) | | )) |
| | end | | end |
| | + | |
| | + | -- Add TemplateStyles |
| | + | root:wikitext(mw.getCurrentFrame():extensionTag{ |
| | + | name = 'templatestyles', |
| | + | args = { src = TEMPLATE_STYLES:format(self.boxType) }, |
| | + | }) |
| | | | |
| | -- Create the box table. | | -- Create the box table. |
| Line 530: |
Line 541: |
| | :addClass('mbox-text-span') | | :addClass('mbox-text-span') |
| | :wikitext(self.issue or nil) | | :wikitext(self.issue or nil) |
| − | if (self.talk or self.fix) then | + | if (self.talk or self.fix) and not self.isSmall then |
| | textCellDiv:tag('span') | | textCellDiv:tag('span') |
| | :addClass('hide-when-compact') | | :addClass('hide-when-compact') |
| Line 544: |
Line 555: |
| | end | | end |
| | if self.removalNotice then | | if self.removalNotice then |
| − | textCellDiv:tag('span') | + | textCellDiv:tag('small') |
| | :addClass('hide-when-compact') | | :addClass('hide-when-compact') |
| | :tag('i') | | :tag('i') |