Module:Tnavbar
Jump to navigation
Jump to search
Module documentation
This documentation is transcluded from Template:No documentation/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Tnavbar/doc. [edit]
Module:Tnavbar requires Module:Yesno.
Module:Tnavbar is required by Module:Navbox.
-- <nowiki> -- -- Implements {{tnavbar}} and variants -- -- @todo move the hardcoded css to [[MediaWiki:Common.css]] given how many pages it's found on -- local p = {} local yesno = require( 'Module:Yesno' ) function p._navbar( args ) local tag = mw.html.create( 'div' ) :addClass( 'plainlinks' ) :addClass( 'noprint' ) :css( { ['white-space'] = 'nowrap', ['font-weight'] = 'normal', ['font-size'] = 'xx-small' } ) viewSpan = mw.html.create( 'span' ) :attr( 'title', 'View this template' ) :cssText( fontstyle ) :wikitext( 'v' ) talkSpan = mw.html.create( 'span' ) :attr( 'title', 'Discussion about this template' ) :cssText( fontstyle ) :wikitext( 'd' ) editSpan = mw.html.create( 'span' ) :attr( 'title', 'Edit this template' ) :cssText( fontstyle ) :wikitext( 'e' ) local title = mw.text.trim( args[1] ) local ns, titleTbl, page, talk if mw.ustring.sub( title, 1, 1 ) == ':' then -- mainspace title = mw.ustring.sub( title, 2 ) page = title talk = 'Talk:' .. title elseif mw.ustring.match( title, ':' ) then -- split title to see if it has a valid namespace titleTbl = mw.text.split( title, ':' ) ns = mw.site.namespaces[titleTbl[1]] if ns ~= nil then page = ns.name .. ':' .. table.concat( titleTbl, '', 2 ) if ns.isTalk then talk = page else talk = ns.talk.name .. ':' .. table.concat( titleTbl, '', 2 ) end end end -- this happens if there's no semi-colons in title -- or if there is semi-colons but it didn't have valid ns name if not page then page = 'Template:' .. title talk = 'Template talk:' .. title end tag :wikitext( '[[' .. page .. '|' .. tostring( viewSpan ) .. ']]' ) :wikitext( ' ' ) :tag( 'span' ) :css( 'font-size', '80%' ) :wikitext( '•' ) :done() :wikitext( ' ' ) :wikitext( '[' .. tostring( mw.uri.fullUrl( talk ) ) .. ' ' .. tostring( talkSpan ) .. ']' ) :wikitext( ' ' ) :tag( 'span' ) :css( 'font-size', '80%' ) :wikitext( '•' ) :done() :wikitext( ' ' ) :wikitext( '[' .. tostring( mw.uri.fullUrl( page, 'action=edit' ) ) .. ' ' .. tostring( editSpan ) .. ']' ) return tostring( tag ) end function p._collapsible( args ) local nav_args = { [1] = args[2] } local div = mw.html.create( 'div' ) :css( { float = 'left', ['text-align'] = 'left', width = '6em' } ) :addClass( 'navbar' ) :wikitext(p._navbar(nav_args)) local span = mw.html.create('span'):wikitext(args[1]) return tostring( div ) .. tostring( span ) end return p