مستخدم مجهول
per tper
ط (۱ نسخه واردشده) |
(per tper) |
||
سطر ١٠: | سطر ١٠: | ||
local args | local args | ||
local border | local border | ||
local listnums | local listnums | ||
local ODD_EVEN_MARKER = '\127_ODDEVEN_\127' | local ODD_EVEN_MARKER = '\127_ODDEVEN_\127' | ||
local RESTART_MARKER = '\127_ODDEVEN0_\127' | local RESTART_MARKER = '\127_ODDEVEN0_\127' | ||
سطر ٢٠: | سطر ٢٠: | ||
-- 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('/sandbox$', '') == ' | 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, | ||
mini = 1, | mini = 1, | ||
fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;' | fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none; padding:0;' | ||
}) | }) | ||
end | end | ||
سطر ١١٥: | سطر ١١٥: | ||
if args.titlegroup then | if args.titlegroup then | ||
titleCell | titleCell | ||
:css('border- | :css('border-left', '2px solid #fdfdfd') | ||
:css('width', '100%') | :css('width', '100%') | ||
end | end | ||
local titleColspan = 2 | local titleColspan = 2 | ||
if args. | 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 | ||
سطر ١٣٤: | سطر ١٣٤: | ||
titleCell | titleCell | ||
:tag('div') | :tag('div') | ||
-- id for aria-labelledby attribute | |||
:attr('id', mw.uri.anchorEncode(args.title)) | :attr('id', mw.uri.anchorEncode(args.title)) | ||
:addClass(args.titleclass) | :addClass(args.titleclass) | ||
سطر ١٤٧: | سطر ١٤٨: | ||
local function getAboveBelowColspan() | local function getAboveBelowColspan() | ||
local ret = 2 | local ret = 2 | ||
if args. | 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 | ||
سطر ١٦٣: | سطر ١٦٤: | ||
:attr('colspan', getAboveBelowColspan()) | :attr('colspan', getAboveBelowColspan()) | ||
:tag('div') | :tag('div') | ||
-- id for aria-labelledby attribute, if no title | |||
:attr('id', args.title and nil or mw.uri.anchorEncode(args.above)) | |||
:wikitext(processItem(args.above, args.nowrapitems)) | :wikitext(processItem(args.above, args.nowrapitems)) | ||
end | end | ||
سطر ١٨٦: | سطر ١٨٩: | ||
local row = tbl:tag('tr') | local row = tbl:tag('tr') | ||
if index == 1 and args. | if index == 1 and args.imageleft then | ||
row | row | ||
:tag('td') | :tag('td') | ||
سطر ١٩٣: | سطر ١٩٦: | ||
:css('width', '1px') -- Minimize width | :css('width', '1px') -- Minimize width | ||
:css('padding', '0px 2px 0px 0px') | :css('padding', '0px 2px 0px 0px') | ||
:cssText(args. | :cssText(args.imageleftstyle) | ||
:attr('rowspan', #listnums) | :attr('rowspan', #listnums) | ||
:tag('div') | :tag('div') | ||
:wikitext(processItem(args. | :wikitext(processItem(args.imageleft)) | ||
end | end | ||
if args['group' .. listnum] then | if args['group' .. listnum] then | ||
local groupCell = row:tag('th') | local groupCell = row:tag('th') | ||
-- id for aria-labelledby attribute, if lone group with no title or above | |||
if listnum == 1 and not (args.title or args.above or args.group2) then | |||
groupCell | |||
:attr('id', mw.uri.anchorEncode(args.group1)) | |||
end | |||
groupCell | groupCell | ||
سطر ٢٠٧: | سطر ٢١٦: | ||
:addClass(args.groupclass) | :addClass(args.groupclass) | ||
:cssText(args.basestyle) | :cssText(args.basestyle) | ||
:css('width', args.groupwidth or '1%') -- If groupwidth not specified, minimize width | |||
groupCell | groupCell | ||
سطر ٢١٩: | سطر ٢٢٨: | ||
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) | ||
سطر ٢٥١: | سطر ٢٦٠: | ||
:addClass('navbox-' .. oddEven) | :addClass('navbox-' .. oddEven) | ||
:addClass(args.listclass) | :addClass(args.listclass) | ||
:addClass(args['list' .. listnum .. 'class']) | |||
:tag('div') | :tag('div') | ||
:css('padding', (index == 1 and args.list1padding) or args.listpadding or '0em 0.25em') | :css('padding', (index == 1 and args.list1padding) or args.listpadding or '0em 0.25em') | ||
سطر ٢٨٧: | سطر ٢٩٧: | ||
local function hasBackgroundColors() | local function hasBackgroundColors() | ||
for _, key in ipairs({'titlestyle', 'groupstyle', 'basestyle'}) do | for _, key in ipairs({'titlestyle', 'groupstyle', 'basestyle', 'abovestyle', 'belowstyle'}) do | ||
if tostring(args[key]):find('background', 1, true) then | if tostring(args[key]):find('background', 1, true) then | ||
return true | |||
end | |||
end | |||
end | |||
local function hasBorders() | |||
for _, key in ipairs({'groupstyle', 'basestyle', 'abovestyle', 'belowstyle'}) do | |||
if tostring(args[key]):find('border', 1, true) then | |||
return true | return true | ||
end | end | ||
سطر ٣٠٩: | سطر ٣٢٧: | ||
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, '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 | ||
سطر ٣٣٥: | سطر ٣٥٤: | ||
if args.title and (args.state ~= 'plain' and args.state ~= 'off') then | if args.title and (args.state ~= 'plain' and args.state ~= 'off') then | ||
if args.state == 'collapsed' then args.state = 'mw-collapsed' end | |||
tbl | tbl | ||
:addClass('collapsible') | :addClass('mw-collapsible') | ||
:addClass(args.state or 'autocollapse') | :addClass(args.state or 'autocollapse') | ||
end | end | ||
سطر ٣٦٦: | سطر ٣٨٦: | ||
function p._navbox(navboxArgs) | function p._navbox(navboxArgs) | ||
args = navboxArgs | args = navboxArgs | ||
listnums = {} | |||
for k, _ in pairs(args) do | for k, _ in pairs(args) do | ||
سطر ٣٨٩: | سطر ٤١٠: | ||
:attr('role', 'navigation') | :attr('role', 'navigation') | ||
:node(tbl) | :node(tbl) | ||
if args.title then | -- aria-labelledby title, otherwise above, otherwise lone group | ||
nav:attr('aria-labelledby', mw.uri.anchorEncode(args.title)) | if args.title or args.above or (args.group1 and not args.group2) then | ||
nav:attr('aria-labelledby', mw.uri.anchorEncode(args.title or args.above or args.group1)) | |||
else | else | ||
nav:attr('aria-label', 'Navbox') | nav:attr('aria-label', 'Navbox') | ||
سطر ٤٠٦: | سطر ٤٢٨: | ||
:attr('role', 'navigation') | :attr('role', 'navigation') | ||
:addClass('navbox') | :addClass('navbox') | ||
:addClass(args.navboxclass) | |||
:cssText(args.bodystyle) | :cssText(args.bodystyle) | ||
:cssText(args.style) | :cssText(args.style) | ||
:css('padding', '3px') | :css('padding', '3px') | ||
:node(tbl) | :node(tbl) | ||
if args.title then | -- aria-labelledby title, otherwise above, otherwise lone group | ||
nav:attr('aria-labelledby', mw.uri.anchorEncode(args.title)) | if args.title or args.above or (args.group1 and not args.group2) then | ||
nav:attr('aria-labelledby', mw.uri.anchorEncode(args.title or args.above or args.group1)) | |||
else | else | ||
nav:attr('aria-label', 'Navbox') | nav:attr('aria-label', 'Navbox') | ||
سطر ٤١٧: | سطر ٤٤١: | ||
end | end | ||
renderTrackingCategories(res) | if (args.nocat or 'false'):lower() == 'false' then | ||
renderTrackingCategories(res) | |||
end | |||
return striped(tostring(res)) | return striped(tostring(res)) | ||
end | end | ||
سطر ٤٢٦: | سطر ٤٥١: | ||
getArgs = require('Module:Arguments').getArgs | getArgs = require('Module:Arguments').getArgs | ||
end | end | ||
args = getArgs(frame, {wrappers = ' | args = getArgs(frame, {wrappers = {'Template:Navbox', 'Template:Navbox subgroup'}}) | ||
if frame.args.border then | |||
-- This allows Template:Navbox_subgroup to use {{#invoke:Navbox|navbox|border=...}}. | |||
args.border = frame.args.border | |||
end | |||
-- 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. |