Module:Sandbox/BrandonXLF/3: Difference between revisions

Content deleted Content added
No edit summary
Theme navbox-image
 
(39 intermediate revisions by the same user not shown)
Line 1:
-- Sandbox, do not delete
 
return {
local getArgs = require('Module:Arguments').getArgs
aria_label = 'Navbox',
local p = {}
nowrap_item = '%s<span class="nowrap">%s</span>',
 
templatestyles = mw.getCurrentFrame():extensionTag{
function getImage(frame, image)
name = 'templatestyles', args = { src = 'User:BrandonXLF/styles2.css' }
if not image then
},
return nil
hlist_templatestyles = 'Hlist/styles.css',
end
plainlist_templatestyles = 'Plainlist/styles.css',
 
-- do not localize marker table
local file = nil
marker = {
 
oddeven = '\127_ODDEVEN_\127',
if string.match(image, "(.-)%.(.*)") then
restart = '\127_ODDEVEN0_\127',
file = frame:expandTemplate{title = "flagicon image", args = {image}}
regex = '\127_ODDEVEN(%d?)_\127'
elseif string.match(image, ".-%s%(.-%)") then
},
local country, var = string.match(image,"(.-)%s%((.-)%)")
category = {
file = frame:expandTemplate{title = "flagdeco", args = {country, var}}
orphan = '[[Category:Navbox orphans]]',
else
horizontal_lists = 'Navigational boxes without horizontal lists',
file = frame:expandTemplate{title = "flagdeco", args = {image}}
background_colors = 'Navboxes using background colours',
end
illegible = 'Potentially illegible navboxes',
 
borders = 'Navboxes using borders',
return file
},
end
keyword = {
 
border_subgroup = 'subgroup',
function getCountry(country)
border_child = 'child',
local title = mw.title.new(country)
border_none = 'none',
evenodd_swap = 'swap',
if not title or not title.exists then
navbar_off = 'off',
return country
navbar_plain = 'plain',
end
nocat_false = 'false',
nowrapitems_yes = 'yes',
return '[[' .. country .. ']]'
orphan_yes = 'yes',
end
state_collapsed = 'collapsed',
 
state_off = 'off',
function p.main(frame)
state_plain = 'plain',
local args = getArgs(frame)
subgroups = {'subgroup', 'child', ''},
local hasImages = false
subpage_doc = 'doc',
local entries = {}
subpage_sandbox = 'sandbox',
local i = 1
subpage_testcases = 'testcases',
 
tracking_no = 'no'
while args[i + 2] do
},
image = getImage(frame, args[i])
class = {
autocollapse = 'autocollapse',
table.insert(entries, {
collapsible = 'mw-collapsible',
image = image,
collapsed = 'mw-collapsed',
country = getCountry(args[i + 1]),
-- Warning
post = args[i + 2] and ' (' .. args[i + 2] .. ')' or ''
navbox = 'navbox', -- WMF currently hides 'navbox' from mobile,
})
-- so you probably shouldn't change the navbox class.
navbox_abovebelow = 'navbox-abovebelow notheme',
if image then
navbox_group = 'navbox-group notheme',
hasImages = true
navbox_image = 'navbox-image',
end
navbox_inner = 'navbox-inner notheme',
navbox_list = 'navbox-list notheme',
i = i + 3
navbox_list_with_group = 'navbox-list-with-group',
end
navbox_part = 'navbox-', -- do not l10n
navbox_styles = 'navbox-styles',
if args[i] then
navbox_subgroup = 'navbox-subgroup',
return require('Module:Error').error{'Uneven number of parameters, there should be 3 parameters per entry.'}
navbox_title = 'navbox-title notheme', -- l10n only if you change pattern.navbox_title below
end
navbox_odd_part = 'odd', -- do not l10n
navbox_even_part = 'even', -- do not l10n
local outTable = mw.html.create('table')
nomobile = 'nomobile',
:css({
paddingnowraplinks = '5pxnowraplinks',
noviewer = 'noviewer' -- used to remove images from MediaViewer
float = args.float or 'left',
},
['background-color'] = '#f8f9fa',
pattern = {
border = '1px solid #aaa',
widthlistnum = '20em^list(%d+)$',
['font-size']class = '90%class',
sandbox = '/sandbox$',
})
navbox = 'Template:Navbox',
 
nowrap = '^<span class="nowrap">',
outTable:tag('tr')
:tag(style = 'thstyle$'),
navbox_title = '<th[^>]*"navbox%-title"',
:attr('colspan', hasImages and 2 or 1)
hlist = 'hlist',
:css({
['text-align']plainlist = 'centerplainlist',
},
['font-size'] = 'larger',
arg = {
['font-weight'] = 'bold'
above = 'above',
})
aboveclass = 'aboveclass',
:wikitext(args.title and args.title or 'Historical affiliations')
abovestyle = 'abovestyle',
 
basestyle = 'basestyle',
for i, entry in ipairs(entries) do
bodyclass = 'bodyclass',
local row = outTable:tag('tr')
bodystyle = 'bodystyle',
border = 'border',
if entry.image then
row:tag(below = 'tdbelow'),
belowclass = 'belowclass',
:css('vertical-align', 'top')
belowstyle = 'belowstyle',
:wikitext(entry.image)
evenodd = 'evenodd',
elseif hasImages then
evenstyle = 'evenstyle',
row:tag('td')
group1 = 'group1',
end
group2 = 'group2',
group_and_num = 'group%d',
row:tag('td')
groupstyle_and_num = 'group%dstyle',
:css({
widthgroupclass = '100%groupclass',
groupstyle = 'groupstyle',
['vertical-align'] = 'top'
groupwidth = 'groupwidth',
})
innerstyle = 'innerstyle',
:wikitext(entry.country .. entry.post)
image = 'image',
end
imageclass = 'imageclass',
 
imageleft = 'imageleft',
return tostring(outTable)
imageleftstyle = 'imageleftstyle',
end
imagesetyle = 'imagestyle',
 
list_and_num = 'list%d',
return p
listclass_and_num = 'list%dclass',
liststyle_and_num = 'list%dstyle',
list1padding = 'list1padding',
listclass = 'listclass',
listpadding = 'listpadding',
liststyle = 'liststyle',
name = 'name',
navbar = 'navbar',
navboxclass = 'navboxclass',
nocat = 'nocat',
nowrapitems = 'nowrapitems',
oddstyle = 'oddstyle',
orphan = 'orphan',
state = 'state',
style = 'style',
templatestyles = 'templatestyles',
child_templatestyles = 'child templatestyles',
title = 'title',
titleclass = 'titleclass',
titlestyle = 'titlestyle',
tracking = 'tracking'
},
-- names of navbar arguments
navbar = {
name = 1,
fontstyle = 'fontstyle',
mini = 'mini'
}
}