Module:NavboxMobile: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary Tag: Reverted |
EnWikiAdmin (talk | contribs) No edit summary Tag: Reverted |
||
Line 455: | Line 455: | ||
end | end | ||
-- | |||
-- Main navboxMobile tables | |||
-- | |||
-- | -- | ||
-- Main navboxMobile tables | -- Main navboxMobile tables | ||
Line 461: | Line 464: | ||
local tbl = mw.html.create('table') | local tbl = mw.html.create('table') | ||
:addClass('nowraplinks') | :addClass('nowraplinks') | ||
:addClass(args.bodyclass) | :addClass(args.bodyclass) | ||
--[[if args.title and (args.state ~= 'plain' and args.state ~= 'off') then | |||
tbl | |||
:addClass('collapsible') | |||
:addClass(args.state or 'autocollapse') | |||
end]] | |||
tbl:css('border-spacing', 0) | |||
if border == 'subgroup' or border == 'child' or border == 'none' then | if border == 'subgroup' or border == 'child' or border == 'none' then | ||
tbl | tbl | ||
:addClass(' | :addClass('navboxMobile-subgroup') | ||
: | :cssText(args.bodystyle) | ||
: | :cssText(args.style) | ||
else | else -- regular navobx - bodystyle and style will be applied to the wrapper table | ||
tbl | tbl | ||
:addClass(' | :addClass('navboxMobile-inner') | ||
:css('background', 'transparent') | :css('background', 'transparent') | ||
:css('color', 'inherit') | :css('color', 'inherit') | ||
end | end | ||
tbl:cssText(args.innerstyle) | tbl:cssText(args.innerstyle) | ||
renderTitleRow(tbl) | renderTitleRow(tbl) | ||
renderAboveRow(tbl) | renderAboveRow(tbl) | ||
for | for i, listnum in ipairs(listnums) do | ||
renderListRow(tbl, listnum) | renderListRow(tbl, listnum) | ||
end | end | ||
Line 495: | Line 500: | ||
args = navboxMobileArgs | args = navboxMobileArgs | ||
for k, v in pairs(args) do | for k, v in pairs(args) do | ||
local listnum = ('' .. k):match('^list(%d+)$') | |||
if listnum then table.insert(listnums, tonumber(listnum)) end | |||
end | end | ||
table.sort(listnums) | table.sort(listnums) | ||
border = trim(args.border or args[1] or '') | border = trim(args.border or args[1] or '') | ||
-- | -- render the main body of the navboxMobile | ||
local tbl = renderMainTable() | local tbl = renderMainTable() | ||
-- | -- render the appropriate wrapper around the navboxMobile, depending on the border param | ||
local res = mw.html.create() | local res = mw.html.create() | ||
if border == 'none' then | |||
res:node(tbl) | |||
elseif border == 'subgroup' or border == 'child' then | |||
-- We assume that this navboxMobile is being rendered in a list cell of a parent navboxMobile, and is | |||
-- therefore inside a div with padding:0em 0.25em. We start with a </div> to avoid the | |||
-- padding being applied, and at the end add a <div> to balance out the parent's </div> | |||
res | |||
: | :wikitext('</div>') -- XXX: hack due to lack of unclosed support in mw.html. | ||
:node(tbl) | |||
:wikitext('<div>') -- XXX: hack due to lack of unclosed support in mw.html. | |||
else | else | ||
res | |||
:tag('table') | |||
:addClass('navboxMobile') | |||
:css('border-spacing', 0) | |||
:cssText(args.bodystyle) | |||
:cssText(args.style) | |||
:tag('tr') | |||
:tag('td') | |||
:css('padding', '2px') | |||
:node(tbl) | |||
end | end | ||
renderTrackingCategories(res) | renderTrackingCategories(res) | ||