This module depends on the following other modules: |
This module uses TemplateStyles: |
Implements Template:Navigation header.
main(frame: table) -> string
Takes a frame object containing the template'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.
_main(args: table) -> string
Takes an args object containing another module's arguments into this module and does the same as above.
local p = {}
local standardIcons = require('Module:Standard icons')
local shortcut = require('Module:Shortcut')
local function getIcon(key)
local iconTable = standardIcons.getIconTable()
return iconTablekey or key
end
function p._main(args)
local icon = {}
local label = {}
local itemType = {}
do
local i = 1
while args"icon" .. i or args"type" .. i or args"label" .. i do
iconi = args"icon" .. i or getIcon(args"type" .. i])
labeli = args"label" .. i or ""
itemTypei = args"type" .. i or ""
i = i + 1
end
end
local theme = 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)
local shortcutParam = args"shortcut"
if shortcutParam then
local shortcutBox = shortcut._main({shortcutParam})
output#output + 1 = string.format('<div class="navigation-header-shortcut">%s</div>', shortcutBox)
end
output#output + 1 = '<ul>'
-- Add leadtab if leadtab-label is defined
local leadtabLabel = args"leadtab-label"
if leadtabLabel then
local leadtabIcon = 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>',
itemTypej],
iconj],
labelj
)
end
output#output + 1 = '</ul>'
output#output + 1 = '</div></div>'
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:Navigation header/styles.css' }
} .. table.concat(output, '\n')
end
function p.main(frame)
return p._main(frame:getParent().args)
end
return p
This module depends on the following other modules: |
This module uses TemplateStyles: |
Implements Template:Navigation header.
main(frame: table) -> string
Takes a frame object containing the template'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.
_main(args: table) -> string
Takes an args object containing another module's arguments into this module and does the same as above.
local p = {}
local standardIcons = require('Module:Standard icons')
local shortcut = require('Module:Shortcut')
local function getIcon(key)
local iconTable = standardIcons.getIconTable()
return iconTablekey or key
end
function p._main(args)
local icon = {}
local label = {}
local itemType = {}
do
local i = 1
while args"icon" .. i or args"type" .. i or args"label" .. i do
iconi = args"icon" .. i or getIcon(args"type" .. i])
labeli = args"label" .. i or ""
itemTypei = args"type" .. i or ""
i = i + 1
end
end
local theme = 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)
local shortcutParam = args"shortcut"
if shortcutParam then
local shortcutBox = shortcut._main({shortcutParam})
output#output + 1 = string.format('<div class="navigation-header-shortcut">%s</div>', shortcutBox)
end
output#output + 1 = '<ul>'
-- Add leadtab if leadtab-label is defined
local leadtabLabel = args"leadtab-label"
if leadtabLabel then
local leadtabIcon = 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>',
itemTypej],
iconj],
labelj
)
end
output#output + 1 = '</ul>'
output#output + 1 = '</div></div>'
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:Navigation header/styles.css' }
} .. table.concat(output, '\n')
end
function p.main(frame)
return p._main(frame:getParent().args)
end
return p