FANDOM


--
-- Implements {{tnavbar}}
--
 
local p = {}
 
local function view ( styles, links, target )
 
    local span = mw.html.create( 'span' )
        :attr( 'title', 'View this template' )
        :cssText( styles )
        :wikitext( links['view'] )
 
    span = tostring( span )
 
    return '[[' .. target .. '|' .. span .. ']]'
 
end
 
local function talk ( styles, links, target )
 
    local span = mw.html.create( 'span' )
        :attr( 'title', 'Discussion about this template' )
        :cssText( styles )
        :wikitext( links['talk'] )
 
    span = tostring( span )
 
    return '[' .. mw.site.server .. '/wiki/Template_talk:' .. mw.uri.encode( target, 'WIKI' ) .. ' ' .. span .. ']'
 
end
 
local function edit ( styles, links, target )
 
    local span = mw.html.create( 'span' )
        :attr( 'title', 'You can edit this template. Please use the preview button before saving.' )
        :cssText( styles )
        :wikitext( links['edit'] )
 
    span = tostring( span )
 
    return '[' .. mw.site.server .. '/wiki/Template:' .. mw.uri.encode( target, 'WIKI' ) .. ' ' .. span .. ']'
 
end
 
function p._collapsible ( name, title, plain, fontcolor )
 
    local args = {}
    args[1] = title
    if plain then
        args['plain'] = '1'
    else
        args['mini'] = '1'
    end
    args['fontcolor'] = fontcolor
 
    local div = mw.html.create( 'div' )
        -- @todo move to site css
        :css( {
            ['float'] = 'left',
            ['text-align'] = 'left',
            ['width'] = '6em'
        } )
        :wikitext( p_.navbar( args ) )
 
    local span = mw.html.create( 'span' )
        :wikitext( name )
    if fontcolor then
        span
            :css( 'color', fontcolor )
    end
 
    return tostring( div ) .. tostring( span )
 
end
 
function p._navbar ( args )
 
    local tag
 
    if args['nodiv'] then
        tag = mw.html.create( 'span' )
    else
        tag = mw.html.create( 'div' )
            -- @todo move to site css
            :css( {
                ['background-color'] = 'transparent',
                ['padding'] = '0'
            } )
    end
 
    tag
        :addClass( 'noprint' )
        :addClass( 'plainlinks' )
        -- not sure what this does, if anything
        :addClass( 'plainlinksneverexpand' )
        -- @todo move to site css
        :css( {
            ['white-space'] = 'nowrap',
            ['font-weight'] = 'normal',
            ['font-size'] = 'xx-small'
        } )
 
    local tagstyle = ''
    local fontstyle = ''
 
    if args['style'] then
        tagstyle = args['style']
    end
 
    if args['fontstyle'] then
        tagstyle = tagstyle .. ';' .. args['fontstyle']
        fontstyle = args['fontstyle']
    end
 
    if args['fontcolor'] then
        fontstyle = fontstyle .. ';color:' ..args['fontcolor']
    end
 
    local _links = links['long']
 
    if args['mini'] or args['miniv'] then
        _links = links['mini']
    end
 
    local box = args['mini'] or args['miniv'] or args['plain'] or args['viewplain']
    local wikitext = ''
    local target = args[1]
    local navlinks
 
    if not box then
        wikitext = 'This box: '
    end
 
    if args['miniv'] or args['viewplain'] then
        if mw.ustring.sub( target, 1, 2 ) ~= ':' then
            target = 'Template:' .. target
        end
        wikitext = view( styles, _links, target )
    else
        navlinks = { view( styles, _links, target ), talk( styles, _links, target ), edit( styles, _links, target ) }
        -- @todo move to site css
        sep = '&nbsp;<span style="font-size:80%;">&bull</span>&nbsp;'
        wikitext = wikitext .. arr.join( navlinks, sep )
    end
 
    tag
        :wikitext( wikitext )
 
    local ret = tostring( tag )
 
    if args['nodiv'] then
        ret = '&nbsp;' .. ret .. '&nbsp;'
    end
 
    return ret
 
end
 
function p.navbar ( frame )
 
    local _args = frame:getParent().args
    return p._navbar( args )
 
end

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.