Jump to content
MediaWiki

Module:Navbar

From mediawiki.org
Module documentation

Module Quality

The above documentation is transcluded from Module:Navbar/doc. (edit | history)
Editors can experiment in this module’s sandbox (edit | diff) and testcases (edit) pages.
Subpages of this module.

 localp={}

 localgetArgs
 localul

 functionp.addItem(mini,full,link,descrip,args,url)
 locall
 ifurlthen
 l={'[','',']'}
 else
 l={'[[','|',']]'}
 end
 ul:tag('li')
 :addClass('nv-'..full)
 :wikitext(l[1]..link..l[2])
 :tag(args.miniand'abbr'or'span')
 :attr('title',descrip..' this template')
 :cssText(args.fontstyle)
 :wikitext(args.miniandminiorfull)
 :done()
 :wikitext(l[3])
 end

 functionp.brackets(position,c,args,div)
 ifargs.bracketsthen
 div
 :tag('span')
 :css('margin-'..position,'-0.125em')
 :cssText(args.fontstyle)
 :wikitext(c)
 end
 end

 functionp._navbar(args)
 localshow={true,true,true,false,false,false}
 localtitleArg=1

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

 ifargs.templatethen
 titleArg='template'
 show={true,false,false,false,false,false}
 localindex={t=2,d=2,e=3,h=4,m=5,w=6,talk=2,edit=3,hist=4,move=5,watch=6}
 fork,vinipairs(require('Module:TableTools').compressSparseArray(args))do
 localnum=index[v]
 ifnumthenshow[num]=trueend
 end
 end

 ifargs.noeditthenshow[3]=falseend

 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

 p.brackets('right','[ ',args,div)

 ul=div:tag('ul')
 ifshow[1]thenp.addItem('v','view',title.fullText,'View',args)end
 ifshow[2]thenp.addItem('t','talk',talkpage,'Discuss',args)end
 ifshow[3]thenp.addItem('e','edit',title:fullUrl('action=edit'),'Edit',args,true)end
 ifshow[4]thenp.addItem('h','hist',title:fullUrl('action=history'),'History of',args,true)end
 ifshow[5]then
 localmove=mw.title.new('Special:Movepage')
 p.addItem('m','move',move:fullUrl('target='..title.fullText),'Move',args,true)end
 ifshow[6]thenp.addItem('w','watch',title:fullUrl('action=watch'),'Watch',args,true)end

 p.brackets('left',' ]',args,div)

 ifargs.collapsiblethen
 div
 :done()
 :tag('div')
 :css('font-size','114%')
 :css('margin',args.miniand'0 4em'or'0 7em')
 :cssText(args.fontstyle)
 :wikitext(args[1])
 end

 -- DELIBERATE DELTA FROM EN.WP THAT INTEGRATES HLIST TSTYLES
 -- CARE WHEN SYNCING
 localframe=mw.getCurrentFrame()
 returnframe:extensionTag{
 name='templatestyles',args={src='Flatlist/styles.css'}
 }..frame:extensionTag{
 name='templatestyles',args={src='Module:Navbar/styles.css'}
 }..tostring(div:done())
 end

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

 returnp

AltStyle によって変換されたページ (->オリジナル) /