"سانچہ: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" 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|background:#99CCCC}}};{{{titlegroupstyle|#99CCCC}}}">{{{titlegroup|}}}</td><!--
+
    return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
  --><th style="border-left:2px solid #fdfdfd;width:100%;|<th style="}}{{{basestyle|}}};{{{titlestyle|background:#CCCCFF}}}" <!--
+
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:right;">&nbsp;</div>}}}}|<!--
+
    end
--><div style="float:left; width:6em;text-align:right;"><!--
+
end
  -->{{Tnavbar|{{{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 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:right;border-left:2px solid #fdfdfd;|<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}}}}}}">}}{{{list1|}}}{{#if:{{{list1|}}}|</div></td><!--
+
            args.name,
 
+
            mini = 1,
-->{{#if:{{{image|}}}|<!--
+
            fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') ..  ';background:none transparent;border:none;'
--><td style="width:0%;padding:0px 0px 0px 2px;{{{imagestyle|}}}" <!--
+
        })
-->rowspan={{#expr:1{{#if:{{{list2|}}}|+2}}{{#if:{{{list3|}}}|+2}}{{#if:{{{list4|}}}|+2}}<!--
+
    end
-->{{#if:{{{list5|}}}|+2}}{{#if:{{{list6|}}}|+2}}{{#if:{{{list7|}}}|+2}}{{#if:{{{list8|}}}|+2}}<!--
+
   
-->{{#if:{{{list9|}}}|+2}}{{#if:{{{list10|}}}|+2}}{{#if:{{{list11|}}}|+2}}{{#if:{{{list12|}}}|+2}}<!--
+
    -- Render the spacer div.
-->{{#if:{{{list13|}}}|+2}}{{#if:{{{list14|}}}|+2}}{{#if:{{{list15|}}}|+2}}{{#if:{{{list16|}}}|+2}}<!--
+
    if spacerSide then
-->{{#if:{{{list17|}}}|+2}}{{#if:{{{list18|}}}|+2}}{{#if:{{{list19|}}}|+2}}{{#if:{{{list20|}}}|+2}}}}><!--
+
        titleCell
-->{{{image|}}}</td>}}<!--
+
            .tag('span')
 
+
                .css('float', spacerSide)
--></tr>}}<!--
+
                .css('width', '6em')
 
+
                .wikitext('&nbsp;')
 
+
    end
 
+
end
---Remaining groups/lists---
+
 
+
--
-->{{#if:{{{list2|}}}|<!--
+
--  Title row
-->{{#if:{{{title|}}}{{{above|}}}{{{list1|}}}|<tr style="height:2px"><td></td></tr>}}<tr><!--
+
--
-->{{#if:{{{group2|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group2style|}}}"><!--
+
local function renderTitleRow(tbl)
-->{{{group2}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
    if not args.title then return end
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list2style|}}}" <!--
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
    local titleRow = addTableRow(tbl)
--><div style="padding:{{{listpadding|0em 0.25em}}}">}}{{{list2|}}}{{#if:{{{list2|}}}|</div></td></tr>}}<!--
+
 
+
    if args.titlegroup then
-->{{#if:{{{list3|}}}|<!--
+
        titleRow
-->{{#if:{{{title|}}}{{{above|}}}{{{list1|}}}{{{list2|}}}|<tr style="height:2px"><td></td></tr>}}<tr><!--
+
            .tag('th')
-->{{#if:{{{group3|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group3style|}}}"><!--
+
                .attr('scope', 'row')
-->{{{group3}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
                .addClass('navbox-group')
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list3style|}}}" <!--
+
                .addClass(args.titlegroupclass)
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
                .cssText(args.basestyle)
--><div style="padding:{{{listpadding|0em 0.25em}}}">}}{{{list3|}}}{{#if:{{{list3|}}}|</div></td></tr>}}<!--
+
                .cssText(args.groupstyle)
 
+
                .cssText(args.titlegroupstyle)
-->{{#if:{{{list4|}}}|<!--
+
                .wikitext(args.titlegroup)
--><tr style="height:2px"><td></td></tr><tr><!--
+
    end
-->{{#if:{{{group4|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group4style|}}}"><!--
+
-->{{{group4}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
    local titleCell = titleRow.tag('th').attr('scope', 'col')
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list4style|}}}" <!--
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
    if args.titlegroup then
--><div style="padding:{{{listpadding|0em 0.25em}}}">}}{{{list4|}}}{{#if:{{{list4|}}}|</div></td></tr>}}<!--
+
        titleCell
 
+
            .css('border-left', '2px solid #fdfdfd')
-->{{#if:{{{list5|}}}|<!--
+
            .css('width', '100%')
--><tr style="height:2px"><td></td></tr><tr><!--
+
    end
-->{{#if:{{{group5|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group5style|}}}"><!--
+
-->{{{group5}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
    local titleColspan = 2
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list5style|}}}" <!--
+
    if args.imageleft then titleColspan = titleColspan + 1 end
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
    if args.image then titleColspan = titleColspan + 1 end
--><div style="padding:{{{listpadding|0em 0.25em}}}">}}{{{list5|}}}{{#if:{{{list5|}}}|</div></td></tr>}}<!--
+
    if args.titlegroup then titleColspan = titleColspan - 1 end
 
+
   
-->{{#if:{{{list6|}}}|<!--
+
    titleCell
--><tr style="height:2px"><td></td></tr><tr><!--
+
        .cssText(args.basestyle)
-->{{#if:{{{group6|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group6style|}}}"><!--
+
        .cssText(args.titlestyle)
-->{{{group6}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
        .addClass('navbox-title')
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list6style|}}}" <!--
+
        .attr('colspan', titleColspan)
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list6|}}}</div></td></tr>}}<!--
+
    renderNavBar(titleCell)
 
+
-->{{#if:{{{list7|}}}|<!--
+
    titleCell
--><tr style="height:2px"><td></td></tr><tr><!--
+
        .tag('div')
-->{{#if:{{{group7|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group7style|}}}"><!--
+
            .addClass(args.titleclass)
-->{{{group7}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
            .wikitext(addNewline(args.title))
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list7style|}}}" <!--
+
end
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list7|}}}</div></td></tr>}}<!--
+
--
 
+
--  Above/Below rows
-->{{#if:{{{list8|}}}|<!--
+
--
--><tr style="height:2px"><td></td></tr><tr><!--
+
-->{{#if:{{{group8|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group8style|}}}"><!--
+
local function getAboveBelowColspan()
-->{{{group8}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
    local ret = 2
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list8style|}}}" <!--
+
    if args.imageleft then ret = ret + 1 end
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
    if args.image then ret = ret + 1 end
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list8|}}}</div></td></tr>}}<!--
+
    return ret
 
+
end
-->{{#if:{{{list9|}}}|<!--
+
   
--><tr style="height:2px"><td></td></tr><tr><!--
+
local function renderAboveRow(tbl)
-->{{#if:{{{group9|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group9style|}}}"><!--
+
    if not args.above then return end
-->{{{group9}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list9style|}}}" <!--
+
    addTableRow(tbl)
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
        .tag('td')
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list9|}}}</div></td></tr>}}<!--
+
            .addClass('navbox-abovebelow')
 
+
            .addClass(args.aboveclass)
-->{{#if:{{{list10|}}}|<!--
+
            .cssText(args.basestyle)
--><tr style="height:2px"><td></td></tr><tr><!--
+
            .cssText(args.abovestyle)
-->{{#if:{{{group10|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group10style|}}}"><!--
+
            .attr('colspan', getAboveBelowColspan())
-->{{{group10}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
            .tag('div')
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list10style|}}}" <!--
+
                .wikitext(addNewline(args.above))
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
end
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list10|}}}</div></td></tr>}}<!--
+
 
+
local function renderBelowRow(tbl)
-->{{#if:{{{list11|}}}|<!--
+
    if not args.below then return end
--><tr style="height:2px"><td></td></tr><tr><!--
+
-->{{#if:{{{group11|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group11style|}}}"><!--
+
    addTableRow(tbl)
-->{{{group11}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
        .tag('td')
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list11style|}}}" <!--
+
            .addClass('navbox-abovebelow')
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
            .addClass(args.belowclass)
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list11|}}}</div></td></tr>}}<!--
+
            .cssText(args.basestyle)
 
+
            .cssText(args.belowstyle)
-->{{#if:{{{list12|}}}|<!--
+
            .attr('colspan', getAboveBelowColspan())
--><tr style="height:2px"><td></td></tr><tr><!--
+
            .tag('div')
-->{{#if:{{{group12|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group12style|}}}"><!--
+
                .wikitext(addNewline(args.below))
-->{{{group12}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
end
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list12style|}}}" <!--
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
--
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list12|}}}</div></td></tr>}}<!--
+
--   List rows
 
+
--
-->{{#if:{{{list13|}}}|<!--
+
local function renderListRow(tbl, listnum)
--><tr style="height:2px"><td></td></tr><tr><!--
+
    local row = addTableRow(tbl)
-->{{#if:{{{group13|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group13style|}}}"><!--
+
-->{{{group13}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
    if listnum == 1 and args.imageleft then
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list13style|}}}" <!--
+
        row
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
            .tag('td')
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list13|}}}</div></td></tr>}}<!--
+
                .addClass('navbox-image')
 
+
                .addClass(args.imageclass)
-->{{#if:{{{list14|}}}|<!--
+
                .css('width', '0%')
--><tr style="height:2px"><td></td></tr><tr><!--
+
                .css('padding', '0px 2px 0px 0px')
-->{{#if:{{{group14|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group14style|}}}"><!--
+
                .cssText(args.imageleftstyle)
-->{{{group14}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
                .attr('rowspan', 2 * #listnums - 1)
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list14style|}}}" <!--
+
                .tag('div')
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
                    .wikitext(addNewline(args.imageleft))
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list14|}}}</div></td></tr>}}<!--
+
    end
 
+
   
-->{{#if:{{{list15|}}}|<!--
+
    if args['group' .. listnum] then
--><tr style="height:2px"><td></td></tr><tr><!--
+
        local groupCell = row.tag('th')
-->{{#if:{{{group15|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group15style|}}}"><!--
+
   
-->{{{group15}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
        groupCell
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list15style|}}}" <!--
+
              .attr('scope', 'row')
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
              .addClass('navbox-group')
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list15|}}}</div></td></tr>}}<!--
+
              .addClass(args.groupclass)
 
+
              .cssText(args.basestyle)
-->{{#if:{{{list16|}}}|<!--
+
--><tr style="height:2px"><td></td></tr><tr><!--
+
        if args.groupwidth then
-->{{#if:{{{group16|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group16style|}}}"><!--
+
            groupCell.css('width', args.groupwidth)
-->{{{group16}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
        end
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list16style|}}}" <!--
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
        groupCell
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list16|}}}</div></td></tr>}}<!--
+
            .cssText(args.groupstyle)
 
+
            .cssText(args['group' .. listnum .. 'style'])
-->{{#if:{{{list17|}}}|<!--
+
            .wikitext(args['group' .. listnum])
--><tr style="height:2px"><td></td></tr><tr><!--
+
    end
-->{{#if:{{{group17|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group17style|}}}"><!--
+
-->{{{group17}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
    local listCell = row.tag('td')
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list17style|}}}" <!--
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
    if args['group' .. listnum] then
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list17|}}}</div></td></tr>}}<!--
+
        listCell
 
+
            .css('text-align', 'right')
-->{{#if:{{{list18|}}}|<!--
+
            .css('border-right-width', '2px')
--><tr style="height:2px"><td></td></tr><tr><!--
+
            .css('border-right-style', 'solid')
-->{{#if:{{{group18|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group18style|}}}"><!--
+
    else
-->{{{group18}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
        listCell.attr('colspan', 2)
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list18style|}}}" <!--
+
    end
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list18|}}}</div></td></tr>}}<!--
+
    if not args.groupwidth then
 
+
        listCell.css('width', '100%')
-->{{#if:{{{list19|}}}|<!--
+
    end
--><tr style="height:2px"><td></td></tr><tr><!--
+
-->{{#if:{{{group19|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group19style|}}}"><!--
+
    local isOdd = (listnum % 2) == 1
-->{{{group19}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
    local rowstyle = args.evenstyle
-->width:100%;padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list19style|}}}" <!--
+
    if isOdd then rowstyle = args.oddstyle end
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
+
   
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list19|}}}</div></td></tr>}}<!--
+
    local evenOdd
 
+
    if args.evenodd == 'swap' then
-->{{#if:{{{list20|}}}|<!--
+
        if isOdd then evenOdd = 'even' else evenOdd = 'odd' end
--><tr style="height:2px"><td></td></tr><tr><!--
+
    else
-->{{#if:{{{group20|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{group20style|}}}"><!--
+
        if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end
-->{{{group20}}}</td><td style="text-align:right;border-left:2px solid #fdfdfd;|<td colspan=2 style="}}<!--
+
    end
-->width:100%;padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list20style|}}}" <!--
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
+
    listCell
--><div style="padding:{{{listpadding|0em 0.25em}}}">{{{list20|}}}</div></td></tr>}}<!--
+
        .css('padding', '0px')
 
+
        .cssText(args.liststyle)
 
+
        .cssText(rowstyle)
---Below---
+
        .cssText(args['list' .. listnum .. 'style'])
-->{{#if:{{{below|}}}|<!--
+
        .addClass('navbox-list')
-->{{#if:{{{title|}}}{{{above|}}}{{{list1|}}}{{{list2|}}}{{{list3|}}}|<tr style="height:2px;"><td></td></tr>}}<!--
+
        .addClass('navbox-' .. evenOdd)
--><tr><td class="navbox-abovebelow" style="{{{basestyle|}}};{{{belowstyle|}}}" <!--
+
        .addClass(args.listclass)
-->colspan="{{#expr:2{{#if:{{{imageleft|}}}|+1}}{{#if:{{{image|}}}|+1}}}}">{{{below}}}</td></tr>}}<!--
+
        .tag('div')
 
+
            .css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
 
+
            .wikitext(addNewline(args['list' .. listnum]))
--></table>{{#switch:{{{border|{{{1|}}}}}}|subgroup|child=<div>|none=|#default=</td></tr></table>}}<!--
+
 
+
    if listnum == 1 and args.image then
--><noinclude>
+
        row
{{documentation}}
+
            .tag('td')
{{pp-template|small=yes}}
+
                .addClass('navbox-image')
 
+
                .addClass(args.imageclass)
[[زمرہ:سانچے]]
+
                .css('width', '0%')
<!-- Add categories and interwikis to the /doc subpage, not here! -->
+
                .css('padding', '0px 0px 0px 2px')
</noinclude>
+
                .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('[[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

حالیہ نسخہ بمطابق 08: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