Модуль:Карточка: различия между версиями

мНет описания правки
мНет описания правки
Метки: с мобильного устройства из мобильной версии через расширенный мобильный режим
 
(не показана 1 промежуточная версия этого же участника)
Строка 17: Строка 17:
-- set to `nil` (not in quotes) to remove such rows altogether in the tabs where they're missing
-- set to `nil` (not in quotes) to remove such rows altogether in the tabs where they're missing
local TABBED_NONEXIST = nil -- `''` or `nil` or `'N/A'` etc. Don't put nil in quotes.
local TABBED_NONEXIST = nil -- `''` or `nil` or `'N/A'` etc. Don't put nil in quotes.
local SKIP_SECTIONS_DEFAULT = 2


---------------------------------------------------------------------------
---------------------------------------------------------------------------
Строка 45: Строка 46:
h.increment()
h.increment()
local args = h.overwrite()
local args = h.overwrite()
h.skipSectionRows = tonumber(args.skipSectionRows) or 3
h.sectionHeaderCounter = 0
local sep = args.sep or ','
local sep = args.sep or ','
h.castArgs(args, sep)
h.castArgs(args, sep)
local skip = tonumber(args.skipSections) or SKIP_SECTIONS_DEFAULT
h.skipSections = skip
h.printCount = 0
if h.castBool(args.setmainimage or 'yes') then
if h.castBool(args.setmainimage or 'yes') then
h.setMainImage(args.images[1])
--h.setMainImage(args.images[1])
end
end
-- suggest to use HIDDENCAT here; will be used for maintenance & gadget imports
-- suggest to use HIDDENCAT here; will be used for maintenance & gadget imports
local output = h.makeInfobox(args, sep)
local output = h.makeInfobox(args, sep)
return frame:preprocess(tostring(output))
local finalOutput = tostring(output)
return frame:preprocess(finalOutput)
end
end


Строка 163: Строка 166:
h.printImages(out, args.images, args)
h.printImages(out, args.images, args)
for _, section in ipairs(args.sections) do
for _, section in ipairs(args.sections) do
-- cannot begin tagging here because we don't know if any applicable args are present
local cols = args[section .. '_columns']
local cols = args[section .. '_columns']
local makeSection = cols and h.makeGridSection or h.makeSection
local makeSection = cols and h.makeGridSection or h.makeSection
out:node(makeSection(section, args[section], args, tonumber(cols)))
local secNode = makeSection(section, args[section], args, tonumber(cols))
if secNode then
out:node(secNode)
end
end
end
h.runHook('onMakeOutputEnd', out, args)
h.runHook('onMakeOutputEnd', out, args)
Строка 384: Строка 389:
local shouldPrintItem = h.printData(node, item, section, args)
local shouldPrintItem = h.printData(node, item, section, args)
if shouldPrintItem then
if shouldPrintItem then
h.printCount = h.printCount + 1
shouldPrint = true
shouldPrint = true
local tr = container:tag(h.getTag('row'))
local tr = container:tag(h.getTag('row'))
Строка 487: Строка 493:


function h.printSectionHeader(node, section, args)
function h.printSectionHeader(node, section, args)
local fields = args[section] or {}
local hasContent = args[section .. '_columns']
and (h.countItems(fields, section, args) > 0)
  or (function()
for _, item in ipairs(fields) do
if h.printData(mw.html.create(), item, section, args) then
return true
end
end
return false
end)()
if not hasContent then return end
if h.castBool(args[section .. '_nolabel']) then return end
if h.castBool(args[section .. '_nolabel']) then return end
h.sectionHeaderCounter = h.sectionHeaderCounter + 1
 
if h.sectionHeaderCounter <= h.skipSectionRows then return end
h.printCount = h.printCount + 1
 
if h.printCount <= h.skipSections then
return
end


local tr = node:tag(h.getTag('row'))
local tr = node:tag(h.getTag('row'))
:attr('data-druid-section', h.escape(section))
:attr('data-druid-section', h.escape(section))
:addClass('data-druid-section')
local th = tr:tag(h.getTag('sectionTitle'))
:attr('colspan', 2)
:addClass('druid-section')
:addClass('druid-section')
:addClass('druid-section-' .. h.escape(section))
:addClass('druid-section-' .. h.escape(section))
Строка 501: Строка 527:
end
end
end
end
local th = tr:tag(h.getTag('sectionTitle'))
 
:attr('colspan', 2)
:addClass('druid-section')
:addClass('druid-section-' .. h.escape(section))
local emptySections = {}
local emptySections = {}
for _, label in ipairs(args.tabs) do
for _, label in ipairs(args.tabs) do
Строка 539: Строка 562:
local tabs = args[section .. '_tabs']
local tabs = args[section .. '_tabs']
if not tabs or #tabs == 0 then return end
if not tabs or #tabs == 0 then return end
if h.sectionHeaderCounter <= h.skipSectionRows then return end
local tr = node:tag(h.getTag('sectionTabsOuter'))
local tr = node:tag(h.getTag('sectionTabsOuter'))
:attr('data-druid-section', h.escape(section))
:attr('data-druid-section', h.escape(section))
:addClass('druid-section-tabs')
:addClass('data-druid-section')
local th = tr:tag(h.getTag('sectionTabs'))
local th = tr:tag(h.getTag('sectionTabs'))
:attr('colspan', 2)
:attr('colspan', 2)