Module:Navbar/sandbox: Difference between revisions

Content deleted Content added
more fixes
put some sane limits
Line 3:
local getArgs
local ul
local args
 
function p.addItem (mini, full, link, descrip, args, ismini, url)
local l
if url then
Line 14 ⟶ 15:
:addClass('nv-'..full)
:wikitext(l[1] .. link .. l[2])
:tag(isminiargs.mini and 'abbr' or 'span')
:attr('title', descrip..' this template')
:cssText(args.fontstyle)
:wikitext(isminiargs.mini and mini or full)
:done()
:wikitext(l[3])
end
 
function p._navbar(args)
local show = {true, true, true, false, false, false}
local minis = {}
local titleArg = 1
 
if args.collapsible then
titleArg = 2
Line 41:
titleArg = 'template'
show = {true, false, false, false, false, false}
local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6, talk = 2, edit = 3, hist = 4, move = 5, watch = 6}
local indexf = {talk = 2, edit = 3, hist = 4, move = 5, watch = 6}
for k,v in ipairs(require ('Module:TableTools').compressSparseArray(args)) do
num = index[v]
if num then
show[num] = true
minis[num] = true
else
num = indexf[v]
if num then
show[num] = true
end
end
end
Line 94 ⟶ 87:
:cssText(args.fontstyle)
:wikitext('[ ')
end
if args.mini then
minis = {true, true, true, true, true, true}
end
local function checkaddItem (mini, full, link, descrip, num, url)
if show[num] then p.addItem(mini, full, link, descrip, args, minis[num], url) end
end
ul = div:tag('ul')
local move = mw.title.new ('Special:Movepage')
checkaddItemif show[1] then p.addItem('v', 'view', title.fullText, 'View', 1) end
checkaddItemif show[2] then p.addItem('t', 'talk', talkpage, 'Discuss', 2) end
checkaddItemif show[3] then p.addItem('e', 'edit', title:fullUrl('action=edit'), 'Edit', 3, true) end
checkaddItemif show[4] then p.addItem('h', 'hist', title:fullUrl('action=history'), 'History of', 4, true) end
checkaddItemif show[5] then p.addItem('m', 'move', move:fullUrl('target='..title.fullText), 'Move', 5, true) end
checkaddItemif show[6] then p.addItem('w', 'watch', title:fullUrl('action=watch'), 'Watch', 6, true) end
if args.brackets then
Line 135 ⟶ 122:
getArgs = require('Module:Arguments').getArgs
end
returnargs = p._navbar(getArgs(frame))
return p._navbar()
end