Module:Navigation tabs
Provides functionality to Template:Navigation tabs
Functions
editgetIcon
editgetIcon(key: string) -> string
Takes an icon key and returns the corresponding icon filename from the standard icons table.
key: A string representing the key for the standard icon.
Returns: The filename of the corresponding icon from the standard icons table, or the input key if the key is not found in the table.
navigationHeader
editnavigationHeader(frame: table) -> string
Takes a frame object containing the module's arguments and generates a navigation header.
frame: A table containing the arguments passed to the module.
Returns: A string representing the generated HTML for the navigation header.
Usage
edit
local p = {}
-- Import the standard icons modules
local standardIcons = require('Module:Standard icons')
function p.getIcon(key)
local iconTable = standardIcons.getIconTable()
return iconTable[key] or key
end
function p.navigationHeader(frame)
local parentFrame = frame:getParent()
local icon = {}
local label = {}
local itemType = {}
local i = 1
while parentFrame.args["icon" .. i] or parentFrame.args["type" .. i] or parentFrame.args["label" .. i] do
icon[i] = parentFrame.args["icon" .. i] or p.getIcon(parentFrame.args["type" .. i])
label[i] = parentFrame.args["label" .. i] or ""
itemType[i] = parentFrame.args["type" .. i] or ""
i = i + 1
end
local theme = parentFrame.args["theme"] or "blue-theme"
if theme ~= "gray-theme" and theme ~= "blue-theme" then
theme = "blue-theme"
end
local output = {}
output[#output + 1] = string.format('<div class="navigation-header %s"><div role="navigation" class="navigation-header-tabs">', theme)
output[#output + 1] = '<ul>'
-- Add leadtab if leadtab-label is defined
local leadtabLabel = parentFrame.args["leadtab-label"]
if leadtabLabel then
local leadtabIcon = parentFrame.args["leadtab-icon"]
if leadtabIcon then
output[#output + 1] = string.format(
'<li id="leadtab"><div class="navigation-header-icon">[[File:%s|x18px|link=]]</div> %s</li>',
leadtabIcon,
leadtabLabel
)
else
output[#output + 1] = string.format(
'<li id="leadtab">%s</li>',
leadtabLabel
)
end
end
for j = 1, #icon do
output[#output + 1] = string.format(
'<li id="%s"><div class="navigation-header-icon">[[File:%s|x18px|link=]]</div> %s</li>',
itemType[j],
icon[j],
label[j]
)
end
output[#output + 1] = '</ul>'
output[#output + 1] = '</div></div>'
return table.concat(output, '\n')
end
return p