Changes

Jump to navigation Jump to search
489 bytes added ,  11:56, 5 September 2017
m
1 revision imported
Line 9: Line 9:     
local args
 
local args
local tableRowAdded = false
   
local border
 
local border
 
local listnums = {}
 
local listnums = {}
Line 57: Line 56:  
end
 
end
   −
local function addNewline(s)
+
local function processItem(item, nowrapitems)
if s:match('^[*:;#]') or s:match('^{|') then
+
if item:sub(1, 2) == '{|' then
return '\n' .. s ..'\n'
+
-- Applying nowrap to lines in a table does not make sense.
else
+
-- Add newlines to compensate for trim of x in |parm=x in a template.
return s
+
return '\n' .. item ..'\n'
 +
end
 +
if nowrapitems == 'yes' then
 +
local lines = {}
 +
for line in (item .. '\n'):gmatch('([^\n]*)\n') do
 +
local prefix, content = line:match('^([*:;#]+)%s*(.*)')
 +
if prefix and not content:match('^<span class="nowrap">') then
 +
line = prefix .. '<span class="nowrap">' .. content .. '</span>'
 +
end
 +
table.insert(lines, line)
 +
end
 +
item = table.concat(lines, '\n')
 
end
 
end
end
+
if item:match('^[*:;#]') then
 
+
return '\n' .. item ..'\n'
local function addTableRow(tbl)
  −
-- If any other rows have already been added, then we add a 2px gutter row.
  −
if tableRowAdded then
  −
tbl
  −
:tag('tr')
  −
:css('height', '2px')
  −
:tag('td')
  −
:attr('colspan',2)
   
end
 
end
 
+
return item
tableRowAdded = true
  −
 
  −
return tbl:tag('tr')
   
end
 
end
   Line 86: Line 85:  
args.name,
 
args.name,
 
mini = 1,
 
mini = 1,
fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;'
+
fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;'
 
})
 
})
 
end
 
end
Line 98: Line 97:  
if not args.title then return end
 
if not args.title then return end
   −
local titleRow = addTableRow(tbl)
+
local titleRow = tbl:tag('tr')
    
if args.titlegroup then
 
if args.titlegroup then
Line 139: Line 138:  
:css('font-size', '114%')
 
:css('font-size', '114%')
 
:css('margin', '0 4em')
 
:css('margin', '0 4em')
:wikitext(addNewline(args.title))
+
:wikitext(processItem(args.title))
 
end
 
end
   Line 156: Line 155:  
if not args.above then return end
 
if not args.above then return end
   −
addTableRow(tbl)
+
tbl:tag('tr')
 
:tag('td')
 
:tag('td')
 
:addClass('navbox-abovebelow')
 
:addClass('navbox-abovebelow')
Line 164: Line 163:  
:attr('colspan', getAboveBelowColspan())
 
:attr('colspan', getAboveBelowColspan())
 
:tag('div')
 
:tag('div')
:wikitext(addNewline(args.above))
+
:wikitext(processItem(args.above, args.nowrapitems))
 
end
 
end
   Line 170: Line 169:  
if not args.below then return end
 
if not args.below then return end
   −
addTableRow(tbl)
+
tbl:tag('tr')
 
:tag('td')
 
:tag('td')
 
:addClass('navbox-abovebelow')
 
:addClass('navbox-abovebelow')
Line 178: Line 177:  
:attr('colspan', getAboveBelowColspan())
 
:attr('colspan', getAboveBelowColspan())
 
:tag('div')
 
:tag('div')
:wikitext(addNewline(args.below))
+
:wikitext(processItem(args.below, args.nowrapitems))
 
end
 
end
   Line 185: Line 184:  
--
 
--
 
local function renderListRow(tbl, index, listnum)
 
local function renderListRow(tbl, index, listnum)
local row = addTableRow(tbl)
+
local row = tbl:tag('tr')
    
if index == 1 and args.imageleft then
 
if index == 1 and args.imageleft then
Line 192: Line 191:  
:addClass('navbox-image')
 
:addClass('navbox-image')
 
:addClass(args.imageclass)
 
:addClass(args.imageclass)
:css('width', '0%')
+
:css('width', '1px')               -- Minimize width
 
:css('padding', '0px 2px 0px 0px')
 
:css('padding', '0px 2px 0px 0px')
 
:cssText(args.imageleftstyle)
 
:cssText(args.imageleftstyle)
:attr('rowspan', 2 * #listnums - 1)
+
:attr('rowspan', #listnums)
 
:tag('div')
 
:tag('div')
:wikitext(addNewline(args.imageleft))
+
:wikitext(processItem(args.imageleft))
 
end
 
end
   Line 208: Line 207:  
:addClass(args.groupclass)
 
:addClass(args.groupclass)
 
:cssText(args.basestyle)
 
:cssText(args.basestyle)
 
+
            :css('width', args.groupwidth or '1%') -- If groupwidth not specified, minimize width
if args.groupwidth then
  −
groupCell:css('width', args.groupwidth)
  −
end
      
groupCell
 
groupCell
Line 257: Line 253:  
:tag('div')
 
:tag('div')
 
:css('padding', (index == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
 
:css('padding', (index == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
:wikitext(addNewline(listText))
+
:wikitext(processItem(listText, args.nowrapitems))
    
if index == 1 and args.image then
 
if index == 1 and args.image then
Line 264: Line 260:  
:addClass('navbox-image')
 
:addClass('navbox-image')
 
:addClass(args.imageclass)
 
:addClass(args.imageclass)
:css('width', '0%')
+
:css('width', '1px')               -- Minimize width
 
:css('padding', '0px 0px 0px 2px')
 
:css('padding', '0px 0px 0px 2px')
 
:cssText(args.imagestyle)
 
:cssText(args.imagestyle)
:attr('rowspan', 2 * #listnums - 1)
+
:attr('rowspan', #listnums)
 
:tag('div')
 
:tag('div')
:wikitext(addNewline(args.image))
+
:wikitext(processItem(args.image))
 
end
 
end
 
end
 
end
Line 325: Line 321:  
if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
 
if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
   −
for i, cat in ipairs(getTrackingCategories()) do
+
for _, cat in ipairs(getTrackingCategories()) do
 
builder:wikitext('[[Category:' .. cat .. ']]')
 
builder:wikitext('[[Category:' .. cat .. ']]')
 
end
 
end
Line 371: Line 367:  
args = navboxArgs
 
args = navboxArgs
   −
for k, v in pairs(args) do
+
for k, _ in pairs(args) do
local listnum = ('' .. k):match('^list(%d+)$')
+
if type(k) == 'string' then
if listnum then table.insert(listnums, tonumber(listnum)) end
+
local listnum = k:match('^list(%d+)$')
 +
if listnum then table.insert(listnums, tonumber(listnum)) end
 +
end
 
end
 
end
 
table.sort(listnums)
 
table.sort(listnums)
Bureaucrats, private-view, public-view, Administrators
97,692

edits

Navigation menu