Модуль:Карточка: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки Метки: с мобильного устройства из мобильной версии через расширенный мобильный режим |
||
| (не показана 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() | ||
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( | 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 | ||
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 | ||
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. | |||
if h. | 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 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 | ||
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 | :addClass('data-druid-section') | ||
local th = tr:tag(h.getTag('sectionTabs')) | local th = tr:tag(h.getTag('sectionTabs')) | ||
:attr('colspan', 2) | :attr('colspan', 2) | ||