17,101
edits
(_getShopSkillcapeTable: Fix sorting function & extend to include superior skillcapes) |
(_getShopTable: Allow suppression of stickyHeader class) |
||
Line 401: | Line 401: | ||
["Cost"] = 'style="min-width:100px"' | ["Cost"] = 'style="min-width:100px"' | ||
} | } | ||
local usedColumns, purchHeader, sortOrder, headerProps = {}, 'Purchase', nil, {} | local usedColumns, purchHeader, sortOrder, headerProps, stickyHeader = {}, 'Purchase', nil, {}, true | ||
-- Process options if specified | -- Process options if specified | ||
Line 424: | Line 424: | ||
if options.headerProps ~= nil and type(options.headerProps) == 'table' then | if options.headerProps ~= nil and type(options.headerProps) == 'table' then | ||
headerProps = options.headerProps | headerProps = options.headerProps | ||
end | |||
-- Sticky header class | |||
if options.stickyHeader ~= nil then | |||
if type(options.stickyHeader) == 'boolean' then | |||
stickyHeader = options.stickyHeader | |||
elseif type(options.stickyHeader) == 'string' and string.lower(options.stickyHeader) == 'false' then | |||
stickyHeader = false | |||
end | |||
end | end | ||
end | end | ||
Line 437: | Line 445: | ||
local resultPart = {} | local resultPart = {} | ||
-- Generate header | -- Generate header | ||
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | table.insert(resultPart, '{| class="wikitable sortable' .. (stickyHeader and ' stickyHeader' or '') .. '"') | ||
table.insert(resultPart, '|- class="headerRow-0"') | table.insert(resultPart, '|- class="headerRow-0"') | ||
for i, column in ipairs(usedColumns) do | for i, column in ipairs(usedColumns) do | ||
Line 510: | Line 518: | ||
-- sortOrder: A function determining the order in which table items appear | -- sortOrder: A function determining the order in which table items appear | ||
-- purchaseHeader: Specifies header text for the Purchase column if not 'Purchase' | -- purchaseHeader: Specifies header text for the Purchase column if not 'Purchase' | ||
-- stickyHeader: Specifies if the table will have a sticky header or not | |||
function p.getShopTable(frame) | function p.getShopTable(frame) | ||
local cat = frame.args ~= nil and frame.args[1] or frame | local cat = frame.args ~= nil and frame.args[1] or frame | ||
Line 517: | Line 526: | ||
if frame.args.purchaseHeader ~= nil then options.purchaseHeader = frame.args.purchaseHeader end | if frame.args.purchaseHeader ~= nil then options.purchaseHeader = frame.args.purchaseHeader end | ||
if frame.args.sortOrder ~= nil then options.sortOrder = frame.args.sortOrder end | if frame.args.sortOrder ~= nil then options.sortOrder = frame.args.sortOrder end | ||
if frame.args.stickyHeader ~= nil then options.stickyHeader = frame.args.stickyHeader end | |||
if frame.args.columnProps ~= nil then | if frame.args.columnProps ~= nil then | ||
local columnPropValues = Shared.splitString(frame.args.columnProps, ',') | local columnPropValues = Shared.splitString(frame.args.columnProps, ',') | ||
Line 631: | Line 641: | ||
purchaseHeader = 'Cape', | purchaseHeader = 'Cape', | ||
sortOrder = sortOrderFunc, | sortOrder = sortOrderFunc, | ||
stickyHeader = false, | |||
headerProps = {["Purchase"] = 'colspan="2" style="width:200px;"', ["Cost"] = 'style=width:120px;'} | headerProps = {["Purchase"] = 'colspan="2" style="width:200px;"', ["Cost"] = 'style=width:120px;'} | ||
}) | }) |