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 div1classcollapsibleContainerClass = formatAttributes( 'class', 'NavFrame', not args.expand and 'collapsed' )
'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,
not ( args.frame_style or args.framestyle ) and 'border: none; padding: 0;'
)
local div2classcollapsibleTitleStyle = formatAttributes( 'class', 'NavHead' )
local div2style = formatAttributes(
'style',
'line-height: 1.6em; font-weight: bold; font-size: 105100%; text-align: left;',
args.title_style,
args.titlestyle,
)
not ( args.title_style or args.titlestyle ) and 'background: transparent; text-align: left;'
local div1stylejumpyTitleStyle = formatAttributes(
'style',
centeredTitleSpacing
)
local title = args.title or 'List'
local ulclass = formatAttributes( 'class', 'NavContentmw-collapsible-content', args.hlist and 'hlist' )
local ulstyle = formatAttributes(
'style',
not args.bullets and 'listfont-stylesize: none100%; nonemargin-top: 0; margin-leftbottom: 0; line-height: inherit; text-align: left;',
not args.bullets and 'list-style: none; margin-left: 0;',
args.list_style,
args.liststyle,
not ( args.list_style or args.liststyle ) and 'text-align: left;',
'font-size: 105%; margin-top: 0; margin-bottom: 0; line-height: inherit;'
)
-- 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,
div1classcollapsibleTitleStyle, div1style, div2class, div2stylejumpyTitleStyle, title, ulclass, ulstyle, listItems
)
) .. gettitlestyletracking(args.title_style or args.titlestyle)
end
 
verified
2,499

edits