Module:Navbar/sandbox: Difference between revisions

Content deleted Content added
m Removed protection from "Module:Navbar/sandbox": No longer necessary: Requested at RfPP with nine transclusions
m Removed protection from "Module:Navbar/sandbox"
 
(15 intermediate revisions by 5 users not shown)
Line 1:
local p = {}
local cfg = mw.loadData('Module:Navbar/configuration/sandbox')
 
local function get_title_arg(is_collapsible, template)
Line 28:
local remove_edit_link = args.noedit
if remove_edit_link then show[3] = false end
 
return show
 
end
 
Line 53:
 
local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
 
local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)
if not title then
Line 59:
end
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''
 
-- TODO: Get link_descriptions and show into the configuration module.
-- link_descriptions should be easier...
Line 68:
['link'] = talkpage, ['url'] = false },
{ ['mini'] = 'e', ['full'] = 'edit', ['html_title'] = 'Edit this template',
['link'] = title'Special:fullUrl(EditPage/'action=edit') .. title.fullText, ['url'] = truefalse },
{ ['mini'] = 'h', ['full'] = 'hist', ['html_title'] = 'History of this template',
['link'] = title'Special:fullUrl(PageHistory/'action=history') .. title.fullText, ['url'] = truefalse },
{ ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText:gsub(' ', '_')), ['url'] = true },
{ ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',
['link'] = title:fullUrl('action=watch'), ['url'] = true }
}
Line 82:
:cssText(font_style)
end
 
for i, _ in ipairs(displayed_links) do
if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end
end
return ul:done()
 
end
 
function p._navbar(args)
 
-- TODO: We probably don't need both fontstyle and fontcolor...
local font_style = args.fontstyle
Line 98:
local is_mini = args.mini
local is_plain = args.plain
 
local collapsible_class = nil
if is_collapsible then
Line 107:
end
end
 
local navbar_style = args.style
local div = mw.html.create():tag('div')
Line 119:
if is_mini then div:addClass(cfg.classes.mini) end
 
local box_text = (args.text or cfg.box_text) .. ' '
-- the concatenated space separatesguarantees the box text is separated
if not (is_mini or is_plain) then
div
Line 127 ⟶ 128:
:wikitext(box_text)
end
 
local template = args.template
local displayed_links = choose_links(template, args)
Line 133 ⟶ 134:
local title_arg = get_title_arg(is_collapsible, template)
local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
local links = ''
local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
if args.vte_links_override then
div:node(list)
links = args.vte_links_override
div:wikitext(links)
else
local list links = make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
div:node(listlinks)
end
 
if is_collapsible then
Line 149 ⟶ 156:
:wikitext(args[1])
end
 
local frame = mw.getCurrentFrame()
-- hlist -> navbar is best-effort to preserve old Common.css ordering.