Open main menu

Changes

Module:Navbox

205 bytes removed, 01:45, 16 March 2013
edit for succinctness
function formNavBar( div, args ) if not args[1] then local class span = HtmlBuilder.create('span')  span .addClass('error') .css('float', 'left'noprint plainlinks hlist navbar) .css(';white-space', 'nowrap') .wikitext('Error: No name provided') return span end
local title;
args[1] local pageName = trim( args[1] or '' ); if args[1] == '' then title = mw.title.new( '' ); elseif args[1]pageName:sub(1,1) == ':' then title = mw.title.new( args[1]pageName:sub(2) );
else
title = mw.title.new( args[1] pageName );
if title.namespace == 0 then
title = mw.title.newmakeTitle( 'Template:' .. args[1] , pageName ); end
end
local mainpage, talkpage, editurl; mainpage = title.fullText; local talkpage = title.talkPageTitle; talkpage = talkpageand title.talkPageTitle.fullText or ''; local editurl = title:fullUrl( 'action=edit' );
local viewLink, talkLink, editLink = 'view', 'talk', 'edit' if args.mini ~= nil then class viewLink, talkLink, editLink = class .. ' miniv', 't', 'e';
end
local div = HtmlBuilder.create( 'div' )
div
.addClass( class 'noprint' ) .addClass( 'plainlinks' ) .addClass( 'hlist' ) .addClass( 'navbar') .cssText( args.style or ) if args.mini then div.addClass('mini' )end
if not (args.mini == nil and or args.plain == nil ) then div .tag( 'span' ) .css( 'word-spacing', 0 ) .cssText( args.fontstyle or '' ) .wikitext( args.text or 'This box:' ); .wikitext( ' ' )
end
if args.brackets ~= nil then div.wikitext(' '); div .tag('span') .css('margin-right', '-0.125em') .cssText( args.fontstyle or '' ) .wikitext( '[' ) .newline();
end
local ul = div.tag('ul');
local inner
if args.mini ~= nil then
inner = 'v';
else
inner = 'view';
end
ul .tag( 'li' ) .addClass( 'nv-view' ) .wikitext( '[[' .. mainpage .. '|' ) .tag( 'span ' ) .attr( 'title', 'View this template' ) .cssText( args.fontstyle or '' ) .wikitext( viewLink ) .done() .wikitext( inner ']]' )
.done()
.wikitext( ']]' );  if args.mini ~= nil then inner = 't'; else inner = 'talk'; end ul.tag( 'li' ) .addClass( 'nv-talk' ) .wikitext( '[[' .. talkpage .. '|' ) .tag( 'span ' ) .attr( 'title', 'Discuss this template' ) .cssText( args.fontstyle or '' ) .wikitext( inner ) .done() .wikitext( ']]' );  if args.noedit == nil then if args.mini ~= nil then inner = 'e'; else inner = 'edit'; end ul.tag( 'li' ) .addClass( 'nv-edit' ) .wikitext( '[' .. editurl .. ' ' )
.tag( 'span ' )
.attr( 'title', 'Edit Discuss this template' )
.cssText( args.fontstyle or '' )
.wikitext( inner talkLink )
.done()
.wikitext( ']]' );  if not args.noedit then ul .tag( 'li' ) .addClass( 'nv-edit' ) .wikitext( '[' .. editurl .. ' ' ) .tag( 'span ' ) .attr( 'title', 'Edit this template' ) .cssText( args.fontstyle or '' ) .wikitext( editLink ) .done() .wikitext( ']' );
end
if args.brackets ~= nil then div .tag('span') .css('margin-left', '-0.125em') .cssText( args.fontstyle or '' ) .wikitext( ']' ) .newline();
end
if args.state == 'plain' then spacerSide = 'right' end
if argstitleCell.name then local div = HtmlBuilder.createnode(formNavBar('div');{ local args = { args.name, mini = 1, fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;' }; div = formNavBar( div, args ); titleCell.node( div ) else titleCell .tag('span') .addClass('error') .css('float', 'left') .css('white-space', 'nowrap') .wikitext('Error: No name provided') end
end
end
end
local div = HtmlBuilder.create('div') return tostring( formNavBar( div, args ) )
end
return p
Anonymous user