Module:Collapsible list: Difference between revisions
m
1 revision imported from wikipedia:Module:Collapsible_list
(we need to get back to this. since module loading depends on parsercache, these pages are missing modules now and it takes long for all pages to be invalidate. Will return later.) |
m (1 revision imported from wikipedia:Module:Collapsible_list) |
||
(11 intermediate revisions by 7 users not shown) | |||
Line 2:
local p = {}
local function gettitlestyletracking( ts )
if not ts then return '' end
ts = mw.ustring.gsub(mw.ustring.lower(ts), '%s', '')
local tsvals = mw.text.split(ts, ';')
table.sort(tsvals)
local skey = table.concat(tsvals,';')
skey = mw.ustring.gsub(skey, '^;', '')
skey = mw.text.encode(mw.text.encode(skey),'%c%[%]=')
if (mw.ustring.match(';' .. ts, ';background:') or mw.ustring.match(';' .. ts, ';background%-color:'))
and mw.ustring.match(';' .. ts, ';text%-align:') then
return '[[Category:Pages using collapsible list with both background and text-align in titlestyle|' .. skey .. ' ]]'
end
return '[[Category:Pages using collapsible list without both background and text-align in titlestyle|' .. skey .. ' ]]'
end
local function getListItem( data )
Line 52 ⟶ 67:
end
listItems = table.concat( listItems )
-- hack around mw-collapsible show/hide jumpiness by looking for text-alignment
-- by setting a margin if centered
local textAlignmentCentered = 'text%-align%s*:%s*center'
local centeredTitle = (args.title_style and args.title_style:lower():match(textAlignmentCentered)
or args.titlestyle and args.titlestyle:lower():match(textAlignmentCentered))
local centeredTitleSpacing
if centeredTitle then
centeredTitleSpacing = 'margin: 0 4em'
else
centeredTitleSpacing = ''
end
-- Get class, style and title data.
local
'class',
local div1style = formatAttributes(▼
'mw-collapsible', not args.expand and 'mw-collapsed'
▲ )
local collapsibleContainerStyle = formatAttributes(
'style',
'text-align: center; font-size: 100%;',
args.frame_style,
args.framestyle
)
local
▲ local div2style = formatAttributes(
'style',
'line-height: 1.6em; font-weight: bold; font-size:
args.title_style,
args.titlestyle
)▼
'style',
centeredTitleSpacing
)
local title = args.title or 'List'
local ulclass = formatAttributes( 'class', '
local ulstyle = formatAttributes(
'style',
not args.bullets and 'list-style: none; margin-left: 0;',
args.list_style,
args.liststyle
)
-- Build the list.
return mw.ustring.format(
'<div%s%s>\n<div%s><div%s>%s</div></div>\n<ul%s%s>%s</ul>\n</div>',
collapsibleContainerClass, collapsibleContainerStyle,
▲ )
) .. gettitlestyletracking(args.title_style or args.titlestyle)
end
|