Module:Sandbox/BrandonXLF/3: Difference between revisions

Content deleted Content added
Undid revision 1060234373 by BrandonXLF (talk)
Theme navbox-image
 
(29 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 string.match(image, ".-%+.-") then
},
k, image = string.match(image, "(.-)+(.-)")
hlist_templatestyles = 'Hlist/styles.css',
end
plainlist_templatestyles = 'Plainlist/styles.css',
-- do not localize marker table
if true then
marker = {
return image
oddeven = '\127_ODDEVEN_\127',
end
restart = '\127_ODDEVEN0_\127',
 
regex = '\127_ODDEVEN(%d?)_\127'
local file = nil
},
 
category = {
if string.match(image, ".-%..*") then
orphan = '[[Category:Navbox orphans]]',
file = frame:expandTemplate{title = "flagicon image", args = {image}}
horizontal_lists = 'Navigational boxes without horizontal lists',
elseif string.match(image, ".-%s%(.-%)") then
background_colors = 'Navboxes using background colours',
local country, var = string.match(image,"(.-)%s%((.-)%)")
illegible = 'Potentially illegible navboxes',
file = frame:expandTemplate{title = "flagdeco", args = {country, var}}
borders = 'Navboxes using borders',
else
},
file = frame:expandTemplate{title = "flagdeco", args = {image}}
keyword = {
end
border_subgroup = 'subgroup',
 
border_child = 'child',
return file
border_none = 'none',
end
evenodd_swap = 'swap',
 
navbar_off = 'off',
function getCountry(country)
navbar_plain = 'plain',
if string.match(country, ".-%+.-") then
nocat_false = 'false',
country, _ = string.match(country, "(.-)%+(.-)")
nowrapitems_yes = 'yes',
end
orphan_yes = 'yes',
state_collapsed = 'collapsed',
local title = mw.title.new(country)
state_off = 'off',
state_plain = 'plain',
if not title or not title.exists then
subgroups = {'subgroup', 'child', ''},
return country
subpage_doc = 'doc',
end
subpage_sandbox = 'sandbox',
subpage_testcases = 'testcases',
return '[[' .. country .. ']]'
tracking_no = 'no'
end
},
 
class = {
function p.main(frame)
autocollapse = 'autocollapse',
local args = getArgs(frame)
collapsible = 'mw-collapsible',
local hasImages = false
collapsed = 'mw-collapsed',
local entries = {}
-- Warning
local i = 1
navbox = 'navbox', -- WMF currently hides 'navbox' from mobile,
 
-- so you probably shouldn't change the navbox class.
while args[i + 1] do
navbox_abovebelow = 'navbox-abovebelow notheme',
image = getImage(frame, args[i])
navbox_group = 'navbox-group notheme',
navbox_image = 'navbox-image',
table.insert(entries, {
navbox_inner = 'navbox-inner notheme',
image = image,
navbox_list = 'navbox-list notheme',
country = getCountry(args[i]),
navbox_list_with_group = 'navbox-list-with-group',
post = args[i + 1] and ' (' .. args[i + 1] .. ')' or ''
navbox_part = 'navbox-', -- do not l10n
})
navbox_styles = 'navbox-styles',
navbox_subgroup = 'navbox-subgroup',
if image then
navbox_title = 'navbox-title notheme', -- l10n only if you change pattern.navbox_title below
hasImages = true
navbox_odd_part = 'odd', -- do not l10n
end
navbox_even_part = 'even', -- do not l10n
inomobile = i + 2'nomobile',
nowraplinks = 'nowraplinks',
end
noviewer = 'noviewer' -- used to remove images from MediaViewer
},
if args[i] then
pattern = {
return require('Module:Error').error{'Uneven number of parameters, there should be 3 parameters per entry.'}
listnum = '^list(%d+)$',
end
class = 'class',
sandbox = '/sandbox$',
local outTable = mw.html.create('table')
navbox = 'Template:Navbox',
:css({
paddingnowrap = '5px^<span class="nowrap">',
floatstyle = args.float or 'leftstyle$',
navbox_title = '<th[^>]*"navbox%-title"',
['background-color'] = '#f8f9fa',
borderhlist = '1px solid #aaahlist',
widthplainlist = '20emplainlist',
},
['font-size'] = '90%'
arg = {
})
above = 'above',
 
aboveclass = 'aboveclass',
outTable:tag('tr')
abovestyle = 'abovestyle',
:tag('th')
basestyle = 'basestyle',
:attr('colspan', hasImages and 2 or 1)
bodyclass = 'bodyclass',
:css({
['text-align']bodystyle = 'centerbodystyle',
['font-size']border = 'largerborder',
['font-weight']below = 'boldbelow',
belowclass = 'belowclass',
})
belowstyle = 'belowstyle',
:wikitext(args.title and args.title or 'Historical affiliations')
evenodd = 'evenodd',
 
evenstyle = 'evenstyle',
for i, entry in ipairs(entries) do
group1 = 'group1',
local row = outTable:tag('tr')
group2 = 'group2',
group_and_num = 'group%d',
if entry.image then
groupstyle_and_num = 'group%dstyle',
row:tag('td')
groupclass = 'groupclass',
:css('vertical-align', 'top')
groupstyle = 'groupstyle',
:wikitext(entry.image)
groupwidth = 'groupwidth',
elseif hasImages then
innerstyle = 'innerstyle',
row:tag('td')
image = 'image',
end
imageclass = 'imageclass',
imageleft = 'imageleft',
row:tag('td')
imageleftstyle = 'imageleftstyle',
:css({
widthimagesetyle = '100%imagestyle',
['vertical-align']list_and_num = 'toplist%d',
listclass_and_num = 'list%dclass',
})
liststyle_and_num = 'list%dstyle',
:wikitext(entry.country .. entry.post)
list1padding = 'list1padding',
end
listclass = 'listclass',
 
listpadding = 'listpadding',
return tostring(outTable)
liststyle = 'liststyle',
end
name = 'name',
 
navbar = 'navbar',
return p
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'
}
}