Editing
Module:Tabber
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local getArgs = require( 'Module:Arguments' ).getArgs -- Implements Template:SubTabs. function p.sub(frame) local args = getArgs(frame, { wrappers = { 'Template:SubTabs' } }) local main = args[1] or mw.title.getCurrentTitle().baseText -- Use {{BASEPAGENAME}} if no page is given. local disp = string.match(main, "^(.+)%s+%(") or args['disp'] -- does not display discriminators in parenthesis local subpage = function( page ) return main .. '/' .. page end local sub = function( number ) if args['sub' .. number] then return subpage( args['sub' .. number] ) end end local tabs = { ['this'] = args['this'], ['link1'] = main, ['name1'] = disp, ['link2'] = sub( '1' ), ['name2'] = args['sub1'], ['link3'] = sub( '2' ), ['name3'] = args['sub2'], ['link4'] = sub( '3' ), ['name4'] = args['sub3'], ['link5'] = sub( '4' ), ['name5'] = args['sub4'], ['link6'] = sub( '5' ), ['name6'] = args['sub5'], ['link7'] = sub( '6' ), ['name7'] = args['sub6'], ['link8'] = sub( '7' ), ['name8'] = args['sub7'], ['link9'] = sub( '8' ), ['name9'] = args['sub8'], ['link10'] = sub( '9' ), ['name10'] = args['sub9'], ['link11'] = sub( '10' ), ['name11'] = args['sub10'], ['link12'] = sub( '11' ), ['name12'] = args['sub11'], ['link13'] = sub( '12' ), ['name13'] = args['sub12'], ['link14'] = sub( '13' ), ['name14'] = args['sub13'], ['link15'] = sub( '14' ), ['name15'] = args['sub14'], } return p._main( tabs ) end -- Implements Template:Tabber. function p.main(frame) local args = getArgs(frame, { wrappers = { 'Template:Tabber' } }) return p._main( args ) end function p._main( args ) local current_page = args['this'] or mw.title.getCurrentTitle().prefixedText local rows = {} for n=1,15 do if args['link' .. n] then -- Use the link as the name if none is given. local name = args['name' .. n] or args['link' .. n] if args['link' .. n] == current_page then -- The active tab. table.insert( rows, string.format( '<div class="page-tabber-tab active-tab">%s</div>', name ) ) else -- The inactive tabs. local link = string.format( '[[%s|%s]]', args['link' .. n], name ) table.insert( rows, string.format( '<div class="page-tabber-tab inactive-tab">%s</div>', link ) ) end end end -- The separator is used for the space between two tabs. local separator = '\n<div class="page-tabber-separator"> </div>\n' -- The tail fills the space between the last tab and the end of the line. local tail = '<div class="page-tabber-separator tail"> </div>' return string.format( '<div id="pageTabber" class="page-tabber">\n%s\n%s\n</div>', table.concat( rows, separator ), tail ) end return p
Summary:
Please note that all contributions to Magic the Archiving may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Magic the Archiving:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Tabber/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information