Open main menu

Changes

Module:Navbox

81 bytes added, 16:59, 7 May 2014
don't use globals
local listnums = {}
local function trim(s)
return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
end
local function addNewline(s)
if s:match('^[*:;#]') or s:match('^{|') then
return '\n' .. s ..'\n'
end
local function addTableRow(tbl)
-- If any other rows have already been added, then we add a 2px gutter row.
if tableRowAdded then
end
local function renderNavBar(titleCell)
-- Depending on the presence of the navbar and/or show/hide link, we may need to add a spacer div on the left
-- or right to keep the title centered.
local spacerSide = nil
 
if args.navbar == 'off' then
-- No navbar, and client wants no spacer, i.e. wants the title to be shifted to the left. If there's
-- also no show/hide link, then we need a spacer on the right to achieve the left shift.
if args.state == 'plain' then spacerSide = 'right' end
elseif args.navbar == 'plain' or args.navbar == 'off' or (not args.name and (border == 'subgroup' or border == 'child' or border == 'none')) then
-- No navbar. Need a spacer on the left to balance out the width of the show/hide link.
if args.state ~= 'plain' then spacerSide = 'left' end
else
-- Will render navbar (or error message). If there's no show/hide link, need a spacer on the right
-- to balance out the width of the navbar.
if args.state == 'plain' then spacerSide = 'right' end
 
titleCell.wikitext(Navbar.navbar({
args.name,
mini = 1,
fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;'
}))
end
-- Render the spacer div.
if spacerSide then
titleCell
.tag('span')
.css('float', spacerSide)
.css('width', '6em')
.wikitext(' ')
end
end
--
-- Title row
--
local function renderTitleRow(tbl)
if not args.title then return end
end
function renderNavBar(titleCell)-- -- Depending on the presence of the navbar and/or show Above/hide link, we may need to add a spacer div on the leftBelow rows -- or right to keep the title centered. local spacerSide = nil
local function getAboveBelowColspan() if args.navbar == 'off' then -- No navbar, and client wants no spacer, i.e. wants the title to be shifted to the left. If there's -- also no show/hide link, then we need a spacer on the right to achieve the left shift. if args.state == 'plain' then spacerSide local ret = 'right' end2 elseif args.navbar == 'plain' or args.navbar == 'off' or (not args.name and (border == 'subgroup' or border == 'child' or border == 'none')) then -- No navbar. Need a spacer on the left to balance out the width of the show/hide link. if args.state ~= 'plain' imageleft then spacerSide ret = 'left' ret + 1 end else -- Will render navbar (or error message). If there's no show/hide link, need a spacer on the right -- to balance out the width of the navbar. if args.state == 'plain' image then spacerSide = 'right' end  titleCell.wikitext(Navbar.navbar({ args.name, mini ret = ret + 1, fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;' })) end -- Render the spacer div. if spacerSide then titleCell .tag('span') .css('float', spacerSide) .css('width', '6em') .wikitext(' ') endreturn ret
end
 ---- Above/Below rows--local function renderAboveRow(tbl)
if not args.above then return end
end
local function renderBelowRow(tbl)
if not args.below then return end
.wikitext(addNewline(args.below))
end
 
function getAboveBelowColspan()
local ret = 2
if args.imageleft then ret = ret + 1 end
if args.image then ret = ret + 1 end
return ret
end
--
-- List rows
--
local function renderListRow(tbl, listnum)
local row = addTableRow(tbl)
-- Tracking categories
--
local function renderTrackingCategories(builder)
local frame = mw.getCurrentFrame()
end
local function getTrackingCategories()
local cats = {}
if needsHorizontalLists() then table.insert(cats, 'Navigational boxes without horizontal lists') end
end
local function needsHorizontalLists()
if border == 'child' or border == 'subgroup' or args.tracking == 'no' then return false end
end
local function hasBackgroundColors()
return args.titlestyle or args.groupstyle
end
-- Main navbox tables
--
local function renderMainTable()
local tbl = HtmlBuilder.create('table')
.attr('cellspacing', 0)
Anonymous user