Jump to content

Module:Navbar

Katuka Wikipedia

Documentation for this module may be created atModule:Navbar/doc

localp={}

localgetArgs

functionp._navbar(args)
localtitleArg=1

ifargs.collapsiblethen
titleArg=2
ifnotargs.plainthen
args.mini=1
end
ifargs.fontcolorthen
args.fontstyle='color:'..args.fontcolor..';'
end
args.style='float:left; text-align:left; width:6em;'
end

localtitleText=args[titleArg]or(':'..mw.getCurrentFrame():getParent():getTitle())
localtitle=mw.title.new(mw.text.trim(titleText),'Template');

ifnottitlethen
error('Invalid title '..titleText)
end

localtalkpage=title.talkPageTitleandtitle.talkPageTitle.fullTextor'';

localdiv=mw.html.create():tag('div')
div
:addClass('plainlinks')
:addClass('hlist')
:addClass('navbar')
:cssText(args.style)

ifargs.minithendiv:addClass('mini')end

ifnot(args.miniorargs.plain)then
div
:tag('span')
:css('word-spacing',0)
:cssText(args.fontstyle)
:wikitext(args.textor'This box:')
:wikitext(' ')
end

ifargs.bracketsthen
div
:tag('span')
:css('margin-right','-0.125em')
:cssText(args.fontstyle)
:wikitext('[')
:newline();
end

localul=div:tag('ul');

ul
:tag('li')
:addClass('nv-view')
:wikitext('[['..title.fullText..'|')
:tag('span')
:attr('title','View this template')
:cssText(args.fontstyle)
:wikitext(args.miniand'v'or'view')
:done()
:wikitext(']]')
:done()
:tag('li')
:addClass('nv-talk')
:wikitext('[['..talkpage..'|')
:tag('span')
:attr('title','Discuss this template')
:cssText(args.fontstyle)
:wikitext(args.miniand't'or'talk')
:done()
:wikitext(']]');

ifnotargs.noeditthen
ul
:tag('li')
:addClass('nv-edit')
:wikitext('['..title:fullUrl('action=edit')..' ')
:tag('span')
:attr('title','Edit this template')
:cssText(args.fontstyle)
:wikitext(args.miniand'e'or'edit')
:done()
:wikitext(']');
end

ifargs.bracketsthen
div
:tag('span')
:css('margin-left','-0.125em')
:cssText(args.fontstyle)
:wikitext(']')
:newline();
end

ifargs.collapsiblethen
div
:done()
:tag('span')
:css('font-size','110%')
:cssText(args.fontstyle)
:wikitext(args[1])
end

returntostring(div:done())
end

functionp.navbar(frame)
ifnotgetArgsthen
getArgs=require('Module:Arguments').getArgs
end
returnp._navbar(getArgs(frame))
end

returnp