Modul:Navbar
Megjelenés
![]() | This Lua module is used in system messages. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid major disruption, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | Függ az alábbi moduloktól: |
![]() | TemplateStylest használ: |
This is a Lua implementation of {{Navbar}}. It is used in Module:Navbox.
require('strict')
local p = {}
local i18n = {
mini = {'m', 'v', 'sz'},
plain = {'megtekintés', 'vita', 'szerkesztés'},
normal = {'megnézi', 'vitatja', 'szerkeszti'}, -- a sablont
title = {'Mutasd ezt a sablont', 'A sablon vitalapja', 'A sablon szerkesztése'}
}
local getArgs
function p._navbar(args)
local titleText = args[1] or (':' .. mw.getCurrentFrame():getParent():getTitle())
local title = mw.title.new(mw.text.trim(titleText), 'Sablon');
if not title then
error(string.format('Érvénytelen név: „%s”', titleText))
end
local talkpage = title.talkPageTitle and title.talkPageTitle:fullUrl() or nil;
local fontstyle = args['betűstílus'] or args.fontstyle
local style = args['stílus'] or args.style
local text
if args.mini then
text = i18n.mini
elseif args.plain then
text = i18n.plain
else
text = i18n.normal
end
local div = mw.html.create():tag('div')
div
:addClass('navbar')
:addClass('noprint')
:addClass('hlist')
:addClass('plainlinks')
-- <ul> gets out if <span>, so we have to work it around
:css('display', args.nodiv and 'inline')
:cssText(fontstyle)
:css('font-size', 'xx-small')
:cssText(style)
if args.mini then div:addClass('mini') end
div:wikitext(mw.getCurrentFrame():extensionTag('templatestyles', '', {src = 'hlist/styles.css'}))
-- Internal link for Special:WhatLinksHere
div
:tag('span')
:css('display', 'none')
:wikitext(string.format('[[%s]]', title.fullText))
local ul = div:tag('ul');
ul
:css('display', 'inline')
:tag('li')
:addClass('nv-view')
:wikitext('[' .. title:fullUrl() .. ' ')
:tag('span')
:attr('title', i18n.title[1])
:cssText(fontstyle)
:wikitext(text[1])
:done()
:wikitext(']')
:done()
:wikitext(' ')
:tag('li')
:addClass('nv-talk')
:wikitext(talkpage and '[' .. talkpage .. ' ')
:tag('span')
:attr('title', i18n.title[2])
:cssText(fontstyle)
:wikitext(text[2])
:done()
:wikitext(talkpage and ']')
:done()
:wikitext(' ')
:tag('li')
:addClass('nv-edit')
:wikitext('[' .. title:fullUrl('action=edit') .. ' ')
:tag('span')
:attr('title', i18n.title[3])
:cssText(fontstyle)
:wikitext(text[3])
:done()
:wikitext(']');
if not (args.mini or args.plain) then
div
:tag('span')
:css('word-spacing', 0)
:cssText(fontstyle)
:wikitext(' a sablont');
end
return tostring(div:done())
end
function p.navbar(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
return p._navbar(getArgs(frame))
end
return p