Module:Sandbox/BrandonXLF/3: Difference between revisions

Content deleted Content added
No edit summary
Theme navbox-image
 
(43 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 p.main(frame)
border_child = 'child',
local args = getArgs(frame)
border_none = 'none',
local hasImages = false
evenodd_swap = 'swap',
local entries = {}
navbar_off = 'off',
local i = 1
navbar_plain = 'plain',
 
nocat_false = 'false',
while args[i] do
nowrapitems_yes = 'yes',
image = getImage(frame, args[i])
orphan_yes = 'yes',
state_collapsed = 'collapsed',
table.insert(entries, {
imagestate_off = image'off',
countrystate_plain = args[i + 1]'plain',
subgroups = {'subgroup', 'child', ''},
post = args[i + 2] and ' (' .. args[i + 2] .. ')' or ''
subpage_doc = 'doc',
})
subpage_sandbox = 'sandbox',
subpage_testcases = 'testcases',
if image then
hasImagestracking_no = true'no'
},
end
class = {
autocollapse = 'autocollapse',
i = i + 3
collapsible = 'mw-collapsible',
end
collapsed = 'mw-collapsed',
-- Warning
local outTable = mw.html.create('table')
navbox = 'navbox', -- WMF currently hides 'navbox' from mobile,
:css({
-- so you probably shouldn't change the navbox class.
padding = '5px',
navbox_abovebelow = 'navbox-abovebelow notheme',
float = args.float or 'left',
navbox_group = 'navbox-group notheme',
['background-color'] = '#f8f9fa',
bordernavbox_image = '1px solid #aaanavbox-image',
navbox_inner = 'navbox-inner notheme',
width = '20em',
navbox_list = 'navbox-list notheme',
['font-size'] = '90%'
navbox_list_with_group = 'navbox-list-with-group',
})
navbox_part = 'navbox-', -- do not l10n
 
navbox_styles = 'navbox-styles',
outTable:tag('tr')
navbox_subgroup = 'navbox-subgroup',
:tag('th')
navbox_title = 'navbox-title notheme', -- l10n only if you change pattern.navbox_title below
:attr('colspan', hasImages and 2 or 1)
navbox_odd_part = 'odd', -- do not l10n
:css({
navbox_even_part = 'even', -- do not l10n
['text-align'] = 'center',
['font-size']nomobile = 'largernomobile',
nowraplinks = 'nowraplinks',
['font-weight'] = 'bold'
noviewer = 'noviewer' -- used to remove images from MediaViewer
})
},
:wikitext(args.title and args.title or 'Historical affiliations')
pattern = {
 
listnum = '^list(%d+)$',
for i, entry in ipairs(entries) do
class = 'class',
local row = outTable:tag('tr')
sandbox = '/sandbox$',
navbox = 'Template:Navbox',
if entry.image then
nowrap = '^<span class="nowrap">',
row:tag('td')
style = 'style$',
:css('vertical-align', 'top')
navbox_title = '<th[^>]*"navbox%-title"',
:wikitext(entry.image)
hlist = 'hlist',
elseif hasimages then
plainlist = 'plainlist',
row:tag('td')
},
end
arg = {
row:tag(above = 'tdabove'),
aboveclass = 'aboveclass',
:css({
widthabovestyle = '100%abovestyle',
basestyle = 'basestyle',
['vertical-align'] = 'top'
bodyclass = 'bodyclass',
})
bodystyle = 'bodystyle',
:wikitext(entry.country .. entry.post)
border = 'border',
end
below = 'below',
 
belowclass = 'belowclass',
return tostring(outTable)
belowstyle = 'belowstyle',
end
evenodd = 'evenodd',
 
evenstyle = 'evenstyle',
return p
group1 = 'group1',
group2 = 'group2',
group_and_num = 'group%d',
groupstyle_and_num = 'group%dstyle',
groupclass = 'groupclass',
groupstyle = 'groupstyle',
groupwidth = 'groupwidth',
innerstyle = 'innerstyle',
image = 'image',
imageclass = 'imageclass',
imageleft = 'imageleft',
imageleftstyle = 'imageleftstyle',
imagesetyle = 'imagestyle',
list_and_num = 'list%d',
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'
}
}