Module:Sandbox/BrandonXLF/3: Difference between revisions

Content deleted Content added
No edit summary
Theme navbox-image
 
(28 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
},
image = string.match(image, ".-%+(.+)")
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, noredlink = 'y'}}
orphan = '[[Category:Navbox orphans]]',
else
horizontal_lists = 'Navigational boxes without horizontal lists',
file = frame:expandTemplate{title = "flagdeco", args = {image, noredlink = 'y'}}
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',
if string.match(country, ".-%+") then
border_none = 'none',
country = string.match(country, "(.-)%+")
evenodd_swap = 'swap',
end
navbar_off = 'off',
navbar_plain = 'plain',
local title = mw.title.new(country)
nocat_false = 'false',
nowrapitems_yes = 'yes',
if not title or not title.exists then
orphan_yes = 'yes',
return country
state_collapsed = 'collapsed',
end
state_off = 'off',
state_plain = 'plain',
return '[[' .. country .. ']]'
subgroups = {'subgroup', 'child', ''},
end
subpage_doc = 'doc',
 
subpage_sandbox = 'sandbox',
function p.main(frame)
subpage_testcases = 'testcases',
local args = getArgs(frame)
tracking_no = 'no'
local hasImages = false
},
local entries = {}
local iclass = 1{
autocollapse = 'autocollapse',
 
collapsible = 'mw-collapsible',
while args[i + 1] do
collapsed = 'mw-collapsed',
image = getImage(frame, args[i])
-- Warning
navbox = 'navbox', -- WMF currently hides 'navbox' from mobile,
table.insert(entries, {
-- so you probably shouldn't change the navbox class.
image = image,
navbox_abovebelow = 'navbox-abovebelow notheme',
country = getCountry(args[i]),
navbox_group = 'navbox-group notheme',
post = args[i + 1] and ' (' .. args[i + 1] .. ')' or ''
navbox_image = 'navbox-image',
})
navbox_inner = 'navbox-inner notheme',
navbox_list = 'navbox-list notheme',
if image then
navbox_list_with_group = 'navbox-list-with-group',
hasImages = true
navbox_part = 'navbox-', -- do not l10n
end
navbox_styles = 'navbox-styles',
navbox_subgroup = 'navbox-subgroup',
i = i + 2
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
if args[i] then
nomobile = 'nomobile',
return require('Module:Error').error{'Uneven number of parameters, there should be 3 parameters per entry.'}
nowraplinks = 'nowraplinks',
end
noviewer = 'noviewer' -- used to remove images from MediaViewer
},
local outTable = mw.html.create('table')
pattern = {
:css({
paddinglistnum = '5px^list(%d+)$',
floatclass = args.float or 'leftclass',
['background-color']sandbox = '#f8f9fa/sandbox$',
bordernavbox = '1px solid #aaaTemplate:Navbox',
widthnowrap = '20em^<span class="nowrap">',
['font-size']style = '90%style$',
navbox_title = '<th[^>]*"navbox%-title"',
})
hlist = 'hlist',
 
plainlist = 'plainlist',
outTable:tag('tr')
},
:tag('th')
arg = {
:attr('colspan', hasImages and 2 or 1)
above = 'above',
:css({
['text-align']aboveclass = 'centeraboveclass',
['font-size']abovestyle = 'largerabovestyle',
['font-weight']basestyle = 'boldbasestyle',
bodyclass = 'bodyclass',
})
bodystyle = 'bodystyle',
:wikitext(args.title and args.title or 'Historical affiliations')
border = 'border',
 
below = 'below',
for i, entry in ipairs(entries) do
belowclass = 'belowclass',
local row = outTable:tag('tr')
belowstyle = 'belowstyle',
evenodd = 'evenodd',
if entry.image then
evenstyle = 'evenstyle',
row:tag('td')
group1 = 'group1',
:css('vertical-align', 'top')
group2 = 'group2',
:wikitext(entry.image)
group_and_num = 'group%d',
elseif hasImages then
groupstyle_and_num = 'group%dstyle',
row:tag('td')
groupclass = 'groupclass',
end
groupstyle = 'groupstyle',
groupwidth = 'groupwidth',
row:tag('td')
innerstyle = 'innerstyle',
:css({
widthimage = '100%image',
imageclass = 'imageclass',
['vertical-align'] = 'top'
imageleft = 'imageleft',
})
imageleftstyle = 'imageleftstyle',
:wikitext(entry.country .. entry.post)
imagesetyle = 'imagestyle',
end
list_and_num = 'list%d',
 
listclass_and_num = 'list%dclass',
return tostring(outTable)
liststyle_and_num = 'list%dstyle',
end
list1padding = 'list1padding',
 
listclass = 'listclass',
return p
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'
}
}