Module:Navbox: Difference between revisions
Update from sandbox
m>TheDJ (that was not "show preview" button) |
m>Edokter (Update from sandbox) |
||
Line 16: | Line 16: | ||
function trim(s) | function trim(s) | ||
return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1")) | return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1")) | ||
end | |||
function addNewline(s) | |||
if s:match('^[*:;#]') or s:match('^{|') then | |||
return '\n' .. s ..'\n' | |||
else | |||
return s | |||
end | |||
end | end | ||
Line 25: | Line 33: | ||
.css('height', '2px') | .css('height', '2px') | ||
.tag('td') | .tag('td') | ||
.attr('colspan',2) | |||
end | end | ||
Line 72: | Line 81: | ||
.attr('colspan', titleColspan) | .attr('colspan', titleColspan) | ||
renderNavBar(titleCell) | |||
titleCell | |||
.tag('div') | .tag('div') | ||
.addClass(args.titleclass) | .addClass(args.titleclass) | ||
.css('font-size', '110%') | .css('font-size', '110%') | ||
. | .wikitext(addNewline(args.title)) | ||
end | end | ||
Line 122: | Line 130: | ||
function renderAboveRow(tbl) | function renderAboveRow(tbl) | ||
if not args.above then return end | if not args.above then return end | ||
addTableRow(tbl) | addTableRow(tbl) | ||
.tag('td') | .tag('td') | ||
Line 131: | Line 139: | ||
.attr('colspan', getAboveBelowColspan()) | .attr('colspan', getAboveBelowColspan()) | ||
.tag('div') | .tag('div') | ||
. | .wikitext(addNewline(args.above)) | ||
end | end | ||
function renderBelowRow(tbl) | function renderBelowRow(tbl) | ||
if not args.below then return end | if not args.below then return end | ||
addTableRow(tbl) | addTableRow(tbl) | ||
.tag('td') | .tag('td') | ||
Line 146: | Line 153: | ||
.attr('colspan', getAboveBelowColspan()) | .attr('colspan', getAboveBelowColspan()) | ||
.tag('div') | .tag('div') | ||
. | .wikitext(addNewline(args.below)) | ||
end | end | ||
Line 174: | Line 180: | ||
.attr('rowspan', 2 * #listnums - 1) | .attr('rowspan', 2 * #listnums - 1) | ||
.tag('div') | .tag('div') | ||
. | .wikitext(addNewline(args.imageleft)) | ||
end | end | ||
Line 222: | Line 227: | ||
if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end | if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end | ||
end | end | ||
listCell | listCell | ||
.css('padding', '0px') | .css('padding', '0px') | ||
Line 233: | Line 238: | ||
.tag('div') | .tag('div') | ||
.css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em') | .css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em') | ||
. | .wikitext(addNewline(args['list' .. listnum])) | ||
if listnum == 1 and args.image then | if listnum == 1 and args.image then | ||
Line 246: | Line 250: | ||
.attr('rowspan', 2 * #listnums - 1) | .attr('rowspan', 2 * #listnums - 1) | ||
.tag('div') | .tag('div') | ||
. | .wikitext(addNewline(args.image)) | ||
end | end | ||
end | end |