پودمان:Navbox: تفاوت میان نسخهها
suppress images inside navboxes showing up in Media Viewer
(suppress images inside navboxes showing up in Media Viewer) |
|||
خط ۵: | خط ۵: | ||
local p = {} | local p = {} | ||
local navbar = require(' | local navbar = require('Module:Navbar')._navbar | ||
local getArgs -- lazily initialized | local getArgs -- lazily initialized | ||
خط ۲۰: | خط ۲۰: | ||
-- by parent navboxes. The result is that the category shows all pages | -- by parent navboxes. The result is that the category shows all pages | ||
-- where a child navbox is not contained in a parent navbox. | -- where a child navbox is not contained in a parent navbox. | ||
local orphanCat = '[[ | local orphanCat = '[[Category:Navbox orphans]]' | ||
if border == 'subgroup' and args.orphan ~= 'yes' then | if border == 'subgroup' and args.orphan ~= 'yes' then | ||
-- No change; striping occurs in outermost navbox. | -- No change; striping occurs in outermost navbox. | ||
خط ۸۱: | خط ۸۱: | ||
local function renderNavBar(titleCell) | local function renderNavBar(titleCell) | ||
if args.navbar ~= 'off' and args.navbar ~= 'plain' and not (not args.name and mw.getCurrentFrame():getParent():getTitle():gsub('/ | if args.navbar ~= 'off' and args.navbar ~= 'plain' and not (not args.name and mw.getCurrentFrame():getParent():getTitle():gsub('/sandbox$', '') == 'Template:Navbox') then | ||
titleCell:wikitext(navbar{ | titleCell:wikitext(navbar{ | ||
args.name, | args.name, | ||
خط ۱۲۱: | خط ۱۲۱: | ||
local titleColspan = 2 | local titleColspan = 2 | ||
if args.imageleft then titleColspan = titleColspan + 1 end | if args.imageleft then titleColspan = titleColspan + 1 end | ||
if args.image then titleColspan = titleColspan + 1 end | if args.image then titleColspan = titleColspan + 1 end | ||
if args.titlegroup then titleColspan = titleColspan - 1 end | if args.titlegroup then titleColspan = titleColspan - 1 end | ||
خط ۱۵۰: | خط ۱۴۹: | ||
local ret = 2 | local ret = 2 | ||
if args.imageleft then ret = ret + 1 end | if args.imageleft then ret = ret + 1 end | ||
if args.image then ret = ret + 1 end | if args.image then ret = ret + 1 end | ||
return ret | return ret | ||
خط ۱۹۴: | خط ۱۹۲: | ||
row | row | ||
:tag('td') | :tag('td') | ||
:addClass('noviewer') | |||
:addClass('navbox-image') | :addClass('navbox-image') | ||
:addClass(args.imageclass) | :addClass(args.imageclass) | ||
خط ۲۰۲: | خط ۲۰۱: | ||
:tag('div') | :tag('div') | ||
:wikitext(processItem(args.imageleft)) | :wikitext(processItem(args.imageleft)) | ||
end | end | ||
خط ۲۴۳: | خط ۲۲۹: | ||
if args['group' .. listnum] then | if args['group' .. listnum] then | ||
listCell | listCell | ||
:css('text-align', ' | :css('text-align', 'left') | ||
:css('border- | :css('border-left-width', '2px') | ||
:css('border- | :css('border-left-style', 'solid') | ||
else | else | ||
listCell:attr('colspan', 2) | listCell:attr('colspan', 2) | ||
خط ۲۸۳: | خط ۲۶۹: | ||
row | row | ||
:tag('td') | :tag('td') | ||
:addClass('noviewer') | |||
:addClass('navbox-image') | :addClass('navbox-image') | ||
:addClass(args.imageclass) | :addClass(args.imageclass) | ||
خط ۳۲۸: | خط ۳۱۵: | ||
local function isIllegible() | local function isIllegible() | ||
local styleratio = require(' | local styleratio = require('Module:Color contrast')._styleratio | ||
for key, style in pairs(args) do | for key, style in pairs(args) do | ||
خط ۳۴۲: | خط ۳۲۹: | ||
local function getTrackingCategories() | local function getTrackingCategories() | ||
local cats = {} | local cats = {} | ||
if needsHorizontalLists() then table.insert(cats, ' | if needsHorizontalLists() then table.insert(cats, 'Navigational boxes without horizontal lists') end | ||
if hasBackgroundColors() then table.insert(cats, ' | if hasBackgroundColors() then table.insert(cats, 'Navboxes using background colours') end | ||
if isIllegible() then table.insert(cats, ' | if isIllegible() then table.insert(cats, 'Potentially illegible navboxes') end | ||
if hasBorders() then table.insert(cats, ' | if hasBorders() then table.insert(cats, 'Navboxes using borders') end | ||
return cats | return cats | ||
end | end | ||
خط ۳۵۳: | خط ۳۴۰: | ||
if title.namespace ~= 10 then return end -- not in template space | if title.namespace ~= 10 then return end -- not in template space | ||
local subpage = title.subpageText | local subpage = title.subpageText | ||
if subpage == ' | if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end | ||
for _, cat in ipairs(getTrackingCategories()) do | for _, cat in ipairs(getTrackingCategories()) do | ||
builder:wikitext('[[ | builder:wikitext('[[Category:' .. cat .. ']]') | ||
end | end | ||
end | end | ||
خط ۴۶۴: | خط ۴۵۱: | ||
function p.navbox(frame) | function p.navbox(frame) | ||
if not getArgs then | if not getArgs then | ||
getArgs = require(' | getArgs = require('Module:Arguments').getArgs | ||
end | end | ||
args = getArgs(frame, {wrappers = {'Template:Navbox'}}) | |||
-- Read the arguments in the order they'll be output in, to make references number in the right order. | -- Read the arguments in the order they'll be output in, to make references number in the right order. |