Changes

Jump to navigation Jump to search

Module:Navbox

1,679 bytes added, 22:18, 6 March 2013
add tracking categories
local args
local frame
local tableRowAdded = false
local border
.wikitext(args.image)
end
end
 
 
--
-- Tracking categories
--
function renderTrackingCategories(builder)
if not frame then return end
local s = frame:preprocess('{{#ifeq:{{NAMESPACE}}|{{ns:10}}|1|0}}{{SUBPAGENAME}}')
if mw.ustring.sub(s, 1, 1) == '0' then return end -- not in template space
local subpage = mw.ustring.lower(mw.ustring.sub(s, 2))
if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
for i, cat in ipairs(getTrackingCategories()) do
builder.wikitext('[[Category:' .. cat .. ']]')
end
end
 
function getTrackingCategories()
local cats = {}
if needsHorizontalLists() then table.insert(cats, 'Navigational boxes without horizontal lists') end
if hasCustomListSpacing() then table.insert(cats, 'Navigational boxes with custom list spacing') end
if hasBackgroundColors() then table.insert(cats, 'Navboxes using background colors') end
end
 
function needsHorizontalLists()
if border == 'child' or border == 'subgroup' or args.tracking == 'no' then return false end
local listClasses = {'plainlist', 'hlist', 'hlist hnum', 'hlist vcard', 'vcard hlist'}
for i, cls in ipairs(listClasses) do
if args.listclass == cls or args.bodyclass == cls then
return false
end
end
 
return true
end
 
function hasCustomListSpacing()
return args.liststyle == 'padding: 0.25em 0; line-height: 1.3em;' or
args.liststyle == 'padding:0.25em 0; line-height:1.4em; width:auto;' or
args.liststyle == 'padding:0.4em 0; line-height:1.4em;'
end
 
function hasBackgroundColors()
return args.titlestyle or args.groupstyle
end
end
-- TODO: add tracking categoriesrenderTrackingCategories(res)
return tostring(res)
end
function p.navbox(frm) frame)= frm
return p._navbox(frame:getParent().args)
end
return p
Anonymous user

Navigation menu