Changes

Jump to navigation Jump to search
m
1 revision imported
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 190: Line 201:  
self:addClass(args.class)
 
self:addClass(args.class)
 
self.style = args.style
 
self.style = args.style
self.lang  = args.lang
  −
self.dir  = args.dir or (args.lang and 'auto' or nil)
   
self.attrs = args.attrs
 
self.attrs = args.attrs
   Line 479: 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 490: Line 505:  
:attr('role', 'presentation')
 
:attr('role', 'presentation')
   −
if self.lang then
  −
boxTable:attr('lang', self.lang)
  −
end
  −
if self.dir then
  −
boxTable:attr('dir', self.dir)
  −
end
   
if self.attrs then
 
if self.attrs then
 
boxTable:attr(self.attrs)
 
boxTable:attr(self.attrs)

Navigation menu