Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  














Module:Navbox with collapsible groups






Afrikaans
العربية

Авар
Basa Bali

Башҡортса
Bikol Central
ChiTumbuka
Corsu
Cymraeg
Dansk
الدارجة
Euskara
فارسی
Føroyskt


Հայերեն
Ilokano
Bahasa Indonesia
עברית

Kurdî
Ladin


مصرى

Bahasa Melayu

Português
Simple English
سنڌي
Slovenščina
Ślůnski
کوردی
Српски / srpski
Suomi
Tagalog
ி
Татарча / tatarça
 

Türkçe
Türkmençe
Удмурт
Українська
اردو
Vèneto
Tiếng Vit

 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Meta-Wiki
Wikispecies
Wikisource
Wikiversity
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


Usage

View {{navbox with collapsible groups}}.

-- This module implements {{Navbox with collapsible groups}}
local q = {}
local Navbox = require('Module:Navbox')

-- helper functions
local function concatstrings(s)
 local r = table.concat(s, '')
 if r:match('^%s*$') then r = nil end
 return r
end

local function concatstyles(s)
 local r = table.concat(s, ';')
 while r:match(';%s*;') do
  r = mw.ustring.gsub(r, ';%s*;', ';')
 end
 if r:match('^%s*;%s*$') then r = nil end
 return r
end

function q._navbox(pargs)
 -- table for args passed to navbox
 local targs = {}

 -- process args
 local passthrough = {
  ['name']=true,['navbar']=true,['state']=true,['border']=true,
  ['bodyclass']=true,['groupclass']=true,['listclass']=true,
  ['style']=true,['bodystyle']=true,['basestyle']=true,
  ['title']=true,['titleclass']=true,['titlestyle']=true,
  ['above']=true,['aboveclass']=true,['abovestyle']=true,
  ['below']=true,['belowclass']=true,['belowstyle']=true,
  ['image']=true,['imageclass']=true,['imagestyle']=true,
  ['imageleft']=true,['imageleftstyle']=true
 }
 for k,v in pairs(pargs) do
  if k and type(k) == 'string' then
   if passthrough[k] then
    targs[k] = v
   elseif (k:match('^list[0-9][0-9]*$') 
     or k:match('^content[0-9][0-9]*$') ) then
    local n = mw.ustring.gsub(k, '^[a-z]*([0-9]*)$', '%1')
    if (targs['list' .. n] == nil and pargs['group' .. n] == nil
     and pargs['sect' .. n] == nil and pargs['section' .. n] == nil) then
     targs['list' .. n] = concatstrings(
      {pargs['list' .. n] or '', pargs['content' .. n] or ''})
    end
   elseif (k:match('^group[0-9][0-9]*$') 
     or k:match('^sect[0-9][0-9]*$') 
     or k:match('^section[0-9][0-9]*$') ) then
    local n = mw.ustring.gsub(k, '^[a-z]*([0-9]*)$', '%1')
    if targs['list' .. n] == nil then
     local titlestyle = concatstyles(
      {pargs['groupstyle'] or '',pargs['secttitlestyle'] or '', 
       pargs['group' .. n .. 'style'] or '', 
       pargs['section' .. n ..'titlestyle'] or ''})
     local liststyle = concatstyles(
      {pargs['liststyle'] or '', pargs['contentstyle'] or '', 
       pargs['list' .. n .. 'style'] or '', 
       pargs['content' .. n .. 'style'] or ''})
     local title = concatstrings(
      {pargs['group' .. n] or '', 
       pargs['sect' .. n] or '',
       pargs['section' .. n] or ''})
     local list = concatstrings(
      {pargs['list' .. n] or '', 
       pargs['content' .. n] or ''})
     local state = (pargs['abbr' .. n] and pargs['abbr' .. n] == pargs['selected']) 
      and 'uncollapsed' or pargs['state' .. n] or 'collapsed'
     
     targs['list' .. n] = Navbox._navbox(
      {'child', navbar = 'plain', state = state,
      basestyle = pargs['basestyle'],
      title = title, titlestyle = titlestyle,
      list1 = list, liststyle = liststyle,
      listclass = pargs['list' .. n .. 'class'],
      image = pargs['image' .. n],
      imageleft = pargs['imageleft' .. n],
      listpadding = pargs['listpadding']})
    end
   end
  end
 end
 -- ordering of style and bodystyle
 targs['style'] = concatstyles({targs['style'] or '', targs['bodystyle'] or ''})
 targs['bodystyle'] = nil
 
 -- child or subgroup
 if targs['border'] == nil then targs['border'] = pargs[1] end

 return Navbox._navbox(targs)
end

function q.navbox(frame)
 local pargs = require('Module:Arguments').getArgs(frame, {wrappers = {'Template:Navbox with collapsible groups'}})

 -- Read the arguments in the order they'll be output in, to make references number in the right order.
 local _
 _ = pargs.title
 _ = pargs.above
 for i = 1, 20 do
  _ = pargs["group" .. tostring(i)]
  _ = pargs["list" .. tostring(i)]
 end
 _ = pargs.below

 return q._navbox(pargs)
end

return q

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Navbox_with_collapsible_groups&oldid=880023215"

Category: 
Modules subject to page protection
Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 24 January 2019, at 21:07 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki