Module:Sidebar: Difference between revisions
Appearance
find vanishing TemplateStyles in args, find plainlist in class args |
add templatestyles for hlist |
||
Line 53: | Line 53: | ||
end | end | ||
local function has_navbar(navbar_mode, sidebar_name) | local function has_navbar(navbar_mode, sidebar_name) | ||
return navbar_mode ~= cfg.i18n.navbar_none and | return navbar_mode ~= cfg.i18n.navbar_none and | ||
Line 87: | Line 85: | ||
-- there are a lot of list classes in the wild, so we add their TemplateStyles | -- there are a lot of list classes in the wild, so we add their TemplateStyles | ||
local function add_list_styles(args) | local function add_list_styles(args) | ||
local frame = mw.getCurrentFrame() | |||
local function add_list_templatestyles(htmlclass, templatestyles) | local function add_list_templatestyles(htmlclass, templatestyles) | ||
if has_list_class(args, htmlclass) then | if has_list_class(args, htmlclass) then | ||
return frame:extensionTag{ | return frame:extensionTag{ | ||
Line 97: | Line 95: | ||
end | end | ||
end | end | ||
local plainlist_styles = add_list_templatestyles('plainlist', 'Plainlist/styles.css') | local plainlist_styles = add_list_templatestyles('plainlist', 'Plainlist/styles.css') | ||
local hlist_styles = add_list_templatestyles('hlist', 'Hlist/styles.css') | |||
return plainlist_styles | |||
-- a second workaround for [[phab:T303378]] | |||
-- when that issue is fixed, we can actually use has_navbar not to emit the | |||
-- tag here if we want | |||
if has_navbar(args.navbar, args.name) and hlist_styles == '' then | |||
hlist_styles = frame:extensionTag{ | |||
name = 'templatestyles', args = { src = 'Hlist/styles.css' } | |||
} | |||
end | |||
-- hlist -> plainlist is best-effort to preserve old Common.css ordering. [hlist_note] | |||
return hlist_styles .. plainlist_styles | |||
end | end | ||
Line 340: | Line 348: | ||
return table.concat({ | return table.concat({ | ||
add_list_styles(args), -- see [hlist_note] above about ordering | |||
base_templatestyles, | base_templatestyles, | ||
templatestyles, | templatestyles, | ||
child_templatestyles, | child_templatestyles, | ||
grandchild_templatestyles, | grandchild_templatestyles, | ||
hiding_templatestyles, | hiding_templatestyles, | ||
tostring(root), | tostring(root), |