"سانچہ:Navbox" کے نسخوں کے درمیان فرق

منہاج انسائیکلوپیڈیا سے
Jump to navigation Jump to search
 
(ایک دوسرے صارف کا ایک درمیانی نسخہ نہیں دکھایا گیا)
سطر 1: سطر 1:
<!--
+
--
 
+
-- This module will implement {{Navbox}}
Please do not edit without discussion first as this is a VERY complex template.
+
--
 
+
-->{{#switch:{{{border|{{{1|}}}}}}|subgroup|child=</div>|none=|#default=<table class="navbox {{{bodyclass|}}}" cellspacing="0" <!--
+
local p = {}
  -->style="{{{bodystyle|}}};{{{style|}}}"><tr><td style="padding:2px;">}}<!--
+
 
+
local HtmlBuilder = require('Module:HtmlBuilder')
--><table cellspacing="0" class="nowraplinks {{#if:{{{title|}}}|{{#switch:{{{state|}}}|plain|off=|<!--
+
local navbar = require('Module:Navbar')._navbar
  -->#default=collapsible {{#if:{{{state|}}}|{{{state}}}|autocollapse}}}}}} {{#switch:{{{border|{{{1|}}}}}}|<!--
+
local getArgs -- lazily initialized
-->subgroup|child|none=navbox-subgroup" style="width:100%;{{{bodystyle|}}};{{{style|}}}|<!--
+
-->#default=" style="width:100%;background:transparent;color:inherit}};{{{innerstyle|}}};"><!--
+
local args
 
+
local tableRowAdded = false
 
+
local border
 
+
local listnums = {}
---Title and Navbar---
+
-->{{#if:{{{title|}}}|<tr>{{#if:{{{titlegroup|}}}|<!--
+
local function trim(s)
--><td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{titlegroupstyle|}}}">{{{titlegroup|}}}</td><!--
+
    return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
  --><th style="border-left:2px solid #fdfdfd;width:100%;|<th style="}}{{{basestyle|}}};{{{titlestyle|}}}" <!--
+
end
  -->colspan={{#expr:2{{#if:{{{imageleft|}}}|+1}}{{#if:{{{image|}}}|+1}}{{#if:{{{titlegroup|}}}|-1}}}} <!--
+
   
  -->class="navbox-title"><!--
+
local function addNewline(s)
 
+
    if s:match('^[*:;#]') or s:match('^{|') then
-->{{#if:{{#switch:{{{navbar|}}}|plain|off=1}}<!--
+
        return '\n' .. s ..'\n'
  -->{{#if:{{{name|}}}||{{#switch:{{{border|{{{1|}}}}}}|subgroup|child|none=1}}}}|<!--
+
    else
-->{{#ifeq:{{{navbar|}}}|off|{{#ifeq:{{{state|}}}|plain|<div style="float:right;width:6em;">&nbsp;</div>}}|<!--
+
        return s
  -->{{#ifeq:{{{state|}}}|plain||<div style="float:left; width:6em;text-align:left;">&nbsp;</div>}}}}|<!--
+
    end
--><div style="float:left; width:6em;text-align:left;"><!--
+
end
  -->{{Navbar|{{{name}}}|fontstyle={{{basestyle|}}};{{{titlestyle|}}};border:none;|mini=1}}<!--
+
--></div>{{#ifeq:{{{state|}}}|plain|<div style="float:right;width:6em;">&nbsp;</div>}}}}<!--
+
local function addTableRow(tbl)
 
+
    -- If any other rows have already been added, then we add a 2px gutter row.
  --><span class="{{{titleclass|}}}" style="font-size:{{#switch:{{{border|{{{1|}}}}}}|subgroup|child|none=100|#default=110}}%;"><!--
+
    if tableRowAdded then
-->{{{title}}}</span></th></tr>}}<!--
+
        tbl
 
+
            .tag('tr')
 
+
                .css('height', '2px')
 
+
                .tag('td')
---Above---
+
                .attr('colspan',2)
-->{{#if:{{{above|}}}|<!--
+
    end
  -->{{#if:{{{title|}}}|<tr style="height:2px;"><td></td></tr>}}<!--
+
  --><tr><td class="navbox-abovebelow" style="{{{basestyle|}}};{{{abovestyle|}}}" <!--
+
    tableRowAdded = true
-->colspan="{{#expr:2{{#if:{{{imageleft|}}}|+1}}{{#if:{{{image|}}}|+1}}}}">{{{above}}}</td></tr>}}<!--
+
   
 
+
    return tbl.tag('tr')
 
+
end
 
+
---Body---
+
local function renderNavBar(titleCell)
 
+
    -- Depending on the presence of the navbar and/or show/hide link, we may need to add a spacer div on the left
---First group/list and images---
+
    -- or right to keep the title centered.
-->{{#if:{{{list1|}}}|{{#if:{{{title|}}}{{{above|}}}|<tr style="height:2px;"><td></td></tr>}}<tr><!--
+
    local spacerSide = nil
 
+
-->{{#if:{{{imageleft|}}}|<!--
+
    if args.navbar == 'off' then
  --><td style="width:0%;padding:0px 2px 0px 0px;{{{imageleftstyle|}}}" <!--
+
        -- No navbar, and client wants no spacer, i.e. wants the title to be shifted to the left. If there's
  -->rowspan={{#expr:1{{#if:{{{list2|}}}|+2}}{{#if:{{{list3|}}}|+2}}{{#if:{{{list4|}}}|+2}}<!--
+
        -- also no show/hide link, then we need a spacer on the right to achieve the left shift.
-->{{#if:{{{list5|}}}|+2}}{{#if:{{{list6|}}}|+2}}{{#if:{{{list7|}}}|+2}}{{#if:{{{list8|}}}|+2}}<!--
+
        if args.state == 'plain' then spacerSide = 'left' end
-->{{#if:{{{list9|}}}|+2}}{{#if:{{{list10|}}}|+2}}{{#if:{{{list11|}}}|+2}}{{#if:{{{list12|}}}|+2}}<!--
+
    elseif args.navbar == 'plain' or (not args.name and mw.getCurrentFrame():getParent():getTitle() == 'Template:Navbox' and (border == 'subgroup' or border == 'child' or border == 'none')) then
  -->{{#if:{{{list13|}}}|+2}}{{#if:{{{list14|}}}|+2}}{{#if:{{{list15|}}}|+2}}{{#if:{{{list16|}}}|+2}}<!--
+
        -- No navbar. Need a spacer on the left to balance out the width of the show/hide link.
-->{{#if:{{{list17|}}}|+2}}{{#if:{{{list18|}}}|+2}}{{#if:{{{list19|}}}|+2}}{{#if:{{{list20|}}}|+2}}}}><!--
+
        if args.state ~= 'plain' then spacerSide = 'left' end
  -->{{{imageleft}}}</td>}}<!--
+
    else
 
+
        -- Will render navbar (or error message). If there's no show/hide link, need a spacer on the right
-->{{#if:{{{group1|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group1style|}}}"><!--
+
        -- to balance out the width of the navbar.
  -->{{{group1}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
        if args.state == 'plain' then spacerSide = 'left' end
  -->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list1style|}}}" <!--
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
        titleCell.wikitext(navbar{  
--><div style="padding:{{{list1padding|{{{listpadding|0em 0.25em}}}}}}">
+
            args.name,
{{{list1}}}</div></td><!--
+
            mini = 1,
 
+
            fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') ..  ';background:none transparent;border:none;'
-->{{#if:{{{image|}}}|<!--
+
        })
--><td style="width:0%;padding:0px 0px 0px 2px;{{{imagestyle|}}}" <!--
+
    end
-->rowspan={{#expr:1{{#if:{{{list2|}}}|+2}}{{#if:{{{list3|}}}|+2}}{{#if:{{{list4|}}}|+2}}<!--
+
   
-->{{#if:{{{list5|}}}|+2}}{{#if:{{{list6|}}}|+2}}{{#if:{{{list7|}}}|+2}}{{#if:{{{list8|}}}|+2}}<!--
+
    -- Render the spacer div.
-->{{#if:{{{list9|}}}|+2}}{{#if:{{{list10|}}}|+2}}{{#if:{{{list11|}}}|+2}}{{#if:{{{list12|}}}|+2}}<!--
+
    if spacerSide then
-->{{#if:{{{list13|}}}|+2}}{{#if:{{{list14|}}}|+2}}{{#if:{{{list15|}}}|+2}}{{#if:{{{list16|}}}|+2}}<!--
+
        titleCell
-->{{#if:{{{list17|}}}|+2}}{{#if:{{{list18|}}}|+2}}{{#if:{{{list19|}}}|+2}}{{#if:{{{list20|}}}|+2}}}}><!--
+
            .tag('span')
-->{{{image}}}</td>}}<!--
+
                .css('float', spacerSide)
 
+
                .css('width', '6em')
--></tr>}}<!--
+
                .wikitext('&nbsp;')
 
+
    end
 
+
end
 
+
---Remaining groups/lists---
+
--
 
+
--  Title row
-->{{#if:{{{list2|}}}|<!--
+
--
-->{{#if:{{{title|}}}{{{above|}}}{{{list1|}}}|<tr style="height:2px"><td></td></tr>}}<tr><!--
+
local function renderTitleRow(tbl)
-->{{#if:{{{group2|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group2style|}}}"><!--
+
    if not args.title then return end
-->{{{group2}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list2style|}}}" <!--
+
    local titleRow = addTableRow(tbl)
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
   
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
    if args.titlegroup then
{{{list2}}}</div></td></tr>}}<!--
+
        titleRow
 
+
            .tag('th')
-->{{#if:{{{list3|}}}|<!--
+
                .attr('scope', 'row')
-->{{#if:{{{title|}}}{{{above|}}}{{{list1|}}}{{{list2|}}}|<tr style="height:2px"><td></td></tr>}}<tr><!--
+
                .addClass('navbox-group')
-->{{#if:{{{group3|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group3style|}}}"><!--
+
                .addClass(args.titlegroupclass)
-->{{{group3}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
                .cssText(args.basestyle)
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list3style|}}}" <!--
+
                .cssText(args.groupstyle)
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
                .cssText(args.titlegroupstyle)
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
                .wikitext(args.titlegroup)
{{{list3}}}</div></td></tr>}}<!--
+
    end
 
+
-->{{#if:{{{list4|}}}|<!--
+
    local titleCell = titleRow.tag('th').attr('scope', 'col')
--><tr style="height:2px"><td></td></tr><tr><!--
+
-->{{#if:{{{group4|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group4style|}}}"><!--
+
    if args.titlegroup then
-->{{{group4}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
        titleCell
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list4style|}}}" <!--
+
            .css('border-left', '2px solid #fdfdfd')
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
            .css('width', '100%')
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
    end
{{{list4}}}</div></td></tr>}}<!--
+
 
+
    local titleColspan = 2
-->{{#if:{{{list5|}}}|<!--
+
    if args.imageleft then titleColspan = titleColspan + 1 end
--><tr style="height:2px"><td></td></tr><tr><!--
+
    if args.image then titleColspan = titleColspan + 1 end
-->{{#if:{{{group5|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group5style|}}}"><!--
+
    if args.titlegroup then titleColspan = titleColspan - 1 end
-->{{{group5}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
   
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list5style|}}}" <!--
+
    titleCell
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
        .cssText(args.basestyle)
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
        .cssText(args.titlestyle)
{{{list5}}}</div></td></tr>}}<!--
+
        .addClass('navbox-title')
 
+
        .attr('colspan', titleColspan)
-->{{#if:{{{list6|}}}|<!--
+
--><tr style="height:2px"><td></td></tr><tr><!--
+
    renderNavBar(titleCell)
-->{{#if:{{{group6|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group6style|}}}"><!--
+
-->{{{group6}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
    titleCell
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list6style|}}}" <!--
+
        .tag('div')
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
            .addClass(args.titleclass)
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
            .wikitext(addNewline(args.title))
{{{list6}}}</div></td></tr>}}<!--
+
end
 
+
-->{{#if:{{{list7|}}}|<!--
+
--
--><tr style="height:2px"><td></td></tr><tr><!--
+
--  Above/Below rows
-->{{#if:{{{group7|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group7style|}}}"><!--
+
--
-->{{{group7}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list7style|}}}" <!--
+
local function getAboveBelowColspan()
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
    local ret = 2
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
    if args.imageleft then ret = ret + 1 end
{{{list7}}}</div></td></tr>}}<!--
+
    if args.image then ret = ret + 1 end
 
+
    return ret
-->{{#if:{{{list8|}}}|<!--
+
end
--><tr style="height:2px"><td></td></tr><tr><!--
+
   
-->{{#if:{{{group8|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group8style|}}}"><!--
+
local function renderAboveRow(tbl)
-->{{{group8}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
    if not args.above then return end
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list8style|}}}" <!--
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
    addTableRow(tbl)
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
        .tag('td')
{{{list8}}}</div></td></tr>}}<!--
+
            .addClass('navbox-abovebelow')
 
+
            .addClass(args.aboveclass)
-->{{#if:{{{list9|}}}|<!--
+
            .cssText(args.basestyle)
--><tr style="height:2px"><td></td></tr><tr><!--
+
            .cssText(args.abovestyle)
-->{{#if:{{{group9|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group9style|}}}"><!--
+
            .attr('colspan', getAboveBelowColspan())
-->{{{group9}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
            .tag('div')
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list9style|}}}" <!--
+
                .wikitext(addNewline(args.above))
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
end
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
   
{{{list9}}}</div></td></tr>}}<!--
+
local function renderBelowRow(tbl)
 
+
    if not args.below then return end
-->{{#if:{{{list10|}}}|<!--
+
--><tr style="height:2px"><td></td></tr><tr><!--
+
    addTableRow(tbl)
-->{{#if:{{{group10|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group10style|}}}"><!--
+
        .tag('td')
-->{{{group10}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
            .addClass('navbox-abovebelow')
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list10style|}}}" <!--
+
            .addClass(args.belowclass)
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
            .cssText(args.basestyle)
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
            .cssText(args.belowstyle)
{{{list10}}}</div></td></tr>}}<!--
+
            .attr('colspan', getAboveBelowColspan())
 
+
            .tag('div')
-->{{#if:{{{list11|}}}|<!--
+
                .wikitext(addNewline(args.below))
--><tr style="height:2px"><td></td></tr><tr><!--
+
end
-->{{#if:{{{group11|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group11style|}}}"><!--
+
-->{{{group11}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
--
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list11style|}}}" <!--
+
--   List rows
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
--
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
local function renderListRow(tbl, listnum)
{{{list11}}}</div></td></tr>}}<!--
+
    local row = addTableRow(tbl)
 
+
   
-->{{#if:{{{list12|}}}|<!--
+
    if listnum == 1 and args.imageleft then
--><tr style="height:2px"><td></td></tr><tr><!--
+
        row
-->{{#if:{{{group12|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group12style|}}}"><!--
+
            .tag('td')
-->{{{group12}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
                .addClass('navbox-image')
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list12style|}}}" <!--
+
                .addClass(args.imageclass)
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
                .css('width', '0%')
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
                .css('padding', '0px 2px 0px 0px')
{{{list12}}}</div></td></tr>}}<!--
+
                .cssText(args.imageleftstyle)
 
+
                .attr('rowspan', 2 * #listnums - 1)
-->{{#if:{{{list13|}}}|<!--
+
                .tag('div')
--><tr style="height:2px"><td></td></tr><tr><!--
+
                    .wikitext(addNewline(args.imageleft))
-->{{#if:{{{group13|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group13style|}}}"><!--
+
    end
-->{{{group13}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list13style|}}}" <!--
+
    if args['group' .. listnum] then
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
        local groupCell = row.tag('th')
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
{{{list13}}}</div></td></tr>}}<!--
+
        groupCell
 
+
              .attr('scope', 'row')
-->{{#if:{{{list14|}}}|<!--
+
              .addClass('navbox-group')
--><tr style="height:2px"><td></td></tr><tr><!--
+
              .addClass(args.groupclass)
-->{{#if:{{{group14|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group14style|}}}"><!--
+
              .cssText(args.basestyle)
-->{{{group14}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
   
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list14style|}}}" <!--
+
        if args.groupwidth then
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
            groupCell.css('width', args.groupwidth)
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
        end
{{{list14}}}</div></td></tr>}}<!--
+
 
+
        groupCell
-->{{#if:{{{list15|}}}|<!--
+
            .cssText(args.groupstyle)
--><tr style="height:2px"><td></td></tr><tr><!--
+
            .cssText(args['group' .. listnum .. 'style'])
-->{{#if:{{{group15|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group15style|}}}"><!--
+
            .wikitext(args['group' .. listnum])
-->{{{group15}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
    end
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list15style|}}}" <!--
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
    local listCell = row.tag('td')
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
{{{list15}}}</div></td></tr>}}<!--
+
    if args['group' .. listnum] then
 
+
        listCell
-->{{#if:{{{list16|}}}|<!--
+
            .css('text-align', 'right')
--><tr style="height:2px"><td></td></tr><tr><!--
+
            .css('border-right-width', '2px')
-->{{#if:{{{group16|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group16style|}}}"><!--
+
            .css('border-right-style', 'solid')
-->{{{group16}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
    else
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list16style|}}}" <!--
+
        listCell.attr('colspan', 2)
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
    end
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
{{{list16}}}</div></td></tr>}}<!--
+
    if not args.groupwidth then
 
+
        listCell.css('width', '100%')
-->{{#if:{{{list17|}}}|<!--
+
    end
--><tr style="height:2px"><td></td></tr><tr><!--
+
   
-->{{#if:{{{group17|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group17style|}}}"><!--
+
    local isOdd = (listnum % 2) == 1
-->{{{group17}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
    local rowstyle = args.evenstyle
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list17style|}}}" <!--
+
    if isOdd then rowstyle = args.oddstyle end
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
   
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
    local evenOdd
{{{list17}}}</div></td></tr>}}<!--
+
    if args.evenodd == 'swap' then
 
+
        if isOdd then evenOdd = 'even' else evenOdd = 'odd' end
-->{{#if:{{{list18|}}}|<!--
+
    else
--><tr style="height:2px"><td></td></tr><tr><!--
+
        if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end
-->{{#if:{{{group18|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group18style|}}}"><!--
+
    end
-->{{{group18}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list18style|}}}" <!--
+
    listCell
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
        .css('padding', '0px')
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
        .cssText(args.liststyle)
{{{list18}}}</div></td></tr>}}<!--
+
        .cssText(rowstyle)
 
+
        .cssText(args['list' .. listnum .. 'style'])
-->{{#if:{{{list19|}}}|<!--
+
        .addClass('navbox-list')
--><tr style="height:2px"><td></td></tr><tr><!--
+
        .addClass('navbox-' .. evenOdd)
-->{{#if:{{{group19|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group19style|}}}"><!--
+
        .addClass(args.listclass)
-->{{{group19}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
        .tag('div')
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list19style|}}}" <!--
+
            .css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
            .wikitext(addNewline(args['list' .. listnum]))
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
{{{list19}}}</div></td></tr>}}<!--
+
    if listnum == 1 and args.image then
 
+
        row
-->{{#if:{{{list20|}}}|<!--
+
            .tag('td')
--><tr style="height:2px"><td></td></tr><tr><!--
+
                .addClass('navbox-image')
-->{{#if:{{{group20|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group20style|}}}"><!--
+
                .addClass(args.imageclass)
-->{{{group20}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
+
                .css('width', '0%')
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list20style|}}}" <!--
+
                .css('padding', '0px 0px 0px 2px')
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
                .cssText(args.imagestyle)
--><div style="padding:{{{listpadding|0em 0.25em}}}">
+
                .attr('rowspan', 2 * #listnums - 1)
{{{list20}}}</div></td></tr>}}<!--
+
                .tag('div')
 
+
                    .wikitext(addNewline(args.image))
 
+
    end
---Below---
+
end
-->{{#if:{{{below|}}}|<!--
+
-->{{#if:{{{title|}}}{{{above|}}}{{{list1|}}}{{{list2|}}}{{{list3|}}}|<tr style="height:2px;"><td></td></tr>}}<!--
+
--><tr><td class="navbox-abovebelow" style="{{{basestyle|}}};{{{belowstyle|}}}" <!--
+
--
-->colspan="{{#expr:2{{#if:{{{imageleft|}}}|+1}}{{#if:{{{image|}}}|+1}}}}">{{{below}}}</td></tr>}}<!--
+
--   Tracking categories
 
+
--
 
+
--></table>{{#switch:{{{border|{{{1|}}}}}}|subgroup|child=<div>|none=|#default=</td></tr></table>}}<!--
+
local function needsHorizontalLists()
 
+
    if border == 'child' or border == 'subgroup'  or args.tracking == 'no' then return false end
--><noinclude>
+
 
+
    local listClasses = {'plainlist', 'hlist', 'hlist hnum', 'hlist hwrap', 'hlist vcard', 'vcard hlist', 'hlist vevent'}
{{pp-template|small=yes}}
+
    for i, cls in ipairs(listClasses) do
 
+
        if args.listclass == cls or args.bodyclass == cls then
{{documentation}}
+
            return false
<!-- Add categories and interwikis to the /doc subpage, not here! -->
+
        end
</noinclude>
+
    end
 +
 +
    return true
 +
end
 +
   
 +
local function hasBackgroundColors()
 +
    return mw.ustring.match(args.titlestyle or '','background') or mw.ustring.match(args.groupstyle or '','background') or mw.ustring.match(args.basestyle or '','background')
 +
end
 +
 +
local function getTrackingCategories()
 +
    local cats = {}
 +
    if needsHorizontalLists() then table.insert(cats, 'بغیر افقی فہرست والے ناوباکس') end
 +
    if hasBackgroundColors() then table.insert(cats, 'پس منظری رنگ والے ناوباکس') end
 +
    return cats
 +
end
 +
   
 +
local function renderTrackingCategories(builder)
 +
    local title = mw.title.getCurrentTitle()
 +
    if title.namespace ~= 10 then return end -- not in template space
 +
    local subpage = title.subpageText
 +
    if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
 +
 +
    for i, cat in ipairs(getTrackingCategories()) do
 +
        builder.wikitext('[[Category:' .. cat .. ']]')
 +
    end
 +
end
 +
 +
--
 +
--   Main navbox tables
 +
--
 +
local function renderMainTable()
 +
    local tbl = HtmlBuilder.create('table')
 +
        .attr('cellspacing', 0)
 +
        .addClass('nowraplinks')
 +
        .addClass(args.bodyclass)
 +
 +
    if args.title and (args.state ~= 'plain' and args.state ~= 'off') then
 +
        tbl
 +
            .addClass('collapsible')
 +
            .addClass(args.state or 'autocollapse')
 +
    end
 +
 +
    tbl.css('border-spacing', 0)
 +
    if border == 'subgroup' or border == 'child' or border == 'none' then
 +
        tbl
 +
            .addClass('navbox-subgroup')
 +
            .cssText(args.bodystyle)
 +
            .cssText(args.style)
 +
    else -- regular navobx - bodystyle and style will be applied to the wrapper table
 +
        tbl
 +
            .addClass('navbox-inner')
 +
            .css('background', 'transparent')
 +
            .css('color', 'inherit')
 +
    end
 +
    tbl.cssText(args.innerstyle)
 +
 +
    renderTitleRow(tbl)
 +
    renderAboveRow(tbl)
 +
    for i, listnum in ipairs(listnums) do
 +
        renderListRow(tbl, listnum)
 +
    end
 +
    renderBelowRow(tbl)
 +
 +
    return tbl
 +
end
 +
 +
function p._navbox(navboxArgs)
 +
    args = navboxArgs
 +
 +
    for k, v in pairs(args) do
 +
        local listnum = ('' .. k):match('^list(%d+)$')
 +
        if listnum then table.insert(listnums, tonumber(listnum)) end
 +
    end
 +
    table.sort(listnums)
 +
 +
    border = trim(args.border or args[1] or '')
 +
   
 +
    -- render the main body of the navbox
 +
    local tbl = renderMainTable()
 +
 +
    -- render the appropriate wrapper around the navbox, depending on the border param
 +
    local res = HtmlBuilder.create()
 +
    if border == 'none' then
 +
        res.node(tbl)
 +
    elseif border == 'subgroup' or border == 'child' then
 +
        -- We assume that this navbox is being rendered in a list cell of a parent navbox, and is
 +
        -- therefore inside a div with padding:0em 0.25em. We start with a </div> to avoid the
 +
        -- padding being applied, and at the end add a <div> to balance out the parent's </div>
 +
        res
 +
            .tag('/div', {unclosed = true})
 +
                .done()
 +
            .node(tbl)
 +
            .tag('div', {unclosed = true})
 +
    else
 +
        res
 +
            .tag('table')
 +
                .attr('cellspacing', 0)
 +
                .addClass('navbox')
 +
                .css('border-spacing', 0)
 +
                .cssText(args.bodystyle)
 +
                .cssText(args.style)
 +
                .tag('tr')
 +
                    .tag('td')
 +
                        .css('padding', '2px')
 +
                        .node(tbl)
 +
    end
 +
 +
    renderTrackingCategories(res)
 +
 +
    return tostring(res)
 +
end
 +
 +
function p.navbox(frame)
 +
    -- ParserFunctions considers the empty string to be false, so to preserve the previous
 +
    -- behavior of {{navbox}}, change any empty arguments to nil, so Lua will consider
 +
    -- them false too.
 +
    local args = {}
 +
    local parent_args = frame:getParent().args;
 +
   
 +
    -- Out of order parsing bug.
 +
    local temp;
 +
    temp = parent_args.title;
 +
    temp = parent_args.above;
 +
    for i = 1, 20 do
 +
        temp = parent_args["group" .. tostring(i)];
 +
        temp = parent_args["list" .. tostring(i)];
 +
    end   
 +
    temp = parent_args.below;
 +
   
 +
    for k, v in pairs(parent_args) do
 +
        if v ~= '' then
 +
            args[k] = v
 +
        end
 +
    end
 +
    return p._navbox(args)
 +
end
 +
   
 +
return p

حالیہ نسخہ بمطابق 13:54، 27 مارچ 2015ء

-- -- This module will implement -- -- This module will implement سانچہ میں تکرار پایا گیا: سانچہ:Navbox --

local p = {}

local HtmlBuilder = require('Module:HtmlBuilder') local navbar = require('Module:Navbar')._navbar local getArgs -- lazily initialized

local args local tableRowAdded = false local border local listnums = {}

local function trim(s)

   return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))

end

local function addNewline(s)

   if s:match('^[*:;#]') or s:match('^{|') then
       return '\n' .. s ..'\n'
   else
       return s
   end

end

local function addTableRow(tbl)

   -- If any other rows have already been added, then we add a 2px gutter row.
   if tableRowAdded then
       tbl
           .tag('tr')
               .css('height', '2px')
               .tag('td')
               	.attr('colspan',2)
   end

   tableRowAdded = true

   return tbl.tag('tr')

end

local function renderNavBar(titleCell)

   -- Depending on the presence of the navbar and/or show/hide link, we may need to add a spacer div on the left
   -- or right to keep the title centered.
   local spacerSide = nil

   if args.navbar == 'off' then
       -- No navbar, and client wants no spacer, i.e. wants the title to be shifted to the left. If there's
       -- also no show/hide link, then we need a spacer on the right to achieve the left shift.
       if args.state == 'plain' then spacerSide = 'left' end
   elseif args.navbar == 'plain' or (not args.name and mw.getCurrentFrame():getParent():getTitle() == 'Template:Navbox' and (border == 'subgroup' or border == 'child' or border == 'none')) then
       -- No navbar. Need a spacer on the left to balance out the width of the show/hide link.
       if args.state ~= 'plain' then spacerSide = 'left' end
   else
       -- Will render navbar (or error message). If there's no show/hide link, need a spacer on the right
       -- to balance out the width of the navbar.
       if args.state == 'plain' then spacerSide = 'left' end

       titleCell.wikitext(navbar{ 
           args.name, 
           mini = 1, 
           fontstyle = (args.basestyle or ) .. ';' .. (args.titlestyle or ) ..  ';background:none transparent;border:none;'
       })
   end

   -- Render the spacer div.
   if spacerSide then
       titleCell
           .tag('span')
               .css('float', spacerSide)
               .css('width', '6em')
               .wikitext(' ')
   end

end

-- -- Title row -- local function renderTitleRow(tbl)

   if not args.title then return end

   local titleRow = addTableRow(tbl)

   if args.titlegroup then
       titleRow
           .tag('th')
               .attr('scope', 'row')
               .addClass('navbox-group')
               .addClass(args.titlegroupclass)
               .cssText(args.basestyle)
               .cssText(args.groupstyle)
               .cssText(args.titlegroupstyle)
               .wikitext(args.titlegroup)
   end

   local titleCell = titleRow.tag('th').attr('scope', 'col')

   if args.titlegroup then
       titleCell
           .css('border-left', '2px solid #fdfdfd')
           .css('width', '100%')
   end

   local titleColspan = 2
   if args.imageleft then titleColspan = titleColspan + 1 end
   if args.image then titleColspan = titleColspan + 1 end
   if args.titlegroup then titleColspan = titleColspan - 1 end

   titleCell
       .cssText(args.basestyle)
       .cssText(args.titlestyle)
       .addClass('navbox-title')
       .attr('colspan', titleColspan)

   renderNavBar(titleCell)

   titleCell
        .tag('div')
            .addClass(args.titleclass)
            .wikitext(addNewline(args.title))

end

-- -- Above/Below rows --

local function getAboveBelowColspan()

   local ret = 2
   if args.imageleft then ret = ret + 1 end
   if args.image then ret = ret + 1 end
   return ret

end

local function renderAboveRow(tbl)

   if not args.above then return end

   addTableRow(tbl)
       .tag('td')
           .addClass('navbox-abovebelow')
           .addClass(args.aboveclass)
           .cssText(args.basestyle)
           .cssText(args.abovestyle)
           .attr('colspan', getAboveBelowColspan())
           .tag('div')
               .wikitext(addNewline(args.above))

end

local function renderBelowRow(tbl)

   if not args.below then return end

   addTableRow(tbl)
       .tag('td')
           .addClass('navbox-abovebelow')
           .addClass(args.belowclass)
           .cssText(args.basestyle)
           .cssText(args.belowstyle)
           .attr('colspan', getAboveBelowColspan())
           .tag('div')
               .wikitext(addNewline(args.below))

end

-- -- List rows -- local function renderListRow(tbl, listnum)

   local row = addTableRow(tbl)

   if listnum == 1 and args.imageleft then
       row
           .tag('td')
               .addClass('navbox-image')
               .addClass(args.imageclass)
               .css('width', '0%')
               .css('padding', '0px 2px 0px 0px')
               .cssText(args.imageleftstyle)
               .attr('rowspan', 2 * #listnums - 1)
               .tag('div')
                   .wikitext(addNewline(args.imageleft))
   end

   if args['group' .. listnum] then
       local groupCell = row.tag('th')

       groupCell
              .attr('scope', 'row')
              .addClass('navbox-group')
              .addClass(args.groupclass)
              .cssText(args.basestyle)

       if args.groupwidth then
           groupCell.css('width', args.groupwidth)
       end

       groupCell
           .cssText(args.groupstyle)
           .cssText(args['group' .. listnum .. 'style'])
           .wikitext(args['group' .. listnum])
   end

   local listCell = row.tag('td')

   if args['group' .. listnum] then
       listCell
           .css('text-align', 'right')
           .css('border-right-width', '2px')
           .css('border-right-style', 'solid')
   else
       listCell.attr('colspan', 2)
   end

   if not args.groupwidth then 
       listCell.css('width', '100%')
   end

   local isOdd = (listnum % 2) == 1
   local rowstyle = args.evenstyle
   if isOdd then rowstyle = args.oddstyle end

   local evenOdd
   if args.evenodd == 'swap' then
       if isOdd then evenOdd = 'even' else evenOdd = 'odd' end
   else
       if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end
   end

   listCell
       .css('padding', '0px')
       .cssText(args.liststyle)
       .cssText(rowstyle)
       .cssText(args['list' .. listnum .. 'style'])
       .addClass('navbox-list')
       .addClass('navbox-' .. evenOdd)
       .addClass(args.listclass)
       .tag('div')
           .css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
           .wikitext(addNewline(args['list' .. listnum]))

   if listnum == 1 and args.image then
       row
           .tag('td')
               .addClass('navbox-image')
               .addClass(args.imageclass)
               .css('width', '0%')
               .css('padding', '0px 0px 0px 2px')
               .cssText(args.imagestyle)
               .attr('rowspan', 2 * #listnums - 1)
               .tag('div')
                   .wikitext(addNewline(args.image))
   end

end


-- -- Tracking categories --

local function needsHorizontalLists()

   if border == 'child' or border == 'subgroup'  or args.tracking == 'no' then return false end

   local listClasses = {'plainlist', 'hlist', 'hlist hnum', 'hlist hwrap', 'hlist vcard', 'vcard hlist', 'hlist vevent'}
   for i, cls in ipairs(listClasses) do
       if args.listclass == cls or args.bodyclass == cls then
           return false
       end
   end

   return true

end

local function hasBackgroundColors()

   return mw.ustring.match(args.titlestyle or ,'background') or mw.ustring.match(args.groupstyle or ,'background') or mw.ustring.match(args.basestyle or ,'background')

end

local function getTrackingCategories()

   local cats = {}
   if needsHorizontalLists() then table.insert(cats, 'بغیر افقی فہرست والے ناوباکس') end
   if hasBackgroundColors() then table.insert(cats, 'پس منظری رنگ والے ناوباکس') end
   return cats

end

local function renderTrackingCategories(builder)

   local title = mw.title.getCurrentTitle()
   if title.namespace ~= 10 then return end -- not in template space
   local subpage = title.subpageText
   if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end

   for i, cat in ipairs(getTrackingCategories()) do
       builder.wikitext() 
   end

end

-- -- Main navbox tables -- local function renderMainTable()

   local tbl = HtmlBuilder.create('table')
       .attr('cellspacing', 0)
       .addClass('nowraplinks')
       .addClass(args.bodyclass)

   if args.title and (args.state ~= 'plain' and args.state ~= 'off') then
       tbl
           .addClass('collapsible')
           .addClass(args.state or 'autocollapse')
   end

   tbl.css('border-spacing', 0)
   if border == 'subgroup' or border == 'child' or border == 'none' then
       tbl
           .addClass('navbox-subgroup')
           .cssText(args.bodystyle)
           .cssText(args.style)
   else -- regular navobx - bodystyle and style will be applied to the wrapper table
       tbl
           .addClass('navbox-inner')
           .css('background', 'transparent')
           .css('color', 'inherit')
   end
   tbl.cssText(args.innerstyle)

   renderTitleRow(tbl)
   renderAboveRow(tbl)
   for i, listnum in ipairs(listnums) do
       renderListRow(tbl, listnum) 
   end
   renderBelowRow(tbl)

   return tbl

end

function p._navbox(navboxArgs)

   args = navboxArgs

   for k, v in pairs(args) do
       local listnum = ( .. k):match('^list(%d+)$')
       if listnum then table.insert(listnums, tonumber(listnum)) end
   end
   table.sort(listnums)

   border = trim(args.border or args[1] or )

   -- render the main body of the navbox
   local tbl = renderMainTable()

   -- render the appropriate wrapper around the navbox, depending on the border param
   local res = HtmlBuilder.create()
   if border == 'none' then
       res.node(tbl)
   elseif border == 'subgroup' or border == 'child' then
       -- We assume that this navbox is being rendered in a list cell of a parent navbox, and is

-- therefore inside a div with padding:0em 0.25em. We start with a to avoid the -- padding being applied, and at the end add a

to balance out the parent's
       res
           .tag('/div', {unclosed = true})
               .done()
           .node(tbl)
           .tag('div', {unclosed = true})
   else
       res
           .tag('table')
               .attr('cellspacing', 0)
               .addClass('navbox')
               .css('border-spacing', 0)
               .cssText(args.bodystyle)
               .cssText(args.style)
               .tag('tr')
                   .tag('td')
                       .css('padding', '2px')
                       .node(tbl)
   end

   renderTrackingCategories(res)

   return tostring(res)

end

function p.navbox(frame)

   -- ParserFunctions considers the empty string to be false, so to preserve the previous 
   -- behavior of سانچہ میں تکرار پایا گیا: سانچہ:Navbox, change any empty arguments to nil, so Lua will consider
   -- them false too.
   local args = {}
   local parent_args = frame:getParent().args;

   -- Out of order parsing bug.
   local temp;
   temp = parent_args.title;
   temp = parent_args.above;
   for i = 1, 20 do
       temp = parent_args["group" .. tostring(i)];
       temp = parent_args["list" .. tostring(i)];
   end    
   temp = parent_args.below;

   for k, v in pairs(parent_args) do
       if v ~=  then
           args[k] = v
       end
   end
   return p._navbox(args)

end

return p --

local p = {}

local HtmlBuilder = require('Module:HtmlBuilder') local navbar = require('Module:Navbar')._navbar local getArgs -- lazily initialized

local args local tableRowAdded = false local border local listnums = {}

local function trim(s)

   return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))

end

local function addNewline(s)

   if s:match('^[*:;#]') or s:match('^{|') then
       return '\n' .. s ..'\n'
   else
       return s
   end

end

local function addTableRow(tbl)

   -- If any other rows have already been added, then we add a 2px gutter row.
   if tableRowAdded then
       tbl
           .tag('tr')
               .css('height', '2px')
               .tag('td')
               	.attr('colspan',2)
   end

   tableRowAdded = true

   return tbl.tag('tr')

end

local function renderNavBar(titleCell)

   -- Depending on the presence of the navbar and/or show/hide link, we may need to add a spacer div on the left
   -- or right to keep the title centered.
   local spacerSide = nil

   if args.navbar == 'off' then
       -- No navbar, and client wants no spacer, i.e. wants the title to be shifted to the left. If there's
       -- also no show/hide link, then we need a spacer on the right to achieve the left shift.
       if args.state == 'plain' then spacerSide = 'left' end
   elseif args.navbar == 'plain' or (not args.name and mw.getCurrentFrame():getParent():getTitle() == 'Template:Navbox' and (border == 'subgroup' or border == 'child' or border == 'none')) then
       -- No navbar. Need a spacer on the left to balance out the width of the show/hide link.
       if args.state ~= 'plain' then spacerSide = 'left' end
   else
       -- Will render navbar (or error message). If there's no show/hide link, need a spacer on the right
       -- to balance out the width of the navbar.
       if args.state == 'plain' then spacerSide = 'left' end

       titleCell.wikitext(navbar{ 
           args.name, 
           mini = 1, 
           fontstyle = (args.basestyle or ) .. ';' .. (args.titlestyle or ) ..  ';background:none transparent;border:none;'
       })
   end

   -- Render the spacer div.
   if spacerSide then
       titleCell
           .tag('span')
               .css('float', spacerSide)
               .css('width', '6em')
               .wikitext(' ')
   end

end

-- -- Title row -- local function renderTitleRow(tbl)

   if not args.title then return end

   local titleRow = addTableRow(tbl)

   if args.titlegroup then
       titleRow
           .tag('th')
               .attr('scope', 'row')
               .addClass('navbox-group')
               .addClass(args.titlegroupclass)
               .cssText(args.basestyle)
               .cssText(args.groupstyle)
               .cssText(args.titlegroupstyle)
               .wikitext(args.titlegroup)
   end

   local titleCell = titleRow.tag('th').attr('scope', 'col')

   if args.titlegroup then
       titleCell
           .css('border-left', '2px solid #fdfdfd')
           .css('width', '100%')
   end

   local titleColspan = 2
   if args.imageleft then titleColspan = titleColspan + 1 end
   if args.image then titleColspan = titleColspan + 1 end
   if args.titlegroup then titleColspan = titleColspan - 1 end

   titleCell
       .cssText(args.basestyle)
       .cssText(args.titlestyle)
       .addClass('navbox-title')
       .attr('colspan', titleColspan)

   renderNavBar(titleCell)

   titleCell
        .tag('div')
            .addClass(args.titleclass)
            .wikitext(addNewline(args.title))

end

-- -- Above/Below rows --

local function getAboveBelowColspan()

   local ret = 2
   if args.imageleft then ret = ret + 1 end
   if args.image then ret = ret + 1 end
   return ret

end

local function renderAboveRow(tbl)

   if not args.above then return end

   addTableRow(tbl)
       .tag('td')
           .addClass('navbox-abovebelow')
           .addClass(args.aboveclass)
           .cssText(args.basestyle)
           .cssText(args.abovestyle)
           .attr('colspan', getAboveBelowColspan())
           .tag('div')
               .wikitext(addNewline(args.above))

end

local function renderBelowRow(tbl)

   if not args.below then return end

   addTableRow(tbl)
       .tag('td')
           .addClass('navbox-abovebelow')
           .addClass(args.belowclass)
           .cssText(args.basestyle)
           .cssText(args.belowstyle)
           .attr('colspan', getAboveBelowColspan())
           .tag('div')
               .wikitext(addNewline(args.below))

end

-- -- List rows -- local function renderListRow(tbl, listnum)

   local row = addTableRow(tbl)

   if listnum == 1 and args.imageleft then
       row
           .tag('td')
               .addClass('navbox-image')
               .addClass(args.imageclass)
               .css('width', '0%')
               .css('padding', '0px 2px 0px 0px')
               .cssText(args.imageleftstyle)
               .attr('rowspan', 2 * #listnums - 1)
               .tag('div')
                   .wikitext(addNewline(args.imageleft))
   end

   if args['group' .. listnum] then
       local groupCell = row.tag('th')

       groupCell
              .attr('scope', 'row')
              .addClass('navbox-group')
              .addClass(args.groupclass)
              .cssText(args.basestyle)

       if args.groupwidth then
           groupCell.css('width', args.groupwidth)
       end

       groupCell
           .cssText(args.groupstyle)
           .cssText(args['group' .. listnum .. 'style'])
           .wikitext(args['group' .. listnum])
   end

   local listCell = row.tag('td')

   if args['group' .. listnum] then
       listCell
           .css('text-align', 'right')
           .css('border-right-width', '2px')
           .css('border-right-style', 'solid')
   else
       listCell.attr('colspan', 2)
   end

   if not args.groupwidth then 
       listCell.css('width', '100%')
   end

   local isOdd = (listnum % 2) == 1
   local rowstyle = args.evenstyle
   if isOdd then rowstyle = args.oddstyle end

   local evenOdd
   if args.evenodd == 'swap' then
       if isOdd then evenOdd = 'even' else evenOdd = 'odd' end
   else
       if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end
   end

   listCell
       .css('padding', '0px')
       .cssText(args.liststyle)
       .cssText(rowstyle)
       .cssText(args['list' .. listnum .. 'style'])
       .addClass('navbox-list')
       .addClass('navbox-' .. evenOdd)
       .addClass(args.listclass)
       .tag('div')
           .css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
           .wikitext(addNewline(args['list' .. listnum]))

   if listnum == 1 and args.image then
       row
           .tag('td')
               .addClass('navbox-image')
               .addClass(args.imageclass)
               .css('width', '0%')
               .css('padding', '0px 0px 0px 2px')
               .cssText(args.imagestyle)
               .attr('rowspan', 2 * #listnums - 1)
               .tag('div')
                   .wikitext(addNewline(args.image))
   end

end


-- -- Tracking categories --

local function needsHorizontalLists()

   if border == 'child' or border == 'subgroup'  or args.tracking == 'no' then return false end

   local listClasses = {'plainlist', 'hlist', 'hlist hnum', 'hlist hwrap', 'hlist vcard', 'vcard hlist', 'hlist vevent'}
   for i, cls in ipairs(listClasses) do
       if args.listclass == cls or args.bodyclass == cls then
           return false
       end
   end

   return true

end

local function hasBackgroundColors()

   return mw.ustring.match(args.titlestyle or ,'background') or mw.ustring.match(args.groupstyle or ,'background') or mw.ustring.match(args.basestyle or ,'background')

end

local function getTrackingCategories()

   local cats = {}
   if needsHorizontalLists() then table.insert(cats, 'بغیر افقی فہرست والے ناوباکس') end
   if hasBackgroundColors() then table.insert(cats, 'پس منظری رنگ والے ناوباکس') end
   return cats

end

local function renderTrackingCategories(builder)

   local title = mw.title.getCurrentTitle()
   if title.namespace ~= 10 then return end -- not in template space
   local subpage = title.subpageText
   if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end

   for i, cat in ipairs(getTrackingCategories()) do
       builder.wikitext() 
   end

end

-- -- Main navbox tables -- local function renderMainTable()

   local tbl = HtmlBuilder.create('table')
       .attr('cellspacing', 0)
       .addClass('nowraplinks')
       .addClass(args.bodyclass)

   if args.title and (args.state ~= 'plain' and args.state ~= 'off') then
       tbl
           .addClass('collapsible')
           .addClass(args.state or 'autocollapse')
   end

   tbl.css('border-spacing', 0)
   if border == 'subgroup' or border == 'child' or border == 'none' then
       tbl
           .addClass('navbox-subgroup')
           .cssText(args.bodystyle)
           .cssText(args.style)
   else -- regular navobx - bodystyle and style will be applied to the wrapper table
       tbl
           .addClass('navbox-inner')
           .css('background', 'transparent')
           .css('color', 'inherit')
   end
   tbl.cssText(args.innerstyle)

   renderTitleRow(tbl)
   renderAboveRow(tbl)
   for i, listnum in ipairs(listnums) do
       renderListRow(tbl, listnum) 
   end
   renderBelowRow(tbl)

   return tbl

end

function p._navbox(navboxArgs)

   args = navboxArgs

   for k, v in pairs(args) do
       local listnum = ( .. k):match('^list(%d+)$')
       if listnum then table.insert(listnums, tonumber(listnum)) end
   end
   table.sort(listnums)

   border = trim(args.border or args[1] or )

   -- render the main body of the navbox
   local tbl = renderMainTable()

   -- render the appropriate wrapper around the navbox, depending on the border param
   local res = HtmlBuilder.create()
   if border == 'none' then
       res.node(tbl)
   elseif border == 'subgroup' or border == 'child' then
       -- We assume that this navbox is being rendered in a list cell of a parent navbox, and is

-- therefore inside a div with padding:0em 0.25em. We start with a to avoid the -- padding being applied, and at the end add a

to balance out the parent's
       res
           .tag('/div', {unclosed = true})
               .done()
           .node(tbl)
           .tag('div', {unclosed = true})
   else
       res
           .tag('table')
               .attr('cellspacing', 0)
               .addClass('navbox')
               .css('border-spacing', 0)
               .cssText(args.bodystyle)
               .cssText(args.style)
               .tag('tr')
                   .tag('td')
                       .css('padding', '2px')
                       .node(tbl)
   end

   renderTrackingCategories(res)

   return tostring(res)

end

function p.navbox(frame)

   -- ParserFunctions considers the empty string to be false, so to preserve the previous 
   -- behavior of --

-- This module will implement سانچہ میں تکرار پایا گیا: سانچہ:Navbox --

local p = {}

local HtmlBuilder = require('Module:HtmlBuilder') local navbar = require('Module:Navbar')._navbar local getArgs -- lazily initialized

local args local tableRowAdded = false local border local listnums = {}

local function trim(s)

   return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))

end

local function addNewline(s)

   if s:match('^[*:;#]') or s:match('^{|') then
       return '\n' .. s ..'\n'
   else
       return s
   end

end

local function addTableRow(tbl)

   -- If any other rows have already been added, then we add a 2px gutter row.
   if tableRowAdded then
       tbl
           .tag('tr')
               .css('height', '2px')
               .tag('td')
               	.attr('colspan',2)
   end

   tableRowAdded = true

   return tbl.tag('tr')

end

local function renderNavBar(titleCell)

   -- Depending on the presence of the navbar and/or show/hide link, we may need to add a spacer div on the left
   -- or right to keep the title centered.
   local spacerSide = nil

   if args.navbar == 'off' then
       -- No navbar, and client wants no spacer, i.e. wants the title to be shifted to the left. If there's
       -- also no show/hide link, then we need a spacer on the right to achieve the left shift.
       if args.state == 'plain' then spacerSide = 'left' end
   elseif args.navbar == 'plain' or (not args.name and mw.getCurrentFrame():getParent():getTitle() == 'Template:Navbox' and (border == 'subgroup' or border == 'child' or border == 'none')) then
       -- No navbar. Need a spacer on the left to balance out the width of the show/hide link.
       if args.state ~= 'plain' then spacerSide = 'left' end
   else
       -- Will render navbar (or error message). If there's no show/hide link, need a spacer on the right
       -- to balance out the width of the navbar.
       if args.state == 'plain' then spacerSide = 'left' end

       titleCell.wikitext(navbar{ 
           args.name, 
           mini = 1, 
           fontstyle = (args.basestyle or ) .. ';' .. (args.titlestyle or ) ..  ';background:none transparent;border:none;'
       })
   end

   -- Render the spacer div.
   if spacerSide then
       titleCell
           .tag('span')
               .css('float', spacerSide)
               .css('width', '6em')
               .wikitext(' ')
   end

end

-- -- Title row -- local function renderTitleRow(tbl)

   if not args.title then return end

   local titleRow = addTableRow(tbl)

   if args.titlegroup then
       titleRow
           .tag('th')
               .attr('scope', 'row')
               .addClass('navbox-group')
               .addClass(args.titlegroupclass)
               .cssText(args.basestyle)
               .cssText(args.groupstyle)
               .cssText(args.titlegroupstyle)
               .wikitext(args.titlegroup)
   end

   local titleCell = titleRow.tag('th').attr('scope', 'col')

   if args.titlegroup then
       titleCell
           .css('border-left', '2px solid #fdfdfd')
           .css('width', '100%')
   end

   local titleColspan = 2
   if args.imageleft then titleColspan = titleColspan + 1 end
   if args.image then titleColspan = titleColspan + 1 end
   if args.titlegroup then titleColspan = titleColspan - 1 end

   titleCell
       .cssText(args.basestyle)
       .cssText(args.titlestyle)
       .addClass('navbox-title')
       .attr('colspan', titleColspan)

   renderNavBar(titleCell)

   titleCell
        .tag('div')
            .addClass(args.titleclass)
            .wikitext(addNewline(args.title))

end

-- -- Above/Below rows --

local function getAboveBelowColspan()

   local ret = 2
   if args.imageleft then ret = ret + 1 end
   if args.image then ret = ret + 1 end
   return ret

end

local function renderAboveRow(tbl)

   if not args.above then return end

   addTableRow(tbl)
       .tag('td')
           .addClass('navbox-abovebelow')
           .addClass(args.aboveclass)
           .cssText(args.basestyle)
           .cssText(args.abovestyle)
           .attr('colspan', getAboveBelowColspan())
           .tag('div')
               .wikitext(addNewline(args.above))

end

local function renderBelowRow(tbl)

   if not args.below then return end

   addTableRow(tbl)
       .tag('td')
           .addClass('navbox-abovebelow')
           .addClass(args.belowclass)
           .cssText(args.basestyle)
           .cssText(args.belowstyle)
           .attr('colspan', getAboveBelowColspan())
           .tag('div')
               .wikitext(addNewline(args.below))

end

-- -- List rows -- local function renderListRow(tbl, listnum)

   local row = addTableRow(tbl)

   if listnum == 1 and args.imageleft then
       row
           .tag('td')
               .addClass('navbox-image')
               .addClass(args.imageclass)
               .css('width', '0%')
               .css('padding', '0px 2px 0px 0px')
               .cssText(args.imageleftstyle)
               .attr('rowspan', 2 * #listnums - 1)
               .tag('div')
                   .wikitext(addNewline(args.imageleft))
   end

   if args['group' .. listnum] then
       local groupCell = row.tag('th')

       groupCell
              .attr('scope', 'row')
              .addClass('navbox-group')
              .addClass(args.groupclass)
              .cssText(args.basestyle)

       if args.groupwidth then
           groupCell.css('width', args.groupwidth)
       end

       groupCell
           .cssText(args.groupstyle)
           .cssText(args['group' .. listnum .. 'style'])
           .wikitext(args['group' .. listnum])
   end

   local listCell = row.tag('td')

   if args['group' .. listnum] then
       listCell
           .css('text-align', 'right')
           .css('border-right-width', '2px')
           .css('border-right-style', 'solid')
   else
       listCell.attr('colspan', 2)
   end

   if not args.groupwidth then 
       listCell.css('width', '100%')
   end

   local isOdd = (listnum % 2) == 1
   local rowstyle = args.evenstyle
   if isOdd then rowstyle = args.oddstyle end

   local evenOdd
   if args.evenodd == 'swap' then
       if isOdd then evenOdd = 'even' else evenOdd = 'odd' end
   else
       if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end
   end

   listCell
       .css('padding', '0px')
       .cssText(args.liststyle)
       .cssText(rowstyle)
       .cssText(args['list' .. listnum .. 'style'])
       .addClass('navbox-list')
       .addClass('navbox-' .. evenOdd)
       .addClass(args.listclass)
       .tag('div')
           .css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
           .wikitext(addNewline(args['list' .. listnum]))

   if listnum == 1 and args.image then
       row
           .tag('td')
               .addClass('navbox-image')
               .addClass(args.imageclass)
               .css('width', '0%')
               .css('padding', '0px 0px 0px 2px')
               .cssText(args.imagestyle)
               .attr('rowspan', 2 * #listnums - 1)
               .tag('div')
                   .wikitext(addNewline(args.image))
   end

end


-- -- Tracking categories --

local function needsHorizontalLists()

   if border == 'child' or border == 'subgroup'  or args.tracking == 'no' then return false end

   local listClasses = {'plainlist', 'hlist', 'hlist hnum', 'hlist hwrap', 'hlist vcard', 'vcard hlist', 'hlist vevent'}
   for i, cls in ipairs(listClasses) do
       if args.listclass == cls or args.bodyclass == cls then
           return false
       end
   end

   return true

end

local function hasBackgroundColors()

   return mw.ustring.match(args.titlestyle or ,'background') or mw.ustring.match(args.groupstyle or ,'background') or mw.ustring.match(args.basestyle or ,'background')

end

local function getTrackingCategories()

   local cats = {}
   if needsHorizontalLists() then table.insert(cats, 'بغیر افقی فہرست والے ناوباکس') end
   if hasBackgroundColors() then table.insert(cats, 'پس منظری رنگ والے ناوباکس') end
   return cats

end

local function renderTrackingCategories(builder)

   local title = mw.title.getCurrentTitle()
   if title.namespace ~= 10 then return end -- not in template space
   local subpage = title.subpageText
   if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end

   for i, cat in ipairs(getTrackingCategories()) do
       builder.wikitext() 
   end

end

-- -- Main navbox tables -- local function renderMainTable()

   local tbl = HtmlBuilder.create('table')
       .attr('cellspacing', 0)
       .addClass('nowraplinks')
       .addClass(args.bodyclass)

   if args.title and (args.state ~= 'plain' and args.state ~= 'off') then
       tbl
           .addClass('collapsible')
           .addClass(args.state or 'autocollapse')
   end

   tbl.css('border-spacing', 0)
   if border == 'subgroup' or border == 'child' or border == 'none' then
       tbl
           .addClass('navbox-subgroup')
           .cssText(args.bodystyle)
           .cssText(args.style)
   else -- regular navobx - bodystyle and style will be applied to the wrapper table
       tbl
           .addClass('navbox-inner')
           .css('background', 'transparent')
           .css('color', 'inherit')
   end
   tbl.cssText(args.innerstyle)

   renderTitleRow(tbl)
   renderAboveRow(tbl)
   for i, listnum in ipairs(listnums) do
       renderListRow(tbl, listnum) 
   end
   renderBelowRow(tbl)

   return tbl

end

function p._navbox(navboxArgs)

   args = navboxArgs

   for k, v in pairs(args) do
       local listnum = ( .. k):match('^list(%d+)$')
       if listnum then table.insert(listnums, tonumber(listnum)) end
   end
   table.sort(listnums)

   border = trim(args.border or args[1] or )

   -- render the main body of the navbox
   local tbl = renderMainTable()

   -- render the appropriate wrapper around the navbox, depending on the border param
   local res = HtmlBuilder.create()
   if border == 'none' then
       res.node(tbl)
   elseif border == 'subgroup' or border == 'child' then
       -- We assume that this navbox is being rendered in a list cell of a parent navbox, and is

-- therefore inside a div with padding:0em 0.25em. We start with a to avoid the -- padding being applied, and at the end add a

to balance out the parent's
       res
           .tag('/div', {unclosed = true})
               .done()
           .node(tbl)
           .tag('div', {unclosed = true})
   else
       res
           .tag('table')
               .attr('cellspacing', 0)
               .addClass('navbox')
               .css('border-spacing', 0)
               .cssText(args.bodystyle)
               .cssText(args.style)
               .tag('tr')
                   .tag('td')
                       .css('padding', '2px')
                       .node(tbl)
   end

   renderTrackingCategories(res)

   return tostring(res)

end

function p.navbox(frame)

   -- ParserFunctions considers the empty string to be false, so to preserve the previous 
   -- behavior of سانچہ میں تکرار پایا گیا: سانچہ:Navbox, change any empty arguments to nil, so Lua will consider
   -- them false too.
   local args = {}
   local parent_args = frame:getParent().args;

   -- Out of order parsing bug.
   local temp;
   temp = parent_args.title;
   temp = parent_args.above;
   for i = 1, 20 do
       temp = parent_args["group" .. tostring(i)];
       temp = parent_args["list" .. tostring(i)];
   end    
   temp = parent_args.below;

   for k, v in pairs(parent_args) do
       if v ~=  then
           args[k] = v
       end
   end
   return p._navbox(args)

end

return p, change any empty arguments to nil, so Lua will consider

   -- them false too.
   local args = {}
   local parent_args = frame:getParent().args;

   -- Out of order parsing bug.
   local temp;
   temp = parent_args.title;
   temp = parent_args.above;
   for i = 1, 20 do
       temp = parent_args["group" .. tostring(i)];
       temp = parent_args["list" .. tostring(i)];
   end    
   temp = parent_args.below;

   for k, v in pairs(parent_args) do
       if v ~=  then
           args[k] = v
       end
   end
   return p._navbox(args)

end

return p