Module:Navbox/sandbox: Difference between revisions

Content deleted Content added
Make hiding_templatestyles global
sandbox config
 
(11 intermediate revisions by 2 users not shown)
Line 24:
 
-- helper functions
local andnum = function(s, n) return string.format(cfg.arg[s .. '_and_num'], n) end
local isblank = function(v) return (v or '') == '' end
 
Line 118:
-- Applying nowrap to lines in a table does not make sense.
-- Add newlines to compensate for trim of x in |parm=x in a template.
return '\n' .. item .. '\n'
end
if nowrapitems == cfg.keyword.nowrapitems_yes then
Line 132:
end
if item:match('^[*:;#]') then
return '\n' .. item .. '\n'
end
return item
Line 156:
local function renderNavBar(titleCell)
if has_navbar() then
local navbar = require('Module:Navbar/sandbox')._navbar
titleCell:wikitext(navbar{
[cfg.navbar.name] = args[cfg.arg.name],
Line 190:
:tag('div')
-- id for aria-labelledby attribute
:attr('id', mw.uri.anchorEncode(args[cfg.arg.title]) .. args.argHash)
:addClass(args[cfg.arg.titleclass])
:css('font-size', '114%')
Line 217:
-- id for aria-labelledby attribute, if no title
:attr('id', (not args[cfg.arg.title]) and
(mw.uri.anchorEncode(args[cfg.arg.above]) .. args.argHash)
or nil)
:wikitext(processItem(args[cfg.arg.above], args[cfg.arg.nowrapitems]))
Line 245:
:addClass(cfg.class.navbox_image)
:addClass(args[cfg.arg.imageclass])
:css('width', '1px0px') -- Minimize width
:css('padding', '0 2px 0 0')
:cssText(args[cfg.arg.imageleftstyle])
Line 261:
if listnum == 1 and not (args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group2]) then
groupCell
:attr('id', mw.uri.anchorEncode(args[cfg.arg.group1]) .. args.argHash)
end
 
Line 331:
:addClass(cfg.class.navbox_image)
:addClass(args[cfg.arg.imageclass])
:css('width', '1px0px') -- Minimize width
:css('padding', '0 0 0 2px')
:cssText(args[cfg.arg.imagestyle])
Line 527:
-- for each arg: find all the templatestyles strip markers, insert them into a
-- table. then remove all templatestyles markers from the arg
local strip_marker_pattern = '(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)'
local function move_hiding_templatestyles(args)
local gfindargHash = string.gfind0
for k, arg in pairs(args) do
local gsub = string.gsub
if type(arg) == 'string' then
local templatestyles_markers = {}
for marker in string.gfind(arg, strip_marker_pattern) do
local strip_marker_pattern = '(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)'
table.insert(hiding_templatestyles, vmarker)
for k, arg in pairs(args) do
for marker in gfind(arg, strip_marker_pattern) do
table.insert(templatestyles_markers, marker)
end
argHash = argHash + #arg
args[k] = string.gsub(arg, strip_marker_pattern, '')
end
return templatestyles_markers
end
if not args.argHash then args.argHash = argHash end
 
for _, v in ipairs(move_hiding_templatestyles(args)) do
if not inArray(hiding_templatestyles, v) then
table.insert(hiding_templatestyles, v)
end
end
local listnums = {}
 
Line 552 ⟶ 546:
if type(k) == 'string' then
local listnum = k:match(cfg.pattern.listnum)
if listnum thenand table.insertargs[andnum(listnums'list', tonumber(listnum))] endthen
table.insert(listnums, tonumber(listnum))
end
end
end
Line 580 ⟶ 576:
mw.uri.anchorEncode(
args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]
) .. args.argHash
)
else
Line 602 ⟶ 598:
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
:css('padding', '3px0px')
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
Line 611 ⟶ 607:
mw.uri.anchorEncode(
args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]
) .. args.argHash
)
else
nav:attr('aria-label', cfg.aria_label .. args.argHash)
end
end
Line 839 ⟶ 835:
and isblank(pargs[andnum('colfooter', 1)]) then
targs[andnum('list', 1)] = targs[andnum('list', 1)] ..
'[[' .. cfg.patterncategory.without_first_col .. ']]'
end